Merge branch 'maint'
[org-mode/org-tableheadings.git] / doc / org-manual.org
blob0ffa73911627ecdb7b3de5387edca8d789d5b087
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 $ cd org-mode/
140 $ make autoloads
141 #+end_example
143 Note that in this case, ~make autoloads~ is mandatory: it defines
144 Org's version in =org-version.el= and Org's autoloads in
145 =org-loaddefs.el=.
147 Remember to add the correct load-path as described in the method
148 above.
150 You can also compile with =make=, generate the documentation with
151 =make doc=, create a local configuration with =make config= and
152 install Org with =make install=.  Please run =make help= to get the
153 list of compilation/installation options.
155 For more detailed explanations on Org's build system, please check the
156 Org Build System page on [[https://orgmode.org/worg/dev/org-build-system.html][Worg]].
158 ** Activation
159 :PROPERTIES:
160 :DESCRIPTION: How to activate Org for certain buffers.
161 :END:
162 #+cindex: activation
163 #+cindex: autoload
164 #+cindex: ELPA
165 #+cindex: global key bindings
166 #+cindex: key bindings, global
168 Org mode buffers need Font Lock to be turned on: this is the default
169 in Emacs[fn:1].
171 There are compatibility issues between Org mode and some other Elisp
172 packages (see [[*Packages that conflict with Org mode]]).  Please take the
173 time to check the list.
175 #+findex: org-agenda
176 #+findex: org-capture
177 #+findex: org-store-link
178 For a better experience, the three Org commands ~org-store-link~,
179 ~org-capture~ and ~org-agenda~ ought to be accessible anywhere in
180 Emacs, not just in Org buffers.  To that effect, you need to bind them
181 to globally available keys, like the ones reserved for users (see
182 [[info:elisp::Key%20Binding%20Conventions]]).  Here are suggested
183 bindings, please modify the keys to your own liking.
185 #+begin_src emacs-lisp
186 (global-set-key "\C-cl" 'org-store-link)
187 (global-set-key "\C-ca" 'org-agenda)
188 (global-set-key "\C-cc" 'org-capture)
189 #+end_src
191 #+cindex: Org mode, turning on
192 Files with the =.org= extension use Org mode by default.  To turn on
193 Org mode in a file that does not have the extension =.org=, make the
194 first line of a file look like this:
196 : MY PROJECTS    -*- mode: org; -*-
198 #+vindex: org-insert-mode-line-in-empty-file
199 #+texinfo: @noindent
200 which selects Org mode for this buffer no matter what the file's name
201 is.  See also the variable ~org-insert-mode-line-in-empty-file~.
203 Many commands in Org work on the region if the region is /active/.  To
204 make use of this, you need to have ~transient-mark-mode~ turned on,
205 which is the default.  If you do not like ~transient-mark-mode~, you
206 can create an active region by using the mouse to select a region, or
207 pressing {{{kbd(C-SPC)}}} twice before moving the cursor.
209 ** Feedback
210 :PROPERTIES:
211 :DESCRIPTION: Bug reports, ideas, patches, etc.
212 :END:
213 #+cindex: feedback
214 #+cindex: bug reports
215 #+cindex: reporting a bug
216 #+cindex: maintainer
217 #+cindex: author
219 If you find problems with Org, or if you have questions, remarks, or
220 ideas about it, please mail to the Org mailing list
221 [[mailto:emacs-orgmode@gnu.org]].  You can subscribe to the list [[https://lists.gnu.org/mailman/listinfo/emacs-orgmode][on this
222 web page]].  If you are not a member of the mailing list, your mail will
223 be passed to the list after a moderator has approved it[fn:2].
225 #+findex: org-version
226 #+findex: org-submit-bug-report
227 For bug reports, please first try to reproduce the bug with the latest
228 version of Org available---if you are running an outdated version, it
229 is quite possible that the bug has been fixed already.  If the bug
230 persists, prepare a report and provide as much information as
231 possible, including the version information of Emacs ({{{kbd(M-x
232 emacs-version)}}}) and Org ({{{kbd(M-x org-version)}}}), as well as
233 the Org related setup in the Emacs init file.  The easiest way to do
234 this is to use the command
236 : M-x org-submit-bug-report <RET>
238 #+texinfo: @noindent
239 which puts all this information into an Emacs mail buffer so that you
240 only need to add your description.  If you are not sending the Email
241 from within Emacs, please copy and paste the content into your Email
242 program.
244 Sometimes you might face a problem due to an error in your Emacs or
245 Org mode setup.  Before reporting a bug, it is very helpful to start
246 Emacs with minimal customizations and reproduce the problem.  Doing so
247 often helps you determine if the problem is with your customization or
248 with Org mode itself.  You can start a typical minimal session with
249 a command like the example below.
251 : $ emacs -Q -l /path/to/minimal-org.el
253 However if you are using Org mode as distributed with Emacs, a minimal
254 setup is not necessary.  In that case it is sufficient to start Emacs
255 as =emacs -Q=.  The =minimal-org.el= setup file can have contents as
256 shown below.
258 #+begin_src emacs-lisp
259 ;;; Minimal setup to load latest `org-mode'.
261 ;; Activate debugging.
262 (setq debug-on-error t
263       debug-on-signal nil
264       debug-on-quit nil)
266 ;; Add latest Org mode to load path.
267 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
268 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
269 #+end_src
271 If an error occurs, a "backtrace" can be very useful---see below on
272 how to create one.  Often a small example file helps, along with clear
273 information about:
275 1. What exactly did you do?
276 2. What did you expect to happen?
277 3. What happened instead?
279 #+texinfo: @noindent
280 Thank you for helping to improve this program.
282 *** How to create a useful backtrace
283 :PROPERTIES:
284 :UNNUMBERED: notoc
285 :END:
287 #+cindex: backtrace of an error
288 If working with Org produces an error with a message you do not
289 understand, you may have hit a bug.  The best way to report this is by
290 providing, in addition to what was mentioned above, a backtrace.  This
291 is information from the built-in debugger about where and how the
292 error occurred.  Here is how to produce a useful backtrace:
294 1. Reload uncompiled versions of all Org mode Lisp files.  The
295    backtrace contains much more information if it is produced with
296    uncompiled code.  To do this, use
298    : C-u M-x org-reload <RET>
300    #+texinfo: @noindent
301    or, from the menu: Org \rarr Refresh/Reload \rarr Reload Org uncompiled.
303 2. Then, activate the debugger:
305    : M-x toggle-debug-or-error <RET>
307    #+texinfo: @noindent
308    or, from the menu: Options \rarr Enter Debugger on Error.
310 3. Do whatever you have to do to hit the error.  Do not forget to
311    document the steps you take.
313 4. When you hit the error, a =*Backtrace*= buffer appears on the
314    screen.  Save this buffer to a file---for example using {{{kbd(C-x
315    C-w)}}}---and attach it to your bug report.
317 ** Typesetting Conventions Used in this Manual
318 :PROPERTIES:
319 :DESCRIPTION: Typesetting conventions used in this manual.
320 :ALT_TITLE: Conventions
321 :END:
323 *** TODO keywords, tags, properties, etc.
324 :PROPERTIES:
325 :UNNUMBERED: notoc
326 :END:
328 Org uses various syntactical elements: TODO keywords, tags, property
329 names, keywords, blocks, etc.  In this manual we use the following
330 conventions:
332 #+attr_texinfo: :sep ,
333 - =TODO=, =WAITING= ::
335      TODO keywords are written with all capitals, even if they are
336      user-defined.
338 - =boss=, =ARCHIVE= ::
340      User-defined tags are written in lowercase; built-in tags with
341      special meaning are written with all capitals.
343 - =Release=, =PRIORITY= ::
345      User-defined properties are capitalized; built-in properties with
346      special meaning are written with all capitals.
348 - =TITLE=, =BEGIN= ... =END= ::
350      Keywords and blocks are written in uppercase to enhance their
351      readability, but you can use lowercase in your Org files.
353 *** Key bindings and commands
354 :PROPERTIES:
355 :UNNUMBERED: notoc
356 :END:
358 The manual lists both the keys and the corresponding commands for
359 accessing a functionality.  Org mode often uses the same key for
360 different functions, depending on context.  The command that is bound
361 to such keys has a generic name, like ~org-metaright~.  In the manual
362 we will, wherever possible, give the function that is internally
363 called by the generic command.  For example, in the chapter on
364 document structure, {{{kbd(M-RIGHT)}}} will be listed to call
365 ~org-do-demote~, while in the chapter on tables, it will be listed to
366 call ~org-table-move-column-right~.
368 * Document Structure
369 :PROPERTIES:
370 :DESCRIPTION: A tree works like your brain.
371 :END:
372 #+cindex: document structure
373 #+cindex: structure of document
375 Org is based on Outline mode and provides flexible commands to
376 edit the structure of the document.
378 ** Outlines
379 :PROPERTIES:
380 :DESCRIPTION: Org is based on Outline mode.
381 :END:
382 #+cindex: outlines
383 #+cindex: Outline mode
385 Org is implemented on top of Outline mode.  Outlines allow a document
386 to be organized in a hierarchical structure, which, least for me, is
387 the best representation of notes and thoughts.  An overview of this
388 structure is achieved by folding, i.e., hiding large parts of the
389 document to show only the general document structure and the parts
390 currently being worked on.  Org greatly simplifies the use of outlines
391 by compressing the entire show and hide functionalities into a single
392 command, ~org-cycle~, which is bound to the {{{kbd(TAB)}}} key.
394 ** Headlines
395 :PROPERTIES:
396 :DESCRIPTION: How to typeset Org tree headlines.
397 :END:
398 #+cindex: headlines
399 #+cindex: outline tree
400 #+vindex: org-special-ctrl-a/e
401 #+vindex: org-special-ctrl-k
402 #+vindex: org-ctrl-k-protect-subtree
404 Headlines define the structure of an outline tree.  The headlines in
405 Org start with one or more stars, on the left margin[fn:3].  For
406 example:
408 #+begin_example
409 ,* Top level headline
410 ,** Second level
411 ,*** Third level
412     some text
413 ,*** Third level
414     more text
415 ,* Another top level headline
416 #+end_example
418 #+vindex: org-footnote-section
419 #+texinfo: @noindent
420 Note that the name defined in ~org-footnote-section~ is reserved.  Do
421 not use it as a title for your own headings.
423 Some people find the many stars too noisy and would prefer an outline
424 that has whitespace followed by a single star as headline starters.
425 See [[*A Cleaner Outline View]].
427 #+vindex: org-cycle-separator-lines
428 An empty line after the end of a subtree is considered part of it and
429 is hidden when the subtree is folded.  However, if you leave at least
430 two empty lines, one empty line remains visible after folding the
431 subtree, in order to structure the collapsed view.  See the variable
432 ~org-cycle-separator-lines~ to modify this behavior.
434 ** Visibility Cycling
435 :PROPERTIES:
436 :DESCRIPTION: Show and hide, much simplified.
437 :END:
438 #+cindex: cycling, visibility
439 #+cindex: visibility cycling
440 #+cindex: trees, visibility
441 #+cindex: show hidden text
442 #+cindex: hide text
444 *** Global and local cycling
445 :PROPERTIES:
446 :DESCRIPTION: Cycling through various visibility states.
447 :END:
448 #+cindex: subtree visibility states
449 #+cindex: subtree cycling
450 #+cindex: folded, subtree visibility state
451 #+cindex: children, subtree visibility state
452 #+cindex: subtree, subtree visibility state
454 Outlines make it possible to hide parts of the text in the buffer.
455 Org uses just two commands, bound to {{{kbd(TAB)}}} and
456 {{{kbd(S-TAB)}}} to change the visibility in the buffer.
458 #+attr_texinfo: :sep ,
459 - {{{kbd(TAB)}}} (~org-cycle~) ::
461      #+kindex: TAB
462      #+findex: org-cycle
463      /Subtree cycling/: Rotate current subtree among the states
465      #+begin_example
466      ,-> FOLDED -> CHILDREN -> SUBTREE --.
467      '-----------------------------------'
468      #+end_example
470      #+vindex: org-cycle-emulate-tab
471      The cursor must be on a headline for this to work[fn:4].
473 - {{{kbd(S-TAB)}}} (~org-global-cycle~), {{{kbd(C-u TAB)}}} ::
475      #+cindex: global visibility states
476      #+cindex: global cycling
477      #+cindex: overview, global visibility state
478      #+cindex: contents, global visibility state
479      #+cindex: show all, global visibility state
480      #+kindex: C-u TAB
481      #+kindex: S-TAB
482      #+findex: org-global-cycle
483      /Global cycling/: Rotate the entire buffer among the states
485      #+begin_example
486      ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
487      '--------------------------------------'
488      #+end_example
490      When {{{kbd(S-TAB)}}} is called with a numeric prefix argument N,
491      the CONTENTS view up to headlines of level N are shown.  Note
492      that inside tables (see [[*Tables]]), {{{kbd(S-TAB)}}} jumps to the
493      previous field instead.
495      #+vindex: org-cycle-global-at-bob
496      You can run global cycling using {{{kbd(TAB)}}} only if point is
497      at the very beginning of the buffer, but not on a headline, and
498      ~org-cycle-global-at-bob~ is set to a non-~nil~ value.
500 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
502      #+cindex: startup visibility
503      #+kindex: C-u C-u TAB
504      #+findex: org-set-startup-visibility
505      Switch back to the startup visibility of the buffer (see [[*Initial
506      visibility]]).
508 - {{{kbd(C-u C-u C-u TAB)}}} (~outline-show-all~) ::
510      #+cindex: show all, command
511      #+kindex: C-u C-u C-u TAB
512      #+findex: outline-show-all
513      Show all, including drawers.
515 - {{{kbd(C-c C-r)}}} (~org-reveal~) ::
517      #+cindex: revealing context
518      #+kindex: C-c C-r
519      #+findex: org-reveal
520      Reveal context around point, showing the current entry, the
521      following heading and the hierarchy above.  Useful for working
522      near a location that has been exposed by a sparse tree command
523      (see [[*Sparse Trees]]) or an agenda command (see [[*Commands in the
524      Agenda Buffer]]).  With a prefix argument show, on each level, all
525      sibling headings.  With a double prefix argument, also show the
526      entire subtree of the parent.
528 - {{{kbd(C-c C-k)}}} (~outline-show-branches~) ::
530      #+cindex: show branches, command
531      #+kindex: C-c C-k
532      #+findex: outline-show-branches
533      Expose all the headings of the subtree, CONTENTS view for just
534      one subtree.
536 - {{{kbd(C-c TAB)}}} (~outline-show-children~) ::
538      #+cindex: show children, command
539      #+kindex: C-c TAB
540      #+findex: outline-show-children
541      Expose all direct children of the subtree.  With a numeric prefix
542      argument N, expose all children down to level N.
544 - {{{kbd(C-c C-x b)}}} (~org-tree-to-indirect-buffer~) ::
546      #+kindex: C-c C-x b
547      #+findex: org-tree-to-indirect-buffer
548      Show the current subtree in an indirect buffer[fn:5].  With
549      a numeric prefix argument, N, go up to level N and then take that
550      tree.  If N is negative then go up that many levels.  With
551      a {{{kbd(C-u)}}} prefix, do not remove the previously used
552      indirect buffer.
554 - {{{kbd(C-c C-x v)}}} (~org-copy-visible~) ::
556      #+kindex: C-c C-x v
557      #+findex: org-copy-visible
558      Copy the /visible/ text in the region into the kill ring.
560 *** Initial visibility
561 :PROPERTIES:
562 :DESCRIPTION: Setting the initial visibility state.
563 :END:
565 #+vindex: org-startup-folded
566 When Emacs first visits an Org file, the global state is set to
567 OVERVIEW, i.e., only the top level headlines are visible[fn:6].  This
568 can be configured through the variable ~org-startup-folded~, or on
569 a per-file basis by adding one of the following lines anywhere in the
570 buffer:
572 #+cindex: STARTUP, keyword
573 #+begin_example
574 ,#+STARTUP: overview
575 ,#+STARTUP: content
576 ,#+STARTUP: showall
577 ,#+STARTUP: showeverything
578 #+end_example
580 #+cindex: @samp{VISIBILITY}, property
581 #+texinfo: @noindent
582 Furthermore, any entries with a =VISIBILITY= property (see [[*Properties
583 and Columns]]) get their visibility adapted accordingly.  Allowed values
584 for this property are =folded=, =children=, =content=, and ~all~.
586 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
588      #+kindex: C-u C-u TAB
589      #+findex: org-set-startup-visibility
590      Switch back to the startup visibility of the buffer, i.e.,
591      whatever is requested by startup options and =VISIBILITY=
592      properties in individual entries.
594 *** Catching invisible edits
595 :PROPERTIES:
596 :DESCRIPTION: Preventing mistakes when editing invisible parts.
597 :END:
598 #+cindex: edits, catching invisible
600 #+vindex: org-catch-invisible-edits
601 Sometimes you may inadvertently edit an invisible part of the buffer
602 and be confused on what has been edited and how to undo the mistake.
603 Setting ~org-catch-invisible-edits~ to non-~nil~ helps preventing
604 this.  See the docstring of this option on how Org should catch
605 invisible edits and process them.
607 ** Motion
608 :PROPERTIES:
609 :DESCRIPTION: Jumping to other headlines.
610 :END:
611 #+cindex: motion, between headlines
612 #+cindex: jumping, to headlines
613 #+cindex: headline navigation
615 The following commands jump to other headlines in the buffer.
617 - {{{kbd(C-c C-n)}}} (~outline-next-visible-heading~) ::
619      #+kindex: C-c C-n
620      #+findex: outline-next-visible-heading
621      Next heading.
623 - {{{kbd(C-c C-p)}}} (~outline-previous-visible-heading~) ::
625      #+kindex: C-c C-p
626      #+findex: outline-previous-visible-heading
627      Previous heading.
629 - {{{kbd(C-c C-f)}}} (~org-forward-same-level~) ::
631      #+kindex: C-c C-f
632      #+findex: org-forward-same-level
633      Next heading same level.
635 - {{{kbd(C-c C-b)}}} (~org-backward-same-level~) ::
637      #+kindex: C-c C-b
638      #+findex: org-backward-same-level
639      Previous heading same level.
641 - {{{kbd(C-c C-u)}}} (~outline-up-heading~) ::
643      #+kindex: C-c C-u
644      #+findex: outline-up-heading
645      Backward to higher level heading.
647 - {{{kbd(C-c C-j)}}} (~org-goto~) ::
649      #+kindex: C-c C-j
650      #+findex: org-goto
651      #+vindex: org-goto-auto-isearch
652      Jump to a different place without changing the current outline
653      visibility.  Shows the document structure in a temporary buffer,
654      where you can use the following keys to find your destination:
656      #+attr_texinfo: :columns 0.3 0.7
657      | {{{kbd(TAB)}}}                  | Cycle visibility.               |
658      | {{{kbd(DOWN)}}} / {{{kbd(UP)}}} | Next/previous visible headline. |
659      | {{{kbd(RET)}}}                  | Select this location.           |
660      | {{{kbd(/)}}}                    | Do a Sparse-tree search         |
662      #+texinfo: @noindent
663      The following keys work if you turn off ~org-goto-auto-isearch~
665      #+attr_texinfo: :columns 0.3 0.7
666      | {{{kbd(n)}}} / {{{kbd(p)}}}   | Next/previous visible headline.    |
667      | {{{kbd(f)}}} / {{{kbd(b)}}}   | Next/previous headline same level. |
668      | {{{kbd(u)}}}                  | One level up.                      |
669      | {{{kbd(0)}}} ... {{{kbd(9)}}} | Digit argument.                    |
670      | {{{kbd(q)}}}                  | Quit.                              |
672      #+vindex: org-goto-interface
673      #+texinfo: @noindent
674      See also the variable ~org-goto-interface~.
676 ** Structure Editing
677 :PROPERTIES:
678 :DESCRIPTION: Changing sequence and level of headlines.
679 :END:
680 #+cindex: structure editing
681 #+cindex: headline, promotion and demotion
682 #+cindex: promotion, of subtrees
683 #+cindex: demotion, of subtrees
684 #+cindex: subtree, cut and paste
685 #+cindex: pasting, of subtrees
686 #+cindex: cutting, of subtrees
687 #+cindex: copying, of subtrees
688 #+cindex: sorting, of subtrees
689 #+cindex: subtrees, cut and paste
691 - {{{kbd(M-RET)}}} (~org-meta-return~) ::
693      #+kindex: M-RET
694      #+findex: org-meta-return
695      #+vindex: org-M-RET-may-split-line
696      Insert a new heading, item or row.
698      If the command is used at the /beginning/ of a line, and if there
699      is a heading or a plain list item (see [[*Plain Lists]]) at point,
700      the new heading/item is created /before/ the current line.  When
701      used at the beginning of a regular line of text, turn that line
702      into a heading.
704      When this command is used in the middle of a line, the line is
705      split and the rest of the line becomes the new item or headline.
706      If you do not want the line to be split, customize
707      ~org-M-RET-may-split-line~.
709      Calling the command with a {{{kbd(C-u)}}} prefix unconditionally
710      inserts a new heading at the end of the current subtree, thus
711      preserving its contents.  With a double {{{kbd(C-u C-u)}}}
712      prefix, the new heading is created at the end of the parent
713      subtree instead.
715 - {{{kbd(C-RET)}}} (~org-insert-heading-respect-content~) ::
717      #+kindex: C-RET
718      #+findex: org-insert-heading-respect-content
719      Insert a new heading at the end of the current subtree.
721 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
723      #+kindex: M-S-RET
724      #+findex: org-insert-todo-heading
725      #+vindex: org-treat-insert-todo-heading-as-state-change
726      Insert new TODO entry with same level as current heading.  See
727      also the variable
728      ~org-treat-insert-todo-heading-as-state-change~.
730 - {{{kbd(C-S-RET)}}} (~org-insert-todo-heading-respect-content~) ::
732      #+kindex: C-S-RET
733      #+findex: org-insert-todo-heading-respect-content
734      Insert new TODO entry with same level as current heading.  Like
735      {{{kbd(C-RET)}}}, the new headline is inserted after the current
736      subtree.
738 - {{{kbd(TAB)}}} (~org-cycle~) ::
740      #+kindex: TAB
741      #+findex: org-cycle
742      In a new entry with no text yet, the first {{{kbd(TAB)}}} demotes
743      the entry to become a child of the previous one.  The next
744      {{{kbd(TAB)}}} makes it a parent, and so on, all the way to top
745      level.  Yet another {{{kbd(TAB)}}}, and you are back to the
746      initial level.
748 - {{{kbd(M-LEFT)}}} (~org-do-promote~) ::
750      #+kindex: M-LEFT
751      #+findex: org-do-promote
752      Promote current heading by one level.
754 - {{{kbd(M-RIGHT)}}} (~org-do-demote~) ::
756      #+kindex: M-RIGHT
757      #+findex: org-do-demote
758      Demote current heading by one level.
760 - {{{kbd(M-S-LEFT)}}} (~org-promote-subtree~) ::
762      #+kindex: M-S-LEFT
763      #+findex: org-promote-subtree
764      Promote the current subtree by one level.
766 - {{{kbd(M-S-RIGHT)}}} (~org-demote-subtree~) ::
768      #+kindex: M-S-RIGHT
769      #+findex: org-demote-subtree
770      Demote the current subtree by one level.
772 - {{{kbd(M-UP)}}} (~org-move-subtree-up~) ::
774      #+kindex: M-UP
775      #+findex: org-move-subtree-up
776      Move subtree up, i.e., swap with previous subtree of same level.
778 - {{{kbd(M-DOWN)}}} (~org-move-subtree-down~) ::
780      #+kindex: M-DOWN
781      #+findex: org-move-subtree-down
782      Move subtree down, i.e., swap with next subtree of same level.
784 - {{{kbd(C-c @)}}} (~org-mark-subtree~) ::
786      #+kindex: C-c @@
787      #+findex: org-mark-subtree
788      Mark the subtree at point.  Hitting repeatedly marks subsequent
789      subtrees of the same level as the marked subtree.
791 - {{{kbd(C-c C-x C-w)}}} (~org-cut-subtree~) ::
793      #+kindex: C-c C-x C-w
794      #+findex: org-cut-subtree
795      Kill subtree, i.e., remove it from buffer but save in kill ring.
796      With a numeric prefix argument N, kill N sequential subtrees.
798 - {{{kbd(C-c C-x M-w)}}} (~org-copy-subtree~) ::
800      #+kindex: C-c C-x M-w
801      #+findex: org-copy-subtree
802      Copy subtree to kill ring.  With a numeric prefix argument N,
803      copy the N sequential subtrees.
805 - {{{kbd(C-c C-x C-y)}}} (~org-paste-subtree~) ::
807      #+kindex: C-c C-x C-y
808      #+findex: org-paste-subtree
809      Yank subtree from kill ring.  This does modify the level of the
810      subtree to make sure the tree fits in nicely at the yank
811      position.  The yank level can also be specified with a numeric
812      prefix argument, or by yanking after a headline marker like
813      =****=.
815 - {{{kbd(C-y)}}} (~org-yank~) ::
817      #+kindex: C-y
818      #+findex: org-yank
819      #+vindex: org-yank-adjusted-subtrees
820      #+vindex: org-yank-folded-subtrees
821      Depending on the variables ~org-yank-adjusted-subtrees~ and
822      ~org-yank-folded-subtrees~, Org's internal ~yank~ command pastes
823      subtrees folded and in a clever way, using the same command as
824      {{{kbd(C-c C-x C-y)}}}.  With the default settings, no level
825      adjustment takes place, but the yanked tree is folded unless
826      doing so would swallow text previously visible.  Any prefix
827      argument to this command forces a normal ~yank~ to be executed,
828      with the prefix passed along.  A good way to force a normal yank
829      is {{{kbd(C-u C-y)}}}.  If you use ~yank-pop~ after a yank, it
830      yanks previous kill items plainly, without adjustment and
831      folding.
833 - {{{kbd(C-c C-x c)}}} (~org-clone-subtree-with-time-shift~) ::
835      #+kindex: C-c C-x c
836      #+findex: org-clone-subtree-with-time-shift
837      Clone a subtree by making a number of sibling copies of it.  You
838      are prompted for the number of copies to make, and you can also
839      specify if any timestamps in the entry should be shifted.  This
840      can be useful, for example, to create a number of tasks related
841      to a series of lectures to prepare.  For more details, see the
842      docstring of the command ~org-clone-subtree-with-time-shift~.
844 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
846      #+kindex: C-c C-w
847      #+findex: org-refile
848      Refile entry or region to a different location.  See [[Refile and
849      Copy]].
851 - {{{kbd(C-c ^)}}} (~org-sort~) ::
853      #+kindex: C-c ^
854      #+findex: org-sort
855      Sort same-level entries.  When there is an active region, all
856      entries in the region are sorted.  Otherwise the children of the
857      current headline are sorted.  The command prompts for the sorting
858      method, which can be alphabetically, numerically, by time---first
859      timestamp with active preferred, creation time, scheduled time,
860      deadline time---by priority, by TODO keyword---in the sequence
861      the keywords have been defined in the setup---or by the value of
862      a property.  Reverse sorting is possible as well.  You can also
863      supply your own function to extract the sorting key.  With
864      a {{{kbd(C-u)}}} prefix, sorting is case-sensitive.
866 - {{{kbd(C-x n s)}}} (~org-narrow-to-subtree~) ::
868      #+kindex: C-x n s
869      #+findex: org-narrow-to-subtree
870      Narrow buffer to current subtree.
872 - {{{kbd(C-x n b)}}} (~org-narrow-to-block~) ::
874      #+kindex: C-x n b
875      #+findex: org-narrow-to-block
876      Narrow buffer to current block.
878 - {{{kbd(C-x n w)}}} (~widen~) ::
880      #+kindex: C-x n w
881      #+findex: widen
882      Widen buffer to remove narrowing.
884 - {{{kbd(C-c *)}}} (~org-toggle-heading~) ::
886      #+kindex: C-c *
887      #+findex: org-toggle-heading
888      Turn a normal line or plain list item into a headline---so that
889      it becomes a subheading at its location.  Also turn a headline
890      into a normal line by removing the stars.  If there is an active
891      region, turn all lines in the region into headlines.  If the
892      first line in the region was an item, turn only the item lines
893      into headlines.  Finally, if the first line is a headline, remove
894      the stars from all headlines in the region.
896 #+cindex: region, active
897 #+cindex: active region
898 #+cindex: transient mark mode
899 When there is an active region---i.e., when Transient Mark mode is
900 active---promotion and demotion work on all headlines in the region.
901 To select a region of headlines, it is best to place both point and
902 mark at the beginning of a line, mark at the beginning of the first
903 headline, and point at the line just after the last headline to
904 change.  Note that when the cursor is inside a table (see [[*Tables]]),
905 the Meta-Cursor keys have different functionality.
907 ** Sparse Trees
908 :PROPERTIES:
909 :DESCRIPTION: Matches embedded in context.
910 :END:
911 #+cindex: sparse trees
912 #+cindex: trees, sparse
913 #+cindex: folding, sparse trees
914 #+cindex: occur, command
916 #+vindex: org-show-context-detail
917 An important feature of Org mode is the ability to construct /sparse
918 trees/ for selected information in an outline tree, so that the entire
919 document is folded as much as possible, but the selected information
920 is made visible along with the headline structure above it[fn:7].
921 Just try it out and you will see immediately how it works.
923 Org mode contains several commands creating such trees, all these
924 commands can be accessed through a dispatcher:
926 - {{{kbd(C-c /)}}} (~org-sparse-tree~) ::
928      #+kindex: C-c /
929      #+findex: org-sparse-tree
930      This prompts for an extra key to select a sparse-tree creating
931      command.
933 - {{{kbd(C-c / r)}}} or {{{kbd(C-c / /)}}} (~org-occur~) ::
935      #+kindex: C-c / r
936      #+kindex: C-c / /
937      #+findex: org-occur
938      #+vindex: org-remove-highlights-with-change
939      Prompts for a regexp and shows a sparse tree with all matches.
940      If the match is in a headline, the headline is made visible.  If
941      the match is in the body of an entry, headline and body are made
942      visible.  In order to provide minimal context, also the full
943      hierarchy of headlines above the match is shown, as well as the
944      headline following the match.  Each match is also highlighted;
945      the highlights disappear when the buffer is changed by an editing
946      command, or by pressing {{{kbd(C-c C-c)}}}[fn:8].  When called
947      with a {{{kbd(C-u)}}} prefix argument, previous highlights are
948      kept, so several calls to this command can be stacked.
950 - {{{kbd(M-g n)}}} or {{{kbd(M-g M-n)}}} (~next-error~) ::
952      #+kindex: M-g n
953      #+kindex: M-g M-n
954      #+findex: next-error
955      Jump to the next sparse tree match in this buffer.
957 - {{{kbd(M-g p)}}} or {{{kbd(M-g M-p)}}} (~previous-error~) ::
959      #+kindex: M-g p
960      #+kindex: M-g M-p
961      #+findex: previous-error
962      Jump to the previous sparse tree match in this buffer.
964 #+vindex: org-agenda-custom-commands
965 #+texinfo: @noindent
966 For frequently used sparse trees of specific search strings, you can
967 use the variable ~org-agenda-custom-commands~ to define fast keyboard
968 access to specific sparse trees.  These commands will then be
969 accessible through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
970 For example:
972 #+begin_src emacs-lisp
973 (setq org-agenda-custom-commands
974       '(("f" occur-tree "FIXME")))
975 #+end_src
977 #+texinfo: @noindent
978 defines the key {{{kbd(f)}}} as a shortcut for creating a sparse tree
979 matching the string =FIXME=.
981 The other sparse tree commands select headings based on TODO keywords,
982 tags, or properties and are discussed later in this manual.
984 #+kindex: C-c C-e v
985 #+cindex: printing sparse trees
986 #+cindex: visible text, printing
987 To print a sparse tree, you can use the Emacs command
988 ~ps-print-buffer-with-faces~ which does not print invisible parts of
989 the document.  Or you can use the command {{{kbd(C-c C-e v)}}} to
990 export only the visible part of the document and print the resulting
991 file.
993 ** Plain Lists
994 :PROPERTIES:
995 :DESCRIPTION: Additional structure within an entry.
996 :END:
997 #+cindex: plain lists
998 #+cindex: lists, plain
999 #+cindex: lists, ordered
1000 #+cindex: ordered lists
1002 Within an entry of the outline tree, hand-formatted lists can provide
1003 additional structure.  They also provide a way to create lists of
1004 checkboxes (see [[*Checkboxes]]).  Org supports editing such lists, and
1005 every exporter (see [[*Exporting]]) can parse and format them.
1007 Org knows ordered lists, unordered lists, and description lists.
1009 #+attr_texinfo: :indic @bullet
1010 - /Unordered/ list items start with =-=, =+=, or =*=[fn:9] as bullets.
1013   #+vindex: org-plain-list-ordered-item-terminator
1014   #+vindex: org-alphabetical-lists
1015   /Ordered/ list items start with a numeral followed by either
1016   a period or a right parenthesis[fn:10], such as =1.= or =1)=[fn:11]
1017   If you want a list to start with a different value---e.g.,
1018   20---start the text of the item with =[@20]=[fn:12].  Those
1019   constructs can be used in any item of the list in order to enforce
1020   a particular numbering.
1022 - /Description/ list items are unordered list items, and contain the
1023   separator =::= to distinguish the description /term/ from the
1024   description.
1026 Items belonging to the same list must have the same indentation on the
1027 first line.  In particular, if an ordered list reaches number =10.=,
1028 then the 2-digit numbers must be written left-aligned with the other
1029 numbers in the list.  An item ends before the next line that is less
1030 or equally indented than its bullet/number.
1032 A list ends whenever every item has ended, which means before any line
1033 less or equally indented than items at top level.  It also ends before
1034 two blank lines.  In that case, all items are closed.  Here is an
1035 example:
1037 #+begin_example
1038 ,* Lord of the Rings
1039 My favorite scenes are (in this order)
1040 1. The attack of the Rohirrim
1041 2. Eowyn's fight with the witch king
1042    + this was already my favorite scene in the book
1043    + I really like Miranda Otto.
1044 3. Peter Jackson being shot by Legolas
1045    - on DVD only
1046    He makes a really funny face when it happens.
1047 But in the end, no individual scenes matter but the film as a whole.
1048 Important actors in this film are:
1049 - Elijah Wood :: He plays Frodo
1050 - Sean Astin :: He plays Sam, Frodo's friend. I still remember him
1051      very well from his role as Mikey Walsh in /The Goonies/.
1052 #+end_example
1054 Org supports these lists by tuning filling and wrapping commands to
1055 deal with them correctly, and by exporting them properly (see
1056 [[Exporting]]).  Since indentation is what governs the structure of these
1057 lists, many structural constructs like =#+BEGIN_= blocks can be
1058 indented to signal that they belong to a particular item.
1060 #+vindex: org-list-demote-modify-bullet
1061 #+vindex: org-list-indent-offset
1062 If you find that using a different bullet for a sub-list---than that
1063 used for the current list-level---improves readability, customize the
1064 variable ~org-list-demote-modify-bullet~.  To get a greater difference
1065 of indentation between items and theirs sub-items, customize
1066 ~org-list-indent-offset~.
1068 #+vindex: org-list-automatic-rules
1069 The following commands act on items when the cursor is in the first
1070 line of an item---the line with the bullet or number.  Some of them
1071 imply the application of automatic rules to keep list structure
1072 intact.  If some of these actions get in your way, configure
1073 ~org-list-automatic-rules~ to disable them individually.
1075 #+attr_texinfo: :sep ,
1076 - {{{kbd(TAB)}}} (~org-cycle~) ::
1078      #+cindex: cycling, in plain lists
1079      #+kindex: TAB
1080      #+findex: org-cycle
1081      #+vindex: org-cycle-include-plain-lists
1082      Items can be folded just like headline levels.  Normally this
1083      works only if the cursor is on a plain list item.  For more
1084      details, see the variable ~org-cycle-include-plain-lists~.  If
1085      this variable is set to ~integrate~, plain list items are treated
1086      like low-level headlines.  The level of an item is then given by
1087      the indentation of the bullet/number.  Items are always
1088      subordinate to real headlines, however; the hierarchies remain
1089      completely separated.  In a new item with no text yet, the first
1090      {{{kbd(TAB)}}} demotes the item to become a child of the previous
1091      one.  Subsequent {{{kbd(TAB)}}}s move the item to meaningful
1092      levels in the list and eventually get it back to its initial
1093      position.
1095 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
1097      #+kindex: M-RET
1098      #+findex: org-insert-heading
1099      #+vindex: org-M-RET-may-split-line
1100      Insert new item at current level.  With a prefix argument, force
1101      a new heading (see [[*Structure Editing]]).  If this command is used
1102      in the middle of an item, that item is /split/ in two, and the
1103      second part becomes the new item[fn:13].  If this command is
1104      executed /before item's body/, the new item is created /before/
1105      the current one.
1107 - {{{kbd(M-S-RET)}}} ::
1109      #+kindex: M-S-RET
1110      Insert a new item with a checkbox (see [[Checkboxes]]).
1112 - {{{kbd(S-UP)}}}, {{{kbd(S-DOWN)}}} ::
1114      #+kindex: S-UP
1115      #+kindex: S-DOWN
1116      #+cindex: shift-selection-mode
1117      #+vindex: org-support-shift-select
1118      #+vindex: org-list-use-circular-motion
1119      Jump to the previous/next item in the current list, but only if
1120      ~org-support-shift-select~ is off[fn:14].  If not, you can
1121      still use paragraph jumping commands like {{{kbd(C-UP)}}}
1122      and {{{kbd(C-DOWN)}}} to quite similar effect.
1124 - {{{kbd(M-UP)}}}, {{{kbd(M-DOWN)}}} ::
1126      #+kindex: M-UP
1127      #+kindex: M-DOWN
1128      Move the item including subitems up/down[fn:15], i.e., swap with
1129      previous/next item of same indentation.  If the list is ordered,
1130      renumbering is automatic.
1132 - {{{kbd(M-LEFT)}}}, {{{kbd(M-RIGHT)}}} ::
1134      #+kindex: M-LEFT
1135      #+kindex: M-RIGHT
1136      Decrease/increase the indentation of an item, leaving children
1137      alone.
1139 - {{{kbd(M-S-LEFT)}}}, {{{kbd(M-S-RIGHT)}}} ::
1141      #+kindex: M-S-LEFT
1142      #+kindex: M-S-RIGHT
1143      Decrease/increase the indentation of the item, including
1144      subitems.  Initially, the item tree is selected based on current
1145      indentation.  When these commands are executed several times in
1146      direct succession, the initially selected region is used, even if
1147      the new indentation would imply a different hierarchy.  To use
1148      the new hierarchy, break the command chain with a cursor motion
1149      or so.
1151      As a special case, using this command on the very first item of
1152      a list moves the whole list.  This behavior can be disabled by
1153      configuring ~org-list-automatic-rules~.  The global indentation
1154      of a list has no influence on the text /after/ the list.
1156 - {{{kbd(C-c C-c)}}} ::
1158      #+kindex: C-c C-c
1159      If there is a checkbox (see [[Checkboxes]]) in the item line, toggle
1160      the state of the checkbox.  In any case, verify bullets and
1161      indentation consistency in the whole list.
1163 - {{{kbd(C-c -)}}} ::
1165      #+kindex: C-c -
1166      #+vindex: org-plain-list-ordered-item-terminator
1167      Cycle the entire list level through the different
1168      itemize/enumerate bullets (=-=, =+=, =*=, =1.=, =1)=) or a subset
1169      of them, depending on ~org-plain-list-ordered-item-terminator~,
1170      the type of list, and its indentation.  With a numeric prefix
1171      argument N, select the Nth bullet from this list.  If there is an
1172      active region when calling this, selected text is changed into an
1173      item.  With a prefix argument, all lines are converted to list
1174      items.  If the first line already was a list item, any item
1175      marker is removed from the list.  Finally, even without an active
1176      region, a normal line is converted into a list item.
1178 - {{{kbd(C-c *)}}} ::
1180      #+kindex: C-c *
1181      Turn a plain list item into a headline---so that it becomes
1182      a subheading at its location.  See [[*Structure Editing]], for
1183      a detailed explanation.
1185 - {{{kbd(C-c C-*)}}} ::
1187      #+kindex: C-c C-*
1188      Turn the whole plain list into a subtree of the current heading.
1189      Checkboxes (see [[*Checkboxes]]) become TODO, respectively DONE,
1190      keywords when unchecked, respectively checked.
1192 - {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} ::
1194      #+vindex: org-support-shift-select
1195      #+kindex: S-LEFT
1196      #+kindex: S-RIGHT
1197      This command also cycles bullet styles when the cursor in on the
1198      bullet or anywhere in an item line, details depending on
1199      ~org-support-shift-select~.
1201 - {{{kbd(C-c ^)}}} ::
1203      #+kindex: C-c ^
1204      #+cindex: sorting, of plain list
1205      Sort the plain list.  Prompt for the sorting method: numerically,
1206      alphabetically, by time, or by custom function.
1208 ** Drawers
1209 :PROPERTIES:
1210 :DESCRIPTION: Tucking stuff away.
1211 :END:
1212 #+cindex: drawers
1213 #+cindex: visibility cycling, drawers
1215 Sometimes you want to keep information associated with an entry, but
1216 you normally do not want to see it.  For this, Org mode has /drawers/.
1217 They can contain anything but a headline and another drawer.  Drawers
1218 look like this:
1220 #+begin_example
1221 ,** This is a headline
1222 Still outside the drawer
1223 :DRAWERNAME:
1224 This is inside the drawer.
1225 :END:
1226 After the drawer.
1227 #+end_example
1229 #+kindex: C-c C-x d
1230 #+findex: org-insert-drawer
1231 You can interactively insert a drawer at point by calling
1232 ~org-insert-drawer~, which is bound to {{{kbd(C-c C-x d)}}}.  With an
1233 active region, this command puts the region inside the drawer.  With
1234 a prefix argument, this command calls ~org-insert-property-drawer~,
1235 which creates a =PROPERTIES= drawer right below the current headline.
1236 Org mode uses this special drawer for storing properties (see
1237 [[*Properties and Columns]]).  You cannot use it for anything else.
1239 Completion over drawer keywords is also possible using
1240 {{{kbd(M-TAB)}}}[fn:16].
1242 Visibility cycling (see [[*Visibility Cycling]]) on the headline hides and
1243 shows the entry, but keep the drawer collapsed to a single line.  In
1244 order to look inside the drawer, you need to move the cursor to the
1245 drawer line and press {{{kbd(TAB)}}} there.
1247 You can also arrange for state change notes (see [[Tracking TODO state
1248 changes]]) and clock times (see [[*Clocking Work Time]]) to be stored in
1249 a =LOGBOOK= drawer.  If you want to store a quick note there, in
1250 a similar way to state changes, use
1252 - {{{kbd(C-c C-z)}}} ::
1254      #+kindex: C-c C-z
1255      Add a time-stamped note to the =LOGBOOK= drawer.
1257 ** Blocks
1258 :PROPERTIES:
1259 :DESCRIPTION: Folding blocks.
1260 :END:
1261 #+vindex: org-hide-block-startup
1262 #+cindex: blocks, folding
1264 Org mode uses =#+BEGIN= ... =#+END= blocks for various purposes from
1265 including source code examples (see [[*Literal Examples]]) to capturing
1266 time logging information (see [[*Clocking Work Time]]).  These blocks can
1267 be folded and unfolded by pressing {{{kbd(TAB)}}} in the =#+BEGIN=
1268 line.  You can also get all blocks folded at startup by configuring
1269 the variable ~org-hide-block-startup~ or on a per-file basis by using
1271 #+cindex: STARTUP, keyword
1272 #+begin_example
1273 ,#+STARTUP: hideblocks
1274 ,#+STARTUP: nohideblocks
1275 #+end_example
1277 ** Creating Footnotes
1278 :PROPERTIES:
1279 :DESCRIPTION: How footnotes are defined in Org's syntax.
1280 :END:
1281 #+cindex: footnotes
1283 Org mode supports the creation of footnotes.
1285 A footnote is started by a footnote marker in square brackets in
1286 column 0, no indentation allowed.  It ends at the next footnote
1287 definition, headline, or after two consecutive empty lines.  The
1288 footnote reference is simply the marker in square brackets, inside
1289 text.  Markers always start with =fn:=.  For example:
1291 #+begin_example
1292 The Org homepage[fn:1] now looks a lot better than it used to.
1294 [fn:1] The link is: https://orgmode.org
1295 #+end_example
1297 Org mode extends the number-based syntax to /named/ footnotes and
1298 optional inline definition.  Here are the valid references:
1300 - =[fn:NAME]= ::
1302      A named footnote reference, where {{{var(NAME)}}} is a unique
1303      label word, or, for simplicity of automatic creation, a number.
1305 - =[fn:: This is the inline definition of this footnote]= ::
1307      A LaTeX-like anonymous footnote where the definition is given
1308      directly at the reference point.
1310 - =[fn:NAME: a definition]= ::
1312      An inline definition of a footnote, which also specifies a name
1313      for the note.  Since Org allows multiple references to the same
1314      note, you can then use =[fn:NAME]= to create additional
1315      references.
1317 #+vindex: org-footnote-auto-label
1318 Footnote labels can be created automatically, or you can create names
1319 yourself.  This is handled by the variable ~org-footnote-auto-label~
1320 and its corresponding =STARTUP= keywords.  See the docstring of that
1321 variable for details.
1323 #+texinfo: @noindent
1324 The following command handles footnotes:
1326 - {{{kbd(C-c C-x f)}}} ::
1328      The footnote action command.
1330      #+kindex: C-c C-x f
1331      When the cursor is on a footnote reference, jump to the
1332      definition.  When it is at a definition, jump to
1333      the---first---reference.
1335      #+vindex: org-footnote-define-inline
1336      #+vindex: org-footnote-section
1337      Otherwise, create a new footnote.  Depending on the variable
1338      ~org-footnote-define-inline~[fn:17], the definition is placed
1339      right into the text as part of the reference, or separately into
1340      the location determined by the variable ~org-footnote-section~.
1342      When this command is called with a prefix argument, a menu of
1343      additional options is offered:
1345      #+attr_texinfo: :columns 0.1 0.9
1346      | {{{kbd(s)}}} | Sort the footnote definitions by reference sequence.               |
1347      | {{{kbd(r)}}} | Renumber the simple =fn:N= footnotes.                              |
1348      | {{{kbd(S)}}} | Short for first {{{kbd(r)}}}, then {{{kbd(s)}}} action.            |
1349      | {{{kbd(n)}}} | Rename all footnotes into a =fn:1= ... =fn:n= sequence.            |
1350      | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
1352      #+vindex: org-footnote-auto-adjust
1353      Depending on the variable ~org-footnote-auto-adjust~[fn:18],
1354      renumbering and sorting footnotes can be automatic after each
1355      insertion or deletion.
1357 - {{{kbd(C-c C-c)}}} ::
1359      #+kindex: C-c C-c
1360      If the cursor is on a footnote reference, jump to the definition.
1361      If it is at the definition, jump back to the reference.  When
1362      called at a footnote location with a prefix argument, offer the
1363      same menu as {{{kbd(C-c C-x f)}}}.
1365 - {{{kbd(C-c C-o)}}} or {{{kbd(mouse-1/2)}}} ::
1367      #+kindex: C-c C-o
1368      #+kindex: mouse-1
1369      #+kindex: mouse-2
1370      Footnote labels are also links to the corresponding definition or
1371      reference, and you can use the usual commands to follow these
1372      links.
1374 ** Org Syntax
1375 :PROPERTIES:
1376 :DESCRIPTION: Formal description of Org's syntax.
1377 :END:
1379 A reference document providing a formal description of Org's syntax is
1380 available as [[https://orgmode.org/worg/dev/org-syntax.html][a draft on Worg]], written and maintained by Nicolas
1381 Goaziou.  It defines Org's core internal concepts such as =headlines=,
1382 =sections=, =affiliated keywords=, =(greater) elements= and =objects=.
1383 Each part of an Org file falls into one of the categories above.
1385 To explore the abstract structure of an Org buffer, run this in
1386 a buffer:
1388 : M-: (org-element-parse-buffer) <RET>
1390 #+texinfo: @noindent
1391 It outputs a list containing the buffer's content represented as an
1392 abstract structure.  The export engine relies on the information
1393 stored in this list.  Most interactive commands---e.g., for structure
1394 editing---also rely on the syntactic meaning of the surrounding
1395 context.
1397 #+cindex: syntax checker
1398 #+cindex: linter
1399 #+findex: org-lint
1400 You can check syntax in your documents using ~org-lint~ command.
1402 * Tables
1403 :PROPERTIES:
1404 :DESCRIPTION: Pure magic for quick formatting.
1405 :END:
1406 #+cindex: tables
1407 #+cindex: editing tables
1409 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1410 calculations are supported using the Emacs Calc package (see [[info:calc][GNU Emacs
1411 Calculator Manual]]).
1413 ** Built-in Table Editor
1414 :PROPERTIES:
1415 :DESCRIPTION: Simple tables.
1416 :END:
1417 #+cindex: table editor, built-in
1419 Org makes it easy to format tables in plain ASCII.  Any line with =|=
1420 as the first non-whitespace character is considered part of a table.
1421 =|= is also the column separator[fn:19].  A table might look like
1422 this:
1424 #+begin_example
1425 | Name  | Phone | Age |
1426 |-------+-------+-----|
1427 | Peter |  1234 |  17 |
1428 | Anna  |  4321 |  25 |
1429 #+end_example
1431 A table is re-aligned automatically each time you press
1432 {{{kbd(TAB)}}}, {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} inside the table.
1433 {{{kbd(TAB)}}} also moves to the next field---{{{kbd(RET)}}} to the
1434 next row---and creates new table rows at the end of the table or
1435 before horizontal lines.  The indentation of the table is set by the
1436 first line.  Any line starting with =|-= is considered as a horizontal
1437 separator line and will be expanded on the next re-align to span the
1438 whole table width.  So, to create the above table, you would only type
1440 #+begin_example
1441 |Name|Phone|Age|
1443 #+end_example
1445 #+texinfo: @noindent
1446 and then press {{{kbd(TAB)}}} to align the table and start filling in
1447 fields.  Even faster would be to type =|Name|Phone|Age= followed by
1448 {{{kbd(C-c RET)}}}.
1450 When typing text into a field, Org treats {{{kbd(DEL)}}},
1451 {{{kbd(Backspace)}}}, and all character keys in a special way, so that
1452 inserting and deleting avoids shifting other fields.  Also, when
1453 typing /immediately/ after the cursor was moved into a new field with
1454 {{{kbd(TAB)}}}, {{{kbd(S-TAB)}}} or {{{kbd(RET)}}}, the field is
1455 automatically made blank.  If this behavior is too unpredictable for
1456 you, configure the option ~org-table-auto-blank-field~.
1458 *** Creation and conversion
1459 :PROPERTIES:
1460 :UNNUMBERED: notoc
1461 :END:
1463 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1465      #+kindex: C-c |
1466      #+findex: org-table-create-or-convert-from-region
1467      Convert the active region to table.  If every line contains at
1468      least one {{{kbd(TAB)}}} character, the function assumes that the
1469      material is tab separated.  If every line contains a comma,
1470      comma-separated values (CSV) are assumed.  If not, lines are
1471      split at whitespace into fields.  You can use a prefix argument
1472      to force a specific separator: {{{kbd(C-u)}}} forces CSV,
1473      {{{kbd(C-u C-u)}}} forces {{{kbd(TAB)}}}, {{{kbd(C-u C-u C-u)}}}
1474      prompts for a regular expression to match the separator, and
1475      a numeric argument N indicates that at least N consecutive
1476      spaces, or alternatively a {{{kbd(TAB)}}} will be the separator.
1478      If there is no active region, this command creates an empty Org
1479      table.  But it is easier just to start typing, like {{{kbd(|
1480      N a m e | P h o n e | A g e RET | - TAB)}}}.
1482 *** Re-aligning and field motion
1483 :PROPERTIES:
1484 :UNNUMBERED: notoc
1485 :END:
1487 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1489      #+kindex: C-c C-c
1490      #+findex: org-table-align
1491      Re-align the table without moving the cursor.
1493 - {{{kbd(TAB)}}} (~org-table-next-field~) ::
1495      #+kindex: TAB
1496      #+findex: org-table-next-field
1497      Re-align the table, move to the next field.  Creates a new row if
1498      necessary.
1500 - {{{kbd(C-c SPC)}}} (~org-table-blank-field~) ::
1502      #+kindex: C-c SPC
1503      #+findex: org-table-blank-field
1504      Blank the field at point.
1506 - {{{kbd(S-TAB)}}} (~org-table-previous-field~) ::
1508      #+kindex: S-TAB
1509      #+findex: org-table-previous-field
1510      Re-align, move to previous field.
1512 - {{{kbd(RET)}}} (~org-table-next-row~) ::
1514      #+kindex: RET
1515      #+findex: org-table-next-row
1516      Re-align the table and move down to next row.  Creates a new row
1517      if necessary.  At the beginning or end of a line, {{{kbd(RET)}}}
1518      still inserts a new line, so it can be used to split a table.
1520 - {{{kbd(M-a)}}} (~org-table-beginning-of-field~) ::
1522      #+kindex: M-a
1523      #+findex: org-table-beginning-of-field
1524      Move to beginning of the current table field, or on to the
1525      previous field.
1527 - {{{kbd(M-e)}}} (~org-table-end-of-field~) ::
1529      #+kindex: M-e
1530      #+findex: org-table-end-of-field
1531      Move to end of the current table field, or on to the next field.
1533 *** Column and row editing
1534 :PROPERTIES:
1535 :UNNUMBERED: notoc
1536 :END:
1538 - {{{kbd(M-LEFT)}}} (~org-table-move-column-left~) ::
1540      #+kindex: M-LEFT
1541      #+findex: org-table-move-column-left
1542      Move the current column left.
1544 - {{{kbd(M-RIGHT)}}} (~org-table-move-column-right~) ::
1546      #+kindex: M-RIGHT
1547      #+findex: org-table-move-column-right
1548      Move the current column right.
1550 - {{{kbd(M-S-LEFT)}}} (~org-table-delete-column~) ::
1552      #+kindex: M-S-LEFT
1553      #+findex: org-table-delete-column
1554      Kill the current column.
1556 - {{{kbd(M-S-RIGHT)}}} (~org-table-insert-column~) ::
1558      #+kindex: M-S-RIGHT
1559      #+findex: org-table-insert-column
1560      Insert a new column to the left of the cursor position.
1562 - {{{kbd(M-UP)}}} (~org-table-move-row-up~) ::
1564      #+kindex: M-UP
1565      #+findex: org-table-move-row-up
1566      Move the current row up.
1568 - {{{kbd(M-DOWN)}}} (~org-table-move-row-down~) ::
1570      #+kindex: M-DOWN
1571      #+findex: org-table-move-row-down
1572      Move the current row down.
1574 - {{{kbd(M-S-UP)}}} (~org-table-kill-row~) ::
1576      #+kindex: M-S-UP
1577      #+findex: org-table-kill-row
1578      Kill the current row or horizontal line.
1580 - {{{kbd(M-S-DOWN)}}} (~org-table-insert-row~) ::
1582      #+kindex: M-S-DOWN
1583      #+findex: org-table-insert-row
1584      Insert a new row above the current row.  With a prefix argument,
1585      the line is created below the current one.
1587 - {{{kbd(C-c -)}}} (~org-table-insert-hline~) ::
1589      #+kindex: C-c -
1590      #+findex: org-table-insert-hline
1591      Insert a horizontal line below current row.  With a prefix
1592      argument, the line is created above the current line.
1594 - {{{kbd(C-c RET)}}} (~org-table-hline-and-move~) ::
1596      #+kindex: C-c RET
1597      #+findex: org-table-hline-and-move
1598      Insert a horizontal line below current row, and move the cursor
1599      into the row below that line.
1601 - {{{kbd(C-c ^)}}} (~org-table-sort-lines~) ::
1603      #+kindex: C-c ^
1604      #+findex: org-table-sort-lines
1605      Sort the table lines in the region.  The position of point
1606      indicates the column to be used for sorting, and the range of
1607      lines is the range between the nearest horizontal separator
1608      lines, or the entire table.  If point is before the first column,
1609      you are prompted for the sorting column.  If there is an active
1610      region, the mark specifies the first line and the sorting column,
1611      while point should be in the last line to be included into the
1612      sorting.  The command prompts for the sorting type,
1613      alphabetically, numerically, or by time.  You can sort in normal
1614      or reverse order.  You can also supply your own key extraction
1615      and comparison functions.  When called with a prefix argument,
1616      alphabetic sorting is case-sensitive.
1618 *** Regions
1619 :PROPERTIES:
1620 :UNNUMBERED: notoc
1621 :END:
1623 - {{{kbd(C-c C-x M-w)}}} (~org-table-copy-region~) ::
1625      #+kindex: C-c C-x M-w
1626      #+findex: org-table-copy-region
1627      Copy a rectangular region from a table to a special clipboard.
1628      Point and mark determine edge fields of the rectangle.  If there
1629      is no active region, copy just the current field.  The process
1630      ignores horizontal separator lines.
1632 - {{{kbd(C-c C-x C-w)}}} (~org-table-cut-region~) ::
1634      #+kindex: C-c C-x C-w
1635      #+findex: org-table-cut-region
1636      Copy a rectangular region from a table to a special clipboard,
1637      and blank all fields in the rectangle.  So this is the "cut"
1638      operation.
1640 - {{{kbd(C-c C-x C-y)}}} (~org-table-paste-rectangle~) ::
1642      #+kindex: C-c C-x C-y
1643      #+findex: org-table-paste-rectangle
1644      Paste a rectangular region into a table.  The upper left corner
1645      ends up in the current field.  All involved fields are
1646      overwritten.  If the rectangle does not fit into the present
1647      table, the table is enlarged as needed.  The process ignores
1648      horizontal separator lines.
1650 - {{{kbd(M-RET)}}} (~org-table-wrap-region~) ::
1652      #+kindex: M-RET
1653      #+findex: org-table-wrap-region
1654      Split the current field at the cursor position and move the rest
1655      to the line below.  If there is an active region, and both point
1656      and mark are in the same column, the text in the column is
1657      wrapped to minimum width for the given number of lines.
1658      A numeric prefix argument may be used to change the number of
1659      desired lines.  If there is no region, but you specify a prefix
1660      argument, the current field is made blank, and the content is
1661      appended to the field above.
1663 *** Calculations
1664 :PROPERTIES:
1665 :UNNUMBERED: notoc
1666 :END:
1668 #+cindex: formula, in tables
1669 #+cindex: calculations, in tables
1671 - {{{kbd(C-c +)}}} (~org-table-sum~) ::
1673      #+kindex: C-c +
1674      #+findex: org-table-sum
1675      Sum the numbers in the current column, or in the rectangle
1676      defined by the active region.  The result is shown in the echo
1677      area and can be inserted with {{{kbd(C-y)}}}.
1679 - {{{kbd(S-RET)}}} (~org-table-copy-down~) ::
1681      #+kindex: S-RET
1682      #+findex: org-table-copy-down
1683      #+vindex: org-table-copy-increment
1684      When current field is empty, copy from first non-empty field
1685      above.  When not empty, copy current field down to next row and
1686      move cursor along with it.  Depending on the variable
1687      ~org-table-copy-increment~, integer field values can be
1688      incremented during copy.  Integers that are too large are not
1689      incremented, however.  Also, a ~0~ prefix argument temporarily
1690      disables the increment.  This key is also used by shift-selection
1691      and related modes (see [[*Packages that conflict with Org mode]]).
1693 *** Miscellaneous
1694 :PROPERTIES:
1695 :UNNUMBERED: notoc
1696 :END:
1698 - {{{kbd(C-c `)}}} (~org-table-edit-field~) ::
1700      #+kindex: C-c `
1701      #+findex: org-table-edit-field
1702      Edit the current field in a separate window.  This is useful for
1703      fields that are not fully visible (see [[*Column Width and
1704      Alignment]]).  When called with a {{{kbd(C-u)}}} prefix, just make
1705      the full field visible, so that it can be edited in place.  When
1706      called with two {{{kbd(C-u)}}} prefixes, make the editor window
1707      follow the cursor through the table and always show the current
1708      field.  The follow mode exits automatically when the cursor
1709      leaves the table, or when you repeat this command with {{{kbd(C-u
1710      C-u C-c `)}}}.
1712 - {{{kbd(M-x org-table-import)}}} ::
1714      #+findex: org-table-import
1715      Import a file as a table.  The table should be TAB or whitespace
1716      separated.  Use, for example, to import a spreadsheet table or
1717      data from a database, because these programs generally can write
1718      TAB-separated text files.  This command works by inserting the
1719      file into the buffer and then converting the region to a table.
1720      Any prefix argument is passed on to the converter, which uses it
1721      to determine the separator.
1723 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1725      #+kindex: C-c |
1726      #+findex: org-table-create-or-convert-from-region
1727      Tables can also be imported by pasting tabular text into the Org
1728      buffer, selecting the pasted text with {{{kbd(C-x C-x)}}} and
1729      then using the {{{kbd(C-c |)}}} command (see [[*Creation and
1730      conversion]]).
1732 - {{{kbd(M-x org-table-export)}}} ::
1734      #+findex: org-table-export
1735      #+vindex: org-table-export-default-format
1736      Export the table, by default as a TAB-separated file.  Use for
1737      data exchange with, for example, spreadsheet or database
1738      programs.  The format used to export the file can be configured
1739      in the variable ~org-table-export-default-format~.  You may also
1740      use properties =TABLE_EXPORT_FILE= and =TABLE_EXPORT_FORMAT= to
1741      specify the file name and the format for table export in
1742      a subtree.  Org supports quite general formats for exported
1743      tables.  The exporter format is the same as the format used by
1744      Orgtbl radio tables, see [[*Translator functions]], for a detailed
1745      description.
1747 ** Column Width and Alignment
1748 :PROPERTIES:
1749 :DESCRIPTION: Overrule the automatic settings.
1750 :END:
1751 #+cindex: narrow columns in tables
1752 #+cindex: alignment in tables
1754 The width of columns is automatically determined by the table editor.
1755 The alignment of a column is determined automatically from the
1756 fraction of number-like versus non-number fields in the column.
1758 #+vindex: org-table-automatic-realign
1759 Editing a field may modify alignment of the table.  Moving
1760 a contiguous row or column---i.e., using {{{kbd(TAB)}}} or
1761 {{{kbd(RET)}}}---automatically re-aligns it.  If you want to disable
1762 this behavior, set ~org-table-automatic-realign~ to ~nil~.  In any
1763 case, you can always align manually a table:
1765 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1767      #+kindex: C-c C-c
1768      #+findex: org-table-align
1769      Align the current table.
1771 #+texinfo: @noindent
1772 #+vindex: org-startup-align-all-tables
1773 Setting the option ~org-startup-align-all-tables~ re-aligns all tables
1774 in a file upon visiting it.  You can also set this option on
1775 a per-file basis with:
1777 #+begin_example
1778 ,#+STARTUP: align
1779 ,#+STARTUP: noalign
1780 #+end_example
1782 Sometimes a single field or a few fields need to carry more text,
1783 leading to inconveniently wide columns.  Maybe you want to hide away
1784 several columns or display them with a fixed width, regardless of
1785 content, as shown in the following example.
1787 #+begin_example
1788 |---+---------------------+--------|           |---+-------…|…|
1789 |   | <6>                 |        |           |   | <6>   â€¦|…|
1790 | 1 | one                 | some   |   ----\   | 1 | one   â€¦|…|
1791 | 2 | two                 | boring |   ----/   | 2 | two   â€¦|…|
1792 | 3 | This is a long text | column |           | 3 | This i…|…|
1793 |---+---------------------+--------|           |---+-------…|…|
1794 #+end_example
1796 To set the width of a column, one field anywhere in the column may
1797 contain just the string =<N>= where {{{var(N)}}} specifies the width
1798 as a number of characters.  You control displayed width of columns
1799 with the following tools:
1801 - {{{kbd(C-c TAB)}}} (~org-table-toggle-column-width~) ::
1803      #+kindex: C-c TAB
1804      #+findex: org-table-toggle-column-width
1805      Shrink or expand current column.
1807      If a width cookie specifies a width W for the column, shrinking
1808      it displays the first W visible characters only.  Otherwise, the
1809      column is shrunk to a single character.
1811      When called before the first column or after the last one, ask
1812      for a list of column ranges to operate on.
1814 - {{{kbd(C-u C-c TAB)}}} (~org-table-shrink~) ::
1816      #+kindex: C-u C-c TAB
1817      #+findex: org-table-shrink
1818      Shrink all columns with a column width.  Expand the others.
1820 - {{{kbd(C-u C-u C-c TAB)}}} (~org-table-expand~) ::
1822      #+kindex: C-u C-u C-c TAB
1823      #+findex: org-table-expand
1824      Expand all columns.
1826 To see the full text of a shrunk field, hold the mouse over it:
1827 a tool-tip window then shows the full contents of the field.
1828 Alternatively, {{{kbd(C-h .)}}} (~display-local-help~) reveals them,
1829 too.  For convenience, any change near the shrunk part of a column
1830 expands it.
1832 #+vindex: org-startup-shrink-all-tables
1833 Setting the option ~org-startup-shrink-all-tables~ shrinks all columns
1834 containing a width cookie in a file the moment it is visited.  You can
1835 also set this option on a per-file basis with:
1837 : #+STARTUP: shrink
1839 If you would like to overrule the automatic alignment of number-rich
1840 columns to the right and of string-rich columns to the left, you can
1841 use =<r>=, =<c>= or =<l>= in a similar fashion.  You may also combine
1842 alignment and field width like this: =<r10>=.
1844 Lines which only contain these formatting cookies are removed
1845 automatically upon exporting the document.
1847 ** Column Groups
1848 :PROPERTIES:
1849 :DESCRIPTION: Grouping to trigger vertical lines.
1850 :END:
1851 #+cindex: grouping columns in tables
1853 When Org exports tables, it does so by default without vertical lines
1854 because that is visually more satisfying in general.  Occasionally
1855 however, vertical lines can be useful to structure a table into groups
1856 of columns, much like horizontal lines can do for groups of rows.  In
1857 order to specify column groups, you can use a special row where the
1858 first field contains only =/=.  The further fields can either contain
1859 =<= to indicate that this column should start a group, =>= to indicate
1860 the end of a column, or =<>= (no space between =<= and =>=) to make
1861 a column a group of its own.  Upon export, boundaries between column
1862 groups are marked with vertical lines.  Here is an example:
1864 #+begin_example
1865 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1866 |---+-----+-----+-----+---------+------------|
1867 | / |  <  |     |  >  |       < |          > |
1868 | 1 |  1  |  1  |  1  |       1 |          1 |
1869 | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
1870 | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
1871 |---+-----+-----+-----+---------+------------|
1872 ,#+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
1873 #+end_example
1875 It is also sufficient to just insert the column group starters after
1876 every vertical line you would like to have:
1878 #+begin_example
1879 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1880 |---+-----+-----+-----+---------+------------|
1881 | / | <   |     |     | <       |            |
1882 #+end_example
1884 ** The Orgtbl Minor Mode
1885 :PROPERTIES:
1886 :DESCRIPTION: The table editor as minor mode.
1887 :ALT_TITLE: Orgtbl Mode
1888 :END:
1889 #+cindex: Orgtbl mode
1890 #+cindex: minor mode for tables
1892 #+findex: orgtbl-mode
1893 If you like the intuitive way the Org table editor works, you might
1894 also want to use it in other modes like Text mode or Mail mode.  The
1895 minor mode Orgtbl mode makes this possible.  You can always toggle the
1896 mode with {{{kbd(M-x orgtbl-mode)}}}.  To turn it on by default, for
1897 example in Message mode, use
1899 #+begin_src emacs-lisp
1900 (add-hook 'message-mode-hook 'turn-on-orgtbl)
1901 #+end_src
1903 Furthermore, with some special setup, it is possible to maintain
1904 tables in arbitrary syntax with Orgtbl mode.  For example, it is
1905 possible to construct LaTeX tables with the underlying ease and power
1906 of Orgtbl mode, including spreadsheet capabilities.  For details, see
1907 [[*Tables in Arbitrary Syntax]].
1909 ** The spreadsheet
1910 :PROPERTIES:
1911 :DESCRIPTION: The table editor has spreadsheet capabilities.
1912 :END:
1913 #+cindex: calculations, in tables
1914 #+cindex: spreadsheet capabilities
1915 #+cindex: Calc package
1917 The table editor makes use of the Emacs Calc package to implement
1918 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
1919 to derive fields from other fields.  While fully featured, Org's
1920 implementation is not identical to other spreadsheets.  For example,
1921 Org knows the concept of a /column formula/ that will be applied to
1922 all non-header fields in a column without having to copy the formula
1923 to each relevant field.  There is also a formula debugger, and
1924 a formula editor with features for highlighting fields in the table
1925 corresponding to the references at the point in the formula, moving
1926 these references by arrow keys.
1928 *** References
1929 :PROPERTIES:
1930 :DESCRIPTION: How to refer to another field or range.
1931 :END:
1932 #+cindex: references
1934 To compute fields in the table from other fields, formulas must
1935 reference other fields or ranges.  In Org, fields can be referenced by
1936 name, by absolute coordinates, and by relative coordinates.  To find
1937 out what the coordinates of a field are, press {{{kbd(C-c ?)}}} in
1938 that field, or press {{{kbd(C-c })}}} to toggle the display of a grid.
1940 **** Field references
1941 :PROPERTIES:
1942 :UNNUMBERED: notoc
1943 :END:
1945 #+cindex: field references
1946 #+cindex: references, to fields
1947 Formulas can reference the value of another field in two ways.  Like
1948 in any other spreadsheet, you may reference fields with
1949 a letter/number combination like =B3=, meaning the second field in the
1950 third row.  However, Org prefers to use another, more general
1951 representation that looks like this:[fn:20]
1953 : @ROW$COLUMN
1955 Column specifications can be absolute like =$1=, =$2=, ..., =$N=, or
1956 relative to the current column, i.e., the column of the field which is
1957 being computed, like =$+1= or =$-2=.  =$<= and =$>= are immutable
1958 references to the first and last column, respectively, and you can use
1959 =$>>>= to indicate the third column from the right.
1961 The row specification only counts data lines and ignores horizontal
1962 separator lines, or "hlines".  Like with columns, you can use absolute
1963 row numbers =@1=, =@2=, ..., =@N=, and row numbers relative to the
1964 current row like =@+3= or =@-1=.  =@<= and =@>= are immutable
1965 references the first and last row in the table, respectively.  You may
1966 also specify the row relative to one of the hlines: =@I= refers to the
1967 first hline, =@II= to the second, etc.  =@-I= refers to the first such
1968 line above the current line, =@+I= to the first such line below the
1969 current line.  You can also write =@III+2= which is the second data
1970 line after the third hline in the table.
1972 =@0= and =$0= refer to the current row and column, respectively, i.e.,
1973 to the row/column for the field being computed.  Also, if you omit
1974 either the column or the row part of the reference, the current
1975 row/column is implied.
1977 Org's references with /unsigned/ numbers are fixed references in the
1978 sense that if you use the same reference in the formula for two
1979 different fields, the same field is referenced each time.  Org's
1980 references with /signed/ numbers are floating references because the
1981 same reference operator can reference different fields depending on
1982 the field being calculated by the formula.
1984 Here are a few examples:
1986 #+attr_texinfo: :columns 0.2 0.8
1987 | =@2$3=   | 2nd row, 3rd column (same as =C2=)                 |
1988 | =$5=     | column 5 in the current row (same as =E&=)         |
1989 | =@2=     | current column, row 2                              |
1990 | =@-1$-3= | field one row up, three columns to the left        |
1991 | =@-I$2=  | field just under hline above current row, column 2 |
1992 | =@>$5=   | field in the last row, in column 5                 |
1994 **** Range references
1995 :PROPERTIES:
1996 :UNNUMBERED: notoc
1997 :END:
1999 #+cindex: range references
2000 #+cindex: references, to ranges
2001 You may reference a rectangular range of fields by specifying two
2002 field references connected by two dots =..=.  If both fields are in
2003 the current row, you may simply use =$2..$7=, but if at least one
2004 field is in a different row, you need to use the general =@ROW$COLUMN=
2005 format at least for the first field, i.e., the reference must start
2006 with =@= in order to be interpreted correctly.  Examples:
2008 #+attr_texinfo: :columns 0.2 0.8
2009 | =$1..$3=      | first three fields in the current row                          |
2010 | =$P..$Q=      | range, using column names (see [[*Advanced features]])             |
2011 | =$<<<..$>>=   | start in third column, continue to the last but one            |
2012 | =@2$1..@4$3=  | six fields between these two fields (same as =A2..C4=)         |
2013 | =@-1$-2..@-1= | 3 fields in the row above, starting from 2 columns on the left |
2014 | =@I..II=      | between first and second hline, short for =@I..@II=            |
2016 #+texinfo: @noindent
2017 Range references return a vector of values that can be fed into Calc
2018 vector functions.  Empty fields in ranges are normally suppressed, so
2019 that the vector contains only the non-empty fields.  For other options
2020 with the mode switches =E=, =N= and examples, see [[*Formula syntax for
2021 Calc]].
2023 **** Field coordinates in formulas
2024 :PROPERTIES:
2025 :UNNUMBERED: notoc
2026 :END:
2028 #+cindex: field coordinates
2029 #+cindex: coordinates, of field
2030 #+cindex: row, of field coordinates
2031 #+cindex: column, of field coordinates
2032 #+vindex: org-table-current-column
2033 #+vindex: org-table-current-dline
2034 One of the very first actions during evaluation of Calc formulas and
2035 Lisp formulas is to substitute =@#= and =$#= in the formula with the
2036 row or column number of the field where the current result will go to.
2037 The traditional Lisp formula equivalents are ~org-table-current-dline~
2038 and ~org-table-current-column~.  Examples:
2040 - =if(@# % 2, $#, string(""))= ::
2042      Insert column number on odd rows, set field to empty on even
2043      rows.
2045 - =$2 = '(identity remote(FOO, @@#$1))= ::
2047      Copy text or values of each row of column 1 of the table named
2048      {{{var(FOO)}}} into column 2 of the current table.
2050 - =@3 = 2 * remote(FOO, @@1$$#)= ::
2052      Insert the doubled value of each column of row 1 of the table
2053      named {{{var(FOO)}}} into row 3 of the current table.
2055 #+texinfo: @noindent
2056 For the second and third examples, table {{{var(FOO)}}} must have at
2057 least as many rows or columns as the current table.  Note that this is
2058 inefficient[fn:21] for large number of rows.
2060 **** Named references
2061 :PROPERTIES:
2062 :UNNUMBERED: notoc
2063 :END:
2064 #+cindex: named references
2065 #+cindex: references, named
2066 #+cindex: name, of column or field
2067 #+cindex: constants, in calculations
2068 #+cindex: @samp{CONSTANTS}, keyword
2069 #+vindex: org-table-formula-constants
2071 =$name= is interpreted as the name of a column, parameter or constant.
2072 Constants are defined globally through the variable
2073 ~org-table-formula-constants~, and locally---for the file---through
2074 a line like this example:
2076 : #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2078 #+texinfo: @noindent
2079 #+vindex: constants-unit-system
2080 #+pindex: constants.el
2081 Also, properties (see [[*Properties and Columns]]) can be used as
2082 constants in table formulas: for a property =Xyz= use the name
2083 =$PROP_Xyz=, and the property will be searched in the current outline
2084 entry and in the hierarchy above it.  If you have the =constants.el=
2085 package, it will also be used to resolve constants, including natural
2086 constants like =$h= for Planck's constant, and units like =$km= for
2087 kilometers[fn:22].  Column names and parameters can be specified in
2088 special table lines.  These are described below, see [[*Advanced
2089 features]].  All names must start with a letter, and further consist
2090 of letters and numbers.
2092 **** Remote references
2093 :PROPERTIES:
2094 :UNNUMBERED: notoc
2095 :END:
2097 #+cindex: remote references
2098 #+cindex: references, remote
2099 #+cindex: references, to a different table
2100 #+cindex: name, of column or field
2101 #+cindex: @samp{NAME}, keyword
2102 You may also reference constants, fields and ranges from a different
2103 table, either in the current file or even in a different file.  The
2104 syntax is
2106 : remote(NAME,REF)
2108 #+texinfo: @noindent
2109 where {{{var(NAME)}}} can be the name of a table in the current file
2110 as set by a =#+NAME:= line before the table.  It can also be the ID of
2111 an entry, even in a different file, and the reference then refers to
2112 the first table in that entry.  {{{var(REF)}}} is an absolute field or
2113 range reference as described above for example =@3$3= or =$somename=,
2114 valid in the referenced table.
2116 #+cindex: table indirection
2117 When {{{var(NAME)}}} has the format =@ROW$COLUMN=, it is substituted
2118 with the name or ID found in this field of the current table.  For
2119 example =remote($1, @@>$2)= \Rightarrow =remote(year_2013, @@>$1)=.  The format
2120 =B3= is not supported because it can not be distinguished from a plain
2121 table name or ID.
2123 *** Formula syntax for Calc
2124 :PROPERTIES:
2125 :DESCRIPTION: Using Calc to compute stuff.
2126 :END:
2127 #+cindex: formula syntax, Calc
2128 #+cindex: syntax, of formulas
2130 A formula can be any algebraic expression understood by the Emacs Calc
2131 package.  Note that Calc has the non-standard convention that =/= has
2132 lower precedence than =*=, so that =a/b*c= is interpreted as
2133 =(a/(b*c))=.  Before evaluation by ~calc-eval~ (see [[info:calc#Calling Calc from Your Programs][Calling Calc from
2134 Your Lisp Programs]]), variable substitution takes place according to
2135 the rules described above.
2137 #+cindex: vectors, in table calculations
2138 The range vectors can be directly fed into the Calc vector functions
2139 like ~vmean~ and ~vsum~.
2141 #+cindex: format specifier, in spreadsheet
2142 #+cindex: mode, for Calc
2143 #+vindex: org-calc-default-modes
2144 A formula can contain an optional mode string after a semicolon.  This
2145 string consists of flags to influence Calc and other modes during
2146 execution.  By default, Org uses the standard Calc modes (precision
2147 12, angular units degrees, fraction and symbolic modes off).  The
2148 display format, however, has been changed to ~(float 8)~ to keep
2149 tables compact.  The default settings can be configured using the
2150 variable ~org-calc-default-modes~.
2152 - =p20= ::
2154      Set the internal Calc calculation precision to 20 digits.
2156 - =n3=, =s3=, =e2=, =f4= ::
2158      Normal, scientific, engineering or fixed format of the result of
2159      Calc passed back to Org.  Calc formatting is unlimited in
2160      precision as long as the Calc calculation precision is greater.
2162 - =D=, =R= ::
2164      Degree and radian angle modes of Calc.
2166 - =F=, =S= ::
2168      Fraction and symbolic modes of Calc.
2170 - =T=, =t=, =U= ::
2172      Duration computations in Calc or Lisp, [[*Durations and time
2173      values]].
2175 - =E= ::
2177      If and how to consider empty fields.  Without =E= empty fields in
2178      range references are suppressed so that the Calc vector or Lisp
2179      list contains only the non-empty fields.  With =E= the empty
2180      fields are kept.  For empty fields in ranges or empty field
2181      references the value =nan= (not a number) is used in Calc
2182      formulas and the empty string is used for Lisp formulas.  Add =N=
2183      to use 0 instead for both formula types.  For the value of
2184      a field the mode =N= has higher precedence than =E=.
2186 - =N= ::
2188      Interpret all fields as numbers, use 0 for non-numbers.  See the
2189      next section to see how this is essential for computations with
2190      Lisp formulas.  In Calc formulas it is used only occasionally
2191      because there number strings are already interpreted as numbers
2192      without =N=.
2194 - =L= ::
2196      Literal, for Lisp formulas only.  See the next section.
2198 #+texinfo: @noindent
2199 Unless you use large integer numbers or high-precision calculation and
2200 display for floating point numbers you may alternatively provide
2201 a ~printf~ format specifier to reformat the Calc result after it has
2202 been passed back to Org instead of letting Calc already do the
2203 formatting[fn:23].  A few examples:
2205 | =$1+$2=            | Sum of first and second field                    |
2206 | =$1+$2;%.2f=       | Same, format result to two decimals              |
2207 | =exp($2)+exp($1)=  | Math functions can be used                       |
2208 | =$0;%.1f=          | Reformat current cell to 1 decimal               |
2209 | =($3-32)*5/9=      | Degrees F \to C conversion                         |
2210 | =$c/$1/$cm=        | Hz \to cm conversion, using =constants.el=         |
2211 | =tan($1);Dp3s1=    | Compute in degrees, precision 3, display SCI 1   |
2212 | =sin($1);Dp3%.1e=  | Same, but use ~printf~ specifier for display     |
2213 | =vmean($2..$7)=    | Compute column range mean, using vector function |
2214 | =vmean($2..$7);EN= | Same, but treat empty fields as 0                |
2215 | =taylor($3,x=7,2)= | Taylor series of $3, at x=7, second degree       |
2217 Calc also contains a complete set of logical operations (see [[info:calc#Logical%20Operations][Logical
2218 Operations]]).  For example
2220 - =if($1 < 20, teen, string(""))= ::
2222      ="teen"= if age =$1= is less than 20, else the Org table result
2223      field is set to empty with the empty string.
2225 - =if("$1" == "nan" || "$2" == "nan", string(""), $1 + $2); E f-1= ::
2227      Sum of the first two columns.  When at least one of the input
2228      fields is empty the Org table result field is set to empty.  =E=
2229      is required to not convert empty fields to 0.  =f-1= is an
2230      optional Calc format string similar to =%.1f= but leaves empty
2231      results empty.
2233 - =if(typeof(vmean($1..$7)) == 12, string(""), vmean($1..$7); E= ::
2235      Mean value of a range unless there is any empty field.  Every
2236      field in the range that is empty is replaced by =nan= which lets
2237      =vmean= result in =nan=.  Then =typeof == 12= detects the =nan=
2238      from ~vmean~ and the Org table result field is set to empty.  Use
2239      this when the sample set is expected to never have missing
2240      values.
2242 - =if("$1..$7" == "[]", string(""), vmean($1..$7))= ::
2244      Mean value of a range with empty fields skipped.  Every field in
2245      the range that is empty is skipped.  When all fields in the range
2246      are empty the mean value is not defined and the Org table result
2247      field is set to empty.  Use this when the sample set can have
2248      a variable size.
2250 - =vmean($1..$7); EN= ::
2252      To complete the example before: Mean value of a range with empty
2253      fields counting as samples with value 0.  Use this only when
2254      incomplete sample sets should be padded with 0 to the full size.
2256 You can add your own Calc functions defined in Emacs Lisp with
2257 ~defmath~ and use them in formula syntax for Calc.
2259 *** Emacs Lisp forms as formulas
2260 :PROPERTIES:
2261 :DESCRIPTION: Writing formulas in Emacs Lisp.
2262 :ALT_TITLE: Formula syntax for Lisp
2263 :END:
2264 #+cindex: Lisp forms, as table formulas
2266 It is also possible to write a formula in Emacs Lisp.  This can be
2267 useful for string manipulation and control structures, if Calc's
2268 functionality is not enough.
2270 If a formula starts with a single-quote followed by an opening
2271 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2272 should return either a string or a number.  Just as with Calc
2273 formulas, you can specify modes and a ~printf~ format after
2274 a semicolon.
2276 With Emacs Lisp forms, you need to be conscious about the way field
2277 references are interpolated into the form.  By default, a reference is
2278 interpolated as a Lisp string (in double-quotes) containing the field.
2279 If you provide the =N= mode switch, all referenced elements are
2280 numbers---non-number fields will be zero---and interpolated as Lisp
2281 numbers, without quotes.  If you provide the =L= flag, all fields are
2282 interpolated literally, without quotes.  I.e., if you want a reference
2283 to be interpreted as a string by the Lisp form, enclose the reference
2284 operator itself in double-quotes, like ="$3"=.  Ranges are inserted as
2285 space-separated fields, so you can embed them in list or vector
2286 syntax.
2288 Here are a few examples---note how the =N= mode is used when we do
2289 computations in Lisp:
2291 - ='(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))= ::
2293      Swap the first two characters of the content of column 1.
2295 - ='(+ $1 $2);N= ::
2297      Add columns 1 and 2, equivalent to Calc's =$1+$2=.
2299 - ='(apply '+ '($1..$4));N= ::
2301      Compute the sum of columns 1 to 4, like Calc's =vsum($1..$4)=.
2303 *** Durations and time values
2304 :PROPERTIES:
2305 :DESCRIPTION: How to compute durations and time values.
2306 :END:
2307 #+cindex: Duration, computing
2308 #+cindex: Time, computing
2309 #+vindex: org-table-duration-custom-format
2311 If you want to compute time values use the =T=, =t=, or =U= flag,
2312 either in Calc formulas or Elisp formulas:
2314 #+begin_example
2315 |  Task 1 |   Task 2 |    Total |
2316 |---------+----------+----------|
2317 |    2:12 |     1:47 | 03:59:00 |
2318 |    2:12 |     1:47 |    03:59 |
2319 | 3:02:20 | -2:07:00 |     0.92 |
2320 ,#+TBLFM: @2$3=$1+$2;T::@3$3=$1+$2;U::@4$3=$1+$2;t
2321 #+end_example
2323 Input duration values must be of the form =HH:MM[:SS]=, where seconds
2324 are optional.  With the =T= flag, computed durations are displayed as
2325 =HH:MM:SS= (see the first formula above).  With the =U= flag, seconds
2326 are omitted so that the result is only =HH:MM= (see second formula
2327 above).  Zero-padding of the hours field depends upon the value of the
2328 variable ~org-table-duration-hour-zero-padding~.
2330 With the =t= flag, computed durations are displayed according to the
2331 value of the option ~org-table-duration-custom-format~, which defaults
2332 to ~hours~ and displays the result as a fraction of hours (see the
2333 third formula in the example above).
2335 Negative duration values can be manipulated as well, and integers are
2336 considered as seconds in addition and subtraction.
2338 *** Field and range formulas
2339 :PROPERTIES:
2340 :DESCRIPTION: Formula for specific (ranges of) fields.
2341 :END:
2342 #+cindex: field formula
2343 #+cindex: range formula
2344 #+cindex: formula, for individual table field
2345 #+cindex: formula, for range of fields
2347 To assign a formula to a particular field, type it directly into the
2348 field, preceded by =:==, for example =vsum(@II..III)=.  When you press
2349 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with the cursor
2350 still in the field, the formula is stored as the formula for this
2351 field, evaluated, and the current field is replaced with the result.
2353 #+cindex: @samp{TBLFM}, keyword
2354 Formulas are stored in a special =TBLFM= keyword located directly
2355 below the table.  If you type the equation in the fourth field of the
2356 third data line in the table, the formula looks like =@3$4=$1+$2=.
2357 When inserting/deleting/swapping column and rows with the appropriate
2358 commands, /absolute references/ (but not relative ones) in stored
2359 formulas are modified in order to still reference the same field.  To
2360 avoid this from happening, in particular in range references, anchor
2361 ranges at the table borders (using =@<=, =@>=, =$<=, =$>=), or at
2362 hlines using the =@I= notation.  Automatic adaptation of field
2363 references does of course not happen if you edit the table structure
2364 with normal editing commands---then you must fix the equations
2365 yourself.
2367 Instead of typing an equation into the field, you may also use the
2368 following command
2370 - {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2372      #+kindex: C-u C-c =
2373      #+findex: org-table-eval-formula
2374      Install a new formula for the current field.  The command prompts
2375      for a formula with default taken from the =TBLFM= keyword,
2376      applies it to the current field, and stores it.
2378 The left-hand side of a formula can also be a special expression in
2379 order to assign the formula to a number of different fields.  There is
2380 no keyboard shortcut to enter such range formulas.  To add them, use
2381 the formula editor (see [[*Editing and debugging formulas]]) or edit the
2382 =TBLFM= keyword directly.
2384 - =$2== ::
2386      Column formula, valid for the entire column.  This is so common
2387      that Org treats these formulas in a special way, see [[*Column
2388      formulas]].
2390 - ~@3=~ ::
2392      Row formula, applies to all fields in the specified row.  =@>==
2393      means the last row.
2395 - =@1$2..@4$3== ::
2397      Range formula, applies to all fields in the given rectangular
2398      range.  This can also be used to assign a formula to some but not
2399      all fields in a row.
2401 - =$NAME== ::
2403      Named field, see [[*Advanced features]].
2405 *** Column formulas
2406 :PROPERTIES:
2407 :DESCRIPTION: Formulas valid for an entire column.
2408 :END:
2409 #+cindex: column formula
2410 #+cindex: formula, for table column
2412 When you assign a formula to a simple column reference like =$3==, the
2413 same formula is used in all fields of that column, with the following
2414 very convenient exceptions: (i) If the table contains horizontal
2415 separator hlines with rows above and below, everything before the
2416 first such hline is considered part of the table /header/ and is not
2417 modified by column formulas.  Therefore a header is mandatory when you
2418 use column formulas and want to add hlines to group rows, like for
2419 example to separate a total row at the bottom from the summand rows
2420 above.  (ii) Fields that already get a value from a field/range
2421 formula are left alone by column formulas.  These conditions make
2422 column formulas very easy to use.
2424 To assign a formula to a column, type it directly into any field in
2425 the column, preceded by an equal sign, like ==$1+$2=.  When you press
2426 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with the cursor
2427 still in the field, the formula is stored as the formula for the
2428 current column, evaluated and the current field replaced with the
2429 result.  If the field contains only ===, the previously stored formula
2430 for this column is used.  For each column, Org only remembers the most
2431 recently used formula.  In the =TBLFM= keyword, column formulas look
2432 like =$4=$1+$2=.  The left-hand side of a column formula can not be
2433 the name of column, it must be the numeric column reference or =$>=.
2435 Instead of typing an equation into the field, you may also use the
2436 following command:
2438 - {{{kbd(C-c =)}}} (~org-table-eval-formula~) ::
2440      #+kindex: C-c =
2441      #+findex: org-table-eval-formula
2442      Install a new formula for the current column and replace current
2443      field with the result of the formula.  The command prompts for
2444      a formula, with default taken from the =TBLFM= keyword, applies
2445      it to the current field and stores it.  With a numeric prefix
2446      argument, e.g., {{{kbd(C-5 C-c =)}}}, the command applies it to
2447      that many consecutive fields in the current column.
2449 *** Lookup functions
2450 :PROPERTIES:
2451 :DESCRIPTION: Lookup functions for searching tables.
2452 :END:
2453 #+cindex: lookup functions in tables
2454 #+cindex: table lookup functions
2456 Org has three predefined Emacs Lisp functions for lookups in tables.
2458 - ~(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)~ ::
2460      #+findex: org-lookup-first
2461      Searches for the first element {{{var(S)}}} in list
2462      {{{var(S-LIST)}}} for which
2463      #+begin_src emacs-lisp
2464      (PREDICATE VAL S)
2465      #+end_src
2466      is non-~nil~; returns the value from the corresponding position
2467      in list {{{var(R-LIST)}}}.  The default {{{var(PREDICATE)}}} is
2468      ~equal~.  Note that the parameters {{{var(VAL)}}} and
2469      {{{var(S)}}} are passed to {{{var(PREDICATE)}}} in the same order
2470      as the corresponding parameters are in the call to
2471      ~org-lookup-first~, where {{{var(VAL)}}} precedes
2472      {{{var(S-LIST)}}}.  If {{{var(R-LIST)}}} is ~nil~, the matching
2473      element {{{var(S)}}} of {{{var(S-LIST)}}} is returned.
2475 - ~(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)~ ::
2477      #+findex: org-lookup-last
2478      Similar to ~org-lookup-first~ above, but searches for the /last/
2479      element for which {{{var(PREDICATE)}}} is non-~nil~.
2481 - ~(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)~ ::
2483      #+findex: org-lookup-all
2484      Similar to ~org-lookup-first~, but searches for /all/ elements
2485      for which {{{var(PREDICATE)}}} is non-~nil~, and returns /all/
2486      corresponding values.  This function can not be used by itself in
2487      a formula, because it returns a list of values.  However,
2488      powerful lookups can be built when this function is combined with
2489      other Emacs Lisp functions.
2491 If the ranges used in these functions contain empty fields, the =E=
2492 mode for the formula should usually be specified: otherwise empty
2493 fields are not included in {{{var(S-LIST)}}} and/or {{{var(R-LIST)}}}
2494 which can, for example, result in an incorrect mapping from an element
2495 of {{{var(S-LIST)}}} to the corresponding element of
2496 {{{var(R-LIST)}}}.
2498 These three functions can be used to implement associative arrays,
2499 count matching cells, rank results, group data, etc.  For practical
2500 examples see [[https://orgmode.org/worg/org-tutorials/org-lookups.html][this tutorial on Worg]].
2502 *** Editing and debugging formulas
2503 :PROPERTIES:
2504 :DESCRIPTION: Fixing formulas.
2505 :END:
2506 #+cindex: formula editing
2507 #+cindex: editing, of table formulas
2509 #+vindex: org-table-use-standard-references
2510 You can edit individual formulas in the minibuffer or directly in the
2511 field.  Org can also prepare a special buffer with all active formulas
2512 of a table.  When offering a formula for editing, Org converts
2513 references to the standard format (like =B3= or =D&=) if possible.  If
2514 you prefer to only work with the internal format (like =@3$2= or
2515 =$4=), configure the variable ~org-table-use-standard-references~.
2517 - {{{kbd(C-c =)}}} or {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2519      #+kindex: C-c =
2520      #+kindex: C-u C-c =
2521      #+findex: org-table-eval-formula
2522      Edit the formula associated with the current column/field in the
2523      minibuffer.  See [[*Column formulas]], and [[*Field and range formulas]].
2525 - {{{kbd(C-u C-u C-c =)}}} (~org-table-eval-formula~) ::
2527      #+kindex: C-u C-u C-c =
2528      #+findex: org-table-eval-formula
2529      Re-insert the active formula (either a field formula, or a column
2530      formula) into the current field, so that you can edit it directly
2531      in the field.  The advantage over editing in the minibuffer is
2532      that you can use the command {{{kbd(C-c ?)}}}.
2534 - {{{kbd(C-c ?)}}} (~org-table-field-info~) ::
2536      #+kindex: C-c ?
2537      #+findex: org-table-field-info
2538      While editing a formula in a table field, highlight the field(s)
2539      referenced by the reference at the cursor position in the
2540      formula.
2542 - {{{kbd(C-c })}}} (~org-table-toggle-coordinate-overlays~) ::
2544      #+kindex: C-c @}
2545      #+findex: org-table-toggle-coordinate-overlays
2546      Toggle the display of row and column numbers for a table, using
2547      overlays.  These are updated each time the table is aligned; you
2548      can force it with {{{kbd(C-c C-c)}}}.
2550 - {{{kbd(C-c {)}}} (~org-table-toggle-formula-debugger~) ::
2552      #+kindex: C-c @{
2553      #+findex: org-table-toggle-formula-debugger
2554      Toggle the formula debugger on and off.  See below.
2556 - {{{kbd(C-c ')}}} (~org-table-edit-formulas~) ::
2558      #+kindex: C-c '
2559      #+findex: org-table-edit-formulas
2560      Edit all formulas for the current table in a special buffer,
2561      where the formulas are displayed one per line.  If the current
2562      field has an active formula, the cursor in the formula editor
2563      marks it.  While inside the special buffer, Org automatically
2564      highlights any field or range reference at the cursor position.
2565      You may edit, remove and add formulas, and use the following
2566      commands:
2568      - {{{kbd(C-c C-c)}}} or {{{kbd(C-x C-s)}}} (~org-table-fedit-finish~) ::
2570           #+kindex: C-x C-s
2571           #+kindex: C-c C-c
2572           #+findex: org-table-fedit-finish
2573           Exit the formula editor and store the modified formulas.  With
2574           {{{kbd(C-u)}}} prefix, also apply the new formulas to the
2575           entire table.
2577      - {{{kbd(C-c C-q)}}} (~org-table-fedit-abort~) ::
2579           #+kindex: C-c C-q
2580           #+findex: org-table-fedit-abort
2581           Exit the formula editor without installing changes.
2583      - {{{kbd(C-c C-r)}}} (~org-table-fedit-toggle-ref-type~) ::
2585           #+kindex: C-c C-r
2586           #+findex: org-table-fedit-toggle-ref-type
2587           Toggle all references in the formula editor between standard
2588           (like =B3=) and internal (like =@3$2=).
2590      - {{{kbd(TAB)}}} (~org-table-fedit-lisp-indent~) ::
2592           #+kindex: TAB
2593           #+findex: org-table-fedit-lisp-indent
2594           Pretty-print or indent Lisp formula at point.  When in a line
2595           containing a Lisp formula, format the formula according to
2596           Emacs Lisp rules.  Another {{{kbd(TAB)}}} collapses the formula
2597           back again.  In the open formula, {{{kbd(TAB)}}} re-indents
2598           just like in Emacs Lisp mode.
2600      - {{{kbd(M-TAB)}}} (~lisp-complete-symbol~) ::
2602           #+kindex: M-TAB
2603           #+findex: lisp-complete-symbol
2604           Complete Lisp symbols, just like in Emacs Lisp mode.
2606      - {{{kbd(S-UP)}}}, {{{kbd(S-DOWN)}}}, {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} ::
2608           #+kindex: S-UP
2609           #+kindex: S-DOWN
2610           #+kindex: S-LEFT
2611           #+kindex: S-RIGHT
2612           #+findex: org-table-fedit-ref-up
2613           #+findex: org-table-fedit-ref-down
2614           #+findex: org-table-fedit-ref-left
2615           #+findex: org-table-fedit-ref-right
2616           Shift the reference at point.  For example, if the reference
2617           is =B3= and you press {{{kbd(S-RIGHT)}}}, it becomes =C3=.
2618           This also works for relative references and for hline
2619           references.
2621      - {{{kbd(M-S-UP)}}} (~org-table-fedit-line-up~) ::
2623           #+kindex: M-S-UP
2624           #+findex: org-table-fedit-line-up
2625           Move the test line for column formulas up in the Org buffer.
2627      - {{{kbd(M-S-DOWN)}}} (~org-table-fedit-line-down~) ::
2629           #+kindex: M-S-DOWN
2630           #+findex: org-table-fedit-line-down
2631           Move the test line for column formulas down in the Org buffer.
2633      - {{{kbd(M-UP)}}} (~org-table-fedit-scroll-up~) ::
2635           #+kindex: M-UP
2636           #+findex: org-table-fedit-scroll-up
2637           Scroll up the window displaying the table.
2639      - {{{kbd(M-DOWN)}}} (~org-table-fedit-scroll-down~) ::
2641           #+kindex: M-DOWN
2642           #+findex: org-table-fedit-scroll-down
2643           Scroll down the window displaying the table.
2645      - {{{kbd(C-c })}}} ::
2647           #+kindex: C-c @}
2648           #+findex: org-table-toggle-coordinate-overlays
2649           Turn the coordinate grid in the table on and off.
2651 Making a table field blank does not remove the formula associated with
2652 the field, because that is stored in a different line---the =TBLFM=
2653 keyword line.  During the next recalculation, the field will be filled
2654 again.  To remove a formula from a field, you have to give an empty
2655 reply when prompted for the formula, or to edit the =TBLFM= keyword.
2657 #+kindex: C-c C-c
2658 You may edit the =TBLFM= keyword directly and re-apply the changed
2659 equations with {{{kbd(C-c C-c)}}} in that line or with the normal
2660 recalculation commands in the table.
2662 **** Using multiple =TBLFM= lines
2663 :PROPERTIES:
2664 :UNNUMBERED: notoc
2665 :END:
2666 #+cindex: multiple formula lines
2667 #+cindex: @samp{TBLFM} keywords, multiple
2668 #+cindex: @samp{TBLFM}, switching
2670 #+kindex: C-c C-c
2671 You may apply the formula temporarily.  This is useful when you switch
2672 the formula.  Place multiple =TBLFM= keywords right after the table,
2673 and then press {{{kbd(C-c C-c)}}} on the formula to apply.  Here is an
2674 example:
2676 #+begin_example
2677 | x | y |
2678 |---+---|
2679 | 1 |   |
2680 | 2 |   |
2681 ,#+TBLFM: $2=$1*1
2682 ,#+TBLFM: $2=$1*2
2683 #+end_example
2685 #+texinfo: @noindent
2686 Pressing {{{kbd(C-c C-c)}}} in the line of =#+TBLFM: $2=$1*2= yields:
2688 #+begin_example
2689 | x | y |
2690 |---+---|
2691 | 1 | 2 |
2692 | 2 | 4 |
2693 ,#+TBLFM: $2=$1*1
2694 ,#+TBLFM: $2=$1*2
2695 #+end_example
2697 #+texinfo: @noindent
2698 Note: If you recalculate this table, with {{{kbd(C-u C-c *)}}}, for
2699 example, you get the following result of applying only the first
2700 =TBLFM= keyword.
2702 #+begin_example
2703 | x | y |
2704 |---+---|
2705 | 1 | 1 |
2706 | 2 | 2 |
2707 ,#+TBLFM: $2=$1*1
2708 ,#+TBLFM: $2=$1*2
2709 #+end_example
2711 **** Debugging formulas
2712 :PROPERTIES:
2713 :UNNUMBERED: notoc
2714 :END:
2715 #+cindex: formula debugging
2716 #+cindex: debugging, of table formulas
2718 When the evaluation of a formula leads to an error, the field content
2719 becomes the string =#ERROR=.  If you would like to see what is going
2720 on during variable substitution and calculation in order to find
2721 a bug, turn on formula debugging in the Tbl menu and repeat the
2722 calculation, for example by pressing {{{kbd(C-u C-u C-c = RET)}}} in
2723 a field.  Detailed information are displayed.
2725 *** Updating the table
2726 :PROPERTIES:
2727 :DESCRIPTION: Recomputing all dependent fields.
2728 :END:
2729 #+cindex: recomputing table fields
2730 #+cindex: updating, table
2732 Recalculation of a table is normally not automatic, but needs to be
2733 triggered by a command.  To make recalculation at least
2734 semi-automatic, see [[*Advanced features]].
2736 In order to recalculate a line of a table or the entire table, use the
2737 following commands:
2739 - {{{kbd(C-c *)}}} (~org-table-recalculate~) ::
2741      #+kindex: C-c *
2742      #+findex: org-table-recalculate
2743      Recalculate the current row by first applying the stored column
2744      formulas from left to right, and all field/range formulas in the
2745      current row.
2747 - {{{kbd(C-u C-c *)}}} or {{{kbd(C-u C-c C-c)}}} ::
2749      #+kindex: C-u C-c *
2750      #+kindex: C-u C-c C-c
2751      Recompute the entire table, line by line.  Any lines before the
2752      first hline are left alone, assuming that these are part of the
2753      table header.
2755 - {{{kbd(C-u C-u C-c *)}}} or {{{kbd(C-u C-u C-c C-c)}}} (~org-table-iterate~) ::
2757      #+kindex: C-u C-u C-c *
2758      #+kindex: C-u C-u C-c C-c
2759      #+findex: org-table-iterate
2760      Iterate the table by recomputing it until no further changes
2761      occur.  This may be necessary if some computed fields use the
2762      value of other fields that are computed /later/ in the
2763      calculation sequence.
2765 - {{{kbd(M-x org-table-recalculate-buffer-tables)}}} ::
2767      #+findex: org-table-recalculate-buffer-tables
2768      Recompute all tables in the current buffer.
2770 - {{{kbd(M-x org-table-iterate-buffer-tables)}}} ::
2772      #+findex: org-table-iterate-buffer-tables
2773      Iterate all tables in the current buffer, in order to converge
2774      table-to-table dependencies.
2776 *** Advanced features
2777 :PROPERTIES:
2778 :DESCRIPTION: Field and column names, automatic recalculation...
2779 :END:
2781 If you want the recalculation of fields to happen automatically, or if
2782 you want to be able to assign /names/[fn:24] to fields and columns,
2783 you need to reserve the first column of the table for special marking
2784 characters.
2786 - {{{kbd(C-#)}}} (~org-table-rotate-recalc-marks~) ::
2788      #+kindex: C-#
2789      #+findex: org-table-rotate-recalc-marks
2790      Rotate the calculation mark in first column through the states
2791      =#=, =*=, =!=, =$=.  When there is an active region, change all
2792      marks in the region.
2794 Here is an example of a table that collects exam results of students
2795 and makes use of these features:
2797 #+begin_example
2798 |---+---------+--------+--------+--------+-------+------|
2799 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2800 |---+---------+--------+--------+--------+-------+------|
2801 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2802 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2803 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2804 |---+---------+--------+--------+--------+-------+------|
2805 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2806 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2807 |---+---------+--------+--------+--------+-------+------|
2808 |   | Average |        |        |        |  25.0 |      |
2809 | ^ |         |        |        |        |    at |      |
2810 | $ | max=50  |        |        |        |       |      |
2811 |---+---------+--------+--------+--------+-------+------|
2812 ,#+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@-II..@-I);%.1f
2813 #+end_example
2815 #+texinfo: @noindent
2816 *Important*: please note that for these special tables, recalculating
2817 the table with {{{kbd(C-u C-c *)}}} only affects rows that are marked
2818 =#= or =*=, and fields that have a formula assigned to the field
2819 itself.  The column formulas are not applied in rows with empty first
2820 field.
2822 #+cindex: marking characters, tables
2823 The marking characters have the following meaning:
2825 - =!= ::
2827      The fields in this line define names for the columns, so that you
2828      may refer to a column as =$Tot= instead of =$6=.
2830 - =^= ::
2832      This row defines names for the fields /above/ the row.  With such
2833      a definition, any formula in the table may use =$m1= to refer to
2834      the value =10=.  Also, if you assign a formula to a names field,
2835      it is stored as =$name = ...=.
2837 - =_= ::
2839      Similar to =^=, but defines names for the fields in the row
2840      /below/.
2842 - =$= ::
2844      Fields in this row can define /parameters/ for formulas.  For
2845      example, if a field in a =$= row contains =max=50=, then formulas
2846      in this table can refer to the value 50 using =$max=.  Parameters
2847      work exactly like constants, only that they can be defined on
2848      a per-table basis.
2850 - =#= ::
2852      Fields in this row are automatically recalculated when pressing
2853      {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(S-TAB)}}} in this row.
2854      Also, this row is selected for a global recalculation with
2855      {{{kbd(C-u C-c *)}}}.  Unmarked lines are left alone by this
2856      command.
2858 - =*= ::
2860      Selects this line for global recalculation with {{{kbd(C-u C-c
2861      *)}}}, but not for automatic recalculation.  Use this when
2862      automatic recalculation slows down editing too much.
2864 - =/= ::
2866      Do not export this line.  Useful for lines that contain the
2867      narrowing =<N>= markers or column group markers.
2869 Finally, just to whet your appetite for what can be done with the
2870 fantastic Calc package, here is a table that computes the Taylor
2871 series of degree n at location x for a couple of functions.
2873 #+begin_example
2874 |---+-------------+---+-----+--------------------------------------|
2875 |   | Func        | n | x   | Result                               |
2876 |---+-------------+---+-----+--------------------------------------|
2877 | # | exp(x)      | 1 | x   | 1 + x                                |
2878 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2879 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2880 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2881 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2882 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2883 |---+-------------+---+-----+--------------------------------------|
2884 ,#+TBLFM: $5=taylor($2,$4,$3);n3
2885 #+end_example
2887 ** Org Plot
2888 :PROPERTIES:
2889 :DESCRIPTION: Plotting from Org tables.
2890 :END:
2891 #+cindex: graph, in tables
2892 #+cindex: plot tables using Gnuplot
2894 Org Plot can produce graphs of information stored in Org tables,
2895 either graphically or in ASCII art.
2897 *** Graphical plots using Gnuplot
2898 :PROPERTIES:
2899 :UNNUMBERED: notoc
2900 :END:
2902 #+cindex: @samp{PLOT}, keyword
2903 Org Plot can produce 2D and 3D graphs of information stored in Org
2904 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
2905 that you have both Gnuplot and Gnuplot mode installed on your system,
2906 then call {{{kbd(C-c \quot g)}}} or {{{kbd(M-x org-plot/gnuplot)}}} on the
2907 following table.
2909 #+begin_example
2910 ,#+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2911 | Sede      | Max cites | H-index |
2912 |-----------+-----------+---------|
2913 | Chile     |    257.72 |   21.39 |
2914 | Leeds     |    165.77 |   19.68 |
2915 | Sao Paolo |     71.00 |   11.50 |
2916 | Stockholm |    134.19 |   14.33 |
2917 | Morelia   |    257.56 |   17.67 |
2918 #+end_example
2920 Notice that Org Plot is smart enough to apply the table's headers as
2921 labels.  Further control over the labels, type, content, and
2922 appearance of plots can be exercised through the =PLOT= keyword
2923 preceding a table.  See below for a complete list of Org Plot options.
2924 For more information and examples see the [[https://orgmode.org/worg/org-tutorials/org-plot.html][Org Plot tutorial]].
2926 **** Plot options
2927 :PROPERTIES:
2928 :UNNUMBERED: notoc
2929 :END:
2931 - =set= ::
2933      Specify any Gnuplot option to be set when graphing.
2935 - =title= ::
2937      Specify the title of the plot.
2939 - =ind= ::
2941      Specify which column of the table to use as the =x= axis.
2943 - =deps= ::
2945      Specify the columns to graph as a Lisp style list, surrounded by
2946      parentheses and separated by spaces for example =dep:(3 4)= to
2947      graph the third and fourth columns.  Defaults to graphing all
2948      other columns aside from the =ind= column.
2950 - =type= ::
2952      Specify whether the plot is =2d=, =3d=, or =grid=.
2954 - =with= ::
2956      Specify a =with= option to be inserted for every column being
2957      plotted, e.g., =lines=, =points=, =boxes=, =impulses=.  Defaults
2958      to =lines=.
2960 - =file= ::
2962      If you want to plot to a file, specify
2963      ="path/to/desired/output-file"=.
2965 - =labels= ::
2967      List of labels to be used for the =deps=.  Defaults to the column
2968      headers if they exist.
2970 - =line= ::
2972      Specify an entire line to be inserted in the Gnuplot script.
2974 - =map= ::
2976      When plotting =3d= or =grid= types, set this to =t= to graph
2977      a flat mapping rather than a =3d= slope.
2979 - =timefmt= ::
2981      Specify format of Org mode timestamps as they will be parsed by
2982      Gnuplot.  Defaults to =%Y-%m-%d-%H:%M:%S=.
2984 - =script= ::
2986      If you want total control, you can specify a script file---place
2987      the file name between double-quotes---which will be used to plot.
2988      Before plotting, every instance of =$datafile= in the specified
2989      script will be replaced with the path to the generated data file.
2990      Note: even if you set this option, you may still want to specify
2991      the plot type, as that can impact the content of the data file.
2993 *** ASCII bar plots
2994 :PROPERTIES:
2995 :UNNUMBERED: notoc
2996 :END:
2998 While the cursor is on a column, typing {{{kbd(C-c " a)}}} or
2999 {{{kbd(M-x orgtbl-ascii-plot)}}} create a new column containing an
3000 ASCII-art bars plot.  The plot is implemented through a regular column
3001 formula.  When the source column changes, the bar plot may be updated
3002 by refreshing the table, for example typing {{{kbd(C-u C-c *)}}}.
3004 #+begin_example
3005 | Sede          | Max cites |              |
3006 |---------------+-----------+--------------|
3007 | Chile         |    257.72 | WWWWWWWWWWWW |
3008 | Leeds         |    165.77 | WWWWWWWh     |
3009 | Sao Paolo     |     71.00 | WWW;         |
3010 | Stockholm     |    134.19 | WWWWWW:      |
3011 | Morelia       |    257.56 | WWWWWWWWWWWH |
3012 | Rochefourchat |      0.00 |              |
3013 ,#+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
3014 #+end_example
3016 The formula is an Elisp call.
3018 #+attr_texinfo: :options orgtbl-ascii-draw value min max &optional width
3019 #+begin_defun
3020 Draw an ASCII bar in a table.
3022 {{{var(VALUE)}}} is the value to plot.
3024 {{{var(MIN)}}} is the value displayed as an empty bar.  {{{var(MAX)}}}
3025 is the value filling all the {{{var(WIDTH)}}}.  Sources values outside
3026 this range are displayed as =too small= or =too large=.
3028 {{{var(WIDTH)}}} is the number of characters of the bar plot.  It
3029 defaults to =12=.
3030 #+end_defun
3032 * Hyperlinks
3033 :PROPERTIES:
3034 :DESCRIPTION: Notes in context.
3035 :END:
3036 #+cindex: hyperlinks
3038 Like HTML, Org provides links inside a file, external links to
3039 other files, Usenet articles, emails, and much more.
3041 ** Link Format
3042 :PROPERTIES:
3043 :DESCRIPTION: How links in Org are formatted.
3044 :END:
3045 #+cindex: link format
3046 #+cindex: format, of links
3048 Org recognizes plain URL-like links and activate them as clickable
3049 links.  The general link format, however, looks like this:
3051 : [[LINK][DESCRIPTION]]
3053 #+texinfo: @noindent
3054 or alternatively
3056 : [[LINK]]
3058 #+texinfo: @noindent
3059 Once a link in the buffer is complete (all brackets present), Org
3060 changes the display so that =DESCRIPTION= is displayed instead of
3061 =[[LINK][DESCRIPTION]]= and =LINK= is displayed instead of =[[LINK]]=.  Links are be
3062 highlighted in the face ~org-link~, which by default is an underlined
3063 face.  You can directly edit the visible part of a link.  Note that
3064 this can be either the LINK part, if there is no description, or the
3065 {{{var(DESCRIPTION)}}} part.  To edit also the invisible
3066 {{{var(LINK)}}} part, use {{{kbd(C-c C-l)}}} with the cursor on the
3067 link.
3069 If you place the cursor at the beginning or just behind the end of the
3070 displayed text and press {{{kbd(BS)}}}, you remove
3071 the---invisible---bracket at that location.  This makes the link
3072 incomplete and the internals are again displayed as plain text.
3073 Inserting the missing bracket hides the link internals again.  To show
3074 the internal structure of all links, use the menu: Org \rarr Hyperlinks \rarr
3075 Literal links.
3077 ** Internal Links
3078 :PROPERTIES:
3079 :DESCRIPTION: Links to other places in the current file.
3080 :END:
3081 #+cindex: internal links
3082 #+cindex: links, internal
3083 #+cindex: targets, for links
3085 #+cindex: @samp{CUSTOM_ID}, property
3086 If the link does not look like a URL, it is considered to be internal
3087 in the current file.  The most important case is a link like
3088 =[[#my-custom-id]]= which links to the entry with the =CUSTOM_ID= property
3089 =my-custom-id=.  You are responsible yourself to make sure these
3090 custom IDs are unique in a file.
3092 Links such as =[[My Target]]= or =[[My Target][Find my target]]= lead to a text search in
3093 the current file.
3095 The link can be followed with {{{kbd(C-c C-o)}}} when the cursor is on
3096 the link, or with a mouse click (see [[*Handling Links]]).  Links to
3097 custom IDs point to the corresponding headline.  The preferred match
3098 for a text link is a /dedicated target/: the same string in double
3099 angular brackets, like =<<My Target>>=.
3101 #+cindex: @samp{NAME}, keyword
3102 If no dedicated target exists, the link tries to match the exact name
3103 of an element within the buffer.  Naming is done with the =NAME=
3104 keyword, which has to be put in the line before the element it refers
3105 to, as in the following example
3107 #+begin_example
3108 ,#+NAME: My Target
3109 | a  | table      |
3110 |----+------------|
3111 | of | four cells |
3112 #+end_example
3114 If none of the above succeeds, Org searches for a headline that is
3115 exactly the link text but may also include a TODO keyword and
3116 tags[fn:25].
3118 During export, internal links are used to mark objects and assign them
3119 a number.  Marked objects are then referenced by links pointing to
3120 them.  In particular, links without a description appear as the number
3121 assigned to the marked object[fn:26].  In the following excerpt from
3122 an Org buffer
3124 #+begin_example
3125 1. one item
3126 2. <<target>>another item
3127 Here we refer to item [[target]].
3128 #+end_example
3130 #+texinfo: @noindent
3131 The last sentence will appear as =Here we refer to item 2= when
3132 exported.
3134 In non-Org files, the search looks for the words in the link text.  In
3135 the above example the search would be for =target=.
3137 Following a link pushes a mark onto Org's own mark ring.  You can
3138 return to the previous position with {{{kbd(C-c &)}}}.  Using this
3139 command several times in direct succession goes back to positions
3140 recorded earlier.
3142 ** Radio Targets
3143 :PROPERTIES:
3144 :DESCRIPTION: Make targets trigger links in plain text.
3145 :END:
3146 #+cindex: radio targets
3147 #+cindex: targets, radio
3148 #+cindex: links, radio targets
3150 Org can automatically turn any occurrences of certain target names in
3151 normal text into a link.  So without explicitly creating a link, the
3152 text connects to the target radioing its position.  Radio targets are
3153 enclosed by triple angular brackets.  For example, a target =<<<My
3154 Target>>>= causes each occurrence of =my target= in normal text to
3155 become activated as a link.  The Org file is scanned automatically for
3156 radio targets only when the file is first loaded into Emacs.  To
3157 update the target list during editing, press {{{kbd(C-c C-c)}}} with
3158 the cursor on or at a target.
3160 ** External Links
3161 :PROPERTIES:
3162 :DESCRIPTION: URL-like links to the world.
3163 :END:
3164 #+cindex: links, external
3165 #+cindex: external links
3166 #+cindex: Gnus links
3167 #+cindex: BBDB links
3168 #+cindex: irc links
3169 #+cindex: URL links
3170 #+cindex: file links
3171 #+cindex: Rmail links
3172 #+cindex: MH-E links
3173 #+cindex: Usenet links
3174 #+cindex: shell links
3175 #+cindex: Info links
3176 #+cindex: Elisp links
3178 Org supports links to files, websites, Usenet and email messages, BBDB
3179 database entries and links to both IRC conversations and their logs.
3180 External links are URL-like locators.  They start with a short
3181 identifying string followed by a colon.  There can be no space after
3182 the colon.  The following list shows examples for each link type.
3184 | =http://www.astro.uva.nl/=dominik=          | on the web                     |
3185 | =doi:10.1000/182=                           | DOI for an electronic resource |
3186 | =file:/home/dominik/images/jupiter.jpg=     | file, absolute path            |
3187 | =/home/dominik/images/jupiter.jpg=          | same as above                  |
3188 | =file:papers/last.pdf=                      | file, relative path            |
3189 | =./papers/last.pdf=                         | same as above                  |
3190 | =file:/ssh:me@some.where:papers/last.pdf=   | file, path on remote machine   |
3191 | =/ssh:me@some.where:papers/last.pdf=        | same as above                  |
3192 | =file:sometextfile::NNN=                    | file, jump to line number      |
3193 | =file:projects.org=                         | another Org file               |
3194 | =file:projects.org::some words=             | text search in Org file[fn:27] |
3195 | =file:projects.org::*task title=            | heading search in Org file     |
3196 | =file+sys:/path/to/file=                    | open via OS, like double-click |
3197 | =file+emacs:/path/to/file=                  | force opening by Emacs         |
3198 | =docview:papers/last.pdf::NNN=              | open in doc-view mode at page  |
3199 | =id:B7423F4D-2E8A-471B-8810-C40F074717E9=   | Link to heading by ID          |
3200 | =news:comp.emacs=                           | Usenet link                    |
3201 | =mailto:adent@galaxy.net=                   | Mail link                      |
3202 | =mhe:folder=                                | MH-E folder link               |
3203 | =mhe:folder#id=                             | MH-E message link              |
3204 | =rmail:folder=                              | Rmail folder link              |
3205 | =rmail:folder#id=                           | Rmail message link             |
3206 | =gnus:group=                                | Gnus group link                |
3207 | =gnus:group#id=                             | Gnus article link              |
3208 | =bbdb:R.*Stallman=                          | BBDB link (with regexp)        |
3209 | =irc:/irc.com/#emacs/bob=                   | IRC link                       |
3210 | =info:org#External links=                   | Info node link                 |
3211 | =shell:ls *.org=                            | A shell command                |
3212 | =elisp:org-agenda=                          | Interactive Elisp command      |
3213 | =elisp:(find-file-other-frame "Elisp.org")= | Elisp form to evaluate         |
3215 #+cindex: VM links
3216 #+cindex: Wanderlust links
3217 On top of these built-in link types, some are available through the
3218 =contrib/= directory (see [[*Installation]]).  For example, these links to
3219 VM or Wanderlust messages are available when you load the
3220 corresponding libraries from the =contrib/= directory:
3222 | =vm:folder=                            | VM folder link          |
3223 | =vm:folder#id=                         | VM message link         |
3224 | =vm://myself@some.where.org/folder#id= | VM on remote machine    |
3225 | =vm-imap:account:folder=               | VM IMAP folder link     |
3226 | =vm-imap:account:folder#id=            | VM IMAP message link    |
3227 | =wl:folder=                            | Wanderlust folder link  |
3228 | =wl:folder#id=                         | Wanderlust message link |
3230 For customizing Org to add new link types, see [[*Adding Hyperlink
3231 Types]].
3233 A link should be enclosed in double brackets and may contain
3234 a descriptive text to be displayed instead of the URL (see [[*Link
3235 Format]]), for example:
3237 : [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3239 #+texinfo: @noindent
3240 If the description is a file name or URL that points to an image, HTML
3241 export (see [[*HTML Export]]) inlines the image as a clickable button.  If
3242 there is no description at all and the link points to an image, that
3243 image is inlined into the exported HTML file.
3245 #+cindex: square brackets, around links
3246 #+cindex: angular brackets, around links
3247 #+cindex: plain text external links
3248 Org also finds external links in the normal text and activates them as
3249 links.  If spaces must be part of the link (for example in
3250 =bbdb:Richard Stallman=), or if you need to remove ambiguities about
3251 the end of the link, enclose them in square or angular brackets.
3253 ** Handling Links
3254 :PROPERTIES:
3255 :DESCRIPTION: Creating, inserting and following.
3256 :END:
3257 #+cindex: links, handling
3259 Org provides methods to create a link in the correct syntax, to insert
3260 it into an Org file, and to follow the link.
3262 #+findex: org-store-link
3263 #+cindex: storing links
3264 The main function is ~org-store-link~, called with {{{kbd(M-x
3265 org-store-link)}}}.  Because of its importance, we suggest to bind it
3266 to a widely available key (see [[*Activation]]).  It stores a link to the
3267 current location.  The link is stored for later insertion into an Org
3268 buffer---see below.  What kind of link is created depends on the
3269 current buffer:
3271 - /Org mode buffers/ ::
3273      For Org files, if there is a =<<target>>= at the cursor, the link
3274      points to the target.  Otherwise it points to the current
3275      headline, which is also the description[fn:28].
3277      #+vindex: org-link-to-org-use-id
3278      #+cindex: @samp{CUSTOM_ID}, property
3279      #+cindex: @samp{ID}, property
3280      If the headline has a =CUSTOM_ID= property, store a link to this
3281      custom ID.  In addition or alternatively, depending on the value
3282      of ~org-link-to-org-use-id~, create and/or use a globally unique
3283      ID property for the link[fn:29].  So using this command in Org
3284      buffers potentially creates two links: a human-readable link from
3285      the custom ID, and one that is globally unique and works even if
3286      the entry is moved from file to file.  Later, when inserting the
3287      link, you need to decide which one to use.
3289 - /Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus/ ::
3291      Pretty much all Emacs mail clients are supported.  The link
3292      points to the current article, or, in some Gnus buffers, to the
3293      group.  The description is constructed from the author and the
3294      subject.
3296 - /Web browsers: W3, W3M and EWW/ ::
3298      Here the link is the current URL, with the page title as
3299      description.
3301 - /Contacts: BBDB/ ::
3303      Links created in a BBDB buffer point to the current entry.
3305 - /Chat: IRC/ ::
3307      #+vindex: org-irc-links-to-logs
3308      For IRC links, if the variable ~org-irc-link-to-logs~ is
3309      non-~nil~, create a =file= style link to the relevant point in
3310      the logs for the current conversation.  Otherwise store an =irc=
3311      style link to the user/channel/server under the point.
3313 - /Other files/ ::
3315      For any other file, the link points to the file, with a search
3316      string (see [[*Search Options in File Links]]) pointing to the
3317      contents of the current line.  If there is an active region, the
3318      selected words form the basis of the search string.  If the
3319      automatically created link is not working correctly or accurately
3320      enough, you can write custom functions to select the search
3321      string and to do the search for particular file types (see
3322      [[*Custom Searches]]).
3324      You can also define dedicated links to other files.  See [[*Adding
3325      Hyperlink Types]].
3327 - /Agenda view/ ::
3329      When the cursor is in an agenda view, the created link points to
3330      the entry referenced by the current line.
3332 From an Org buffer, the following commands create, navigate or, more
3333 generally, act on links.
3335 #+attr_texinfo: :sep ,
3336 - {{{kbd(C-c C-l)}}} (~org-insert-link~) ::
3338      #+kindex: C-c C-l
3339      #+findex: org-insert-link
3340      #+cindex: link completion
3341      #+cindex: completion, of links
3342      #+cindex: inserting links
3343      #+vindex: org-keep-stored-link-after-insertion
3344      Insert a link[fn:30].  This prompts for a link to be inserted
3345      into the buffer.  You can just type a link, using text for an
3346      internal link, or one of the link type prefixes mentioned in the
3347      examples above.  The link is inserted into the buffer, along with
3348      a descriptive text[fn:31].  If some text was selected at this
3349      time, it becomes the default description.
3351   - /Inserting stored links/ ::
3353        All links stored during the current session are part of the
3354        history for this prompt, so you can access them with
3355        {{{kbd(UP)}}} and {{{kbd(DOWN)}}} (or {{{kbd(M-p)}}},
3356        {{{kbd(M-n)}}}).
3358   - /Completion support/ ::
3360        Completion with {{{kbd(TAB)}}} helps you to insert valid link
3361        prefixes like =http= or =ftp=, including the prefixes defined
3362        through link abbreviations (see [[*Link Abbreviations]]).  If you
3363        press {{{kbd(RET)}}} after inserting only the prefix, Org
3364        offers specific completion support for some link types[fn:32].
3365        For example, if you type {{{kbd(f i l e RET)}}}---alternative
3366        access: {{{kbd(C-u C-c C-l)}}}, see below---Org offers file
3367        name completion, and after {{{kbd(b b d b RET)}}} you can
3368        complete contact names.
3370 - {{{kbd(C-u C-c C-l)}}} ::
3372      #+cindex: file name completion
3373      #+cindex: completion, of file names
3374      #+kindex: C-u C-c C-l
3375      When {{{kbd(C-c C-l)}}} is called with a {{{kbd(C-u)}}} prefix
3376      argument, insert a link to a file.  You may use file name
3377      completion to select the name of the file.  The path to the file
3378      is inserted relative to the directory of the current Org file, if
3379      the linked file is in the current directory or in a sub-directory
3380      of it, or if the path is written relative to the current
3381      directory using =../=.  Otherwise an absolute path is used, if
3382      possible with =~/= for your home directory.  You can force an
3383      absolute path with two {{{kbd(C-u)}}} prefixes.
3385 - {{{kbd(C-c C-l)}}} (with cursor on existing link) ::
3387      #+cindex: following links
3388      When the cursor is on an existing link, {{{kbd(C-c C-l)}}} allows
3389      you to edit the link and description parts of the link.
3391 - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
3393      #+kindex: C-c C-o
3394      #+findex: org-open-at-point
3395      #+vindex: org-file-apps
3396      Open link at point.  This launches a web browser for URL (using
3397      ~browse-url-at-point~), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
3398      for the corresponding links, and execute the command in a shell
3399      link.  When the cursor is on an internal link, this command runs
3400      the corresponding search.  When the cursor is on a TAG list in
3401      a headline, it creates the corresponding TAGS view.  If the
3402      cursor is on a timestamp, it compiles the agenda for that date.
3403      Furthermore, it visits text and remote files in =file= links with
3404      Emacs and select a suitable application for local non-text files.
3405      Classification of files is based on file extension only.  See
3406      option ~org-file-apps~.  If you want to override the default
3407      application and visit the file with Emacs, use a {{{kbd(C-u)}}}
3408      prefix.  If you want to avoid opening in Emacs, use a {{{kbd(C-u
3409      C-u)}}} prefix.
3411      #+vindex: org-link-frame-setup
3412      If the cursor is on a headline, but not on a link, offer all
3413      links in the headline and entry text.  If you want to setup the
3414      frame configuration for following links, customize
3415      ~org-link-frame-setup~.
3417 - {{{kbd(RET)}}} ::
3419      #+vindex: org-return-follows-link
3420      #+kindex: RET
3421      When ~org-return-follows-link~ is set, {{{kbd(RET)}}} also
3422      follows the link at point.
3424 - {{{kbd(mouse-2)}}} or {{{kbd(mouse-1)}}} ::
3426      #+kindex: mouse-2
3427      #+kindex: mouse-1
3428      On links, {{{kbd(mouse-1)}}} and {{{kbd(mouse-2)}}} opens the
3429      link just as {{{kbd(C-c C-o)}}} does.
3431 - {{{kbd(mouse-3)}}} ::
3433      #+vindex: org-display-internal-link-with-indirect-buffer
3434      #+kindex: mouse-3
3435      Like {{{kbd(mouse-2)}}}, but force file links to be opened with
3436      Emacs, and internal links to be displayed in another
3437      window[fn:33].
3439 - {{{kbd(C-c C-x C-v)}}} (~org-toggle-inline-images~) ::
3441      #+cindex: inlining images
3442      #+cindex: images, inlining
3443      #+vindex: org-startup-with-inline-images
3444      #+kindex: C-c C-x C-v
3445      #+findex: org-toggle-inline-images
3446      Toggle the inline display of linked images.  Normally this only
3447      inlines images that have no description part in the link, i.e.,
3448      images that are inlined during export.  When called with a prefix
3449      argument, also display images that do have a link description.
3450      You can ask for inline images to be displayed at startup by
3451      configuring the variable ~org-startup-with-inline-images~[fn:34].
3453 - {{{kbd(C-c %)}}} (~org-mark-ring-push~) ::
3455      #+kindex: C-c %
3456      #+findex: org-mark-ring-push
3457      #+cindex: mark ring
3458      Push the current position onto the mark ring, to be able to
3459      return easily.  Commands following an internal link do this
3460      automatically.
3462 - {{{kbd(C-c &)}}} (~org-mark-ring-goto~) ::
3464      #+kindex: C-c &
3465      #+findex: org-mark-ring-goto
3466      #+cindex: links, returning to
3467      Jump back to a recorded position.  A position is recorded by the
3468      commands following internal links, and by {{{kbd(C-c %)}}}.
3469      Using this command several times in direct succession moves
3470      through a ring of previously recorded positions.
3472 - {{{kbd(C-c C-x C-n)}}} (~org-next-link~), {{{kbd(C-c C-x C-p)}}} (~org-previous-link~) ::
3474      #+kindex: C-c C-x C-p
3475      #+findex: org-previous-link
3476      #+kindex: C-c C-x C-n
3477      #+findex: org-next-link
3478      #+cindex: links, finding next/previous
3479      Move forward/backward to the next link in the buffer.  At the
3480      limit of the buffer, the search fails once, and then wraps
3481      around.  The key bindings for this are really too long; you might
3482      want to bind this also to {{{kbd(M-n)}}} and {{{kbd(M-p)}}}.
3484      #+begin_src emacs-lisp
3485      (add-hook 'org-load-hook
3486                (lambda ()
3487                  (define-key org-mode-map "\M-n" 'org-next-link)
3488                  (define-key org-mode-map "\M-p" 'org-previous-link)))
3489      #+end_src
3491 ** Using Links Outside Org
3492 :PROPERTIES:
3493 :DESCRIPTION: Linking from my C source code?
3494 :END:
3496 #+findex: org-insert-link-global
3497 #+findex: org-open-at-point-global
3498 You can insert and follow links that have Org syntax not only in Org,
3499 but in any Emacs buffer.  For this, Org provides two functions:
3500 ~org-insert-link-global~ and ~org-open-at-point-global~.
3502 You might want to bind them to globally available keys.  See
3503 [[*Activation]] for some advice.
3505 ** Link Abbreviations
3506 :PROPERTIES:
3507 :DESCRIPTION: Shortcuts for writing complex links.
3508 :END:
3509 #+cindex: link abbreviations
3510 #+cindex: abbreviation, links
3512 Long URL can be cumbersome to type, and often many similar links are
3513 needed in a document.  For this you can use link abbreviations.  An
3514 abbreviated link looks like this
3516 : [[linkword:tag][description]]
3518 #+texinfo: @noindent
3519 #+vindex: org-link-abbrev-alist
3520 where the tag is optional.  The /linkword/ must be a word, starting
3521 with a letter, followed by letters, numbers, =-=, and =_=.
3522 Abbreviations are resolved according to the information in the
3523 variable ~org-link-abbrev-alist~ that relates the linkwords to
3524 replacement text.  Here is an example:
3526 #+begin_src emacs-lisp
3527 (setq org-link-abbrev-alist
3528       '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3529         ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3530         ("google"    . "http://www.google.com/search?q=")
3531         ("gmap"      . "http://maps.google.com/maps?q=%s")
3532         ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3533         ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3534 #+end_src
3536 If the replacement text contains the string =%s=, it is replaced with
3537 the tag.  Using =%h= instead of =%s= percent-encodes the tag (see the
3538 example above, where we need to encode the URL parameter).  Using
3539 =%(my-function)= passes the tag to a custom function, and replace it
3540 by the resulting string.
3542 If the replacement text do not contain any specifier, it is simply
3543 appended to the string in order to create the link.
3545 Instead of a string, you may also specify a function that will be
3546 called with the tag as the only argument to create the link.
3548 With the above setting, you could link to a specific bug with
3549 =[[bugzilla:129]]=, search the web for =OrgMode= with =[[google:OrgMode]]=,
3550 show the map location of the Free Software Foundation =[[gmap:51
3551 Franklin Street, Boston]]= or of Carsten office =[[omap:Science Park 904,
3552 Amsterdam, The Netherlands]]= and find out what the Org author is doing
3553 besides Emacs hacking with =[[ads:Dominik,C]]=.
3555 If you need special abbreviations just for a single Org buffer, you
3556 can define them in the file with
3558 #+cindex: @samp{LINK}, keyword
3559 #+begin_example
3560 ,#+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3561 ,#+LINK: google    http://www.google.com/search?q=%s
3562 #+end_example
3564 #+texinfo: @noindent
3565 In-buffer completion (see [[*Completion]]) can be used after =[= to
3566 complete link abbreviations.  You may also define a function that
3567 implements special (e.g., completion) support for inserting such
3568 a link with {{{kbd(C-c C-l)}}}.  Such a function should not accept any
3569 arguments, and return the full link with prefix.  You can set the link
3570 completion function like this:
3572 #+begin_src emacs-lisp
3573 (org-link-set-parameter "type" :complete #'some-completion-function)
3574 #+end_src
3576 ** Search Options in File Links
3577 :PROPERTIES:
3578 :DESCRIPTION: Linking to a specific location.
3579 :ALT_TITLE: Search Options
3580 :END:
3581 #+cindex: search option in file links
3582 #+cindex: file links, searching
3584 File links can contain additional information to make Emacs jump to
3585 a particular location in the file when following a link.  This can be
3586 a line number or a search option after a double colon[fn:35].  For
3587 example, when the command ~org-store-link~ creates a link (see
3588 [[*Handling Links]]) to a file, it encodes the words in the current line
3589 as a search string that can be used to find this line back later when
3590 following the link with {{{kbd(C-c C-o)}}}.
3592 Here is the syntax of the different ways to attach a search to a file
3593 link, together with an explanation:
3595 #+begin_example
3596 [[file:~/code/main.c::255]]
3597 [[file:~/xx.org::My Target]]
3598 [[file:~/xx.org::*My Target]]
3599 [[file:~/xx.org::#my-custom-id]]
3600 [[file:~/xx.org::/regexp/]]
3601 #+end_example
3603 - =255= ::
3605      Jump to line 255.
3607 - =My Target= ::
3609      Search for a link target =<<My Target>>=, or do a text search for
3610      =my target=, similar to the search in internal links, see
3611      [[*Internal Links]].  In HTML export (see [[*HTML Export]]), such a file
3612      link becomes a HTML reference to the corresponding named anchor
3613      in the linked file.
3615 - =*My Target= ::
3617      In an Org file, restrict search to headlines.
3619 - =#my-custom-id= ::
3621      Link to a heading with a =CUSTOM_ID= property
3623 - =/REGEXP/= ::
3625      Do a regular expression search for {{{var(REGEXP)}}}.  This uses
3626      the Emacs command ~occur~ to list all matches in a separate
3627      window.  If the target file is in Org mode, ~org-occur~ is used
3628      to create a sparse tree with the matches.
3630 As a degenerate case, a file link with an empty file name can be used
3631 to search the current file.  For example, =[[file:::find me]]= does
3632 a search for =find me= in the current file, just as =[[find me]]= would.
3634 ** Custom Searches
3635 :PROPERTIES:
3636 :DESCRIPTION: When the default search is not enough.
3637 :END:
3638 #+cindex: custom search strings
3639 #+cindex: search strings, custom
3641 The default mechanism for creating search strings and for doing the
3642 actual search related to a file link may not work correctly in all
3643 cases.  For example, BibTeX database files have many entries like
3644 ~year="1993"~ which would not result in good search strings, because
3645 the only unique identification for a BibTeX entry is the citation key.
3647 #+vindex: org-create-file-search-functions
3648 #+vindex: org-execute-file-search-functions
3649 If you come across such a problem, you can write custom functions to
3650 set the right search string for a particular file type, and to do the
3651 search for the string in the file.  Using ~add-hook~, these functions
3652 need to be added to the hook variables
3653 ~org-create-file-search-functions~ and
3654 ~org-execute-file-search-functions~.  See the docstring for these
3655 variables for more information.  Org actually uses this mechanism for
3656 BibTeX database files, and you can use the corresponding code as an
3657 implementation example.  See the file =org-bibtex.el=.
3659 * TODO Items
3660 :PROPERTIES:
3661 :DESCRIPTION: Every tree branch can be a TODO item.
3662 :END:
3663 #+cindex: TODO items
3665 Org mode does not maintain TODO lists as separate documents[fn:36].
3666 Instead, TODO items are an integral part of the notes file, because
3667 TODO items usually come up while taking notes!  With Org mode, simply
3668 mark any entry in a tree as being a TODO item.  In this way,
3669 information is not duplicated, and the entire context from which the
3670 TODO item emerged is always present.
3672 Of course, this technique for managing TODO items scatters them
3673 throughout your notes file.  Org mode compensates for this by
3674 providing methods to give you an overview of all the things that you
3675 have to do.
3677 ** Basic TODO Functionality
3678 :PROPERTIES:
3679 :DESCRIPTION: Marking and displaying TODO entries.
3680 :ALT_TITLE: TODO Basics
3681 :END:
3683 Any headline becomes a TODO item when it starts with the word =TODO=,
3684 for example:
3686 : *** TODO Write letter to Sam Fortune
3688 #+texinfo: @noindent
3689 The most important commands to work with TODO entries are:
3691 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
3693      #+kindex: C-c C-t
3694      #+cindex: cycling, of TODO states
3695      Rotate the TODO state of the current item among
3697      #+begin_example
3698      ,-> (unmarked) -> TODO -> DONE --.
3699      '--------------------------------'
3700      #+end_example
3702      If TODO keywords have fast access keys (see [[*Fast access to
3703      TODO states]]), prompt for a TODO keyword through the fast
3704      selection interface; this is the default behavior when
3705      ~org-use-fast-todo-selection~ is non-~nil~.
3707      The same rotation can also be done "remotely" from the timeline
3708      and agenda buffers with the {{{kbd(t)}}} command key (see
3709      [[*Commands in the Agenda Buffer]]).
3711 - {{{kbd(C-u C-c C-t)}}} ::
3713      #+kindex: C-u C-c C-t
3714      When TODO keywords have no selection keys, select a specific
3715      keyword using completion; otherwise force cycling through TODO
3716      states with no prompt.  When ~org-use-fast-todo-selection~ is set
3717      to ~prefix~, use the fast selection interface.
3719 - {{{kbd(S-RIGHT)}}} {{{kbd(S-LEFT)}}} ::
3721      #+kindex: S-RIGHT
3722      #+kindex: S-LEFT
3723      #+vindex: org-treat-S-cursor-todo-selection-as-state-change
3724      Select the following/preceding TODO state, similar to cycling.
3725      Useful mostly if more than two TODO states are possible (see
3726      [[*Extended Use of TODO Keywords]]).  See also [[*Packages that
3727      conflict with Org mode]], for a discussion of the interaction with
3728      ~shift-selection-mode~.  See also the variable
3729      ~org-treat-S-cursor-todo-selection-as-state-change~.
3731 - {{{kbd(C-c / t)}}} (~org-show-todo-tree~) ::
3733      #+kindex: C-c / t
3734      #+cindex: sparse tree, for TODO
3735      #+vindex: org-todo-keywords
3736      #+findex: org-show-todo-tree
3737      View TODO items in a /sparse tree/ (see [[*Sparse Trees]]).  Folds
3738      the entire buffer, but shows all TODO items---with not-DONE
3739      state---and the headings hierarchy above them.  With a prefix
3740      argument, or by using {{{kbd(C-c / T)}}}, search for a specific
3741      TODO.  You are prompted for the keyword, and you can also give
3742      a list of keywords like =KWD1|KWD2|...= to list entries that
3743      match any one of these keywords.  With a numeric prefix argument
3744      N, show the tree for the Nth keyword in the variable
3745      ~org-todo-keywords~.  With two prefix arguments, find all TODO
3746      states, both un-done and done.
3748 - {{{kbd(C-c a t)}}} (~org-todo-list~) ::
3750      #+kindex: C-c a t
3751      Show the global TODO list.  Collects the TODO items (with
3752      not-DONE states) from all agenda files (see [[*Agenda Views]]) into
3753      a single buffer.  The new buffer is in Org Agenda mode, which
3754      provides commands to examine and manipulate the TODO entries from
3755      the new buffer (see [[*Commands in the Agenda Buffer]]).  See [[*The
3756      global TODO list]], for more information.
3758 - {{{kbd(S-M-RET)}}} (~org-insert-todo-heading~) ::
3760      #+kindex: S-M-RET
3761      #+findex: org-insert-todo-heading
3762      Insert a new TODO entry below the current one.
3764 #+vindex: org-todo-state-tags-triggers
3765 #+texinfo: @noindent
3766 Changing a TODO state can also trigger tag changes.  See the docstring
3767 of the option ~org-todo-state-tags-triggers~ for details.
3769 ** Extended Use of TODO Keywords
3770 :PROPERTIES:
3771 :DESCRIPTION: Workflow and assignments.
3772 :ALT_TITLE: TODO Extensions
3773 :END:
3774 #+cindex: extended TODO keywords
3776 #+vindex: org-todo-keywords
3777 By default, marked TODO entries have one of only two states: TODO and
3778 DONE.  Org mode allows you to classify TODO items in more complex ways
3779 with /TODO keywords/ (stored in ~org-todo-keywords~).  With special
3780 setup, the TODO keyword system can work differently in different
3781 files.
3783 Note that /tags/ are another way to classify headlines in general and
3784 TODO items in particular (see [[*Tags]]).
3786 *** TODO keywords as workflow states
3787 :PROPERTIES:
3788 :DESCRIPTION: From TODO to DONE in steps.
3789 :ALT_TITLE: Workflow states
3790 :END:
3791 #+cindex: TODO workflow
3792 #+cindex: workflow states as TODO keywords
3794 You can use TODO keywords to indicate different /sequential/ states in
3795 the process of working on an item, for example[fn:37]:
3797 #+begin_src emacs-lisp
3798 (setq org-todo-keywords
3799       '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3800 #+end_src
3802 The vertical bar separates the TODO keywords (states that /need
3803 action/) from the DONE states (which need /no further action/).  If
3804 you do not provide the separator bar, the last state is used as the
3805 DONE state.
3807 #+cindex: completion, of TODO keywords
3808 With this setup, the command {{{kbd(C-c C-t)}}} cycles an entry from
3809 =TODO= to =FEEDBACK=, then to =VERIFY=, and finally to =DONE= and
3810 =DELEGATED=.  You may also use a numeric prefix argument to quickly
3811 select a specific state.  For example {{{kbd(C-3 C-c C-t)}}} changes
3812 the state immediately to =VERIFY=.  Or you can use {{{kbd(S-LEFT)}}}
3813 to go backward through the sequence.  If you define many keywords, you
3814 can use in-buffer completion (see [[*Completion]]) or even a special
3815 one-key selection scheme (see [[*Fast access to TODO states]]) to insert
3816 these words into the buffer.  Changing a TODO state can be logged with
3817 a timestamp, see [[*Tracking TODO state changes]], for more information.
3819 *** TODO keywords as types
3820 :PROPERTIES:
3821 :DESCRIPTION: I do this, Fred does the rest.
3822 :ALT_TITLE: TODO types
3823 :END:
3824 #+cindex: TODO types
3825 #+cindex: names as TODO keywords
3826 #+cindex: types as TODO keywords
3828 The second possibility is to use TODO keywords to indicate different
3829 /types/ of action items.  For example, you might want to indicate that
3830 items are for "work" or "home".  Or, when you work with several people
3831 on a single project, you might want to assign action items directly to
3832 persons, by using their names as TODO keywords.  This would be set up
3833 like this:
3835 #+begin_src emacs-lisp
3836 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3837 #+end_src
3839 In this case, different keywords do not indicate a sequence, but
3840 rather different types.  So the normal work flow would be to assign
3841 a task to a person, and later to mark it DONE.  Org mode supports this
3842 style by adapting the workings of the command {{{kbd(C-c
3843 C-t)}}}[fn:38].  When used several times in succession, it still
3844 cycles through all names, in order to first select the right type for
3845 a task.  But when you return to the item after some time and execute
3846 {{{kbd(C-c C-t)}}} again, it will switch from any name directly to
3847 =DONE=.  Use prefix arguments or completion to quickly select
3848 a specific name.  You can also review the items of a specific TODO
3849 type in a sparse tree by using a numeric prefix to {{{kbd(C-c / t)}}}.
3850 For example, to see all things Lucy has to do, you would use
3851 {{{kbd(C-3 C-c / t)}}}.  To collect Lucy's items from all agenda files
3852 into a single buffer, you would use the numeric prefix argument as
3853 well when creating the global TODO list: {{{kbd(C-3 C-c a t)}}}.
3855 *** Multiple keyword sets in one file
3856 :PROPERTIES:
3857 :DESCRIPTION: Mixing it all, still finding your way.
3858 :ALT_TITLE: Multiple sets in one file
3859 :END:
3860 #+cindex: TODO keyword sets
3862 Sometimes you may want to use different sets of TODO keywords in
3863 parallel.  For example, you may want to have the basic TODO/DONE, but
3864 also a workflow for bug fixing, and a separate state indicating that
3865 an item has been canceled---so it is not DONE, but also does not
3866 require action.  Your setup would then look like this:
3868 #+begin_src emacs-lisp
3869 (setq org-todo-keywords
3870       '((sequence "TODO" "|" "DONE")
3871         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3872         (sequence "|" "CANCELED")))
3873 #+end_src
3875 The keywords should all be different, this helps Org mode to keep
3876 track of which subsequence should be used for a given entry.  In this
3877 setup, {{{kbd(C-c C-t)}}} only operates within a subsequence, so it
3878 switches from =DONE= to (nothing) to =TODO=, and from =FIXED= to
3879 (nothing) to =REPORT=.  Therefore you need a mechanism to initially
3880 select the correct sequence.  Besides the obvious ways like typing
3881 a keyword or using completion, you may also apply the following
3882 commands:
3884 #+attr_texinfo: :sep ,
3885 - {{{kbd(C-u C-u C-c C-t)}}}, {{{kbd(C-S-RIGHT)}}}, {{{kbd(C-S-LEFT)}}} ::
3887      #+kindex: C-S-RIGHT
3888      #+kindex: C-S-LEFT
3889      #+kindex: C-u C-u C-c C-t
3890      These keys jump from one TODO subset to the next.  In the above
3891      example, {{{kbd(C-u C-u C-c C-t)}}} or {{{kbd(C-S-RIGHT)}}} would
3892      jump from =TODO= or =DONE= to =REPORT=, and any of the words in
3893      the second row to =CANCELED=.  Note that the {{{kbd(C-S-)}}} key
3894      binding conflict with ~shift-selection-mode~ (see [[*Packages
3895      that conflict with Org mode]]).
3897 - {{{kbd(S-RIGHT)}}}, {{{kbd(S-LEFT)}}} ::
3899      #+kindex: S-RIGHT
3900      #+kindex: S-LEFT
3901      {{{kbd(S-LEFT)}}} and {{{kbd(S-RIGHT)}}} walk through /all/
3902      keywords from all sets, so for example {{{kbd(S-RIGHT)}}} would
3903      switch from =DONE= to =REPORT= in the example above.  For
3904      a discussion of the interaction with ~shift-selection-mode~, see
3905      [[*Packages that conflict with Org mode]].
3907 *** Fast access to TODO states
3908 :PROPERTIES:
3909 :DESCRIPTION: Single letter selection of state.
3910 :END:
3912 If you would like to quickly change an entry to an arbitrary TODO
3913 state instead of cycling through the states, you can set up keys for
3914 single-letter access to the states.  This is done by adding the
3915 selection character after each keyword, in parentheses[fn:39].  For
3916 example:
3918 #+begin_src emacs-lisp
3919 (setq org-todo-keywords
3920       '((sequence "TODO(t)" "|" "DONE(d)")
3921         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3922         (sequence "|" "CANCELED(c)")))
3923 #+end_src
3925 #+vindex: org-fast-tag-selection-include-todo
3926 If you then press {{{kbd(C-c C-t)}}} followed by the selection key,
3927 the entry is switched to this state.  {{{kbd(SPC)}}} can be used to
3928 remove any TODO keyword from an entry[fn:40].
3930 *** Setting up keywords for individual files
3931 :PROPERTIES:
3932 :DESCRIPTION: Different files, different requirements.
3933 :ALT_TITLE: Per-file keywords
3934 :END:
3935 #+cindex: keyword options
3936 #+cindex: per-file keywords
3937 #+cindex: @samp{TODO}, keyword
3938 #+cindex: @samp{TYP_TODO}, keyword
3939 #+cindex: @samp{SEQ_TODO}, keyword
3941 It can be very useful to use different aspects of the TODO mechanism
3942 in different files.  For file-local settings, you need to add special
3943 lines to the file which set the keywords and interpretation for that
3944 file only.  For example, to set one of the two examples discussed
3945 above, you need one of the following lines, starting in column zero
3946 anywhere in the file:
3948 : #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3950 #+texinfo: @noindent
3951 you may also write =#+SEQ_TODO= to be explicit about the
3952 interpretation, but it means the same as =#+TODO=, or
3954 : #+TYP_TODO: Fred Sara Lucy Mike | DONE
3956 A setup for using several sets in parallel would be:
3958 #+begin_example
3959 ,#+TODO: TODO | DONE
3960 ,#+TODO: REPORT BUG KNOWNCAUSE | FIXED
3961 ,#+TODO: | CANCELED
3962 #+end_example
3964 #+cindex: completion, of option keywords
3965 #+kindex: M-TAB
3966 #+texinfo: @noindent
3967 To make sure you are using the correct keyword, type =#+= into the
3968 buffer and then use {{{kbd(M-TAB)}}} completion.
3970 #+cindex: DONE, final TODO keyword
3971 Remember that the keywords after the vertical bar---or the last
3972 keyword if no bar is there---must always mean that the item is DONE,
3973 although you may use a different word.  After changing one of these
3974 lines, use {{{kbd(C-c C-c)}}} with the cursor still in the line to
3975 make the changes known to Org mode[fn:41].
3977 *** Faces for TODO keywords
3978 :PROPERTIES:
3979 :DESCRIPTION: Highlighting states.
3980 :END:
3981 #+cindex: faces, for TODO keywords
3983 #+vindex: org-todo, face
3984 #+vindex: org-done, face
3985 #+vindex: org-todo-keyword-faces
3986 Org mode highlights TODO keywords with special faces: ~org-todo~ for
3987 keywords indicating that an item still has to be acted upon, and
3988 ~org-done~ for keywords indicating that an item is finished.  If you
3989 are using more than two different states, you might want to use
3990 special faces for some of them.  This can be done using the variable
3991 ~org-todo-keyword-faces~.  For example:
3993 #+begin_src emacs-lisp
3994 (setq org-todo-keyword-faces
3995       '(("TODO" . org-warning) ("STARTED" . "yellow")
3996         ("CANCELED" . (:foreground "blue" :weight bold))))
3997 #+end_src
3999 #+vindex: org-faces-easy-properties
4000 While using a list with face properties as shown for =CANCELED=
4001 /should/ work, this does not always seem to be the case.  If
4002 necessary, define a special face and use that.  A string is
4003 interpreted as a color.  The variable ~org-faces-easy-properties~
4004 determines if that color is interpreted as a foreground or
4005 a background color.
4007 *** TODO dependencies
4008 :PROPERTIES:
4009 :DESCRIPTION: When one task needs to wait for others.
4010 :END:
4011 #+cindex: TODO dependencies
4012 #+cindex: dependencies, of TODO states
4014 #+vindex: org-enforce-todo-dependencies
4015 #+cindex: @samp{ORDERED}, property
4016 The structure of Org files---hierarchy and lists---makes it easy to
4017 define TODO dependencies.  Usually, a parent TODO task should not be
4018 marked DONE until all subtasks, defined as children tasks, are marked
4019 as DONE.  And sometimes there is a logical sequence to a number of
4020 (sub)tasks, so that one task cannot be acted upon before all siblings
4021 above it are done.  If you customize the variable
4022 ~org-enforce-todo-dependencies~, Org blocks entries from changing
4023 state to DONE while they have children that are not DONE.
4024 Furthermore, if an entry has a property =ORDERED=, each of its
4025 children is blocked until all earlier siblings are marked DONE.  Here
4026 is an example:
4028 #+begin_example
4029 ,* TODO Blocked until (two) is done
4030 ,** DONE one
4031 ,** TODO two
4033 ,* Parent
4034 :PROPERTIES:
4035 :ORDERED:  t
4036 :END:
4037 ,** TODO a
4038 ,** TODO b, needs to wait for (a)
4039 ,** TODO c, needs to wait for (a) and (b)
4040 #+end_example
4042 #+cindex: TODO dependencies, NOBLOCKING
4043 #+cindex: NOBLOCKING, property
4044 You can ensure an entry is never blocked by using the =NOBLOCKING=
4045 property:
4047 #+begin_example
4048 ,* This entry is never blocked
4049 :PROPERTIES:
4050 :NOBLOCKING: t
4051 :END:
4052 #+end_example
4054 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4056      #+kindex: C-c C-x o
4057      #+findex: org-toggle-ordered-property
4058      #+vindex: org-track-ordered-property-with-tag
4059      Toggle the =ORDERED= property of the current entry.  A property
4060      is used for this behavior because this should be local to the
4061      current entry, not inherited like a tag.  However, if you would
4062      like to /track/ the value of this property with a tag for better
4063      visibility, customize the variable
4064      ~org-track-ordered-property-with-tag~.
4066 - {{{kbd(C-u C-u C-u C-c C-t)}}} ::
4068      #+kindex: C-u C-u C-u C-c C-t
4069      Change TODO state, circumventing any state blocking.
4071 #+vindex: org-agenda-dim-blocked-tasks
4072 If you set the variable ~org-agenda-dim-blocked-tasks~, TODO entries
4073 that cannot be closed because of such dependencies are shown in
4074 a dimmed font or even made invisible in agenda views (see [[*Agenda
4075 Views]]).
4077 #+cindex: checkboxes and TODO dependencies
4078 #+vindex: org-enforce-todo-dependencies
4079 You can also block changes of TODO states by looking at checkboxes
4080 (see [[*Checkboxes]]).  If you set the variable
4081 ~org-enforce-todo-checkbox-dependencies~, an entry that has unchecked
4082 checkboxes is blocked from switching to DONE.
4084 If you need more complex dependency structures, for example
4085 dependencies between entries in different trees or files, check out
4086 the contributed module =org-depend.el=.
4088 ** Progress Logging
4089 :PROPERTIES:
4090 :DESCRIPTION: Dates and notes for progress.
4091 :END:
4092 #+cindex: progress logging
4093 #+cindex: logging, of progress
4095 Org mode can automatically record a timestamp and possibly a note when
4096 you mark a TODO item as DONE, or even each time you change the state
4097 of a TODO item.  This system is highly configurable, settings can be
4098 on a per-keyword basis and can be localized to a file or even
4099 a subtree.  For information on how to clock working time for a task,
4100 see [[*Clocking Work Time]].
4102 *** Closing items
4103 :PROPERTIES:
4104 :DESCRIPTION: When was this entry marked DONE?
4105 :END:
4107 The most basic logging is to keep track of /when/ a certain TODO item
4108 was finished.  This is achieved with[fn:42]
4110 #+begin_src emacs-lisp
4111 (setq org-log-done 'time)
4112 #+end_src
4114 #+vindex: org-closed-keep-when-no-todo
4115 #+texinfo: @noindent
4116 Then each time you turn an entry from a TODO (not-done) state into any
4117 of the DONE states, a line =CLOSED: [timestamp]= is inserted just
4118 after the headline.  If you turn the entry back into a TODO item
4119 through further state cycling, that line is removed again.  If you
4120 turn the entry back to a non-TODO state (by pressing {{{kbd(C-c C-t
4121 SPC)}}} for example), that line is also removed, unless you set
4122 ~org-closed-keep-when-no-todo~ to non-~nil~.  If you want to record
4123 a note along with the timestamp, use[fn:43]
4125 #+begin_src emacs-lisp
4126 (setq org-log-done 'note)
4127 #+end_src
4129 #+texinfo: @noindent
4130 You are then be prompted for a note, and that note is stored below the
4131 entry with a =Closing Note= heading.
4133 *** Tracking TODO state changes
4134 :PROPERTIES:
4135 :DESCRIPTION: When did the status change?
4136 :END:
4137 #+cindex: drawer, for state change recording
4139 #+vindex: org-log-states-order-reversed
4140 #+vindex: org-log-into-drawer
4141 #+cindex: @samp{LOG_INTO_DRAWER}, property
4142 When TODO keywords are used as workflow states (see [[*TODO keywords as workflow states][*Workflow states]]),
4143 you might want to keep track of when a state change occurred and maybe
4144 take a note about this change.  You can either record just
4145 a timestamp, or a time-stamped note for a change.  These records are
4146 inserted after the headline as an itemized list, newest first[fn:44].
4147 When taking a lot of notes, you might want to get the notes out of the
4148 way into a drawer (see [[*Drawers]]).  Customize the variable
4149 ~org-log-into-drawer~ to get this behavior---the recommended drawer
4150 for this is called =LOGBOOK=[fn:45].  You can also overrule the
4151 setting of this variable for a subtree by setting a =LOG_INTO_DRAWER=
4152 property.
4154 Since it is normally too much to record a note for every state, Org
4155 mode expects configuration on a per-keyword basis for this.  This is
4156 achieved by adding special markers =!= (for a timestamp) or =@= (for
4157 a note with timestamp) in parentheses after each keyword.  For
4158 example, with the setting
4160 #+begin_src emacs-lisp
4161 (setq org-todo-keywords
4162       '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
4163 #+end_src
4165 #+texinfo: @noindent
4166 to record a timestamp without a note for TODO keywords configured with
4167 =@=, just type {{{kbd(C-c C-c)}}} to enter a blank note when prompted.
4169 #+vindex: org-log-done
4170 #+texinfo: @noindent
4171 You not only define global TODO keywords and fast access keys, but
4172 also request that a time is recorded when the entry is set to =DONE=,
4173 and that a note is recorded when switching to =WAIT= or
4174 =CANCELED=[fn:46].  The setting for =WAIT= is even more special: the
4175 =!= after the slash means that in addition to the note taken when
4176 entering the state, a timestamp should be recorded when /leaving/ the
4177 =WAIT= state, if and only if the /target/ state does not configure
4178 logging for entering it.  So it has no effect when switching from
4179 =WAIT= to =DONE=, because =DONE= is configured to record a timestamp
4180 only.  But when switching from =WAIT= back to =TODO=, the =/!= in the
4181 =WAIT= setting now triggers a timestamp even though =TODO= has no
4182 logging configured.
4184 You can use the exact same syntax for setting logging preferences local
4185 to a buffer:
4187 : #+TODO: TODO(t) WAIT(w@/!) | DONE(d!) CANCELED(c@)
4189 #+cindex: @samp{LOGGING}, property
4190 In order to define logging settings that are local to a subtree or
4191 a single item, define a =LOGGING= property in this entry.  Any
4192 non-empty =LOGGING= property resets all logging settings to ~nil~.
4193 You may then turn on logging for this specific tree using =STARTUP=
4194 keywords like =lognotedone= or =logrepeat=, as well as adding state
4195 specific settings like =TODO(!)=.  For example:
4197 #+begin_example
4198 ,* TODO Log each state with only a time
4199   :PROPERTIES:
4200   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4201   :END:
4202 ,* TODO Only log when switching to WAIT, and when repeating
4203   :PROPERTIES:
4204   :LOGGING: WAIT(@) logrepeat
4205   :END:
4206 ,* TODO No logging at all
4207   :PROPERTIES:
4208   :LOGGING: nil
4209   :END:
4210 #+end_example
4212 *** Tracking your habits
4213 :PROPERTIES:
4214 :DESCRIPTION: How consistent have you been?
4215 :END:
4216 #+cindex: habits
4217 #+cindex: STYLE, property
4219 Org has the ability to track the consistency of a special category of
4220 TODO, called "habits."  A habit has the following properties:
4222 1. You have enabled the ~habits~ module by customizing the variable
4223    ~org-modules~.
4225 2. The habit is a TODO item, with a TODO keyword representing an open
4226    state.
4228 3. The property =STYLE= is set to the value =habit=.
4230 4. The TODO has a scheduled date, usually with a =.+= style repeat
4231    interval.  A =++= style may be appropriate for habits with time
4232    constraints, e.g., must be done on weekends, or a =+= style for an
4233    unusual habit that can have a backlog, e.g., weekly reports.
4235 5. The TODO may also have minimum and maximum ranges specified by
4236    using the syntax =.+2d/3d=, which says that you want to do the task
4237    at least every three days, but at most every two days.
4239 6. You must also have state logging for the DONE state enabled (see
4240    [[*Tracking TODO state changes]]), in order for historical data to be
4241    represented in the consistency graph.  If it is not enabled it is
4242    not an error, but the consistency graphs are largely meaningless.
4244 To give you an idea of what the above rules look like in action, here's an
4245 actual habit with some history:
4247 #+begin_example
4248 ,** TODO Shave
4249    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4250    :PROPERTIES:
4251    :STYLE:    habit
4252    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4253    :END:
4254    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4255    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4256    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4257    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4258    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4259    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4260    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4261    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4262    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4263    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4264 #+end_example
4266 What this habit says is: I want to shave at most every 2 days---given
4267 by the =SCHEDULED= date and repeat interval---and at least every
4268 4 days.  If today is the 15th, then the habit first appears in the
4269 agenda on Oct 17, after the minimum of 2 days has elapsed, and will
4270 appear overdue on Oct 19, after four days have elapsed.
4272 What's really useful about habits is that they are displayed along
4273 with a consistency graph, to show how consistent you've been at
4274 getting that task done in the past.  This graph shows every day that
4275 the task was done over the past three weeks, with colors for each day.
4276 The colors used are:
4278 - Blue :: If the task was not to be done yet on that day.
4279 - Green :: If the task could have been done on that day.
4280 - Yellow :: If the task was going to be overdue the next day.
4281 - Red :: If the task was overdue on that day.
4283 In addition to coloring each day, the day is also marked with an
4284 asterisk if the task was actually done that day, and an exclamation
4285 mark to show where the current day falls in the graph.
4287 There are several configuration variables that can be used to change
4288 the way habits are displayed in the agenda.
4290 - ~org-habit-graph-column~ ::
4292      #+vindex: org-habit-graph-column
4293      The buffer column at which the consistency graph should be drawn.
4294      This overwrites any text in that column, so it is a good idea to
4295      keep your habits' titles brief and to the point.
4297 - ~org-habit-preceding-days~ ::
4299      #+vindex: org-habit-preceding-days
4300      The amount of history, in days before today, to appear in
4301      consistency graphs.
4303 - ~org-habit-following-days~ ::
4305      #+vindex: org-habit-following-days
4306      The number of days after today that appear in consistency graphs.
4308 - ~org-habit-show-habits-only-for-today~ ::
4310      #+vindex: org-habit-show-habits-only-for-today
4311      If non-~nil~, only show habits in today's agenda view.  This is
4312      set to true by default.
4314 Lastly, pressing {{{kbd(K)}}} in the agenda buffer causes habits to
4315 temporarily be disabled and do not appear at all.  Press {{{kbd(K)}}}
4316 again to bring them back.  They are also subject to tag filtering, if
4317 you have habits which should only be done in certain contexts, for
4318 example.
4320 ** Priorities
4321 :PROPERTIES:
4322 :DESCRIPTION: Some things are more important than others.
4323 :END:
4324 #+cindex: priorities
4325 #+cindex: priority cookie
4327 If you use Org mode extensively, you may end up with enough TODO items
4328 that it starts to make sense to prioritize them.  Prioritizing can be
4329 done by placing a /priority cookie/ into the headline of a TODO item,
4330 like this
4332 : *** TODO [#A] Write letter to Sam Fortune
4334 #+vindex: org-priority-faces
4335 #+texinfo: @noindent
4336 By default, Org mode supports three priorities: =A=, =B=, and =C=.
4337 =A= is the highest priority.  An entry without a cookie is treated
4338 just like priority =B=.  Priorities make a difference only for sorting
4339 in the agenda (see [[*Weekly/daily agenda]]); outside the agenda, they
4340 have no inherent meaning to Org mode.  The cookies can be highlighted
4341 with special faces by customizing the variable ~org-priority-faces~.
4343 Priorities can be attached to any outline node; they do not need to be
4344 TODO items.
4346 #+attr_texinfo: :sep ;
4347 - {{{kbd(C-c \,)}}} (~org-priority~) ::
4349      #+kindex: C-c ,
4350      #+findex: org-priority
4351      Set the priority of the current headline.  The command prompts
4352      for a priority character =A=, =B= or =C=.  When you press
4353      {{{kbd(SPC)}}} instead, the priority cookie is removed from the
4354      headline.  The priorities can also be changed "remotely" from the
4355      timeline and agenda buffer with the {{{kbd(\,)}}} command (see
4356      [[*Commands in the Agenda Buffer]]).
4358 - {{{kbd(S-UP)}}} (~org-priority-up~); {{{kbd(S-DOWN)}}} (~org-priority-down~) ::
4360      #+kindex: S-UP
4361      #+kindex: S-DOWN
4362      #+findex: org-priority-up
4363      #+findex: org-priority-down
4364      #+vindex: org-priority-start-cycle-with-default
4365      Increase/decrease priority of current headline[fn:47].  Note that
4366      these keys are also used to modify timestamps (see [[*Creating
4367      Timestamps]]).  See also [[*Packages that conflict with Org mode]], for
4368      a discussion of the interaction with ~shift-selection-mode~.
4370 #+vindex: org-highest-priority
4371 #+vindex: org-lowest-priority
4372 #+vindex: org-default-priority
4373 You can change the range of allowed priorities by setting the
4374 variables ~org-highest-priority~, ~org-lowest-priority~, and
4375 ~org-default-priority~.  For an individual buffer, you may set these
4376 values (highest, lowest, default) like this (please make sure that the
4377 highest priority is earlier in the alphabet than the lowest priority):
4379 #+cindex: @samp{PRIORITIES}, keyword
4380 : #+PRIORITIES: A C B
4382 ** Breaking Down Tasks into Subtasks
4383 :PROPERTIES:
4384 :DESCRIPTION: Splitting a task into manageable pieces.
4385 :ALT_TITLE: Breaking Down Tasks
4386 :END:
4387 #+cindex: tasks, breaking down
4388 #+cindex: statistics, for TODO items
4390 #+vindex: org-agenda-todo-list-sublevels
4391 It is often advisable to break down large tasks into smaller,
4392 manageable subtasks.  You can do this by creating an outline tree
4393 below a TODO item, with detailed subtasks on the tree[fn:48].  To keep
4394 the overview over the fraction of subtasks that are already completed,
4395 insert either =[/]= or =[%]= anywhere in the headline.  These cookies
4396 are updated each time the TODO status of a child changes, or when
4397 pressing {{{kbd(C-c C-c)}}} on the cookie.  For example:
4399 #+begin_example
4400 ,* Organize Party [33%]
4401 ,** TODO Call people [1/2]
4402 ,*** TODO Peter
4403 ,*** DONE Sarah
4404 ,** TODO Buy food
4405 ,** DONE Talk to neighbor
4406 #+end_example
4408 #+cindex: @samp{COOKIE_DATA}, property
4409 If a heading has both checkboxes and TODO children below it, the
4410 meaning of the statistics cookie become ambiguous.  Set the property
4411 =COOKIE_DATA= to either =checkbox= or =todo= to resolve this issue.
4413 #+vindex: org-hierarchical-todo-statistics
4414 If you would like to have the statistics cookie count any TODO entries
4415 in the subtree (not just direct children), configure the variable
4416 ~org-hierarchical-todo-statistics~.  To do this for a single subtree,
4417 include the word =recursive= into the value of the =COOKIE_DATA=
4418 property.
4420 #+begin_example org
4421 ,* Parent capturing statistics [2/20]
4422   :PROPERTIES:
4423   :COOKIE_DATA: todo recursive
4424   :END:
4425 #+end_example
4427 If you would like a TODO entry to automatically change to DONE when
4428 all children are done, you can use the following setup:
4430 #+begin_src emacs-lisp
4431 (defun org-summary-todo (n-done n-not-done)
4432   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4433   (let (org-log-done org-log-states)   ; turn off logging
4434     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4436 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4437 #+end_src
4439 Another possibility is the use of checkboxes to identify (a hierarchy
4440 of) a large number of subtasks (see [[*Checkboxes]]).
4442 ** Checkboxes
4443 :PROPERTIES:
4444 :DESCRIPTION: Tick-off lists.
4445 :END:
4446 #+cindex: checkboxes
4448 #+vindex: org-list-automatic-rules
4449 Every item in a plain list[fn:49] (see [[*Plain Lists]]) can be made into
4450 a checkbox by starting it with the string =[ ]=.  This feature is
4451 similar to TODO items (see [[*TODO Items]]), but is more lightweight.
4452 Checkboxes are not included into the global TODO list, so they are
4453 often great to split a task into a number of simple steps.  Or you can
4454 use them in a shopping list.  To toggle a checkbox, use {{{kbd(C-c
4455 C-c)}}}, or use the mouse (thanks to Piotr Zielinski's
4456 =org-mouse.el=).
4458 Here is an example of a checkbox list.
4460 #+begin_example
4461 ,* TODO Organize party [2/4]
4462   - [-] call people [1/3]
4463     - [ ] Peter
4464     - [X] Sarah
4465     - [ ] Sam
4466   - [X] order food
4467   - [ ] think about what music to play
4468   - [X] talk to the neighbors
4469 #+end_example
4471 Checkboxes work hierarchically, so if a checkbox item has children
4472 that are checkboxes, toggling one of the children checkboxes makes the
4473 parent checkbox reflect if none, some, or all of the children are
4474 checked.
4476 #+cindex: statistics, for checkboxes
4477 #+cindex: checkbox statistics
4478 #+cindex: @samp{COOKIE_DATA}, property
4479 #+vindex: org-hierarchical-checkbox-statistics
4480 The =[2/4]= and =[1/3]= in the first and second line are cookies
4481 indicating how many checkboxes present in this entry have been checked
4482 off, and the total number of checkboxes present.  This can give you an
4483 idea on how many checkboxes remain, even without opening a folded
4484 entry.  The cookies can be placed into a headline or into (the first
4485 line of) a plain list item.  Each cookie covers checkboxes of direct
4486 children structurally below the headline/item on which the cookie
4487 appears[fn:50].  You have to insert the cookie yourself by typing
4488 either =[/]= or =[%]=.  With =[/]= you get an =n out of m= result, as
4489 in the examples above.  With =[%]= you get information about the
4490 percentage of checkboxes checked (in the above example, this would be
4491 =[50%]= and =[33%]=, respectively).  In a headline, a cookie can count
4492 either checkboxes below the heading or TODO states of children, and it
4493 displays whatever was changed last.  Set the property =COOKIE_DATA= to
4494 either =checkbox= or =todo= to resolve this issue.
4496 #+cindex: blocking, of checkboxes
4497 #+cindex: checkbox blocking
4498 #+cindex: @samp{ORDERED}, property
4499 If the current outline node has an =ORDERED= property, checkboxes must
4500 be checked off in sequence, and an error is thrown if you try to check
4501 off a box while there are unchecked boxes above it.
4503 #+texinfo: @noindent
4504 The following commands work with checkboxes:
4506 - {{{kbd(C-c C-c)}}} (~org-toggle-checkbox~) ::
4508      #+kindex: C-c C-c
4509      #+findex: org-toggle-checkbox
4510      Toggle checkbox status or---with prefix argument---checkbox
4511      presence at point.  With a single prefix argument, add an empty
4512      checkbox or remove the current one[fn:51].  With a double prefix
4513      argument, set it to =[-]=, which is considered to be an
4514      intermediate state.
4516 - {{{kbd(C-c C-x C-b)}}} (~org-toggle-checkbox~) ::
4518      #+kindex: C-c C-x C-b
4519      Toggle checkbox status or---with prefix argument---checkbox
4520      presence at point.  With double prefix argument, set it to =[-]=,
4521      which is considered to be an intermediate state.
4523      - If there is an active region, toggle the first checkbox in the
4524        region and set all remaining boxes to the same status as the
4525        first.  With a prefix argument, add or remove the checkbox for
4526        all items in the region.
4528      - If the cursor is in a headline, toggle checkboxes in the region
4529        between this headline and the next---so /not/ the entire
4530        subtree.
4532      - If there is no active region, just toggle the checkbox at
4533        point.
4535 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
4537      #+kindex: M-S-RET
4538      #+findex: org-insert-todo-heading
4539      Insert a new item with a checkbox.  This works only if the cursor
4540      is already in a plain list item (see [[*Plain Lists]]).
4542 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4544      #+kindex: C-c C-x o
4545      #+findex: org-toggle-ordered-property
4546      #+vindex: org-track-ordered-property-with-tag
4547      Toggle the =ORDERED= property of the entry, to toggle if
4548      checkboxes must be checked off in sequence.  A property is used
4549      for this behavior because this should be local to the current
4550      entry, not inherited like a tag.  However, if you would like to
4551      /track/ the value of this property with a tag for better
4552      visibility, customize ~org-track-ordered-property-with-tag~.
4554 - {{{kbd(C-c #)}}} (~org-update-statistics-cookies~) ::
4556      #+kindex: C-c #
4557      #+findex: org-update-statistics-cookies
4558      Update the statistics cookie in the current outline entry.  When
4559      called with a {{{kbd(C-u)}}} prefix, update the entire file.
4560      Checkbox statistic cookies are updated automatically if you
4561      toggle checkboxes with {{{kbd(C-c C-c)}}} and make new ones with
4562      {{{kbd(M-S-RET)}}}.  TODO statistics cookies update when changing
4563      TODO states.  If you delete boxes/entries or add/change them by
4564      hand, use this command to get things back into sync.
4566 * Tags
4567 :PROPERTIES:
4568 :DESCRIPTION: Tagging headlines and matching sets of tags.
4569 :END:
4570 #+cindex: tags
4571 #+cindex: headline tagging
4572 #+cindex: matching, tags
4573 #+cindex: sparse tree, tag based
4575 An excellent way to implement labels and contexts for
4576 cross-correlating information is to assign /tags/ to headlines.  Org
4577 mode has extensive support for tags.
4579 #+vindex: org-tag-faces
4580 Every headline can contain a list of tags; they occur at the end of
4581 the headline.  Tags are normal words containing letters, numbers, =_=,
4582 and =@=.  Tags must be preceded and followed by a single colon, e.g.,
4583 =:work:=.  Several tags can be specified, as in =:work:urgent:=.  Tags
4584 by default are in bold face with the same color as the headline.  You
4585 may specify special faces for specific tags using the variable
4586 ~org-tag-faces~, in much the same way as you can for TODO keywords
4587 (see [[*Faces for TODO keywords]]).
4589 ** Tag Inheritance
4590 :PROPERTIES:
4591 :DESCRIPTION: Tags use the tree structure of an outline.
4592 :END:
4593 #+cindex: tag inheritance
4594 #+cindex: inheritance, of tags
4595 #+cindex: sublevels, inclusion into tags match
4597 /Tags/ make use of the hierarchical structure of outline trees.  If
4598 a heading has a certain tag, all subheadings inherit the tag as well.
4599 For example, in the list
4601 #+begin_example
4602 ,* Meeting with the French group      :work:
4603 ,** Summary by Frank                  :boss:notes:
4604 ,*** TODO Prepare slides for him      :action:
4605 #+end_example
4607 #+texinfo: @noindent
4608 the final heading has the tags =work=, =boss=, =notes=, and =action=
4609 even though the final heading is not explicitly marked with those
4610 tags.  You can also set tags that all entries in a file should inherit
4611 just as if these tags were defined in a hypothetical level zero that
4612 surrounds the entire file.  Use a line like this[fn:52]
4614 #+cindex: @samp{FILETAGS}, keyword
4615 : #+FILETAGS: :Peter:Boss:Secret:
4617 #+vindex: org-use-tag-inheritance
4618 #+vindex: org-tags-exclude-from-inheritance
4619 #+texinfo: @noindent
4620 To limit tag inheritance to specific tags, or to turn it off entirely,
4621 use the variables ~org-use-tag-inheritance~ and
4622 ~org-tags-exclude-from-inheritance~.
4624 #+vindex: org-tags-match-list-sublevels
4625 When a headline matches during a tags search while tag inheritance is
4626 turned on, all the sublevels in the same tree---for a simple match
4627 form---match as well[fn:53].  The list of matches may then become
4628 very long.  If you only want to see the first tags match in a subtree,
4629 configure the variable ~org-tags-match-list-sublevels~ (not
4630 recommended).
4632 #+vindex: org-agenda-use-tag-inheritance
4633 Tag inheritance is relevant when the agenda search tries to match
4634 a tag, either in the ~tags~ or ~tags-todo~ agenda types.  In other
4635 agenda types, ~org-use-tag-inheritance~ has no effect.  Still, you may
4636 want to have your tags correctly set in the agenda, so that tag
4637 filtering works fine, with inherited tags.  Set
4638 ~org-agenda-use-tag-inheritance~ to control this: the default value
4639 includes all agenda types, but setting this to ~nil~ can really speed
4640 up agenda generation.
4642 ** Setting Tags
4643 :PROPERTIES:
4644 :DESCRIPTION: How to assign tags to a headline.
4645 :END:
4646 #+cindex: setting tags
4647 #+cindex: tags, setting
4649 #+kindex: M-TAB
4650 Tags can simply be typed into the buffer at the end of a headline.
4651 After a colon, {{{kbd(M-TAB)}}} offers completion on tags.  There is
4652 also a special command for inserting tags:
4654 - {{{kbd(C-c C-q)}}} (~org-set-tags-command~) ::
4656      #+kindex: C-c C-q
4657      #+findex: org-set-tags-command
4658      #+cindex: completion, of tags
4659      #+vindex: org-tags-column
4660      Enter new tags for the current headline.  Org mode either offers
4661      completion or a special single-key interface for setting tags,
4662      see below.  After pressing {{{kbd(RET)}}}, the tags are inserted
4663      and aligned to ~org-tags-column~.  When called with
4664      a {{{kbd(C-u)}}} prefix, all tags in the current buffer are
4665      aligned to that column, just to make things look nice.  Tags are
4666      automatically realigned after promotion, demotion, and TODO state
4667      changes (see [[*Basic TODO Functionality]]).
4669 - {{{kbd(C-c C-c)}}} (~org-set-tags-command~) ::
4671      #+kindex: C-c C-c
4672      When the cursor is in a headline, this does the same as
4673      {{{kbd(C-c C-q)}}}.
4675 #+vindex: org-tag-alist
4676 Org supports tag insertion based on a /list of tags/.  By default this
4677 list is constructed dynamically, containing all tags currently used in
4678 the buffer.  You may also globally specify a hard list of tags with
4679 the variable ~org-tag-alist~.  Finally you can set the default tags
4680 for a given file with lines like
4682 #+cindex: @samp{TAGS}, keyword
4683 #+begin_example
4684 ,#+TAGS: @work @home @tennisclub
4685 ,#+TAGS: laptop car pc sailboat
4686 #+end_example
4688 If you have globally defined your preferred set of tags using the
4689 variable ~org-tag-alist~, but would like to use a dynamic tag list in
4690 a specific file, add an empty =TAGS= keyword to that file:
4692 : #+TAGS:
4694 #+vindex: org-tag-persistent-alist
4695 If you have a preferred set of tags that you would like to use in
4696 every file, in addition to those defined on a per-file basis by =TAGS=
4697 keyword, then you may specify a list of tags with the variable
4698 ~org-tag-persistent-alist~.  You may turn this off on a per-file basis
4699 by adding a =STARTUP= keyword to that file:
4701 : #+STARTUP: noptag
4703 By default Org mode uses the standard minibuffer completion facilities
4704 for entering tags.  However, it also implements another, quicker, tag
4705 selection method called /fast tag selection/.  This allows you to
4706 select and deselect tags with just a single key press.  For this to
4707 work well you should assign unique letters to most of your commonly
4708 used tags.  You can do this globally by configuring the variable
4709 ~org-tag-alist~ in your Emacs init file.  For example, you may find
4710 the need to tag many items in different files with =@home=.  In this
4711 case you can set something like:
4713 #+begin_src emacs-lisp
4714 (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("laptop" . ?l)))
4715 #+end_src
4717 #+texinfo: @noindent
4718 If the tag is only relevant to the file you are working on, then you
4719 can instead set the =TAGS= keyword as:
4721 : #+TAGS: @work(w)  @home(h)  @tennisclub(t)  laptop(l)  pc(p)
4723 #+texinfo: @noindent
4724 The tags interface shows the available tags in a splash window.  If
4725 you want to start a new line after a specific tag, insert =\n= into
4726 the tag list
4728 : #+TAGS: @work(w) @home(h) @tennisclub(t) \n laptop(l) pc(p)
4730 #+texinfo: @noindent
4731 or write them in two lines:
4733 #+begin_example
4734 ,#+TAGS: @work(w)  @home(h)  @tennisclub(t)
4735 ,#+TAGS: laptop(l)  pc(p)
4736 #+end_example
4738 #+texinfo: @noindent
4739 You can also group together tags that are mutually exclusive by using
4740 braces, as in:
4742 : #+TAGS: { @work(w)  @home(h)  @tennisclub(t) }  laptop(l)  pc(p)
4744 #+texinfo: @noindent
4745 you indicate that at most one of =@work=, =@home=, and =@tennisclub=
4746 should be selected.  Multiple such groups are allowed.
4748 #+texinfo: @noindent
4749 Do not forget to press {{{kbd(C-c C-c)}}} with the cursor in one of
4750 these lines to activate any changes.
4752 #+texinfo: @noindent
4753 To set these mutually exclusive groups in the variable
4754 ~org-tags-alist~, you must use the dummy tags ~:startgroup~ and
4755 ~:endgroup~ instead of the braces.  Similarly, you can use ~:newline~
4756 to indicate a line break.  The previous example would be set globally
4757 by the following configuration:
4759 #+begin_src emacs-lisp
4760 (setq org-tag-alist '((:startgroup . nil)
4761                       ("@work" . ?w) ("@home" . ?h)
4762                       ("@tennisclub" . ?t)
4763                       (:endgroup . nil)
4764                       ("laptop" . ?l) ("pc" . ?p)))
4765 #+end_src
4767 If at least one tag has a selection key then pressing {{{kbd(C-c
4768 C-c)}}} automatically presents you with a special interface, listing
4769 inherited tags, the tags of the current headline, and a list of all
4770 valid tags with corresponding keys[fn:54].
4772 Pressing keys assigned to tags adds or removes them from the list of
4773 tags in the current line.  Selecting a tag in a group of mutually
4774 exclusive tags turns off any other tag from that group.
4776 In this interface, you can also use the following special keys:
4778 - {{{kbd(TAB)}}} ::
4780      #+kindex: TAB
4781      Enter a tag in the minibuffer, even if the tag is not in the
4782      predefined list.  You can complete on all tags present in the
4783      buffer.  You can also add several tags: just separate them with
4784      a comma.
4786 - {{{kbd(SPC)}}} ::
4788      #+kindex: SPC
4789      Clear all tags for this line.
4791 - {{{kbd(RET)}}} ::
4793      #+kindex: RET
4794      Accept the modified set.
4796 - {{{kbd(C-g)}}} ::
4798      #+kindex: C-g
4799      Abort without installing changes.
4801 - {{{kbd(q)}}} ::
4803      #+kindex: q
4804      If {{{kbd(q)}}} is not assigned to a tag, it aborts like
4805      {{{kbd(C-g)}}}.
4807 - {{{kbd(!)}}} ::
4809      #+kindex: !
4810      Turn off groups of mutually exclusive tags.  Use this to (as an
4811      exception) assign several tags from such a group.
4813 - {{{kbd(C-c)}}} ::
4815      #+kindex: C-c C-c
4816      Toggle auto-exit after the next change (see below).  If you are
4817      using expert mode, the first {{{kbd(C-c)}}} displays the
4818      selection window.
4820 #+texinfo: @noindent
4821 This method lets you assign tags to a headline with very few keys.
4822 With the above setup, you could clear the current tags and set
4823 =@home=, =laptop= and =pc= tags with just the following keys:
4824 {{{kbd(C-c C-c SPC h l p RET)}}}.  Switching from =@home= to =@work=
4825 would be done with {{{kbd(C-c C-c w RET)}}} or alternatively with
4826 {{{kbd(C-c C-c C-c w)}}}.  Adding the non-predefined tag =Sarah= could
4827 be done with {{{kbd(C-c C-c TAB S a r a h RET)}}}.
4829 #+vindex: org-fast-tag-selection-single-key
4830 If you find that most of the time you need only a single key press to
4831 modify your list of tags, set the variable
4832 ~org-fast-tag-selection-single-key~.  Then you no longer have to press
4833 {{{kbd(RET)}}} to exit fast tag selection---it exits after the first
4834 change.  If you then occasionally need more keys, press {{{kbd(C-c)}}}
4835 to turn off auto-exit for the current tag selection process (in
4836 effect: start selection with {{{kbd(C-c C-c C-c)}}} instead of
4837 {{{kbd(C-c C-c)}}}).  If you set the variable to the value ~expert~,
4838 the special window is not even shown for single-key tag selection, it
4839 comes up only when you press an extra {{{kbd(C-c)}}}.
4841 ** Tag Hierarchy
4842 :PROPERTIES:
4843 :DESCRIPTION: Create a hierarchy of tags.
4844 :END:
4845 #+cindex: group tags
4846 #+cindex: tags, groups
4847 #+cindex: tags hierarchy
4849 Tags can be defined in hierarchies.  A tag can be defined as a /group
4850 tag/ for a set of other tags.  The group tag can be seen as the
4851 "broader term" for its set of tags.  Defining multiple group tags and
4852 nesting them creates a tag hierarchy.
4854 One use-case is to create a taxonomy of terms (tags) that can be used
4855 to classify nodes in a document or set of documents.
4857 When you search for a group tag, it return matches for all members in
4858 the group and its subgroups.  In an agenda view, filtering by a group
4859 tag displays or hide headlines tagged with at least one of the members
4860 of the group or any of its subgroups.  This makes tag searches and
4861 filters even more flexible.
4863 You can set group tags by using brackets and inserting a colon between
4864 the group tag and its related tags---beware that all whitespaces are
4865 mandatory so that Org can parse this line correctly:
4867 : #+TAGS: [ GTD : Control Persp ]
4869 In this example, =GTD= is the group tag and it is related to two other
4870 tags: =Control=, =Persp=.  Defining =Control= and =Persp= as group
4871 tags creates an hierarchy of tags:
4873 #+begin_example
4874 ,#+TAGS: [ Control : Context Task ]
4875 ,#+TAGS: [ Persp : Vision Goal AOF Project ]
4876 #+end_example
4878 That can conceptually be seen as a hierarchy of tags:
4880 - =GTD=
4881   - =Persp=
4882     - =Vision=
4883     - =Goal=
4884     - =AOF=
4885     - =Project=
4886   - =Control=
4887     - =Context=
4888     - =Task=
4890 You can use the ~:startgrouptag~, ~:grouptags~ and ~:endgrouptag~
4891 keyword directly when setting ~org-tag-alist~ directly:
4893 #+begin_src emacs-lisp
4894 (setq org-tag-alist '((:startgrouptag)
4895                       ("GTD")
4896                       (:grouptags)
4897                       ("Control")
4898                       ("Persp")
4899                       (:endgrouptag)
4900                       (:startgrouptag)
4901                       ("Control")
4902                       (:grouptags)
4903                       ("Context")
4904                       ("Task")
4905                       (:endgrouptag)))
4906 #+end_src
4908 The tags in a group can be mutually exclusive if using the same group
4909 syntax as is used for grouping mutually exclusive tags together; using
4910 curly brackets.
4912 : #+TAGS: { Context : @Home @Work @Call }
4914 When setting ~org-tag-alist~ you can use ~:startgroup~ and ~:endgroup~
4915 instead of ~:startgrouptag~ and ~:endgrouptag~ to make the tags
4916 mutually exclusive.
4918 Furthermore, the members of a group tag can also be regular
4919 expressions, creating the possibility of a more dynamic and rule-based
4920 tag structure.  The regular expressions in the group must be specified
4921 within curly brackets.  Here is an expanded example:
4923 #+begin_example
4924 ,#+TAGS: [ Vision : {V@.+} ]
4925 ,#+TAGS: [ Goal : {G@.+} ]
4926 ,#+TAGS: [ AOF : {AOF@.+} ]
4927 ,#+TAGS: [ Project : {P@.+} ]
4928 #+end_example
4930 Searching for the tag =Project= now lists all tags also including
4931 regular expression matches for =P@.+=, and similarly for tag searches
4932 on =Vision=, =Goal= and =AOF=.  For example, this would work well for
4933 a project tagged with a common project-identifier,
4934 e.g. =P@2014_OrgTags=.
4936 #+kindex: C-c C-x q
4937 #+findex: org-toggle-tags-groups
4938 #+vindex: org-group-tags
4939 If you want to ignore group tags temporarily, toggle group tags
4940 support with ~org-toggle-tags-groups~, bound to {{{kbd(C-c C-x q)}}}.
4941 If you want to disable tag groups completely, set ~org-group-tags~ to
4942 ~nil~.
4944 ** Tag Searches
4945 :PROPERTIES:
4946 :DESCRIPTION: Searching for combinations of tags.
4947 :END:
4948 #+cindex: tag searches
4949 #+cindex: searching for tags
4951 Once a system of tags has been set up, it can be used to collect
4952 related information into special lists.
4954 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
4956      #+kindex: C-c / m
4957      #+kindex: C-c \
4958      #+findex: org-match-sparse-tree
4959      Create a sparse tree with all headlines matching a tags search.
4960      With a {{{kbd(C-u)}}} prefix argument, ignore headlines that are
4961      not a TODO line.
4963 - {{{kbd(C-c a m)}}} (~org-tags-view~) ::
4965      #+kindex: C-c a m
4966      #+findex: org-tags-view
4967      Create a global list of tag matches from all agenda files.  See
4968      [[*Matching tags and properties]].
4970 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
4972      #+kindex: C-c a M
4973      #+vindex: org-tags-match-list-sublevels
4974      Create a global list of tag matches from all agenda files, but
4975      check only TODO items and force checking subitems (see the option
4976      ~org-tags-match-list-sublevels~).
4978 These commands all prompt for a match string which allows basic
4979 Boolean logic like =+boss+urgent-project1=, to find entries with tags
4980 =boss= and =urgent=, but not =project1=, or =Kathy|Sally= to find
4981 entries which are tagged, like =Kathy= or =Sally=.  The full syntax of
4982 the search string is rich and allows also matching against TODO
4983 keywords, entry levels and properties.  For a complete description
4984 with many examples, see [[*Matching tags and properties]].
4986 * Properties and Columns
4987 :PROPERTIES:
4988 :DESCRIPTION: Storing information about an entry.
4989 :END:
4990 #+cindex: properties
4992 A property is a key-value pair associated with an entry.  Properties
4993 can be set so they are associated with a single entry, with every
4994 entry in a tree, or with every entry in an Org file.
4996 There are two main applications for properties in Org mode.  First,
4997 properties are like tags, but with a value.  Imagine maintaining
4998 a file where you document bugs and plan releases for a piece of
4999 software.  Instead of using tags like =release_1=, =release_2=, you
5000 can use a property, say =Release=, that in different subtrees has
5001 different values, such as =1.0= or =2.0=.  Second, you can use
5002 properties to implement (very basic) database capabilities in an Org
5003 buffer.  Imagine keeping track of your music CDs, where properties
5004 could be things such as the album, artist, date of release, number of
5005 tracks, and so on.
5007 Properties can be conveniently edited and viewed in column view (see
5008 [[*Column View]]).
5010 ** Property Syntax
5011 :PROPERTIES:
5012 :DESCRIPTION: How properties are spelled out.
5013 :END:
5014 #+cindex: property syntax
5015 #+cindex: drawer, for properties
5017 Properties are key--value pairs.  When they are associated with
5018 a single entry or with a tree they need to be inserted into a special
5019 drawer (see [[*Drawers]]) with the name =PROPERTIES=, which has to be
5020 located right below a headline, and its planning line (see [[*Deadlines
5021 and Scheduling]]) when applicable.  Each property is specified on
5022 a single line, with the key---surrounded by colons---first, and the
5023 value after it.  Keys are case-insensitive.  Here is an example:
5025 #+begin_example
5026 ,* CD collection
5027 ,** Classic
5028 ,*** Goldberg Variations
5029     :PROPERTIES:
5030     :Title:     Goldberg Variations
5031     :Composer:  J.S. Bach
5032     :Artist:    Glen Gould
5033     :Publisher: Deutsche Grammophon
5034     :NDisks:    1
5035     :END:
5036 #+end_example
5038 Depending on the value of ~org-use-property-inheritance~, a property
5039 set this way is associated either with a single entry, or with the
5040 sub-tree defined by the entry, see [[*Property Inheritance]].
5042 You may define the allowed values for a particular property =Xyz= by
5043 setting a property =Xyz_ALL=.  This special property is /inherited/,
5044 so if you set it in a level 1 entry, it applies to the entire tree.
5045 When allowed values are defined, setting the corresponding property
5046 becomes easier and is less prone to typing errors.  For the example
5047 with the CD collection, we can pre-define publishers and the number of
5048 disks in a box like this:
5050 #+begin_example
5051 ,* CD collection
5052   :PROPERTIES:
5053   :NDisks_ALL:  1 2 3 4
5054   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5055   :END:
5056 #+end_example
5058 If you want to set properties that can be inherited by any entry in
5059 a file, use a line like:
5061 #+cindex: @samp{_ALL} suffix, in properties
5062 #+cindex: @samp{PROPERTY}, keyword
5063 : #+PROPERTY: NDisks_ALL 1 2 3 4
5065 #+cindex: @samp{+} suffix, in properties
5066 If you want to add to the value of an existing property, append a =+=
5067 to the property name.  The following results in the property =var=
5068 having the value =foo=1 bar=2=.
5070 #+begin_example
5071 ,#+PROPERTY: var  foo=1
5072 ,#+PROPERTY: var+ bar=2
5073 #+end_example
5075 It is also possible to add to the values of inherited properties.  The
5076 following results in the =Genres= property having the value =Classic
5077 Baroque= under the =Goldberg Variations= subtree.
5079 #+begin_example
5080 ,* CD collection
5081 ,** Classic
5082     :PROPERTIES:
5083     :Genres: Classic
5084     :END:
5085 ,*** Goldberg Variations
5086     :PROPERTIES:
5087     :Title:     Goldberg Variations
5088     :Composer:  J.S. Bach
5089     :Artist:    Glen Gould
5090     :Publisher: Deutsche Grammophon
5091     :NDisks:    1
5092     :Genres+:   Baroque
5093     :END:
5094 #+end_example
5096 Note that a property can only have one entry per drawer.
5098 #+vindex: org-global-properties
5099 Property values set with the global variable ~org-global-properties~
5100 can be inherited by all entries in all Org files.
5102 #+texinfo: @noindent
5103 The following commands help to work with properties:
5105 #+attr_texinfo: :sep ,
5106 - {{{kbd(M-TAB)}}} (~pcomplete~) ::
5108      #+kindex: M-TAB
5109      #+findex: pcomplete
5110      After an initial colon in a line, complete property keys.  All
5111      keys used in the current file are offered as possible
5112      completions.
5114 - {{{kbd(C-c C-x p)}}} (~org-set-property~) ::
5116      #+kindex: C-c C-x p
5117      #+findex: org-set-property
5118      Set a property.  This prompts for a property name and a value.
5119      If necessary, the property drawer is created as well.
5121 - {{{kbd(C-u M-x org-insert-drawer)}}} ::
5123      #+findex: org-insert-drawer
5124      Insert a property drawer into the current entry.  The drawer is
5125      inserted early in the entry, but after the lines with planning
5126      information like deadlines.
5128 - {{{kbd(C-c C-c)}}} (~org-property-action~) ::
5130      #+kindex: C-c C-c
5131      #+findex: org-property-action
5132      With the cursor in a property drawer, this executes property
5133      commands.
5135 - {{{kbd(C-c C-c s)}}} (~org-set-property~) ::
5137      #+kindex: C-c C-c s
5138      #+findex: org-set-property
5139      Set a property in the current entry.  Both the property and the value
5140      can be inserted using completion.
5142 - {{{kbd(S-RIGHT)}}} (~org-property-next-allowed-values~),  {{{kbd(S-LEFT)}}} (~org-property-previous-allowed-value~) ::
5144      #+kindex: S-RIGHT
5145      #+kindex: S-LEFT
5146      Switch property at point to the next/previous allowed value.
5148 - {{{kbd(C-c C-c d)}}} (~org-delete-property~) ::
5150      #+kindex: C-c C-c d
5151      #+findex: org-delete-property
5152      Remove a property from the current entry.
5154 - {{{kbd(C-c C-c D)}}} (~org-delete-property-globally~) ::
5156      #+kindex: C-c C-c D
5157      #+findex: org-delete-property-globally
5158      Globally remove a property, from all entries in the current file.
5160 - {{{kbd(C-c C-c c)}}} (~org-compute-property-at-point~) ::
5162      #+kindex: C-c C-c c
5163      #+findex: org-compute-property-at-point
5164      Compute the property at point, using the operator and scope from
5165      the nearest column format definition.
5167 ** Special Properties
5168 :PROPERTIES:
5169 :DESCRIPTION: Access to other Org mode features.
5170 :END:
5171 #+cindex: properties, special
5173 Special properties provide an alternative access method to Org mode
5174 features, like the TODO state or the priority of an entry, discussed
5175 in the previous chapters.  This interface exists so that you can
5176 include these states in a column view (see [[*Column View]]), or to use
5177 them in queries.  The following property names are special and should
5178 not be used as keys in the properties drawer:
5180 #+cindex: @samp{ALLTAGS}, special property
5181 #+cindex: @samp{BLOCKED}, special property
5182 #+cindex: @samp{CLOCKSUM}, special property
5183 #+cindex: @samp{CLOCKSUM_T}, special property
5184 #+cindex: @samp{CLOSED}, special property
5185 #+cindex: @samp{DEADLINE}, special property
5186 #+cindex: @samp{FILE}, special property
5187 #+cindex: @samp{ITEM}, special property
5188 #+cindex: @samp{PRIORITY}, special property
5189 #+cindex: @samp{SCHEDULED}, special property
5190 #+cindex: @samp{TAGS}, special property
5191 #+cindex: @samp{TIMESTAMP}, special property
5192 #+cindex: @samp{TIMESTAMP_IA}, special property
5193 #+cindex: @samp{TODO}, special property
5194 | =ALLTAGS=      | All tags, including inherited ones.                            |
5195 | =BLOCKED=      | ~t~ if task is currently blocked by children or siblings.      |
5196 | =CATEGORY=     | The category of an entry.                                      |
5197 | =CLOCKSUM=     | The sum of CLOCK intervals in the subtree.  ~org-clock-sum~    |
5198 |                | must be run first to compute the values in the current buffer. |
5199 | =CLOCKSUM_T=   | The sum of CLOCK intervals in the subtree for today.           |
5200 |                | ~org-clock-sum-today~ must be run first to compute the         |
5201 |                | values in the current buffer.                                  |
5202 | =CLOSED=       | When was this entry closed?                                    |
5203 | =DEADLINE=     | The deadline time string, without the angular brackets.        |
5204 | =FILE=         | The filename the entry is located in.                          |
5205 | =ITEM=         | The headline of the entry.                                     |
5206 | =PRIORITY=     | The priority of the entry, a string with a single letter.      |
5207 | =SCHEDULED=    | The scheduling timestamp, without the angular brackets.        |
5208 | =TAGS=         | The tags defined directly in the headline.                     |
5209 | =TIMESTAMP=    | The first keyword-less timestamp in the entry.                 |
5210 | =TIMESTAMP_IA= | The first inactive timestamp in the entry.                     |
5211 | =TODO=         | The TODO keyword of the entry.                                 |
5213 ** Property Searches
5214 :PROPERTIES:
5215 :DESCRIPTION: Matching property values.
5216 :END:
5217 #+cindex: properties, searching
5218 #+cindex: searching, of properties
5220 To create sparse trees and special lists with selection based on
5221 properties, the same commands are used as for tag searches (see [[*Tag
5222 Searches]]).
5224 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
5226      #+kindex: C-c / m
5227      #+kindex: C-c \
5228      #+findex: org-match-sparse-tree
5229      Create a sparse tree with all matching entries.  With
5230      a {{{kbd(C-u)}}} prefix argument, ignore headlines that are not
5231      a TODO line.
5233 - {{{kbd(C-c a m)}}}, ~org-tags-view~ ::
5235      #+kindex: C-c a m
5236      Create a global list of tag/property matches from all agenda
5237      files.
5239 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
5241      #+kindex: C-c a M
5242      #+findex: org-tags-view
5243      #+vindex: org-tags-match-list-sublevels
5244      Create a global list of tag matches from all agenda files, but
5245      check only TODO items and force checking of subitems (see the
5246      option ~org-tags-match-list-sublevels~).
5248 The syntax for the search string is described in [[*Matching tags and
5249 properties]].
5251 There is also a special command for creating sparse trees based on a
5252 single property:
5254 - {{{kbd(C-c / p)}}} ::
5256      #+kindex: C-c / p
5257      Create a sparse tree based on the value of a property.  This
5258      first prompts for the name of a property, and then for a value.
5259      A sparse tree is created with all entries that define this
5260      property with the given value.  If you enclose the value in curly
5261      braces, it is interpreted as a regular expression and matched
5262      against the property values.
5264 ** Property Inheritance
5265 :PROPERTIES:
5266 :DESCRIPTION: Passing values down a tree.
5267 :END:
5268 #+cindex: properties, inheritance
5269 #+cindex: inheritance, of properties
5271 #+vindex: org-use-property-inheritance
5272 The outline structure of Org documents lends itself to an inheritance
5273 model of properties: if the parent in a tree has a certain property,
5274 the children can inherit this property.  Org mode does not turn this
5275 on by default, because it can slow down property searches
5276 significantly and is often not needed.  However, if you find
5277 inheritance useful, you can turn it on by setting the variable
5278 ~org-use-property-inheritance~.  It may be set to ~t~ to make all
5279 properties inherited from the parent, to a list of properties that
5280 should be inherited, or to a regular expression that matches inherited
5281 properties.  If a property has the value ~nil~, this is interpreted as
5282 an explicit un-define of the property, so that inheritance search
5283 stops at this value and returns ~nil~.
5285 Org mode has a few properties for which inheritance is hard-coded, at
5286 least for the special applications for which they are used:
5288 - ~COLUMNS~ ::
5290      #+cindex: @samp{COLUMNS}, property
5291      The =COLUMNS= property defines the format of column view (see
5292      [[*Column View]]).  It is inherited in the sense that the level where
5293      a =COLUMNS= property is defined is used as the starting point for
5294      a column view table, independently of the location in the subtree
5295      from where columns view is turned on.
5297 - ~CATEGORY~ ::
5299      #+cindex: @samp{CATEGORY}, property
5300      For agenda view, a category set through a =CATEGORY= property
5301      applies to the entire subtree.
5303 - ~ARCHIVE~ ::
5305      #+cindex: @samp{ARCHIVE}, property
5306      For archiving, the =ARCHIVE= property may define the archive
5307      location for the entire subtree (see [[*Moving a tree to an archive
5308      file]]).
5310 - ~LOGGING~ ::
5312      #+cindex: @samp{LOGGING}, property
5313      The =LOGGING= property may define logging settings for an entry
5314      or a subtree (see [[*Tracking TODO state changes]]).
5316 ** Column View
5317 :PROPERTIES:
5318 :DESCRIPTION: Tabular viewing and editing.
5319 :END:
5321 A great way to view and edit properties in an outline tree is /column
5322 view/.  In column view, each outline node is turned into a table row.
5323 Columns in this table provide access to properties of the entries.
5324 Org mode implements columns by overlaying a tabular structure over the
5325 headline of each item.  While the headlines have been turned into
5326 a table row, you can still change the visibility of the outline tree.
5327 For example, you get a compact table by switching to "contents"
5328 view---{{{kbd(S-TAB)}}} {{{kbd(S-TAB)}}}, or simply {{{kbd(c)}}}
5329 while column view is active---but you can still open, read, and edit
5330 the entry below each headline.  Or, you can switch to column view
5331 after executing a sparse tree command and in this way get a table only
5332 for the selected items.  Column view also works in agenda buffers (see
5333 [[*Agenda Views]]) where queries have collected selected items, possibly
5334 from a number of files.
5336 *** Defining columns
5337 :PROPERTIES:
5338 :DESCRIPTION: The COLUMNS format property.
5339 :END:
5340 #+cindex: column view, for properties
5341 #+cindex: properties, column view
5343 Setting up a column view first requires defining the columns.  This is
5344 done by defining a column format line.
5346 **** Scope of column definitions
5347 :PROPERTIES:
5348 :DESCRIPTION: Where defined, where valid?
5349 :END:
5351 To define a column format for an entire file, use a line like:
5353 #+cindex: @samp{COLUMNS}, keyword
5354 : #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5356 To specify a format that only applies to a specific tree, add
5357 a =COLUMNS= property to the top node of that tree, for example:
5359 #+begin_example
5360 ,** Top node for columns view
5361    :PROPERTIES:
5362    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5363    :END:
5364 #+end_example
5366 If a =COLUMNS= property is present in an entry, it defines columns for
5367 the entry itself, and for the entire subtree below it.  Since the
5368 column definition is part of the hierarchical structure of the
5369 document, you can define columns on level 1 that are general enough
5370 for all sublevels, and more specific columns further down, when you
5371 edit a deeper part of the tree.
5373 **** Column attributes
5374 :PROPERTIES:
5375 :DESCRIPTION: Appearance and content of a column.
5376 :END:
5378 A column definition sets the attributes of a column.  The general
5379 definition looks like this:
5381 : %[WIDTH]PROPERTY[(TITLE)][{SUMMARY-TYPE}]
5383 #+texinfo: @noindent
5384 Except for the percent sign and the property name, all items are
5385 optional.  The individual parts have the following meaning:
5387 - {{{var(WIDTH)}}} ::
5389      An integer specifying the width of the column in characters.  If
5390      omitted, the width is determined automatically.
5392 - {{{var(PROPERTY)}}} ::
5394      The property that should be edited in this column.  Special
5395      properties representing meta data are allowed here as well (see
5396      [[*Special Properties]]).
5398 - {{{var(TITLE)}}} ::
5400      The header text for the column.  If omitted, the property name is
5401      used.
5403 - {{{var(SUMMARY-TYPE)}}} ::
5405      The summary type.  If specified, the column values for parent
5406      nodes are computed from the children[fn:55].
5408      Supported summary types are:
5410      | =+=      | Sum numbers in this column.                           |
5411      | =+;%.1f= | Like =+=, but format result with =%.1f=.              |
5412      | =$=      | Currency, short for =+;%.2f=.                         |
5413      | =min=    | Smallest number in column.                            |
5414      | =max=    | Largest number.                                       |
5415      | =mean=   | Arithmetic mean of numbers.                           |
5416      | =X=      | Checkbox status, =[X]= if all children are =[X]=.     |
5417      | =X/=     | Checkbox status, =[n/m]=.                             |
5418      | =X%=     | Checkbox status, =[n%]=.                              |
5419      | =:=      | Sum times, HH:MM, plain numbers are hours.            |
5420      | =:min=   | Smallest time value in column.                        |
5421      | =:max=   | Largest time value.                                   |
5422      | =:mean=  | Arithmetic mean of time values.                       |
5423      | =@min=   | Minimum age[fn:56] (in days/hours/mins/seconds).      |
5424      | =@max=   | Maximum age (in days/hours/mins/seconds).             |
5425      | =@mean=  | Arithmetic mean of ages (in days/hours/mins/seconds). |
5426      | =est+=   | Add low-high estimates.                               |
5428      #+texinfo: @noindent
5429      #+vindex: org-columns-summary-types
5430      You can also define custom summary types by setting
5431      ~org-columns-summary-types~.
5433 The =est+= summary type requires further explanation.  It is used for
5434 combining estimates, expressed as low-high ranges.  For example,
5435 instead of estimating a particular task will take 5 days, you might
5436 estimate it as 5--6 days if you're fairly confident you know how much
5437 work is required, or 1--10 days if you do not really know what needs
5438 to be done.  Both ranges average at 5.5 days, but the first represents
5439 a more predictable delivery.
5441 When combining a set of such estimates, simply adding the lows and
5442 highs produces an unrealistically wide result.  Instead, =est+= adds
5443 the statistical mean and variance of the sub-tasks, generating a final
5444 estimate from the sum.  For example, suppose you had ten tasks, each
5445 of which was estimated at 0.5 to 2 days of work.  Straight addition
5446 produces an estimate of 5 to 20 days, representing what to expect if
5447 everything goes either extremely well or extremely poorly.  In
5448 contrast, =est+= estimates the full job more realistically, at 10--15
5449 days.
5451 Here is an example for a complete columns definition, along with
5452 allowed values[fn:57].
5454 #+begin_example
5455 :COLUMNS:  %25ITEM %9Approved(Approved?){X} %Owner %11Status \
5456                    %10Time_Estimate{:} %CLOCKSUM %CLOCKSUM_T
5457 :Owner_ALL:    Tammy Mark Karl Lisa Don
5458 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5459 :Approved_ALL: "[ ]" "[X]"
5460 #+end_example
5462 #+texinfo: @noindent
5463 The first column, =%25ITEM=, means the first 25 characters of the item
5464 itself, i.e., of the headline.  You probably always should start the
5465 column definition with the =ITEM= specifier.  The other specifiers
5466 create columns =Owner= with a list of names as allowed values, for
5467 =Status= with four different possible values, and for a checkbox field
5468 =Approved=.  When no width is given after the =%= character, the
5469 column is exactly as wide as it needs to be in order to fully display
5470 all values.  The =Approved= column does have a modified title
5471 (=Approved?=, with a question mark).  Summaries are created for the
5472 =Time_Estimate= column by adding time duration expressions like HH:MM,
5473 and for the =Approved= column, by providing an =[X]= status if all
5474 children have been checked.  The =CLOCKSUM= and =CLOCKSUM_T= columns
5475 are special, they lists the sums of CLOCK intervals in the subtree,
5476 either for all clocks or just for today.
5478 *** Using column view
5479 :PROPERTIES:
5480 :DESCRIPTION: How to create and use column view.
5481 :END:
5483 **** Turning column view on or off
5484 :PROPERTIES:
5485 :UNNUMBERED: notoc
5486 :END:
5488 - {{{kbd(C-c C-x C-c)}}} (~org-columns~) ::
5490      #+kindex: C-c C-x C-c
5491      #+vindex: org-columns
5492      #+vindex: org-columns-default-format
5493      Turn on column view.  If the cursor is before the first headline
5494      in the file, column view is turned on for the entire file, using
5495      the =#+COLUMNS= definition.  If the cursor is somewhere inside
5496      the outline, this command searches the hierarchy, up from point,
5497      for a =COLUMNS= property that defines a format.  When one is
5498      found, the column view table is established for the tree starting
5499      at the entry that contains the =COLUMNS= property.  If no such
5500      property is found, the format is taken from the =#+COLUMNS= line
5501      or from the variable ~org-columns-default-format~, and column
5502      view is established for the current entry and its subtree.
5504 - {{{kbd(r)}}} or {{{kbd(g)}}} (~org-columns-redo~) ::
5506      #+kindex: r
5507      #+kindex: g
5508      #+findex: org-columns-redo
5509      Recreate the column view, to include recent changes made in the
5510      buffer.
5512 - {{{kbd(q)}}} (~org-columns-quit~) ::
5514      #+kindex: q
5515      #+findex: org-columns-quit
5516      Exit column view.
5518 **** Editing values
5519 :PROPERTIES:
5520 :UNNUMBERED: notoc
5521 :END:
5523 #+attr_texinfo: :sep and
5524 - {{{kbd(LEFT)}}}, {{{kbd(RIGHT)}}}, {{{kbd(UP)}}}, {{{kbd(DOWN)}}} ::
5526      Move through the column view from field to field.
5528 - {{{kbd(1..9\,0)}}} ::
5530      #+kindex: 1..9,0
5531      Directly select the Nth allowed value, {{{kbd(0)}}} selects the
5532      10th value.
5534 - {{{kbd(n)}}} or {{{kbd(S-RIGHT)}}} (~org-columns-next-allowed-value~) and {{{kbd(p)}}} or {{{kbd(S-LEFT)}}} (~org-columns-previous-allowed-value~) ::
5536      #+kindex: n
5537      #+kindex: S-RIGHT
5538      #+kindex: p
5539      #+kindex: S-LEFT
5540      #+findex: org-columns-next-allowed-value
5541      #+findex: org-columns-previous-allowed-value
5542      Switch to the next/previous allowed value of the field.  For
5543      this, you have to have specified allowed values for a property.
5545 - {{{kbd(e)}}} (~org-columns-edit-value~) ::
5547      #+kindex: e
5548      #+findex: org-columns-edit-value
5549      Edit the property at point.  For the special properties, this
5550      invokes the same interface that you normally use to change that
5551      property.  For example, the tag completion or fast selection
5552      interface pops up when editing a =TAGS= property.
5554 - {{{kbd(C-c C-c)}}} (~org-columns-set-tags-or-toggle~) ::
5556      #+kindex: C-c C-c
5557      #+findex: org-columns-set-tags-or-toggle
5558      When there is a checkbox at point, toggle it.
5560 - {{{kbd(v)}}} (~org-columns-show-value~) ::
5562      #+kindex: v
5563      #+findex: org-columns-show-value
5564      View the full value of this property.  This is useful if the
5565      width of the column is smaller than that of the value.
5567 - {{{kbd(a)}}} (~org-columns-edit-allowed~) ::
5569      #+kindex: a
5570      #+findex: org-columns-edit-allowed
5571      Edit the list of allowed values for this property.  If the list
5572      is found in the hierarchy, the modified values is stored there.
5573      If no list is found, the new value is stored in the first entry
5574      that is part of the current column view.
5576 **** Modifying column view on-the-fly:
5577 :PROPERTIES:
5578 :UNNUMBERED: notoc
5579 :END:
5581 #+attr_texinfo: :sep and
5582 - {{{kbd(<)}}} (~org-columns-narrow~) and {{{kbd(>)}}} (~org-columns-widen~) ::
5584      #+kindex: <
5585      #+kindex: >
5586      #+findex: org-columns-narrow
5587      #+findex: org-columns-widen
5588      Make the column narrower/wider by one character.
5590 - {{{kbd(S-M-RIGHT)}}} (~org-columns-new~) ::
5592      #+kindex: S-M-RIGHT
5593      #+findex: org-columns-new
5594      Insert a new column, to the left of the current column.
5596 - {{{kbd(S-M-LEFT)}}} (~org-columns-delete~) ::
5598      #+kindex: S-M-LEFT
5599      #+findex: org-columns-delete
5600      Delete the current column.
5602 *** Capturing column view
5603 :PROPERTIES:
5604 :DESCRIPTION: A dynamic block for column view.
5605 :END:
5607 Since column view is just an overlay over a buffer, it cannot be
5608 exported or printed directly.  If you want to capture a column view,
5609 use a =columnview= dynamic block (see [[*Dynamic Blocks]]).  The frame of
5610 this block looks like this:
5612 #+cindex: @samp{BEGIN columnview}
5613 #+begin_example
5614 ,* The column view
5615 ,#+BEGIN: columnview :hlines 1 :id "label"
5617 ,#+END:
5618 #+end_example
5620 #+texinfo: @noindent
5621 This dynamic block has the following parameters:
5623 - =:id= ::
5625      This is the most important parameter.  Column view is a feature
5626      that is often localized to a certain (sub)tree, and the capture
5627      block might be at a different location in the file.  To identify
5628      the tree whose view to capture, you can use four values:
5630      - =local= ::
5632           Use the tree in which the capture block is located.
5634      - =global= ::
5636           Make a global view, including all headings in the file.
5638      - =file:FILENAME= ::
5640           Run column view at the top of the {{{var(FILENAME)}}} file
5642      - =LABEL= ::
5644           #+cindex: @samp{ID}, property
5645           Call column view in the tree that has an =ID= property with
5646           the value {{{var(LABEL)}}}.  You can use {{{kbd(M-x
5647           org-id-copy)}}} to create a globally unique ID for the
5648           current entry and copy it to the kill-ring.
5650 - =:hlines= ::
5652      When ~t~, insert an hline after every line.  When a number N,
5653      insert an hline before each headline with level ~<= N~.
5655 - =:vlines= ::
5657      When non-~nil~, force column groups to get vertical lines.
5659 - =:maxlevel= ::
5661      When set to a number, do not capture entries below this level.
5663 - =:skip-empty-rows= ::
5665      When non-~nil~, skip rows where the only non-empty specifier of
5666      the column view is =ITEM=.
5668 - =:indent= ::
5670      When non-~nil~, indent each =ITEM= field according to its level.
5672 #+texinfo: @noindent
5673 The following commands insert or update the dynamic block:
5675 - {{{kbd(C-c C-x i)}}} (~org-insert-columns-dblock~) ::
5677      #+kindex: C-c C-x i
5678      #+findex: org-insert-columns-dblock
5679      Insert a dynamic block capturing a column view.  Prompt for the
5680      scope or ID of the view.
5682 - {{{kbd(C-c C-c)}}} {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
5684      #+kindex: C-c C-c
5685      #+kindex: C-c C-x C-u
5686      #+findex: org-dblock-update
5687      Update dynamic block at point.  The cursor needs to be in the
5688      =#+BEGIN= line of the dynamic block.
5690 - {{{kbd(C-u C-c C-x C-u)}}} (~org-update-all-dblocks~) ::
5692      #+kindex: C-u C-c C-x C-u
5693      Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful
5694      if you have several clock table blocks, column-capturing blocks
5695      or other dynamic blocks in a buffer.
5697 You can add formulas to the column view table and you may add plotting
5698 instructions in front of the table---these survive an update of the
5699 block.  If there is a =TBLFM= keyword after the table, the table is
5700 recalculated automatically after an update.
5702 An alternative way to capture and process property values into a table
5703 is provided by Eric Schulte's =org-collector.el= which is
5704 a contributed package[fn:58].  It provides a general API to collect
5705 properties from entries in a certain scope, and arbitrary Lisp
5706 expressions to process these values before inserting them into a table
5707 or a dynamic block.
5709 * Dates and Times
5710 :PROPERTIES:
5711 :DESCRIPTION: Making items useful for planning.
5712 :END:
5713 #+cindex: dates
5714 #+cindex: times
5715 #+cindex: timestamp
5716 #+cindex: date stamp
5718 To assist project planning, TODO items can be labeled with a date
5719 and/or a time.  The specially formatted string carrying the date and
5720 time information is called a /timestamp/ in Org mode.  This may be
5721 a little confusing because timestamp is often used as indicating when
5722 something was created or last changed.  However, in Org mode this term
5723 is used in a much wider sense.
5725 ** Timestamps, Deadlines and Scheduling
5726 :PROPERTIES:
5727 :DESCRIPTION: Assigning a time to a tree entry.
5728 :ALT_TITLE: Timestamps
5729 :END:
5730 #+cindex: timestamps
5731 #+cindex: ranges, time
5732 #+cindex: date stamps
5733 #+cindex: deadlines
5734 #+cindex: scheduling
5736 A timestamp is a specification of a date (possibly with a time or
5737 a range of times) in a special format, either =<2003-09-16 Tue>= or
5738 =<2003-09-16 Tue 09:39>= or =<2003-09-16 Tue 12:00-12:30>=[fn:59].
5739 A timestamp can appear anywhere in the headline or body of an Org tree
5740 entry.  Its presence causes entries to be shown on specific dates in
5741 the agenda (see [[*Weekly/daily agenda]]).  We distinguish:
5743 - Plain timestamp; Event; Appointment ::
5745      #+cindex: timestamp
5746      #+cindex: appointment
5747      A simple timestamp just assigns a date/time to an item.  This is
5748      just like writing down an appointment or event in a paper agenda.
5749      In the timeline and agenda displays, the headline of an entry
5750      associated with a plain timestamp is shown exactly on that date.
5752      #+begin_example
5753      ,* Meet Peter at the movies
5754        <2006-11-01 Wed 19:15>
5755      ,* Discussion on climate change
5756        <2006-11-02 Thu 20:00-22:00>
5757      #+end_example
5759 - Timestamp with repeater interval ::
5761      #+cindex: timestamp, with repeater interval
5762      A timestamp may contain a /repeater interval/, indicating that it
5763      applies not only on the given date, but again and again after
5764      a certain interval of N days (d), weeks (w), months (m), or years
5765      (y).  The following shows up in the agenda every Wednesday:
5767      #+begin_example
5768      ,* Pick up Sam at school
5769        <2007-05-16 Wed 12:30 +1w>
5770      #+end_example
5772 - Diary-style sexp entries ::
5774      #+cindex: diary style timestamps
5775      #+cindex: sexp timestamps
5776      For more complex date specifications, Org mode supports using the
5777      special sexp diary entries implemented in the Emacs
5778      calendar/diary package[fn:60].  For example, with optional time:
5780      #+begin_example
5781      ,* 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5782        <%%(org-float t 4 2)>
5783      #+end_example
5785 - Time/Date range ::
5787      #+cindex: timerange
5788      #+cindex: date range
5789      Two timestamps connected by =--= denote a range.  The headline is
5790      shown on the first and last day of the range, and on any dates
5791      that are displayed and fall in the range.  Here is an example:
5793      #+begin_example
5794      ,** Meeting in Amsterdam
5795         <2004-08-23 Mon>--<2004-08-26 Thu>
5796      #+end_example
5798 - Inactive timestamp ::
5800      #+cindex: timestamp, inactive
5801      #+cindex: inactive timestamp
5802      Just like a plain timestamp, but with square brackets instead of
5803      angular ones.  These timestamps are inactive in the sense that
5804      they do /not/ trigger an entry to show up in the agenda.
5806      #+begin_example
5807      ,* Gillian comes late for the fifth time
5808        [2006-11-01 Wed]
5809      #+end_example
5811 ** Creating Timestamps
5812 :PROPERTIES:
5813 :DESCRIPTION: Commands to insert timestamps.
5814 :END:
5816 For Org mode to recognize timestamps, they need to be in the specific
5817 format.  All commands listed below produce timestamps in the correct
5818 format.
5820 #+attr_texinfo: :sep ,
5821 - {{{kbd(C-c .)}}} (~org-time-stamp~) ::
5823      #+kindex: C-c .
5824      #+findex: org-time-stamp
5825      Prompt for a date and insert a corresponding timestamp.  When the
5826      cursor is at an existing timestamp in the buffer, the command is
5827      used to modify this timestamp instead of inserting a new one.
5828      When this command is used twice in succession, a time range is
5829      inserted.
5831      #+kindex: C-u C-c .
5832      #+vindex: org-time-stamp-rounding-minutes
5833      When called with a prefix argument, use the alternative format
5834      which contains date and time.  The default time can be rounded to
5835      multiples of 5 minutes.  See the option
5836      ~org-time-stamp-rounding-minutes~.
5838      #+kindex: C-u C-u C-c .
5839      With two prefix arguments, insert an active timestamp with the
5840      current time without prompting.
5842 - {{{kbd(C-c !)}}} (~org-time-stamp-inactive~) ::
5844      #+kindex: C-c !
5845      #+kindex: C-u C-c !
5846      #+kindex: C-u C-u C-c !
5847      #+findex: org-time-stamp-inactive
5848      Like {{{kbd(C-c .)}}}, but insert an inactive timestamp that does
5849      not cause an agenda entry.
5851 - {{{kbd(C-c C-c)}}} ::
5853      #+kindex: C-c C-c
5854      Normalize timestamp, insert or fix day name if missing or wrong.
5856 - {{{kbd(C-c <)}}} (~org-date-from-calendar~) ::
5858      #+kindex: C-c <
5859      #+findex: org-date-from-calendar
5860      Insert a timestamp corresponding to the cursor date in the
5861      calendar.
5863 - {{{kbd(C-c >)}}} (~org-goto-calendar~) ::
5865      #+kindex: C-c >
5866      #+findex: org-goto-calendar
5867      Access the Emacs calendar for the current date.  If there is
5868      a timestamp in the current line, go to the corresponding date
5869      instead.
5871 - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
5873      #+kindex: C-c C-o
5874      #+findex: org-open-at-point
5875      Access the agenda for the date given by the timestamp or -range
5876      at point (see [[*Weekly/daily agenda]]).
5878 - {{{kbd(S-LEFT)}}} (~org-timestamp-down-day~), {{{kbd(S-RIGHT)}}} (~org-timestamp-up-day~) ::
5880      #+kindex: S-LEFT
5881      #+kindex: S-RIGHT
5882      #+findex: org-timestamp-down-day
5883      #+findex: org-timestamp-up-day
5884      Change date at cursor by one day.  These key bindings conflict
5885      with shift-selection and related modes (see [[*Packages that
5886      conflict with Org mode]]).
5888 - {{{kbd(S-UP)}}} (~org-timestamp-up~), {{{kbd(S-DOWN)}}} (~org-timestamp-down~) ::
5890      #+kindex: S-UP
5891      #+kindex: S-DOWN
5892      Change the item under the cursor in a timestamp.  The cursor can
5893      be on a year, month, day, hour or minute.  When the timestamp
5894      contains a time range like =15:30-16:30=, modifying the first
5895      time also shifts the second, shifting the time block with
5896      constant length.  To change the length, modify the second time.
5897      Note that if the cursor is in a headline and not at a timestamp,
5898      these same keys modify the priority of an item.  (see
5899      [[*Priorities]]).  The key bindings also conflict with
5900      shift-selection and related modes (see [[*Packages that conflict
5901      with Org mode]]).
5903 - {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
5905      #+kindex: C-c C-y
5906      #+findex: org-evaluate-time-range
5907      #+cindex: evaluate time range
5908      Evaluate a time range by computing the difference between start
5909      and end.  With a prefix argument, insert result after the time
5910      range (in a table: into the following column).
5912 *** The date/time prompt
5913 :PROPERTIES:
5914 :DESCRIPTION: How Org mode helps you enter dates and times.
5915 :END:
5916 #+cindex: date, reading in minibuffer
5917 #+cindex: time, reading in minibuffer
5919 #+vindex: org-read-date-prefer-future
5920 When Org mode prompts for a date/time, the default is shown in default
5921 date/time format, and the prompt therefore seems to ask for a specific
5922 format.  But it in fact accepts date/time information in a variety of
5923 formats.  Generally, the information should start at the beginning of
5924 the string.  Org mode finds whatever information is in there and
5925 derives anything you have not specified from the /default date and
5926 time/.  The default is usually the current date and time, but when
5927 modifying an existing timestamp, or when entering the second stamp of
5928 a range, it is taken from the stamp in the buffer.  When filling in
5929 information, Org mode assumes that most of the time you want to enter
5930 a date in the future: if you omit the month/year and the given
5931 day/month is /before/ today, it assumes that you mean a future
5932 date[fn:61].  If the date has been automatically shifted into the
5933 future, the time prompt shows this with =(=>F)=.
5935 For example, let's assume that today is *June 13, 2006*.  Here is how
5936 various inputs are interpreted, the items filled in by Org mode are in
5937 *bold*.
5939 | =3-2-5=        | \rArr{} 2003-02-05                              |
5940 | =2/5/3=        | \rArr{} 2003-02-05                              |
5941 | =14=           | \rArr{} *2006*-*06*-14                          |
5942 | =12=           | \rArr{} *2006*-*07*-12                          |
5943 | =2/5=          | \rArr{} *2007*-02-05                            |
5944 | =Fri=          | \rArr{} nearest Friday (default date or later)  |
5945 | =sep 15=       | \rArr{} *2006*-09-15                            |
5946 | =feb 15=       | \rArr{} *2007*-02-15                            |
5947 | =sep 12 9=     | \rArr{} 2009-09-12                              |
5948 | =12:45=        | \rArr{} *2006*-*06*-*13* 12:45                  |
5949 | =22 sept 0:34= | \rArr{} *2006*-09-22 0:34                       |
5950 | =w4=           | \rArr{} ISO week for of the current year *2006* |
5951 | =2012 w4 fri=  | \rArr{} Friday of ISO week 4 in 2012            |
5952 | =2012-w04-5=   | \rArr{} Same as above                           |
5954 Furthermore you can specify a relative date by giving, as the /first/
5955 thing in the input: a plus/minus sign, a number and a letter---=d=,
5956 =w=, =m= or =y=---to indicate change in days, weeks, months, or
5957 years.  With a single plus or minus, the date is always relative to
5958 today.  With a double plus or minus, it is relative to the default
5959 date.  If instead of a single letter, you use the abbreviation of day
5960 name, the date is the Nth such day, e.g.:
5962 | =+0=    | \rArr{} today                       |
5963 | =.=     | \rArr{} today                       |
5964 | =+4d=   | \rArr{} four days from today        |
5965 | =+4=    | \rArr{} same as +4d                 |
5966 | =+2w=   | \rArr{} two weeks from today        |
5967 | =++5=   | \rArr{} five days from default date |
5968 | =+2tue= | \rArr{} second Tuesday from now     |
5970 #+vindex: parse-time-months
5971 #+vindex: parse-time-weekdays
5972 The function understands English month and weekday abbreviations.  If
5973 you want to use un-abbreviated names and/or other languages, configure
5974 the variables ~parse-time-months~ and ~parse-time-weekdays~.
5976 #+vindex: org-read-date-force-compatible-dates
5977 Not all dates can be represented in a given Emacs implementation.  By
5978 default Org mode forces dates into the compatibility range 1970--2037
5979 which works on all Emacs implementations.  If you want to use dates
5980 outside of this range, read the docstring of the variable
5981 ~org-read-date-force-compatible-dates~.
5983 You can specify a time range by giving start and end times or by
5984 giving a start time and a duration (in HH:MM format).  Use one or two
5985 dash(es) as the separator in the former case and use =+= as the
5986 separator in the latter case, e.g.:
5988 | =11am-1:15pm=  | \rArr{} 11:00-13:15   |
5989 | =11am--1:15pm= | \rArr{} same as above |
5990 | =11am+2:15=    | \rArr{} same as above |
5992 #+cindex: calendar, for selecting date
5993 #+vindex: org-popup-calendar-for-date-prompt
5994 Parallel to the minibuffer prompt, a calendar is popped up[fn:62].
5995 When you exit the date prompt, either by clicking on a date in the
5996 calendar, or by pressing {{{kbd(RET)}}}, the date selected in the
5997 calendar is combined with the information entered at the prompt.  You
5998 can control the calendar fully from the minibuffer:
6000 #+kindex: <
6001 #+kindex: >
6002 #+kindex: M-v
6003 #+kindex: C-v
6004 #+kindex: mouse-1
6005 #+kindex: S-RIGHT
6006 #+kindex: S-LEFT
6007 #+kindex: S-DOWN
6008 #+kindex: S-UP
6009 #+kindex: M-S-RIGHT
6010 #+kindex: M-S-LEFT
6011 #+kindex: RET
6012 #+attr_texinfo: :columns 0.25 0.55
6013 | {{{kbd(RET)}}}           | Choose date at cursor in calendar.     |
6014 | {{{kbd(mouse-1)}}}       | Select date by clicking on it.         |
6015 | {{{kbd(S-RIGHT)}}}    | One day forward.                       |
6016 | {{{kbd(S-LEFT)}}}     | One day backward.                      |
6017 | {{{kbd(S-DOWN)}}}     | One week forward.                      |
6018 | {{{kbd(S-UP)}}}       | One week backward.                     |
6019 | {{{kbd(M-S-RIGHT)}}}  | One month forward.                     |
6020 | {{{kbd(M-S-LEFT)}}}   | One month backward.                    |
6021 | {{{kbd(>)}}}             | Scroll calendar forward by one month.  |
6022 | {{{kbd(<)}}}             | Scroll calendar backward by one month. |
6023 | {{{kbd(M-v)}}}           | Scroll calendar forward by 3 months.   |
6024 | {{{kbd(C-v)}}}           | Scroll calendar backward by 3 months.  |
6026 #+vindex: org-read-date-display-live
6027 The actions of the date/time prompt may seem complex, but I assure you
6028 they will grow on you, and you will start getting annoyed by pretty
6029 much any other way of entering a date/time out there.  To help you
6030 understand what is going on, the current interpretation of your input
6031 is displayed live in the minibuffer[fn:63].
6033 *** Custom time format
6034 :PROPERTIES:
6035 :DESCRIPTION: Making dates look different.
6036 :END:
6037 #+cindex: custom date/time format
6038 #+cindex: time format, custom
6039 #+cindex: date format, custom
6041 #+vindex: org-display-custom-times
6042 #+vindex: org-time-stamp-custom-formats
6043 Org mode uses the standard ISO notation for dates and times as it is
6044 defined in ISO 8601.  If you cannot get used to this and require
6045 another representation of date and time to keep you happy, you can get
6046 it by customizing the variables ~org-display-custom-times~ and
6047 ~org-time-stamp-custom-formats~.
6049 - {{{kbd(C-c C-x C-t)}}} (~org-toggle-time-stamp-overlays~) ::
6051      #+kindex: C-c C-x C-t
6052      #+findex: org-toggle-time-stamp-overlays
6053      Toggle the display of custom formats for dates and times.
6055 #+texinfo: @noindent
6056 Org mode needs the default format for scanning, so the custom
6057 date/time format does not /replace/ the default format.  Instead, it
6058 is put /over/ the default format using text properties.  This has the
6059 following consequences:
6061 - You cannot place the cursor onto a timestamp anymore, only before or
6062   after.
6064 - The {{{kbd(S-UP)}}} and {{{kbd(S-DOWN)}}} keys can no longer be used
6065   to adjust each component of a timestamp.  If the cursor is at the
6066   beginning of the stamp, {{{kbd(S-UP)}}} and {{{kbd(S-DOWN)}}} change
6067   the stamp by one day, just like {{{kbd(S-LEFT)}}}
6068   {{{kbd(S-RIGHT)}}}.  At the end of the stamp, change the time by one
6069   minute.
6071 - If the timestamp contains a range of clock times or a repeater,
6072   these are not overlaid, but remain in the buffer as they were.
6074 - When you delete a timestamp character-by-character, it only
6075   disappears from the buffer after /all/ (invisible) characters
6076   belonging to the ISO timestamp have been removed.
6078 - If the custom timestamp format is longer than the default and you
6079   are using dates in tables, table alignment will be messed up.  If
6080   the custom format is shorter, things do work as expected.
6082 ** Deadlines and Scheduling
6083 :PROPERTIES:
6084 :DESCRIPTION: Planning your work.
6085 :END:
6087 A timestamp may be preceded by special keywords to facilitate
6088 planning.  Both the timestamp and the keyword have to be positioned
6089 immediately after the task they refer to.
6091 - =DEADLINE= ::
6093      #+cindex: @samp{DEADLINE}
6094      Meaning: the task (most likely a TODO item, though not
6095      necessarily) is supposed to be finished on that date.
6097      #+vindex: org-deadline-warning-days
6098      On the deadline date, the task is listed in the agenda.  In
6099      addition, the agenda for /today/ carries a warning about the
6100      approaching or missed deadline, starting
6101      ~org-deadline-warning-days~ before the due date, and continuing
6102      until the entry is marked DONE.  An example:
6104      #+begin_example
6105      ,*** TODO write article about the Earth for the Guide
6106          DEADLINE: <2004-02-29 Sun>
6107          The editor in charge is [[bbdb:Ford Prefect]]
6108      #+end_example
6110      #+vindex: org-agenda-skip-deadline-prewarning-if-scheduled
6111      You can specify a different lead time for warnings for a specific
6112      deadlines using the following syntax.  Here is an example with
6113      a warning period of 5 days =DEADLINE: <2004-02-29 Sun -5d>=.
6114      This warning is deactivated if the task gets scheduled and you
6115      set ~org-agenda-skip-deadline-prewarning-if-scheduled~ to ~t~.
6117 - =SCHEDULED= ::
6119      #+cindex: @samp{SCHEDULED}
6120      Meaning: you are planning to start working on that task on the
6121      given date.
6123      #+vindex: org-agenda-skip-scheduled-if-done
6124      The headline is listed under the given date[fn:64].  In addition,
6125      a reminder that the scheduled date has passed is present in the
6126      compilation for /today/, until the entry is marked DONE, i.e.,
6127      the task is automatically forwarded until completed.
6129      #+begin_example
6130      ,*** TODO Call Trillian for a date on New Years Eve.
6131          SCHEDULED: <2004-12-25 Sat>
6132      #+end_example
6134      #+vindex: org-scheduled-delay-days
6135      #+vindex: org-agenda-skip-scheduled-delay-if-deadline
6136      If you want to /delay/ the display of this task in the agenda,
6137      use =SCHEDULED: <2004-12-25 Sat -2d>=: the task is still
6138      scheduled on the 25th but will appear two days later.  In case
6139      the task contains a repeater, the delay is considered to affect
6140      all occurrences; if you want the delay to only affect the first
6141      scheduled occurrence of the task, use =--2d= instead.  See
6142      ~org-scheduled-delay-days~ and
6143      ~org-agenda-skip-scheduled-delay-if-deadline~ for details on how
6144      to control this globally or per agenda.
6146      #+texinfo: @noindent
6147      *Important:* Scheduling an item in Org mode should /not/ be
6148      understood in the same way that we understand /scheduling
6149      a meeting/.  Setting a date for a meeting is just a simple
6150      appointment, you should mark this entry with a simple plain
6151      timestamp, to get this item shown on the date where it applies.
6152      This is a frequent misunderstanding by Org users.  In Org mode,
6153      /scheduling/ means setting a date when you want to start working
6154      on an action item.
6156 You may use timestamps with repeaters in scheduling and deadline
6157 entries.  Org mode issues early and late warnings based on the
6158 assumption that the timestamp represents the /nearest instance/ of the
6159 repeater.  However, the use of diary S-exp entries like
6161 : <%%(org-float t 42)>
6163 #+texinfo: @noindent
6164 in scheduling and deadline timestamps is limited.  Org mode does not
6165 know enough about the internals of each S-exp function to issue early
6166 and late warnings.  However, it shows the item on each day where the
6167 S-exp entry matches.
6169 *** Inserting deadlines or schedules
6170 :PROPERTIES:
6171 :DESCRIPTION: Planning items.
6172 :ALT_TITLE: Inserting deadline/schedule
6173 :END:
6175 The following commands allow you to quickly insert a deadline or to
6176 schedule an item:[fn:65]
6178 - {{{kbd(C-c C-d)}}} (~org-deadline~) ::
6180      #+kindex: C-c C-d
6181      #+findex: org-deadline
6182      #+vindex: org-log-redeadline
6183      Insert =DEADLINE= keyword along with a stamp.  The insertion
6184      happens in the line directly following the headline.  Remove any
6185      =CLOSED= timestamp .  When called with a prefix argument, also
6186      remove any existing deadline from the entry.  Depending on the
6187      variable ~org-log-redeadline~, take a note when changing an
6188      existing deadline[fn:66].
6190 - {{{kbd(C-c C-s)}}} (~org-schedule~) ::
6192      #+kindex: C-c C-s
6193      #+findex: org-schedule
6194      #+vindex: org-log-reschedule
6195      Insert =SCHEDULED= keyword along with a stamp.  The insertion
6196      happens in the line directly following the headline.  Remove any
6197      =CLOSED= timestamp.  When called with a prefix argument, also
6198      remove the scheduling date from the entry.  Depending on the
6199      variable ~org-log-reschedule~, take a note when changing an
6200      existing scheduling time[fn:67].
6202 - {{{kbd(C-c C-x C-k)}}} (~org-mark-entry-for-agenda-action~) ::
6204      #+kindex: C-c C-x C-k
6205      #+kindex: k a
6206      #+kindex: k s
6207      #+findex: org-mark-entry-for-agenda-action
6208      Mark the current entry for agenda action.  After you have marked
6209      the entry like this, you can open the agenda or the calendar to
6210      find an appropriate date.  With the cursor on the selected date,
6211      press {{{kbd(k s)}}} or {{{kbd(k d)}}} to schedule the marked
6212      item.
6214 - {{{kbd(C-c / d)}}} (~org-check-deadlines~) ::
6216      #+kindex: C-c / d
6217      #+findex: org-check-deadlines
6218      #+cindex: sparse tree, for deadlines
6219      #+vindex: org-deadline-warning-days
6220      Create a sparse tree with all deadlines that are either past-due,
6221      or which will become due within ~org-deadline-warning-days~.
6222      With {{{kbd(C-u)}}} prefix, show all deadlines in the file.  With
6223      a numeric prefix, check that many days.  For example, {{{kbd(C-1
6224      C-c / d)}}} shows all deadlines due tomorrow.
6226 - {{{kbd(C-c / b)}}}, ~org-check-before-date~ ::
6228      #+kindex: C-c / b
6229      #+findex: org-check-before-date
6230      Sparse tree for deadlines and scheduled items before a given
6231      date.
6233 - {{{kbd(C-c / a)}}}, ~org-check-after-date~ ::
6235      #+kindex: C-c / a
6236      #+findex: org-check-after-date
6237      Sparse tree for deadlines and scheduled items after a given date.
6239 Note that ~org-schedule~ and ~org-deadline~ supports setting the date
6240 by indicating a relative time e.g., =+1d= sets the date to the next
6241 day after today, and =--1w= sets the date to the previous week before
6242 any current timestamp.
6244 *** Repeated tasks
6245 :PROPERTIES:
6246 :DESCRIPTION: Items that show up again and again.
6247 :END:
6248 #+cindex: tasks, repeated
6249 #+cindex: repeated tasks
6251 Some tasks need to be repeated again and again.  Org mode helps to
6252 organize such tasks using a so-called repeater in a =DEADLINE=,
6253 =SCHEDULED=, or plain timestamp.  In the following example:
6255 #+begin_example
6256 ,** TODO Pay the rent
6257    DEADLINE: <2005-10-01 Sat +1m>
6258 #+end_example
6260 #+texinfo: noindent
6261 the =+1m= is a repeater; the intended interpretation is that the task
6262 has a deadline on =<2005-10-01>= and repeats itself every (one) month
6263 starting from that time.  You can use yearly, monthly, weekly, daily
6264 and hourly repeat cookies by using the ~y/w/m/d/h~ letters.  If you
6265 need both a repeater and a special warning period in a deadline entry,
6266 the repeater should come first and the warning period last: =DEADLINE:
6267 <2005-10-01 Sat +1m -3d>=.
6269 #+vindex: org-todo-repeat-to-state
6270 Deadlines and scheduled items produce entries in the agenda when they
6271 are over-due, so it is important to be able to mark such an entry as
6272 completed once you have done so.  When you mark a =DEADLINE= or
6273 a =SCHEDULED= with the TODO keyword =DONE=, it no longer produces
6274 entries in the agenda.  The problem with this is, however, is that
6275 then also the /next/ instance of the repeated entry will not be
6276 active.  Org mode deals with this in the following way: when you try
6277 to mark such an entry DONE, using {{{kbd(C-c C-t)}}}, it shifts the
6278 base date of the repeating timestamp by the repeater interval, and
6279 immediately sets the entry state back to TODO[fn:68].  In the example
6280 above, setting the state to DONE would actually switch the date like
6281 this:
6283 #+begin_example
6284 ,** TODO Pay the rent
6285    DEADLINE: <2005-11-01 Tue +1m>
6286 #+end_example
6288 To mark a task with a repeater as DONE, use {{{kbd(C-- 1 C-c C-t)}}},
6289 i.e., ~org-todo~ with a numeric prefix argument of =-1=.
6291 #+vindex: org-log-repeat
6292 A timestamp[fn:69] is added under the deadline, to keep a record that
6293 you actually acted on the previous instance of this deadline.
6295 As a consequence of shifting the base date, this entry is no longer
6296 visible in the agenda when checking past dates, but all future
6297 instances will be visible.
6299 With the =+1m= cookie, the date shift is always exactly one month.  So
6300 if you have not paid the rent for three months, marking this entry
6301 DONE still keeps it as an overdue deadline.  Depending on the task,
6302 this may not be the best way to handle it.  For example, if you forgot
6303 to call your father for 3 weeks, it does not make sense to call him
6304 3 times in a single day to make up for it.  Finally, there are tasks
6305 like changing batteries which should always repeat a certain time
6306 /after/ the last time you did it.  For these tasks, Org mode has
6307 special repeaters =++= and =.+=.  For example:
6309 #+begin_example
6310 ,** TODO Call Father
6311    DEADLINE: <2008-02-10 Sun ++1w>
6312    Marking this DONE shifts the date by at least one week, but also
6313    by as many weeks as it takes to get this date into the future.
6314    However, it stays on a Sunday, even if you called and marked it
6315    done on Saturday.
6317 ,** TODO Empty kitchen trash
6318    DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6319    Marking this DONE shifts the date by at least one day, and also
6320    by as many days as it takes to get the timestamp into the future.
6321    Since there is a time in the timestamp, the next deadline in the
6322    future will be on today's date if you complete the task before
6323    20:00.
6325 ,** TODO Check the batteries in the smoke detectors
6326    DEADLINE: <2005-11-01 Tue .+1m>
6327    Marking this DONE will shift the date to one month after today.
6328 #+end_example
6330 #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
6331 You may have both scheduling and deadline information for a specific
6332 task.  If the repeater is set for the scheduling information only, you
6333 probably want the repeater to be ignored after the deadline.  If so,
6334 set the variable ~org-agenda-skip-scheduled-if-deadline-is-shown~ to
6335 ~repeated-after-deadline~.  However, any scheduling information
6336 without a repeater is no longer relevant once the task is done, and
6337 thus, removed upon repeating the task.  If you want both scheduling
6338 and deadline information to repeat after the same interval, set the
6339 same repeater for both timestamps.
6341 An alternative to using a repeater is to create a number of copies of
6342 a task subtree, with dates shifted in each copy.  The command
6343 {{{kbd(C-c C-x c)}}} was created for this purpose; it is described in
6344 [[*Structure Editing]].
6346 ** Clocking Work Time
6347 :PROPERTIES:
6348 :DESCRIPTION: Tracking how long you spend on a task.
6349 :END:
6350 #+cindex: clocking time
6351 #+cindex: time clocking
6353 Org mode allows you to clock the time you spend on specific tasks in
6354 a project.  When you start working on an item, you can start the
6355 clock.  When you stop working on that task, or when you mark the task
6356 done, the clock is stopped and the corresponding time interval is
6357 recorded.  It also computes the total time spent on each
6358 subtree[fn:70] of a project.  And it remembers a history or tasks
6359 recently clocked, to that you can jump quickly between a number of
6360 tasks absorbing your time.
6362 To save the clock history across Emacs sessions, use:
6364 #+begin_src emacs-lisp
6365 (setq org-clock-persist 'history)
6366 (org-clock-persistence-insinuate)
6367 #+end_src
6369 #+vindex: org-clock-persist
6370 When you clock into a new task after resuming Emacs, the incomplete
6371 clock[fn:71] is retrieved (see [[*Resolving idle time]]) and you are
6372 prompted about what to do with it.
6374 *** Clocking commands
6375 :PROPERTIES:
6376 :DESCRIPTION: Starting and stopping a clock.
6377 :END:
6379 #+attr_texinfo: :sep ,
6380 - {{{kbd(C-c C-x C-i)}}} (~org-clock-in~) ::
6382      #+kindex: C-c C-x C-i
6383      #+findex: org-clock-in
6384      #+vindex: org-clock-into-drawer
6385      #+vindex: org-clock-continuously
6386      #+cindex: @samp{LOG_INTO_DRAWER}, property
6387      Start the clock on the current item (clock-in).  This inserts the
6388      CLOCK keyword together with a timestamp.  If this is not the
6389      first clocking of this item, the multiple CLOCK lines are wrapped
6390      into a =LOGBOOK= drawer (see also the variable
6391      ~org-clock-into-drawer~).  You can also overrule the setting of
6392      this variable for a subtree by setting a =CLOCK_INTO_DRAWER= or
6393      =LOG_INTO_DRAWER= property.  When called with a {{{kbd(C-u)}}}
6394      prefix argument, select the task from a list of recently clocked
6395      tasks.  With two {{{kbd(C-u C-u)}}} prefixes, clock into the task
6396      at point and mark it as the default task; the default task is
6397      always be available with letter {{{kbd(d)}}} when selecting
6398      a clocking task.  With three {{{kbd(C-u C-u C-u)}}} prefixes,
6399      force continuous clocking by starting the clock when the last
6400      clock stopped.
6402      #+cindex: @samp{CLOCK_MODELINE_TOTAL}, property
6403      #+cindex: @samp{LAST_REPEAT}, property
6404      #+vindex: org-clock-mode-line-total
6405      #+vindex: org-clock-in-prepare-hook
6406      While the clock is running, Org shows the current clocking time
6407      in the mode line, along with the title of the task.  The clock
6408      time shown is all time ever clocked for this task and its
6409      children.  If the task has an effort estimate (see [[*Effort
6410      Estimates]]), the mode line displays the current clocking time
6411      against it[fn:72].  If the task is a repeating one (see [[*Repeated
6412      tasks]]), show only the time since the last reset of the
6413      task[fn:73].  You can exercise more control over show time with
6414      the =CLOCK_MODELINE_TOTAL= property.  It may have the values
6415      =current= to show only the current clocking instance, =today= to
6416      show all time clocked on this tasks today---see also the
6417      variable ~org-extend-today-until~, ~all~ to include all time, or
6418      ~auto~ which is the default[fn:74].  Clicking with
6419      {{{kbd(mouse-1)}}} onto the mode line entry pops up a menu with
6420      clocking options.
6422 - {{{kbd(C-c C-x C-o)}}} (~org-clock-out~) ::
6424      #+kindex: C-c C-x C-o
6425      #+findex: org-clock-out
6426      #+vindex: org-log-note-clock-out
6427      Stop the clock (clock-out).  This inserts another timestamp at
6428      the same location where the clock was last started.  It also
6429      directly computes the resulting time in inserts it after the time
6430      range as ==>HH:MM=.  See the variable ~org-log-note-clock-out~
6431      for the possibility to record an additional note together with
6432      the clock-out timestamp[fn:75].
6434 - {{{kbd(C-c C-x C-x)}}} (~org-clock-in-last~) ::
6436      #+kindex: C-c C-x C-x
6437      #+findex: org-clock-in-last
6438      #+vindex: org-clock-continuously
6439      Re-clock the last clocked task.  With one {{{kbd(C-u)}}} prefix
6440      argument, select the task from the clock history.  With two
6441      {{{kbd(C-u)}}} prefixes, force continuous clocking by starting
6442      the clock when the last clock stopped.
6444 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6446      #+kindex: C-c C-x C-e
6447      #+findex: org-clock-modify-effort-estimate
6448      Update the effort estimate for the current clock task.
6450 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
6452      #+kindex: C-c C-c
6453      #+kindex: C-c C-y
6454      #+findex: org-evaluate-time-range
6455      Recompute the time interval after changing one of the timestamps.
6456      This is only necessary if you edit the timestamps directly.  If
6457      you change them with {{{kbd(S-<cursor>)}}} keys, the update is
6458      automatic.
6460 - {{{kbd(C-S-UP)}}} (~org-clock-timestamps-up~), {{{kbd(C-S-DOWN)}}} (~org-clock-timestamps-down~) ::
6462      #+kindex: C-S-UP
6463      #+findex: org-clock-timestamps-up
6464      #+kindex: C-S-DOWN
6465      #+findex: org-clock-timestamps-down
6466      On CLOCK log lines, increase/decrease both timestamps so that the
6467      clock duration keeps the same value.
6469 - {{{kbd(S-M-UP)}}} (~org-timestamp-up~), {{{kbd(S-M-DOWN)}}} (~org-timestamp-down~) ::
6471      #+kindex: S-M-UP
6472      #+findex: org-clock-timestamp-up
6473      #+kindex: S-M-DOWN
6474      #+findex: org-clock-timestamp-down
6475      On =CLOCK= log lines, increase/decrease the timestamp at point
6476      and the one of the previous, or the next, clock timestamp by the
6477      same duration.  For example, if you hit {{{kbd(S-M-UP)}}} to
6478      increase a clocked-out timestamp by five minutes, then the
6479      clocked-in timestamp of the next clock is increased by five
6480      minutes.
6482 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
6484      #+kindex: C-c C-t
6485      #+findex: org-todo
6486      Changing the TODO state of an item to DONE automatically stops
6487      the clock if it is running in this same item.
6489 - {{{kbd(C-c C-x C-q)}}} (~org-clock-cancel~) ::
6491      #+kindex: C-c C-x C-q
6492      #+findex: org-clock-cancel
6493      Cancel the current clock.  This is useful if a clock was started
6494      by mistake, or if you ended up working on something else.
6496 - {{{kbd(C-c C-x C-j)}}} (~org-clock-goto~) ::
6498      #+kindex: C-c C-x C-j
6499      #+findex: or-clock-goto
6500      Jump to the headline of the currently clocked in task.  With
6501      a {{{kbd(C-u)}}} prefix argument, select the target task from
6502      a list of recently clocked tasks.
6504 - {{{kbd(C-c C-x C-d)}}} (~org-clock-display~) ::
6506      #+kindex: C-c C-x C-d
6507      #+findex: org-clock-display
6508      #+vindex: org-remove-highlights-with-change
6509      Display time summaries for each subtree in the current buffer.
6510      This puts overlays at the end of each headline, showing the total
6511      time recorded under that heading, including the time of any
6512      subheadings.  You can use visibility cycling to study the tree,
6513      but the overlays disappear when you change the buffer (see
6514      variable ~org-remove-highlights-with-change~) or press {{{kbd(C-c
6515      C-c)}}}.
6517 The {{{kbd(l)}}} key may be used in the agenda (see [[*Weekly/daily
6518 agenda]]) to show which tasks have been worked on or closed during
6519 a day.
6521 *Important:* note that both ~org-clock-out~ and ~org-clock-in-last~
6522 can have a global keybinding and do not modify the window disposition.
6524 *** The clock table
6525 :PROPERTIES:
6526 :DESCRIPTION: Detailed reports.
6527 :END:
6528 #+cindex: clocktable, dynamic block
6529 #+cindex: report, of clocked time
6531 Org mode can produce quite complex reports based on the time clocking
6532 information.  Such a report is called a /clock table/, because it is
6533 formatted as one or several Org tables.
6535 #+attr_texinfo: :sep ,
6536 - {{{kbd(C-c C-x C-r)}}} (~org-clock-report~) ::
6538      #+kindex: C-c C-x C-r
6539      #+findex: org-clock-report
6540      Insert a dynamic block (see [[*Dynamic Blocks]]) containing a clock
6541      report as an Org mode table into the current file.  When the
6542      cursor is at an existing clock table, just update it.  When
6543      called with a prefix argument, jump to the first clock report in
6544      the current document and update it.  The clock table includes
6545      archived trees.
6547 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
6549      #+kindex: C-c C-c
6550      #+kindex: C-c C-x C-u
6551      #+findex: org-dblock-update
6552      Update dynamic block at point.  The cursor needs to be in the
6553      =BEGIN= line of the dynamic block.
6555 - {{{kbd(C-u C-c C-x C-u)}}} ::
6557      #+kindex: C-u C-c C-x C-u
6558      Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful
6559      if you have several clock table blocks in a buffer.
6561 - {{{kbd(S-LEFT)}}}, {{{kbd(S-RIGHT)}}} (~org-clocktable-try-shift~) ::
6563      #+kindex: S-LEFT
6564      #+kindex: S-RIGHT
6565      #+findex: org-clocktable-try-shift
6566      Shift the current =:block= interval and update the table.  The
6567      cursor needs to be in the =#+BEGIN: clocktable= line for this
6568      command.  If =:block= is =today=, it is shifted to =today-1=,
6569      etc.
6571 Here is an example of the frame for a clock table as it is inserted
6572 into the buffer with the {{{kbd(C-c C-x C-r)}}} command:
6574 #+cindex: @samp{BEGIN clocktable}
6575 #+begin_example
6576 ,#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6577 ,#+END: clocktable
6578 #+end_example
6580 #+texinfo: @noindent
6581 #+vindex: org-clocktable-defaults
6582 The =#+BEGIN= line and specify a number of options to define the
6583 scope, structure, and formatting of the report.  Defaults for all
6584 these options can be configured in the variable
6585 ~org-clocktable-defaults~.
6587 #+texinfo: @noindent
6588 First there are options that determine which clock entries are to
6589 be selected:
6591 - :maxlevel ::
6593      Maximum level depth to which times are listed in the table.
6594      Clocks at deeper levels are summed into the upper level.
6596 - :scope ::
6598      The scope to consider.  This can be any of the following:
6600      | ~nil~                  | the current buffer or narrowed region                    |
6601      | ~file~                 | the full current buffer                                  |
6602      | ~subtree~              | the subtree where the clocktable is located              |
6603      | ~treeN~                | the surrounding level N tree, for example =tree3=        |
6604      | ~tree~                 | the surrounding level 1 tree                             |
6605      | ~agenda~               | all agenda files                                         |
6606      | =("file" ...)=         | scan these files                                         |
6607      | =FUNCTION=             | scan files returned by calling FUNCTION with no argument |
6608      | ~file-with-archives~   | current file and its archives                            |
6609      | ~agenda-with-archives~ | all agenda files, including archives                     |
6611 - :block ::
6613      The time block to consider.  This block is specified either
6614      absolutely, or relative to the current time and may be any of
6615      these formats:
6617      | =2007-12-31=                            | New year eve 2007     |
6618      | =2007-12=                               | December 2007         |
6619      | =2007-W50=                              | ISO-week 50 in 2007   |
6620      | =2007-Q2=                               | 2nd quarter in 2007   |
6621      | =2007=                                  | the year 2007         |
6622      | ~today~, ~yesterday~, ~today-N~         | a relative day        |
6623      | ~thisweek~, ~lastweek~, ~thisweek-N~    | a relative week       |
6624      | ~thismonth~, ~lastmonth~, ~thismonth-N~ | a relative month      |
6625      | ~thisyear~, ~lastyear~, ~thisyear-N~    | a relative year       |
6626      | ~untilnow~                              | all clocked time ever |
6628      #+vindex: org-clock-display-default-range
6629      When this option is not set, Org falls back to the value in
6630      ~org-clock-display-default-range~, which defaults to the current
6631      year.
6633      Use {{{kbd(S-LEFT)}}} or {{{kbd(S-RIGHT)}}} to shift the time
6634      interval.
6636 - :tstart ::
6638      A time string specifying when to start considering times.
6639      Relative times like ="<-2w>"= can also be used.  See [[*Matching
6640      tags and properties]] for relative time syntax.
6642 - :tend  ::
6644      A time string specifying when to stop considering times.
6645      Relative times like ="<now>"= can also be used.  See [[*Matching
6646      tags and properties]] for relative time syntax.
6648 - wstart ::
6650      The starting day of the week.  The default is 1 for Monday.
6652 - mstart ::
6654      The starting day of the month.  The default is 1 for the first.
6656 - :step ::
6658      Set to ~week~ or ~day~ to split the table into chunks.  To use
6659      this, ~:block~ or ~:tstart~, ~:tend~ are needed.
6661 - :stepskip0 ::
6663      Do not show steps that have zero time.
6665 - :fileskip0 ::
6667      Do not show table sections from files which did not contribute.
6669 - :tags ::
6671      A tags match to select entries that should contribute.  See
6672      [[*Matching tags and properties]] for the match syntax.
6674 #+findex: org-clocktable-write-default
6675 Then there are options that determine the formatting of the table.
6676 There options are interpreted by the function
6677 ~org-clocktable-write-default~, but you can specify your own function
6678 using the =:formatter= parameter.
6680 - :emphasize ::
6682      When ~t~, emphasize level one and level two items.
6684 - :lang ::
6686      Language[fn:76] to use for descriptive cells like "Task".
6688 - :link ::
6690      Link the item headlines in the table to their origins.
6692 - :narrow ::
6694      An integer to limit the width of the headline column in the Org
6695      table.  If you write it like =50!=, then the headline is also
6696      shortened in export.
6698 - :indent ::
6700      Indent each headline field according to its level.
6702 - :tcolumns ::
6704      Number of columns to be used for times.  If this is smaller than
6705      =:maxlevel=, lower levels are lumped into one column.
6707 - :level ::
6709      Should a level number column be included?
6711 - :sort ::
6713      A cons cell containing the column to sort and a sorting type.
6714      E.g., =:sort (1 . ?a)= sorts the first column alphabetically.
6716 - :compact ::
6718      Abbreviation for =:level nil :indent t :narrow 40! :tcolumns 1=.
6719      All are overwritten except if there is an explicit =:narrow=.
6721 - :timestamp ::
6723      A timestamp for the entry, when available.  Look for SCHEDULED,
6724      DEADLINE, TIMESTAMP and TIMESTAMP_IA special properties (see
6725      [[*Special Properties]]), in this order.
6727 - :properties ::
6729      List of properties shown in the table.  Each property gets its
6730      own column.
6732 - :inherit-props ::
6734      When this flag is non-~nil~, the values for =:properties= are
6735      inherited.
6737 - :formula ::
6739      Content of a =TBLFM= keyword to be added and evaluated.  As
6740      a special case, =:formula %= adds a column with % time.  If you
6741      do not specify a formula here, any existing formula below the
6742      clock table survives updates and is evaluated.
6744 - :formatter ::
6746      A function to format clock data and insert it into the buffer.
6748 To get a clock summary of the current level 1 tree, for the current
6749 day, you could write:
6751 #+begin_example
6752 ,#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6753 ,#+END: clocktable
6754 #+end_example
6756 #+texinfo: @noindent
6757 To use a specific time range you could write[fn:77]
6759 #+begin_example
6760 ,#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6761                     :tend "<2006-08-10 Thu 12:00>"
6762 ,#+END: clocktable
6763 #+end_example
6765 A range starting a week ago and ending right now could be written as
6767 #+begin_example
6768 ,#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6769 ,#+END: clocktable
6770 #+end_example
6772 A summary of the current subtree with % times would be:
6774 #+begin_example
6775 ,#+BEGIN: clocktable :scope subtree :link t :formula %
6776 ,#+END: clocktable
6777 #+end_example
6779 A horizontally compact representation of everything clocked during
6780 last week would be:
6782 #+begin_example
6783 ,#+BEGIN: clocktable :scope agenda :block lastweek :compact t
6784 ,#+END: clocktable
6785 #+end_example
6787 *** Resolving idle time and continuous clocking
6788 :PROPERTIES:
6789 :DESCRIPTION: Resolving time when you've been idle.
6790 :ALT_TITLE: Resolving idle time
6791 :END:
6793 **** Resolving idle time
6794 :PROPERTIES:
6795 :UNNUMBERED: notoc
6796 :END:
6798 #+cindex: resolve idle time
6799 #+cindex: idle, resolve, dangling
6801 If you clock in on a work item, and then walk away from your
6802 computer---perhaps to take a phone call---you often need to
6803 "resolve" the time you were away by either subtracting it from the
6804 current clock, or applying it to another one.
6806 #+vindex: org-clock-idle-time
6807 #+vindex: org-clock-x11idle-program-name
6808 By customizing the variable ~org-clock-idle-time~ to some integer,
6809 such as 10 or 15, Emacs can alert you when you get back to your
6810 computer after being idle for that many minutes[fn:78], and ask what
6811 you want to do with the idle time.  There will be a question waiting
6812 for you when you get back, indicating how much idle time has passed
6813 constantly updated with the current amount, as well as a set of
6814 choices to correct the discrepancy:
6816 - {{{kbd(k)}}} ::
6818      #+kindex: k
6819      To keep some or all of the minutes and stay clocked in, press
6820      {{{kbd(k)}}}.  Org asks how many of the minutes to keep.  Press
6821      {{{kbd(RET)}}} to keep them all, effectively changing nothing, or
6822      enter a number to keep that many minutes.
6824 - {{{kbd(K)}}} ::
6826      #+kindex: K
6827      If you use the shift key and press {{{kbd(K)}}}, it keeps however
6828      many minutes you request and then immediately clock out of that
6829      task.  If you keep all of the minutes, this is the same as just
6830      clocking out of the current task.
6832 - {{{kbd(s)}}} ::
6834      #+kindex: s
6835      To keep none of the minutes, use {{{kbd(s)}}} to subtract all the
6836      away time from the clock, and then check back in from the moment
6837      you returned.
6839 - {{{kbd(S)}}} ::
6841      #+kindex: S
6842      To keep none of the minutes and just clock out at the start of
6843      the away time, use the shift key and press {{{kbd(S)}}}.
6844      Remember that using shift always leave you clocked out, no matter
6845      which option you choose.
6847 - {{{kbd(C)}}} ::
6849      #+kindex: C
6850      To cancel the clock altogether, use {{{kbd(C)}}}.  Note that if
6851      instead of canceling you subtract the away time, and the
6852      resulting clock amount is less than a minute, the clock is still
6853      canceled rather than cluttering up the log with an empty entry.
6855 What if you subtracted those away minutes from the current clock, and
6856 now want to apply them to a new clock?  Simply clock in to any task
6857 immediately after the subtraction.  Org will notice that you have
6858 subtracted time "on the books", so to speak, and will ask if you want
6859 to apply those minutes to the next task you clock in on.
6861 There is one other instance when this clock resolution magic occurs.
6862 Say you were clocked in and hacking away, and suddenly your cat chased
6863 a mouse who scared a hamster that crashed into your UPS's power
6864 button!  You suddenly lose all your buffers, but thanks to auto-save
6865 you still have your recent Org mode changes, including your last clock
6868 If you restart Emacs and clock into any task, Org will notice that you
6869 have a dangling clock which was never clocked out from your last
6870 session.  Using that clock's starting time as the beginning of the
6871 unaccounted-for period, Org will ask how you want to resolve that
6872 time.  The logic and behavior is identical to dealing with away time
6873 due to idleness; it is just happening due to a recovery event rather
6874 than a set amount of idle time.
6876 You can also check all the files visited by your Org agenda for
6877 dangling clocks at any time using {{{kbd(M-x org-resolve-clocks
6878 RET)}}} (or {{{kbd(C-c C-x C-z)}}}).
6880 **** Continuous clocking
6881 :PROPERTIES:
6882 :UNNUMBERED: notoc
6883 :END:
6884 #+cindex: continuous clocking
6886 #+vindex: org-clock-continuously
6887 You may want to start clocking from the time when you clocked out the
6888 previous task.  To enable this systematically, set
6889 ~org-clock-continuously~ to non-~nil~.  Each time you clock in, Org
6890 retrieves the clock-out time of the last clocked entry for this
6891 session, and start the new clock from there.
6893 If you only want this from time to time, use three universal prefix
6894 arguments with ~org-clock-in~ and two {{{kbd(C-u C-u)}}} with
6895 ~org-clock-in-last~.
6897 ** Effort Estimates
6898 :PROPERTIES:
6899 :DESCRIPTION: Planning work effort in advance.
6900 :END:
6901 #+cindex: effort estimates
6902 #+cindex: @samp{EFFORT}, property
6903 #+vindex: org-effort-property
6905 If you want to plan your work in a very detailed way, or if you need
6906 to produce offers with quotations of the estimated work effort, you
6907 may want to assign effort estimates to entries.  If you are also
6908 clocking your work, you may later want to compare the planned effort
6909 with the actual working time, a great way to improve planning
6910 estimates.  Effort estimates are stored in a special property
6911 =EFFORT=.  You can set the effort for an entry with the following
6912 commands:
6914 - {{{kbd(C-c C-x e)}}}  (~org-set-effort~) ::
6916      #+kindex: C-c C-x e
6917      #+findex: org-set-effort
6918      Set the effort estimate for the current entry.  With a prefix
6919      argument, set it to the next allowed value---see below.  This
6920      command is also accessible from the agenda with the {{{kbd(e)}}}
6921      key.
6923 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6925      #+kindex: C-c C-x C-e
6926      #+findex: org-clock-modify-effort-estimate
6927      Modify the effort estimate of the item currently being clocked.
6929 Clearly the best way to work with effort estimates is through column
6930 view (see [[*Column View]]).  You should start by setting up discrete
6931 values for effort estimates, and a =COLUMNS= format that displays
6932 these values together with clock sums---if you want to clock your
6933 time.  For a specific buffer you can use:
6935 #+begin_example
6936 ,#+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6937 ,#+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM
6938 #+end_example
6940 #+texinfo: noindent
6941 #+vindex: org-global-properties
6942 #+vindex: org-columns-default-format
6943 or, even better, you can set up these values globally by customizing
6944 the variables ~org-global-properties~ and
6945 ~org-columns-default-format~.  In particular if you want to use this
6946 setup also in the agenda, a global setup may be advised.
6948 The way to assign estimates to individual items is then to switch to
6949 column mode, and to use {{{kbd(S-RIGHT)}}} and {{{kbd(S-LEFT)}}} to
6950 change the value.  The values you enter are immediately summed up in
6951 the hierarchy.  In the column next to it, any clocked time is
6952 displayed.
6954 #+vindex: org-agenda-columns-add-appointments-to-effort-sum
6955 If you switch to column view in the daily/weekly agenda, the effort
6956 column summarizes the estimated work effort for each day[fn:79], and
6957 you can use this to find space in your schedule.  To get an overview
6958 of the entire part of the day that is committed, you can set the
6959 option ~org-agenda-columns-add-appointments-to-effort-sum~.  The
6960 appointments on a day that take place over a specified time interval
6961 are then also added to the load estimate of the day.
6963 Effort estimates can be used in secondary agenda filtering that is
6964 triggered with the {{{kbd(/)}}} key in the agenda (see [[*Commands in
6965 the Agenda Buffer]]).  If you have these estimates defined consistently,
6966 two or three key presses narrow down the list to stuff that fits into
6967 an available time slot.
6969 ** Taking Notes with a Relative Timer
6970 :PROPERTIES:
6971 :DESCRIPTION: Notes with a running timer.
6972 :ALT_TITLE: Timers
6973 :END:
6974 #+cindex: relative timer
6975 #+cindex: countdown timer
6977 Org provides two types of timers.  There is a relative timer that
6978 counts up, which can be useful when taking notes during, for example,
6979 a meeting or a video viewing.  There is also a countdown timer.
6981 The relative and countdown are started with separate commands.
6983 - {{{kbd(C-c C-x 0)}}} (~org-timer-start~) ::
6985      #+kindex: C-c C-x 0
6986      #+findex: org-timer-start
6987      Start or reset the relative timer.  By default, the timer is set
6988      to 0.  When called with a {{{kbd(C-u)}}} prefix, prompt the user
6989      for a starting offset.  If there is a timer string at point, this
6990      is taken as the default, providing a convenient way to restart
6991      taking notes after a break in the process.  When called with
6992      a double prefix argument {{{kbd(C-u C-u)}}}, change all timer
6993      strings in the active region by a certain amount.  This can be
6994      used to fix timer strings if the timer was not started at exactly
6995      the right moment.
6997 - {{{kbd(C-c C-x ;)}}} (~org-timer-set-timer~) ::
6999      #+kindex: C-c C-x ;
7000      #+findex: org-timer-set-timer
7001      #+vindex: org-timer-default-timer
7002      Start a countdown timer.  The user is prompted for a duration.
7003      ~org-timer-default-timer~ sets the default countdown value.
7004      Giving a numeric prefix argument overrides this default value.
7005      This command is available as {{{kbd(;)}}} in agenda buffers.
7007 Once started, relative and countdown timers are controlled with the
7008 same commands.
7010 - {{{kbd(C-c C-x .)}}} (~org-timer~) ::
7012      #+kindex: C-c C-x .
7013      #+findex: org-timer
7014      Insert a relative time into the buffer.  The first time you use
7015      this, the timer starts.  Using a prefix argument restarts it.
7017 - {{{kbd(C-c C-x -)}}} (~org-timer-item~) ::
7019      #+kindex: C-c C-x -
7020      #+findex: org-timer-item
7021      Insert a description list item with the current relative time.
7022      With a prefix argument, first reset the timer to 0.
7024 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
7026      #+kindex: M-RET
7027      #+findex: org-insert-heading
7028      Once the timer list is started, you can also use
7029      {{{kbd(M-RET)}}} to insert new timer items.
7031 - {{{kbd(C-c C-x \,)}}} (~org-timer-pause-or-continue~) ::
7033      #+kindex: C-c C-x ,
7034      #+findex: org-timer-pause-or-continue
7035      Pause the timer, or continue it if it is already paused.
7037 - {{{kbd(C-c C-x _)}}} (~org-timer-stop~) ::
7039      #+kindex: C-c C-x _
7040      #+findex: org-timer-stop
7041      Stop the timer.  After this, you can only start a new timer, not
7042      continue the old one.  This command also removes the timer from
7043      the mode line.
7045 * Capture, Refile, Archive
7046 :PROPERTIES:
7047 :DESCRIPTION: The ins and outs for projects.
7048 :END:
7049 #+cindex: capture
7051 An important part of any organization system is the ability to quickly
7052 capture new ideas and tasks, and to associate reference material with
7053 them.  Org does this using a process called /capture/.  It also can
7054 store files related to a task (/attachments/) in a special directory.
7055 Once in the system, tasks and projects need to be moved around.
7056 Moving completed project trees to an archive file keeps the system
7057 compact and fast.
7059 ** Capture
7060 :PROPERTIES:
7061 :DESCRIPTION: Capturing new stuff.
7062 :END:
7063 #+cindex: capture
7065 Capture lets you quickly store notes with little interruption of your
7066 work flow.  Org's method for capturing new items is heavily inspired
7067 by John Wiegley's excellent Remember package.
7069 *** Setting up capture
7070 :PROPERTIES:
7071 :DESCRIPTION: Where notes will be stored.
7072 :END:
7074 The following customization sets a default target file for notes.
7076 #+vindex: org-default-notes-file
7077 #+begin_src emacs-lisp
7078 (setq org-default-notes-file (concat org-directory "/notes.org"))
7079 #+end_src
7081 You may also define a global key for capturing new material (see
7082 [[*Activation]]).
7084 *** Using capture
7085 :PROPERTIES:
7086 :DESCRIPTION: Commands to invoke and terminate capture.
7087 :END:
7089 - {{{kbd(M-x org-capture)}}} (~org-capture~) ::
7091      #+findex: org-capture
7092      #+cindex: date tree
7093      Display the capture templates menu.  If you have templates
7094      defined (see [[*Capture templates]]), it offers these templates for
7095      selection or use a new Org outline node as the default template.
7096      It inserts the template into the target file and switch to an
7097      indirect buffer narrowed to this new node.  You may then insert
7098      the information you want.
7100 - {{{kbd(C-c C-c)}}} (~org-capture-finalize~) ::
7102      #+kindex: C-c C-c @r{(Capture buffer)}
7103      #+findex: org-capture-finalize
7104      Once you have finished entering information into the capture
7105      buffer, {{{kbd(C-c C-c)}}} returns you to the window
7106      configuration before the capture process, so that you can resume
7107      your work without further distraction.  When called with a prefix
7108      argument, finalize and then jump to the captured item.
7110 - {{{kbd(C-c C-w)}}} (~org-capture-refile~) ::
7112      #+kindex: C-c C-w @r{(Capture buffer)}
7113      #+findex: org-capture-refile
7114      Finalize the capture process by refiling the note to a different
7115      place (see [[*Refile and Copy]]).  Please realize that this is
7116      a normal refiling command that will be executed---so the cursor
7117      position at the moment you run this command is important.  If you
7118      have inserted a tree with a parent and children, first move the
7119      cursor back to the parent.  Any prefix argument given to this
7120      command is passed on to the ~org-refile~ command.
7122 - {{{kbd(C-c C-k)}}} (~org-capture-kill~) ::
7124      #+kindex: C-c C-k @r{(Capture buffer)}
7125      #+findex: org-capture-kill
7126      Abort the capture process and return to the previous state.
7128 #+kindex: k c @r{(Agenda)}
7129 You can also call ~org-capture~ in a special way from the agenda,
7130 using the {{{kbd(k c)}}} key combination.  With this access, any
7131 timestamps inserted by the selected capture template defaults to the
7132 cursor date in the agenda, rather than to the current date.
7134 To find the locations of the last stored capture, use ~org-capture~
7135 with prefix commands:
7137 - {{{kbd(C-u M-x org-capture)}}} ::
7139      Visit the target location of a capture template.  You get to
7140      select the template in the usual way.
7142 - {{{kbd(C-u C-u M-x org-capture)}}} ::
7144      Visit the last stored capture item in its buffer.
7146 #+vindex: org-capture-bookmark
7147 #+vindex: org-capture-last-stored
7148 You can also jump to the bookmark ~org-capture-last-stored~, which is
7149 automatically created unless you set ~org-capture-bookmark~ to ~nil~.
7151 To insert the capture at point in an Org buffer, call ~org-capture~
7152 with a ~C-0~ prefix argument.
7154 *** Capture templates
7155 :PROPERTIES:
7156 :DESCRIPTION: Define the outline of different note types.
7157 :END:
7158 #+cindex: templates, for Capture
7160 You can use templates for different types of capture items, and for
7161 different target locations.  The easiest way to create such templates
7162 is through the customize interface.
7164 - {{{kbd(C)}}} ::
7166      #+kindex: C @r{(Capture menu}
7167      #+vindex: org-capture-templates
7168      Customize the variable ~org-capture-templates~.
7170 Before we give the formal description of template definitions, let's
7171 look at an example.  Say you would like to use one template to create
7172 general TODO entries, and you want to put these entries under the
7173 heading =Tasks= in your file =~/org/gtd.org=.  Also, a date tree in
7174 the file =journal.org= should capture journal entries.  A possible
7175 configuration would look like:
7177 #+begin_src emacs-lisp
7178 (setq org-capture-templates
7179       '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7180          "* TODO %?\n  %i\n  %a")
7181         ("j" "Journal" entry (file+datetree "~/org/journal.org")
7182          "* %?\nEntered on %U\n  %i\n  %a")))
7183 #+end_src
7185 #+texinfo: @noindent
7186 If you then press {{{kbd(t)}}} from the capture menu, Org will prepare
7187 the template for you like this:
7189 #+begin_example
7190 ,* TODO
7191   [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7192 #+end_example
7194 #+texinfo: @noindent
7195 During expansion of the template, ~%a~ has been replaced by a link to
7196 the location from where you called the capture command.  This can be
7197 extremely useful for deriving tasks from emails, for example.  You
7198 fill in the task definition, press {{{kbd(C-c C-c)}}} and Org returns
7199 you to the same place where you started the capture process.
7201 To define special keys to capture to a particular template without
7202 going through the interactive template selection, you can create your
7203 key binding like this:
7205 #+begin_src emacs-lisp
7206 (define-key global-map "\C-cx"
7207   (lambda () (interactive) (org-capture nil "x")))
7208 #+end_src
7210 **** Template elements
7211 :PROPERTIES:
7212 :DESCRIPTION: What is needed for a complete template entry.
7213 :END:
7215 Now lets look at the elements of a template definition.  Each entry in
7216 ~org-capture-templates~ is a list with the following items:
7218 - keys ::
7220      The keys that selects the template, as a string, characters only,
7221      for example ="a"=, for a template to be selected with a single
7222      key, or ="bt"= for selection with two keys.  When using several
7223      keys, keys using the same prefix key must be sequential in the
7224      list and preceded by a 2-element entry explaining the prefix key,
7225      for example:
7227      #+begin_src emacs-lisp
7228      ("b" "Templates for marking stuff to buy")
7229      #+end_src
7231      #+texinfo: @noindent
7232      If you do not define a template for the {{{kbd(C)}}} key, this
7233      key opens the Customize buffer for this complex variable.
7235 - description ::
7237      A short string describing the template, shown during selection.
7239 - type ::
7241      The type of entry, a symbol.  Valid values are:
7243      - ~entry~ ::
7245           An Org mode node, with a headline.  Will be filed as the child
7246           of the target entry or as a top-level entry.  The target file
7247           should be an Org file.
7249      - ~item~ ::
7251           A plain list item, placed in the first plain list at the
7252           target location.  Again the target file should be an Org
7253           file.
7255      - ~checkitem~ ::
7257           A checkbox item.  This only differs from the plain list item
7258           by the default template.
7260      - ~table-line~ ::
7262           A new line in the first table at the target location.  Where
7263           exactly the line will be inserted depends on the properties
7264           ~:prepend~ and ~:table-line-pos~ (see below).
7266      - ~plain~ ::
7268           Text to be inserted as it is.
7270 - target ::
7272      #+vindex: org-default-notes-file
7273      #+vindex: org-directory
7274      Specification of where the captured item should be placed.  In
7275      Org files, targets usually define a node.  Entries will become
7276      children of this node.  Other types will be added to the table or
7277      list in the body of this node.  Most target specifications
7278      contain a file name.  If that file name is the empty string, it
7279      defaults to ~org-default-notes-file~.  A file can also be given
7280      as a variable or as a function called with no argument.  When an
7281      absolute path is not specified for a target, it is taken as
7282      relative to ~org-directory~.
7284      Valid values are:
7286      - =(file "path/to/file")= ::
7288           Text will be placed at the beginning or end of that file.
7290      - =(id "id of existing org entry")= ::
7292           Filing as child of this entry, or in the body of the entry.
7294      - =(file+headline "filename" "node headline")= ::
7296           Fast configuration if the target heading is unique in the file.
7298      - =(file+olp "filename" "Level 1 heading" "Level 2" ...)= ::
7300           For non-unique headings, the full path is safer.
7302      - =(file+regexp "filename" "regexp to find location")= ::
7304           Use a regular expression to position the cursor.
7306      - =(file+olp+datetree "filename" [ "Level 1 heading" ...])= ::
7308           This target[fn:80] creates a heading in a date tree[fn:81] for
7309           today's date.  If the optional outline path is given, the tree
7310           will be built under the node it is pointing to, instead of at
7311           top level.  Check out the ~:time-prompt~ and ~:tree-type~
7312           properties below for additional options.
7314      - ~(file+function "filename" function-finding-location)~ ::
7316           A function to find the right location in the file.
7318      - ~(clock)~ ::
7320           File to the entry that is currently being clocked.
7322      - ~(function function-finding-location)~ ::
7324           Most general way: write your own function which both visits the
7325           file and moves point to the right location.
7327 - template ::
7329      The template for creating the capture item.  If you leave this
7330      empty, an appropriate default template will be used.  Otherwise
7331      this is a string with escape codes, which will be replaced
7332      depending on time and context of the capture call.  The string
7333      with escapes may be loaded from a template file, using the
7334      special syntax =(file "template filename")=.  See below for more
7335      details.
7337 - properties ::
7339      The rest of the entry is a property list of additional options.
7340      Recognized properties are:
7342      - ~:prepend~ ::
7344           Normally new captured information will be appended at the
7345           target location (last child, last table line, last list item,
7346           ...).  Setting this property changes that.
7348      - ~:immediate-finish~ ::
7350           When set, do not offer to edit the information, just file it
7351           away immediately.  This makes sense if the template only needs
7352           information that can be added automatically.
7354      - ~:empty-lines~ ::
7356           Set this to the number of lines to insert before and after the
7357           new item.  Default 0, and the only other common value is 1.
7359      - ~:clock-in~ ::
7361           Start the clock in this item.
7363      - ~:clock-keep~ ::
7365           Keep the clock running when filing the captured entry.
7367      - ~:clock-resume~ ::
7369           If starting the capture interrupted a clock, restart that clock
7370           when finished with the capture.  Note that ~:clock-keep~ has
7371           precedence over ~:clock-resume~.  When setting both to
7372           non-~nil~, the current clock will run and the previous one will
7373           not be resumed.
7375      - ~:time-prompt~ ::
7377           Prompt for a date/time to be used for date/week trees and when
7378           filling the template.  Without this property, capture uses the
7379           current date and time.  Even if this property has not been set,
7380           you can force the same behavior by calling ~org-capture~ with
7381           a {{{kbd(C-1)}}} prefix argument.
7383      - ~:tree-type~ ::
7385           When ~week~, make a week tree instead of the month tree, i.e.,
7386           place the headings for each day under a heading with the
7387           current ISO week.
7389      - ~:unnarrowed~ ::
7391           Do not narrow the target buffer, simply show the full buffer.  Default
7392           is to narrow it so that you only see the new material.
7394      - ~:table-line-pos~ ::
7396           Specification of the location in the table where the new line
7397           should be inserted.  It should be a string like =II-3= meaning
7398           that the new line should become the third line before the
7399           second horizontal separator line.
7401      - ~:kill-buffer~ ::
7403           If the target file was not yet visited when capture was invoked, kill
7404           the buffer again after capture is completed.
7406 **** Template expansion
7407 :PROPERTIES:
7408 :DESCRIPTION: Filling in information about time and context.
7409 :END:
7411 In the template itself, special "%-escapes"[fn:82] allow dynamic
7412 insertion of content.  The templates are expanded in the order given
7413 here:
7415 - ~%[FILE]~ ::
7417      Insert the contents of the file given by {{{var(FILE)}}}.
7419 - ~%(SEXP)~ ::
7421      Evaluate Elisp SEXP and replace with the result.  The
7422      {{{var(SEXP)}}} must return a string.
7424 - ~%<FORMAT>~ ::
7426      The result of format-time-string on the {{{var(FORMAT)}}}
7427      specification.
7429 - ~%t~ ::
7431      Timestamp, date only.
7433 - ~%T~ ::
7435      Timestamp, with date and time.
7437 - ~%u~, ~%U~ ::
7439      Like ~%t~, ~%T~ above, but inactive timestamps.
7441 - ~%i~ ::
7443      Initial content, the region when capture is called while the
7444      region is active.  The entire text will be indented like ~%i~
7445      itself.
7447 - ~%a~ ::
7449      Annotation, normally the link created with ~org-store-link~.
7451 - ~%A~ ::
7453      Like ~%a~, but prompt for the description part.
7455 - ~%l~ ::
7457      Like ~%a~, but only insert the literal link.
7459 - ~%c~ ::
7461      Current kill ring head.
7463 - ~%x~ ::
7465      Content of the X clipboard.
7467 - ~%k~ ::
7469      Title of the currently clocked task.
7471 - ~%K~ ::
7473      Link to the currently clocked task.
7475 - ~%n~ ::
7477      User name (taken from ~user-full-name~).
7479 - ~%f~ ::
7481      File visited by current buffer when org-capture was called.
7483 - ~%F~ ::
7485      Full path of the file or directory visited by current buffer.
7487 - ~%:keyword~ ::
7489      Specific information for certain link types, see below.
7491 - ~%^g~ ::
7493      Prompt for tags, with completion on tags in target file.
7495 - ~%^G~ ::
7497      Prompt for tags, with completion all tags in all agenda files.
7499 - ~%^t~ ::
7501      Like ~%t~, but prompt for date.  Similarly ~%^T~, ~%^u~, ~%^U~.  You may
7502      define a prompt like ~%^{Birthday}t~.
7504 - ~%^C~ ::
7506      Interactive selection of which kill or clip to use.
7508 - ~%^L~ ::
7510      Like ~%^C~, but insert as link.
7512 - ~%^{PROP}p~ ::
7514      Prompt the user for a value for property PROP.
7516 - ~%^{PROMPT}~ ::
7518      Prompt the user for a string and replace this sequence with it.
7519      You may specify a default value and a completion table with
7520      ~%^{prompt|default|completion2|completion3...}~.  The arrow keys
7521      access a prompt-specific history.
7523 - ~%\n~ ::
7525      Insert the text entered at the Nth ~%^{PROMPT}~, where N is
7526      a number, starting from 1.
7528 - ~%?~ ::
7530      After completing the template, position cursor here.
7532 #+texinfo: @noindent
7533 #+vindex: org-store-link-props
7534 For specific link types, the following keywords are defined[fn:83]:
7536 #+vindex: org-from-is-user-regexp
7537 | Link type    | Available keywords                                       |
7538 |--------------+----------------------------------------------------------|
7539 | bbdb         | ~%:name~, ~%:company~                                    |
7540 | irc          | ~%:server~, ~%:port~, ~%:nick~                           |
7541 | mh, rmail    | ~%:type~, ~%:subject~, ~%:message-id~                    |
7542 |              | ~%:from~, ~%:fromname~, ~%:fromaddress~                  |
7543 |              | ~%:to~, ~%:toname~, ~%:toaddress~                        |
7544 |              | ~%:date~ (message date header field)                     |
7545 |              | ~%:date-timestamp~ (date as active timestamp)            |
7546 |              | ~%:date-timestamp-inactive~ (date as inactive timestamp) |
7547 |              | ~%:fromto~ (either "to NAME" or "from NAME")[fn:84]      |
7548 | gnus         | ~%:group~, for messages also all email fields            |
7549 | w3, w3m      | ~%:url~                                                  |
7550 | info         | ~%:file~, ~%:node~                                       |
7551 | calendar     | ~%:date~                                                 |
7552 | org-protocol | ~%:link~, ~%:description~, ~%:annotation~                |
7554 **** Templates in contexts
7555 :PROPERTIES:
7556 :DESCRIPTION: Only show a template in a specific context.
7557 :END:
7559 #+vindex: org-capture-templates-contexts
7560 To control whether a capture template should be accessible from
7561 a specific context, you can customize
7562 ~org-capture-templates-contexts~.  Let's say, for example, that you
7563 have a capture template "p" for storing Gnus emails containing
7564 patches.  Then you would configure this option like this:
7566 #+begin_src emacs-lisp
7567 (setq org-capture-templates-contexts
7568       '(("p" (in-mode . "message-mode"))))
7569 #+end_src
7571 You can also tell that the command key {{{kbd(p)}}} should refer to
7572 another template.  In that case, add this command key like this:
7574 #+begin_src emacs-lisp
7575 (setq org-capture-templates-contexts
7576       '(("p" "q" (in-mode . "message-mode"))))
7577 #+end_src
7579 See the docstring of the variable for more information.
7581 ** Attachments
7582 :PROPERTIES:
7583 :DESCRIPTION: Add files to tasks.
7584 :END:
7585 #+cindex: attachments
7586 #+vindex: org-attach-directory
7588 It is often useful to associate reference material with an outline
7589 node/task.  Small chunks of plain text can simply be stored in the
7590 subtree of a project.  Hyperlinks (see [[*Hyperlinks]]) can establish
7591 associations with files that live elsewhere on your computer or in the
7592 cloud, like emails or source code files belonging to a project.
7593 Another method is /attachments/, which are files located in
7594 a directory belonging to an outline node.  Org uses directories named
7595 by the unique ID of each entry.  These directories are located in the
7596 ~data~ directory which lives in the same directory where your Org file
7597 lives[fn:85].  If you initialize this directory with =git init=, Org
7598 automatically commits changes when it sees them.  The attachment
7599 system has been contributed to Org by John Wiegley.
7601 In cases where it seems better to do so, you can attach a directory of
7602 your choice to an entry.  You can also make children inherit the
7603 attachment directory from a parent, so that an entire subtree uses the
7604 same attached directory.
7606 #+texinfo: @noindent
7607 The following commands deal with attachments:
7609 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
7611      #+kindex: C-c C-a
7612      #+findex: org-attach
7613      The dispatcher for commands related to the attachment system.
7614      After these keys, a list of commands is displayed and you must
7615      press an additional key to select a command:
7617      - {{{kbd(a)}}} (~org-attach-attach~) ::
7619           #+kindex: C-c C-a a
7620           #+findex: org-attach-attach
7621           #+vindex: org-attach-method
7622           Select a file and move it into the task's attachment
7623           directory.  The file is copied, moved, or linked, depending
7624           on ~org-attach-method~.  Note that hard links are not
7625           supported on all systems.
7627      - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
7629           #+kindex: C-c C-a c
7630           #+kindex: C-c C-a m
7631           #+kindex: C-c C-a l
7632           Attach a file using the copy/move/link method.  Note that
7633           hard links are not supported on all systems.
7635      - {{{kbd(n)}}} (~org-attach-new~) ::
7637           #+kindex: C-c C-a n
7638           #+findex: org-attach-new
7639           Create a new attachment as an Emacs buffer.
7641      - {{{kbd(z)}}} (~org-attach-sync~) ::
7643           #+kindex: C-c C-a z
7644           #+findex: org-attach-sync
7645           Synchronize the current task with its attachment directory, in case
7646           you added attachments yourself.
7648      - {{{kbd(o)}}} (~org-attach-open~) ::
7650           #+kindex: C-c C-a o
7651           #+findex: org-attach-open
7652           #+vindex: org-file-apps
7653           Open current task's attachment.  If there is more than one,
7654           prompt for a file name first.  Opening follows the rules set
7655           by ~org-file-apps~.  For more details, see the information
7656           on following hyperlinks (see [[*Handling Links]]).
7658      - {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
7660           #+kindex: C-c C-a O
7661           #+findex: org-attach-open-in-emacs
7662           Also open the attachment, but force opening the file in
7663           Emacs.
7665      - {{{kbd(f)}}} (~org-attach-reveal~) ::
7667           #+kindex: C-c C-a f
7668           #+findex: org-attach-reveal
7669           Open the current task's attachment directory.
7671      - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
7673           #+kindex: C-c C-a F
7674           #+findex: org-attach-reveal-in-emacs
7675           Also open the directory, but force using Dired in Emacs.
7677      - {{{kbd(d)}}} (~org-attach-delete-one~) ::
7679           #+kindex: C-c C-a d
7680           Select and delete a single attachment.
7682      - {{{kbd(D)}}} (~org-attach-delete-all~) ::
7684           #+kindex: C-c C-a D
7685           Delete all of a task's attachments.  A safer way is to open
7686           the directory in Dired and delete from there.
7688      - {{{kbd(s)}}} (~org-attach-set-directory~) ::
7690           #+kindex: C-c C-a s
7691           #+cindex: @samp{ATTACH_DIR}, property
7692           Set a specific directory as the entry's attachment
7693           directory.  This works by putting the directory path into
7694           the =ATTACH_DIR= property.
7696      - {{{kbd(i)}}} (~org-attach-set-inherit~) ::
7698           #+kindex: C-c C-a i
7699           #+cindex: @samp{ATTACH_DIR_INHERIT}, property
7700           Set the =ATTACH_DIR_INHERIT= property, so that children use
7701           the same directory for attachments as the parent does.
7703 #+cindex: attach from Dired
7704 #+findex: org-attach-dired-to-subtree
7705 It is possible to attach files to a subtree from a Dired buffer.  To
7706 use this feature, have one window in Dired mode containing the file(s)
7707 to be attached and another window with point in the subtree that shall
7708 get the attachments.  In the Dired window, with point on a file,
7709 {{{kbd(M-x org-attach-dired-to-subtree)}}} attaches the file to the
7710 subtree using the attachment method set by variable
7711 ~org-attach-method~.  When files are marked in the Dired window then
7712 all marked files get attached.
7714 Add the following lines to the Emacs init file to have {{{kbd(C-c C-x
7715 a)}}} attach files in Dired buffers.
7717 #+begin_src emacs-lisp
7718 (add-hook 'dired-mode-hook
7719           (lambda ()
7720             (define-key dired-mode-map
7721               (kbd "C-c C-x a")
7722               #'org-attach-dired-to-subtree))))
7723 #+end_src
7725 The following code shows how to bind the previous command with
7726 a specific attachment method.
7728 #+begin_src emacs-lisp
7729 (add-hook 'dired-mode-hook
7730           (lambda ()
7731             (define-key dired-mode-map (kbd "C-c C-x c")
7732               (lambda ()
7733                 (interactive)
7734                 (let ((org-attach-method 'cp))
7735                   (call-interactively #'org-attach-dired-to-subtree))))))
7736 #+end_src
7738 ** RSS Feeds
7739 :PROPERTIES:
7740 :DESCRIPTION: Getting input from RSS feeds.
7741 :END:
7742 #+cindex: RSS feeds
7743 #+cindex: Atom feeds
7745 Org can add and change entries based on information found in RSS feeds
7746 and Atom feeds.  You could use this to make a task out of each new
7747 podcast in a podcast feed.  Or you could use a phone-based
7748 note-creating service on the web to import tasks into Org.  To access
7749 feeds, configure the variable ~org-feed-alist~.  The docstring of this
7750 variable has detailed information.  With the following
7752 #+begin_src emacs-lisp
7753 (setq org-feed-alist
7754       '(("Slashdot"
7755          "http://rss.slashdot.org/Slashdot/slashdot"
7756          "~/txt/org/feeds.org" "Slashdot Entries")))
7757 #+end_src
7759 #+texinfo: @noindent
7760 new items from the feed provided by =rss.slashdot.org= result in new
7761 entries in the file =~/org/feeds.org= under the heading =Slashdot
7762 Entries=, whenever the following command is used:
7764 - {{{kbd(C-c C-x g)}}} (~org-feed-update-all~) ::
7766      #+kindex: C-c C-x g
7767      Collect items from the feeds configured in ~org-feed-alist~ and
7768      act upon them.
7770 - {{{kbd(C-c C-x G)}}} (~org-feed-goto-inbox~) ::
7772      #+kindex: C-c C-x G
7773      Prompt for a feed name and go to the inbox configured for this feed.
7775 Under the same headline, Org creates a drawer =FEEDSTATUS= in which it
7776 stores information about the status of items in the feed, to avoid
7777 adding the same item several times.
7779 For more information, including how to read atom feeds, see
7780 =org-feed.el= and the docstring of ~org-feed-alist~.
7782 ** Protocols for External Access
7783 :PROPERTIES:
7784 :DESCRIPTION: External access to Emacs and Org.
7785 :ALT_TITLE: Protocols
7786 :END:
7787 #+cindex: protocols, for external access
7789 Org protocol is a means to trigger custom actions in Emacs from
7790 external applications.  Any application that supports calling external
7791 programs with an URL as argument may be used with this functionality.
7792 For example, you can configure bookmarks in your web browser to send
7793 a link to the current page to Org and create a note from it using
7794 capture (see [[*Capture]]).  You can also create a bookmark that tells
7795 Emacs to open the local source file of a remote website you are
7796 browsing.
7798 #+cindex: Org protocol, set-up
7799 #+cindex: Installing Org protocol
7800 In order to use Org protocol from an application, you need to register
7801 =org-protocol://= as a valid scheme-handler.  External calls are
7802 passed to Emacs through the =emacsclient= command, so you also need to
7803 ensure an Emacs server is running.  More precisely, when the
7804 application calls
7806 : emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
7808 #+texinfo: @noindent
7809 Emacs calls the handler associated to {{{var(PROTOCOL)}}} with
7810 argument =(:key1 val1 :key2 val2)=.
7812 #+cindex: protocol, new protocol
7813 #+cindex: defining new protocols
7814 Org protocol comes with three predefined protocols, detailed in the
7815 following sections.  Configure ~org-protocol-protocol-alist~ to define
7816 your own.
7818 *** ~store-link~ protocol
7819 :PROPERTIES:
7820 :DESCRIPTION: Store a link, push URL to kill-ring.
7821 :END:
7822 #+cindex: store-link protocol
7823 #+cindex: protocol, store-link
7825 Using ~store-link~ handler, you can copy links, insertable through
7826 {{{kbd(M-x org-insert-link)}}} or yanking thereafter.  More precisely,
7827 the command
7829 : emacsclient org-protocol://store-link?url=URL&title=TITLE
7831 #+texinfo: @noindent
7832 stores the following link:
7834 : [[URL][TITLE]]
7836 In addition, {{{var(URL)}}} is pushed on the kill-ring for yanking.
7837 You need to encode {{{var(URL)}}} and {{{var(TITLE)}}} if they contain
7838 slashes, and probably quote those for the shell.
7840 To use this feature from a browser, add a bookmark with an arbitrary
7841 name, e.g., =Org: store-link= and enter this as /Location/:
7843 #+begin_example
7844 javascript:location.href='org-protocol://store-link?url='+
7845       encodeURIComponent(location.href);
7846 #+end_example
7848 *** ~capture~ protocol
7849 :PROPERTIES:
7850 :DESCRIPTION: Fill a buffer with external information.
7851 :END:
7852 #+cindex: capture protocol
7853 #+cindex: protocol, capture
7855 Activating "capture" handler pops up a =Capture= buffer and fills the
7856 capture template associated to the =X= key with them.
7858 : emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
7860 To use this feature, add a bookmark with an arbitrary name, e.g.
7861 =Org: capture= and enter this as =Location=:
7863 #+begin_example
7864 javascript:location.href='org-protocol://capture?template=x'+
7865       '&url='+encodeURIComponent(window.location.href)+
7866       '&title='+encodeURIComponent(document.title)+
7867       '&body='+encodeURIComponent(window.getSelection());
7868 #+end_example
7870 #+vindex: org-protocol-default-template-key
7871 The result depends on the capture template used, which is set in the
7872 bookmark itself, as in the example above, or in
7873 ~org-protocol-default-template-key~.
7875 The following template placeholders are available:
7877 #+begin_example
7878 %:link          The URL
7879 %:description   The webpage title
7880 %:annotation    Equivalent to [[%:link][%:description]]
7881 %i              The selected text
7882 #+end_example
7884 *** ~open-source~ protocol
7885 :PROPERTIES:
7886 :DESCRIPTION: Edit published contents.
7887 :END:
7888 #+cindex: open-source protocol
7889 #+cindex: protocol, open-source
7891 The ~open-source~ handler is designed to help with editing local
7892 sources when reading a document.  To that effect, you can use
7893 a bookmark with the following location:
7895 #+begin_example
7896 javascript:location.href='org-protocol://open-source?&url='+
7897       encodeURIComponent(location.href)
7898 #+end_example
7900 #+vindex: org-protocol-project-alist
7901 The variable ~org-protocol-project-alist~ maps URLs to local file
7902 names, by stripping URL parameters from the end and replacing the
7903 ~:base-url~ with ~:working-directory~ and ~:online-suffix~ with
7904 ~:working-suffix~.  For example, assuming you own a local copy of
7905 =https://orgmode.org/worg/= contents at =/home/user/worg=, you can set
7906 ~org-protocol-project-alist~ to the following
7908 #+begin_src emacs-lisp
7909 (setq org-protocol-project-alist
7910       '(("Worg"
7911          :base-url "https://orgmode.org/worg/"
7912          :working-directory "/home/user/worg/"
7913          :online-suffix ".html"
7914          :working-suffix ".org")))
7915 #+end_src
7917 #+texinfo: @noindent
7918 If you are now browsing
7919 =https://orgmode.org/worg/org-contrib/org-protocol.html= and find
7920 a typo or have an idea about how to enhance the documentation, simply
7921 click the bookmark and start editing.
7923 #+cindex: rewritten URL in open-source protocol
7924 #+cindex: protocol, open-source rewritten URL
7925 However, such mapping may not yield the desired results.  Suppose you
7926 maintain an online store located at =http://example.com/=.  The local
7927 sources reside in =/home/user/example/=.  It is common practice to
7928 serve all products in such a store through one file and rewrite URLs
7929 that do not match an existing file on the server.  That way, a request
7930 to =http://example.com/print/posters.html= might be rewritten on the
7931 server to something like
7932 =http://example.com/shop/products.php/posters.html.php=.  The
7933 ~open-source~ handler probably cannot find a file named
7934 =/home/user/example/print/posters.html.php= and fails.
7936 Such an entry in ~org-protocol-project-alist~ may hold an additional
7937 property ~:rewrites~.  This property is a list of cons cells, each of
7938 which maps a regular expression to a path relative to the
7939 ~:working-directory~.
7941 Now map the URL to the path =/home/user/example/products.php= by
7942 adding ~:rewrites~ rules like this:
7944 #+begin_src emacs-lisp
7945 (setq org-protocol-project-alist
7946       '(("example.com"
7947          :base-url "http://example.com/"
7948          :working-directory "/home/user/example/"
7949          :online-suffix ".php"
7950          :working-suffix ".php"
7951          :rewrites (("example.com/print/" . "products.php")
7952                     ("example.com/$" . "index.php")))))
7953 #+end_src
7955 #+texinfo: @noindent
7956 Since =example.com/$= is used as a regular expression, it maps
7957 =http://example.com/=, =https://example.com=,
7958 =http://www.example.com/= and similar to
7959 =/home/user/example/index.php=.
7961 The ~:rewrites~ rules are searched as a last resort if and only if no
7962 existing file name is matched.
7964 #+cindex: protocol, open-source, set-up mapping
7965 #+cindex: mappings in open-source protocol
7966 #+findex: org-protocol-create
7967 #+findex: org-protocol-create-for-org
7968 Two functions can help you filling ~org-protocol-project-alist~ with
7969 valid contents: ~org-protocol-create~ and
7970 ~org-protocol-create-for-org~.  The latter is of use if you're editing
7971 an Org file that is part of a publishing project.
7973 ** Refile and Copy
7974 :PROPERTIES:
7975 :DESCRIPTION: Moving/copying a tree from one place to another.
7976 :END:
7977 #+cindex: refiling notes
7978 #+cindex: copying notes
7980 When reviewing the captured data, you may want to refile or to copy
7981 some of the entries into a different list, for example into a project.
7982 Cutting, finding the right location, and then pasting the note is
7983 cumbersome.  To simplify this process, you can use the following
7984 special command:
7986 - {{{kbd(C-c M-w)}}} (~org-copy~) ::
7988      #+kindex: C-c M-w
7989      #+findex: org-copy
7990      Copying works like refiling, except that the original note is not
7991      deleted.
7993 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
7995      #+kindex: C-c C-w
7996      #+findex: org-refile
7997      #+vindex: org-reverse-note-order
7998      #+vindex: org-refile-targets
7999      #+vindex: org-refile-use-outline-path
8000      #+vindex: org-outline-path-complete-in-steps
8001      #+vindex: org-refile-allow-creating-parent-nodes
8002      #+vindex: org-log-refile
8003      Refile the entry or region at point.  This command offers
8004      possible locations for refiling the entry and lets you select one
8005      with completion.  The item (or all items in the region) is filed
8006      below the target heading as a subitem.  Depending on
8007      ~org-reverse-note-order~, it is either the first or last subitem.
8009      By default, all level 1 headlines in the current buffer are
8010      considered to be targets, but you can have more complex
8011      definitions across a number of files.  See the variable
8012      ~org-refile-targets~ for details.  If you would like to select
8013      a location via a file-path-like completion along the outline
8014      path, see the variables ~org-refile-use-outline-path~ and
8015      ~org-outline-path-complete-in-steps~.  If you would like to be
8016      able to create new nodes as new parents for refiling on the fly,
8017      check the variable ~org-refile-allow-creating-parent-nodes~.
8018      When the variable ~org-log-refile~[fn:86] is set, a timestamp or
8019      a note is recorded whenever an entry is refiled.
8021 - {{{kbd(C-u C-c C-w)}}} ::
8023      #+kindex: C-u C-c C-w
8024      Use the refile interface to jump to a heading.
8026 - {{{kbd(C-u C-u C-c C-w)}}} (~org-refile-goto-last-stored~) ::
8028      #+kindex: C-u C-u C-c C-w
8029      #+findex: org-refile-goto-last-stored
8030      Jump to the location where ~org-refile~ last moved a tree to.
8032 - {{{kbd(C-2 C-c C-w)}}} ::
8034      #+kindex: C-2 C-c C-w
8035      Refile as the child of the item currently being clocked.
8037 - {{{kbd(C-3 C-c C-w)}}} ::
8039      #+kindex: C-3 C-c C-w
8040      #+vindex: org-refile-keep
8041      Refile and keep the entry in place.  Also see ~org-refile-keep~
8042      to make this the default behavior, and beware that this may
8043      result in duplicated ~ID~ properties.
8045 - {{{kbd(C-0 C-c C-w)}}} or {{{kbd(C-u C-u C-u C-c C-w)}}} (~org-refile-cache-clear~) ::
8047      #+kindex: C-u C-u C-u C-c C-w
8048      #+kindex: C-0 C-c C-w
8049      #+findex: org-refile-cache-clear
8050      #+vindex: org-refile-use-cache
8051      Clear the target cache.  Caching of refile targets can be turned
8052      on by setting ~org-refile-use-cache~.  To make the command see
8053      new possible targets, you have to clear the cache with this
8054      command.
8056 ** Archiving
8057 :PROPERTIES:
8058 :DESCRIPTION: What to do with finished products.
8059 :END:
8060 #+cindex: archiving
8062 When a project represented by a (sub)tree is finished, you may want to
8063 move the tree out of the way and to stop it from contributing to the
8064 agenda.  Archiving is important to keep your working files compact and
8065 global searches like the construction of agenda views fast.
8067 - {{{kbd(C-c C-x C-a)}}} (~org-archive-subtree-default~) ::
8069      #+kindex: C-c C-x C-a
8070      #+findex: org-archive-subtree-default
8071      #+vindex: org-archive-default-command
8072      Archive the current entry using the command specified in the
8073      variable ~org-archive-default-command~.
8075 *** Moving a tree to an archive file
8076 :PROPERTIES:
8077 :DESCRIPTION: Moving a tree to an archive file.
8078 :ALT_TITLE: Moving subtrees
8079 :END:
8080 #+cindex: external archiving
8082 The most common archiving action is to move a project tree to another
8083 file, the archive file.
8085 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd(C-c $)}}} (~org-archive-subtree~) ::
8087      #+kindex: C-c C-x C-s
8088      #+kindex: C-c $
8089      #+findex: org-archive-subtree
8090      #+vindex: org-archive-location
8091      Archive the subtree starting at the cursor position to the
8092      location given by ~org-archive-location~.
8094 - {{{kbd(C-u C-c C-x C-s)}}} ::
8096      #+kindex: C-u C-c C-x C-s
8097      Check if any direct children of the current headline could be
8098      moved to the archive.  To do this, check each subtree for open
8099      TODO entries.  If none is found, the command offers to move it to
8100      the archive location.  If the cursor is /not/ on a headline when
8101      this command is invoked, check level 1 trees.
8103 - {{{kbd(C-u C-u C-c C-x C-s)}}} ::
8105      #+kindex: C-u C-u C-c C-x C-s
8106      As above, but check subtree for timestamps instead of TODO
8107      entries.  The command offers to archive the subtree if it /does/
8108      contain a timestamp, and that timestamp is in the past.
8110 #+cindex: archive locations
8111 The default archive location is a file in the same directory as the
8112 current file, with the name derived by appending =_archive= to the
8113 current file name.  You can also choose what heading to file archived
8114 items under, with the possibility to add them to a datetree in a file.
8115 For information and examples on how to specify the file and the
8116 heading, see the documentation string of the variable
8117 ~org-archive-location~.
8119 There is also an in-buffer option for setting this variable, for
8120 example:
8122 #+cindex: @samp{ARCHIVE}, keyword
8123 : #+ARCHIVE: %s_done::
8125 #+texinfo: @noindent
8126 #+cindex: ARCHIVE, property
8127 If you would like to have a special archive location for a single
8128 entry or a (sub)tree, give the entry an =ARCHIVE= property with the
8129 location as the value (see [[*Properties and Columns]]).
8131 #+vindex: org-archive-save-context-info
8132 When a subtree is moved, it receives a number of special properties
8133 that record context information like the file from where the entry
8134 came, its outline path the archiving time etc.  Configure the variable
8135 ~org-archive-save-context-info~ to adjust the amount of information
8136 added.
8138 *** Internal archiving
8139 :PROPERTIES:
8140 :DESCRIPTION: Switch off a tree but keep it in the file.
8141 :END:
8143 #+cindex: @samp{ARCHIVE}, tag
8144 If you want to just switch off---for agenda views---certain subtrees
8145 without moving them to a different file, you can use the =ARCHIVE=
8146 tag.
8148 A headline that is marked with the =ARCHIVE= tag (see [[*Tags]]) stays at
8149 its location in the outline tree, but behaves in the following way:
8152   #+vindex: org-cycle-open-archived-trees
8153   It does not open when you attempt to do so with a visibility cycling
8154   command (see [[*Visibility Cycling]]).  You can force cycling archived
8155   subtrees with {{{kbd(C-TAB)}}}, or by setting the option
8156   ~org-cycle-open-archived-trees~.  Also normal outline commands, like
8157   ~outline-show-all~, open archived subtrees.
8160   #+vindex: org-sparse-tree-open-archived-trees
8161   During sparse tree construction (see [[*Sparse Trees]]), matches in
8162   archived subtrees are not exposed, unless you configure the option
8163   ~org-sparse-tree-open-archived-trees~.
8166   #+vindex: org-agenda-skip-archived-trees
8167   During agenda view construction (see [[*Agenda Views]]), the content of
8168   archived trees is ignored unless you configure the option
8169   ~org-agenda-skip-archived-trees~, in which case these trees are
8170   always included.  In the agenda you can press {{{kbd(v a)}}} to get
8171   archives temporarily included.
8174   #+vindex: org-export-with-archived-trees
8175   Archived trees are not exported (see [[*Exporting]]), only the headline
8176   is.  Configure the details using the variable
8177   ~org-export-with-archived-trees~.
8180   #+vindex: org-columns-skip-archived-trees
8181   Archived trees are excluded from column view unless the variable
8182   ~org-columns-skip-archived-trees~ is configured to ~nil~.
8184 The following commands help manage the =ARCHIVE= tag:
8186 - {{{kbd(C-c C-x a)}}} (~org-toggle-archive-tag~) ::
8188      #+kindex: C-c C-x a
8189      #+findex: org-toggle-archive-tag
8190      Toggle the archive tag for the current headline.  When the tag is
8191      set, the headline changes to a shadowed face, and the subtree
8192      below it is hidden.
8194 - {{{kbd(C-u C-c C-x a)}}} ::
8196      #+kindex: C-u C-c C-x a
8197      Check if any direct children of the current headline should be
8198      archived.  To do this, check each subtree for open TODO entries.
8199      If none is found, the command offers to set the =ARCHIVE= tag for
8200      the child.  If the cursor is /not/ on a headline when this
8201      command is invoked, check the level 1 trees.
8203 - {{{kbd(C-TAB)}}}, ~org-force-cycle-archived~ ::
8205      #+kindex: C-TAB
8206      Cycle a tree even if it is tagged with =ARCHIVE=.
8208 - {{{kbd(C-c C-x A)}}} (~org-archive-to-archive-sibling~) ::
8210      #+kindex: C-c C-x A
8211      #+findex: org-archive-to-archive-sibling
8212      Move the current entry to the /Archive Sibling/.  This is
8213      a sibling of the entry with the heading =Archive= and the archive
8214      tag.  The entry becomes a child of that sibling and in this way
8215      retains a lot of its original context, including inherited tags
8216      and approximate position in the outline.
8218 * Agenda Views
8219 :PROPERTIES:
8220 :DESCRIPTION: Collecting information into views.
8221 :END:
8222 #+cindex: agenda views
8224 Due to the way Org works, TODO items, time-stamped items, and tagged
8225 headlines can be scattered throughout a file or even a number of
8226 files.  To get an overview of open action items, or of events that are
8227 important for a particular date, this information must be collected,
8228 sorted and displayed in an organized way.
8230 Org can select items based on various criteria and display them in
8231 a separate buffer.  Seven different view types are provided:
8233 - an /agenda/ that is like a calendar and shows information for
8234   specific dates,
8236 - a /TODO list/ that covers all unfinished action items,
8238 - a /match view/, showings headlines based on the tags, properties,
8239   and TODO state associated with them,
8241 - a /timeline view/ that shows all events in a single Org file, in
8242   time-sorted view,
8244 - a /text search view/ that shows all entries from multiple files that
8245   contain specified keywords,
8247 - a /stuck projects view/ showing projects that currently do not move
8248   along, and
8250 - /custom views/ that are special searches and combinations of
8251   different views.
8253 #+texinfo: @noindent
8254 The extracted information is displayed in a special /agenda buffer/.
8255 This buffer is read-only, but provides commands to visit the
8256 corresponding locations in the original Org files, and even to edit
8257 these files remotely.
8259 #+vindex: org-agenda-skip-comment-trees
8260 #+vindex: org-agenda-skip-archived-trees
8261 #+cindex: commented entries, in agenda views
8262 #+cindex: archived entries, in agenda views
8263 By default, the report ignores commented (see [[*Comment Lines]]) and
8264 archived (see [[*Internal archiving]]) entries.  You can override this by
8265 setting ~org-agenda-skip-comment-trees~ and
8266 ~org-agenda-skip-archived-trees~ to ~nil~.
8268 #+vindex: org-agenda-window-setup
8269 #+vindex: org-agenda-restore-windows-after-quit
8270 Two variables control how the agenda buffer is displayed and whether
8271 the window configuration is restored when the agenda exits:
8272 ~org-agenda-window-setup~ and ~org-agenda-restore-windows-after-quit~.
8274 ** Agenda Files
8275 :PROPERTIES:
8276 :DESCRIPTION: Files being searched for agenda information.
8277 :END:
8278 #+cindex: agenda files
8279 #+cindex: files for agenda
8281 #+vindex: org-agenda-files
8282 The information to be shown is normally collected from all /agenda
8283 files/, the files listed in the variable ~org-agenda-files~[fn:87].
8284 If a directory is part of this list, all files with the extension
8285 =.org= in this directory are part of the list.
8287 Thus, even if you only work with a single Org file, that file should
8288 be put into the list[fn:88].  You can customize ~org-agenda-files~,
8289 but the easiest way to maintain it is through the following commands
8291 #+attr_texinfo: :sep and
8292 - {{{kbd(C-c [)}}} (~org-agenda-file-to-front~) ::
8294      #+kindex: C-c [
8295      #+findex: org-agenda-file-to-front
8296      #+cindex: files, adding to agenda list
8297      Add current file to the list of agenda files.  The file is added
8298      to the front of the list.  If it was already in the list, it is
8299      moved to the front.  With a prefix argument, file is added/moved
8300      to the end.
8302 - {{{kbd(C-c ])}}} (~org-remove-file~) ::
8304      #+kindex: C-c ]
8305      #+findex: org-remove-file
8306      Remove current file from the list of agenda files.
8308 - {{{kbd(C-')}}} and {{{kbd(C-\,)}}} (~org-cycle-agenda-files~) ::
8310      #+kindex: C-'
8311      #+kindex: C-,
8312      #+findex: org-cycle-agenda-files
8313      #+cindex: cycling, of agenda files
8314      Cycle through agenda file list, visiting one file after the other.
8316 - {{{kbd(M-x org-switchb)}}} ::
8318      #+findex: org-switchb
8319      Command to use an iswitchb-like interface to switch to and
8320      between Org buffers.
8322 #+texinfo: @noindent
8323 The Org menu contains the current list of files and can be used to
8324 visit any of them.
8326 If you would like to focus the agenda temporarily on a file not in
8327 this list, or on just one file in the list, or even on only a subtree
8328 in a file, then this can be done in different ways.  For a single
8329 agenda command, you may press {{{kbd(<)}}} once or several times in
8330 the dispatcher (see [[*The Agenda Dispatcher]]).  To restrict the agenda
8331 scope for an extended period, use the following commands:
8333 - {{{kbd(C-c C-x <)}}} (~org-agenda-set-restriction-lock~) ::
8335      #+kindex: C-c C-x <
8336      #+findex: org-agenda-set-restriction-lock
8337      Permanently restrict the agenda to the current subtree.  When
8338      called with a prefix argument, or with the cursor before the
8339      first headline in a file, set the agenda scope to the entire
8340      file.  This restriction remains in effect until removed with
8341      {{{kbd(C-c C-x >)}}}, or by typing either {{{kbd(<)}}} or
8342      {{{kbd(>)}}} in the agenda dispatcher.  If there is a window
8343      displaying an agenda view, the new restriction takes effect
8344      immediately.
8346 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
8348      #+kindex: C-c C-x >
8349      #+findex: org-agenda-remove-restriction-lock
8350      Remove the permanent restriction created by {{{kbd(C-c C-x <)}}}.
8352 #+texinfo: @noindent
8353 When working with =speedbar.el=, you can use the following commands in
8354 the Speedbar frame:
8356 - {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
8358      #+findex: org-speedbar-set-agenda-restriction
8359      Permanently restrict the agenda to the item---either an Org file
8360      or a subtree in such a file---at the cursor in the Speedbar
8361      frame.  If there is a window displaying an agenda view, the new
8362      restriction takes effect immediately.
8364 - {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
8366      #+findex: org-agenda-remove-restriction-lock
8367      Lift the restriction.
8369 ** The Agenda Dispatcher
8370 :PROPERTIES:
8371 :DESCRIPTION: Keyboard access to agenda views.
8372 :ALT_TITLE: Agenda Dispatcher
8373 :END:
8374 #+cindex: agenda dispatcher
8375 #+cindex: dispatching agenda commands
8377 The views are created through a dispatcher, accessible with {{{kbd(M-x
8378 org-agenda)}}}, or, better, bound to a global key (see [[*Activation]]).
8379 It displays a menu from which an additional letter is required to
8380 execute a command.  The dispatcher offers the following default
8381 commands:
8383 - {{{kbd(a)}}} ::
8385      Create the calendar-like agenda (see [[*Weekly/daily agenda]]).
8387 - {{{kbd(t)}}} or {{{kbd(T)}}} ::
8389      Create a list of all TODO items (see [[*The global TODO list]]).
8391 - {{{kbd(m)}}} or {{{kbd(M)}}} ::
8393      Create a list of headlines matching a given expression (see
8394      [[*Matching tags and properties]]).
8396 - {{{kbd(s)}}} ::
8398      #+kindex: s @r{(Agenda dispatcher)}
8399      Create a list of entries selected by a boolean expression of
8400      keywords and/or regular expressions that must or must not occur
8401      in the entry.
8403 - {{{kbd(/)}}} ::
8405      #+kindex: / @r{(Agenda dispatcher)}
8406      #+vindex: org-agenda-text-search-extra-files
8407      Search for a regular expression in all agenda files and
8408      additionally in the files listed in
8409      ~org-agenda-text-search-extra-files~.  This uses the Emacs
8410      command ~multi-occur~.  A prefix argument can be used to specify
8411      the number of context lines for each match, default is
8412      1.
8414 - {{{kbd(#)}}} or {{{kbd(!)}}} ::
8416      Create a list of stuck projects (see [[*Stuck projects]]).
8418 - {{{kbd(<)}}} ::
8420      #+kindex: < @r{(Agenda dispatcher)}
8421      Restrict an agenda command to the current buffer[fn:89].  After
8422      pressing {{{kbd(<)}}}, you still need to press the character
8423      selecting the command.
8425 - {{{kbd(< <)}}} ::
8427      #+kindex: < < @r{(Agenda dispatcher)}
8428      If there is an active region, restrict the following agenda
8429      command to the region.  Otherwise, restrict it to the current
8430      subtree[fn:90].  After pressing {{{kbd(< <)}}}, you still need to
8431      press the character selecting the command.
8433 - {{{kbd(*)}}} ::
8435      #+kindex: * @r{(Agenda dispatcher)}
8436      #+vindex: org-agenda-sticky
8437      #+findex: org-toggle-sticky-agenda
8438      Toggle sticky agenda views.  By default, Org maintains only
8439      a single agenda buffer and rebuilds it each time you change the
8440      view, to make sure everything is always up to date.  If you
8441      switch between views often and the build time bothers you, you
8442      can turn on sticky agenda buffers (make this the default by
8443      customizing the variable ~org-agenda-sticky~).  With sticky
8444      agendas, the dispatcher only switches to the selected view, you
8445      need to update it by hand with {{{kbd(r)}}} or {{{kbd(g)}}}.  You
8446      can toggle sticky agenda view any time with
8447      ~org-toggle-sticky-agenda~.
8449 You can also define custom commands that are accessible through the
8450 dispatcher, just like the default commands.  This includes the
8451 possibility to create extended agenda buffers that contain several
8452 blocks together, for example the weekly agenda, the global TODO list
8453 and a number of special tags matches.  See [[*Custom Agenda Views]].
8455 ** The Built-in Agenda Views
8456 :PROPERTIES:
8457 :DESCRIPTION: What is available out of the box?
8458 :ALT_TITLE: Built-in Agenda Views
8459 :END:
8461 In this section we describe the built-in views.
8463 *** Weekly/daily agenda
8464 :PROPERTIES:
8465 :DESCRIPTION: The calendar page with current tasks.
8466 :END:
8467 #+cindex: agenda
8468 #+cindex: weekly agenda
8469 #+cindex: daily agenda
8471 The purpose of the weekly/daily /agenda/ is to act like a page of
8472 a paper agenda, showing all the tasks for the current week or day.
8474 - {{{kbd(M-x org-agenda a)}}} (~org-agenda-list~) ::
8476      #+kindex: a @r{(Agenda dispatcher)}
8477      #+findex: org-agenda-list
8478      #+cindex: org-agenda, command
8479      Compile an agenda for the current week from a list of Org files.
8480      The agenda shows the entries for each day.  With a numeric prefix
8481      argument[fn:91]---like {{{kbd(C-u 2 1 M-x org-agenda a)}}}---you
8482      may set the number of days to be displayed.
8484 #+vindex: org-agenda-span
8485 #+vindex: org-agenda-start-day
8486 #+vindex: org-agenda-start-on-weekday
8487 The default number of days displayed in the agenda is set by the
8488 variable ~org-agenda-span~.  This variable can be set to any number of
8489 days you want to see by default in the agenda, or to a span name, such
8490 a ~day~, ~week~, ~month~ or ~year~.  For weekly agendas, the default
8491 is to start on the previous Monday (see
8492 ~org-agenda-start-on-weekday~).  You can also set the start date using
8493 a date shift: ~(setq org-agenda-start-day "+10d")~ starts the agenda
8494 ten days from today in the future.
8496 Remote editing from the agenda buffer means, for example, that you can
8497 change the dates of deadlines and appointments from the agenda buffer.
8498 The commands available in the Agenda buffer are listed in [[*Commands in
8499 the Agenda Buffer]].
8501 **** Calendar/Diary integration
8502 :PROPERTIES:
8503 :UNNUMBERED: notoc
8504 :END:
8505 #+cindex: calendar integration
8506 #+cindex: diary integration
8508 Emacs contains the calendar and diary by Edward M. Reingold.  The
8509 calendar displays a three-month calendar with holidays from different
8510 countries and cultures.  The diary allows you to keep track of
8511 anniversaries, lunar phases, sunrise/set, recurrent appointments
8512 (weekly, monthly) and more.  In this way, it is quite complementary to
8513 Org.  It can be very useful to combine output from Org with the diary.
8515 In order to include entries from the Emacs diary into Org mode's
8516 agenda, you only need to customize the variable
8518 #+begin_src emacs-lisp
8519 (setq org-agenda-include-diary t)
8520 #+end_src
8522 #+texinfo: @noindent
8523 After that, everything happens automatically.  All diary entries
8524 including holidays, anniversaries, etc., are included in the agenda
8525 buffer created by Org mode.  {{{kbd(SPC)}}}, {{{kbd(TAB)}}}, and
8526 {{{kbd(RET)}}} can be used from the agenda buffer to jump to the diary
8527 file in order to edit existing diary entries.  The {{{kbd(i)}}}
8528 command to insert new entries for the current date works in the agenda
8529 buffer, as well as the commands {{{kbd(S)}}}, {{{kbd(M)}}}, and
8530 {{{kbd(C)}}} to display Sunrise/Sunset times, show lunar phases and to
8531 convert to other calendars, respectively.  {{{kbd(c)}}} can be used to
8532 switch back and forth between calendar and agenda.
8534 If you are using the diary only for S-exp entries and holidays, it is
8535 faster to not use the above setting, but instead to copy or even move
8536 the entries into an Org file.  Org mode evaluates diary-style sexp
8537 entries, and does it faster because there is no overhead for first
8538 creating the diary display.  Note that the sexp entries must start at
8539 the left margin, no whitespace is allowed before them, as seen in the
8540 following segment of an Org file:[fn:92]
8542 #+begin_example
8543 ,* Holidays
8544   :PROPERTIES:
8545   :CATEGORY: Holiday
8546   :END:
8547 %%(org-calendar-holiday)   ; special function for holiday names
8549 ,* Birthdays
8550   :PROPERTIES:
8551   :CATEGORY: Ann
8552   :END:
8553 %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
8554 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
8555 #+end_example
8557 **** Anniversaries from BBDB
8558 :PROPERTIES:
8559 :UNNUMBERED: notoc
8560 :END:
8561 #+cindex: BBDB, anniversaries
8562 #+cindex: anniversaries, from BBDB
8564 #+findex: org-bbdb-anniversaries
8565 If you are using the Insidious Big Brother Database to store your
8566 contacts, you very likely prefer to store anniversaries in BBDB rather
8567 than in a separate Org or diary file.  Org supports this and can show
8568 BBDB anniversaries as part of the agenda.  All you need to do is to
8569 add the following to one of your agenda files:
8571 #+begin_example
8572 ,* Anniversaries
8573   :PROPERTIES:
8574   :CATEGORY: Anniv
8575   :END:
8576 %%(org-bbdb-anniversaries)
8577 #+end_example
8579 You can then go ahead and define anniversaries for a BBDB record.
8580 Basically, you need to press {{{kbd(C-o anniversary RET)}}} with the
8581 cursor in a BBDB record and then add the date in the format
8582 =YYYY-MM-DD= or =MM-DD=, followed by a space and the class of the
8583 anniversary (=birthday=, =wedding=, or a format string).  If you omit
8584 the class, it defaults to =birthday=.  Here are a few examples, the
8585 header for the file =org-bbdb.el= contains more detailed information.
8587 #+begin_example
8588 1973-06-22
8589 06-22
8590 1955-08-02 wedding
8591 2008-04-14 %s released version 6.01 of Org mode, %d years ago
8592 #+end_example
8594 After a change to BBDB, or for the first agenda display during an
8595 Emacs session, the agenda display suffers a short delay as Org updates
8596 its hash with anniversaries.  However, from then on things will be
8597 very fast, much faster in fact than a long list of
8598 =%%(diary-anniversary)= entries in an Org or Diary file.
8600 #+findex: org-bbdb-anniversaries-future
8601 If you would like to see upcoming anniversaries with a bit of
8602 forewarning, you can use the following instead:
8604 #+begin_example
8605 ,* Anniversaries
8606   :PROPERTIES:
8607   :CATEGORY: Anniv
8608   :END:
8609 %%(org-bbdb-anniversaries-future 3)
8610 #+end_example
8612 That will give you three days' warning: on the anniversary date itself
8613 and the two days prior.  The argument is optional: if omitted, it
8614 defaults to 7.
8616 **** Appointment reminders
8617 :PROPERTIES:
8618 :UNNUMBERED: notoc
8619 :END:
8620 #+cindex: @file{appt.el}
8621 #+cindex: appointment reminders
8622 #+cindex: appointment
8623 #+cindex: reminders
8625 #+cindex: APPT_WARNTIME, keyword
8626 Org can interact with Emacs appointments notification facility.  To
8627 add the appointments of your agenda files, use the command
8628 ~org-agenda-to-appt~.  This command lets you filter through the list
8629 of your appointments and add only those belonging to a specific
8630 category or matching a regular expression.  It also reads
8631 a =APPT_WARNTIME= property which overrides the value of
8632 ~appt-message-warning-time~ for this appointment.  See the docstring
8633 for details.
8635 *** The global TODO list
8636 :PROPERTIES:
8637 :DESCRIPTION: All unfinished action items.
8638 :ALT_TITLE: Global TODO list
8639 :END:
8640 #+cindex: global TODO list
8641 #+cindex: TODO list, global
8643 The global TODO list contains all unfinished TODO items formatted and
8644 collected into a single place.
8646 - {{{kbd(M-x org-agenda t)}}} (~org-todo-list~) ::
8648      #+kindex: t @r{(Agenda dispatcher)}
8649      #+findex: org-todo-list
8650      Show the global TODO list.  This collects the TODO items from all
8651      agenda files (see [[*Agenda Views]]) into a single buffer.  By
8652      default, this lists items with a state the is not a DONE state.
8653      The buffer is in ~agenda-mode~, so there are commands to examine
8654      and manipulate the TODO entries directly from that buffer (see
8655      [[*Commands in the Agenda Buffer]]).
8657 - {{{kbd(M-x org-agenda T)}}} (~org-todo-list~) ::
8659      #+kindex: T @r{(Agenda dispatcher)}
8660      #+findex: org-todo-list
8661      #+cindex: TODO keyword matching
8662      #+vindex: org-todo-keywords
8663      Like the above, but allows selection of a specific TODO keyword.
8664      You can also do this by specifying a prefix argument to
8665      {{{kbd(t)}}}.  You are prompted for a keyword, and you may also
8666      specify several keywords by separating them with =|= as the
8667      boolean OR operator.  With a numeric prefix, the Nth keyword in
8668      ~org-todo-keywords~ is selected.
8670      #+kindex: r
8671      The {{{kbd(r)}}} key in the agenda buffer regenerates it, and you
8672      can give a prefix argument to this command to change the selected
8673      TODO keyword, for example {{{kbd(3 r)}}}.  If you often need
8674      a search for a specific keyword, define a custom command for it
8675      (see [[*The Agenda Dispatcher]]).
8677      Matching specific TODO keywords can also be done as part of
8678      a tags search (see [[*Tag Searches]]).
8680 Remote editing of TODO items means that you can change the state of
8681 a TODO entry with a single key press.  The commands available in the
8682 TODO list are described in [[*Commands in the Agenda Buffer]].
8684 #+cindex: sublevels, inclusion into TODO list
8685 Normally the global TODO list simply shows all headlines with TODO
8686 keywords.  This list can become very long.  There are two ways to keep
8687 it more compact:
8690   #+vindex: org-agenda-todo-ignore-scheduled
8691   #+vindex: org-agenda-todo-ignore-deadlines
8692   #+vindex: org-agenda-todo-ignore-timestamp
8693   #+vindex: org-agenda-todo-ignore-with-date
8694   Some people view a TODO item that has been /scheduled/ for execution
8695   or have a /deadline/ (see [[*Timestamps, Deadlines and Scheduling]]) as
8696   no longer /open/.  Configure the variables
8697   ~org-agenda-todo-ignore-scheduled~,
8698   ~org-agenda-todo-ignore-deadlines~,
8699   ~org-agenda-todo-ignore-timestamp~ and/or
8700   ~org-agenda-todo-ignore-with-date~ to exclude such items from the
8701   global TODO list.
8704   #+vindex: org-agenda-todo-list-sublevels
8705   TODO items may have sublevels to break up the task into subtasks.
8706   In such cases it may be enough to list only the highest level TODO
8707   headline and omit the sublevels from the global list.  Configure the
8708   variable ~org-agenda-todo-list-sublevels~ to get this behavior.
8710 *** Matching tags and properties
8711 :PROPERTIES:
8712 :DESCRIPTION: Structured information with fine-tuned search.
8713 :END:
8714 #+cindex: matching, of tags
8715 #+cindex: matching, of properties
8716 #+cindex: tags view
8717 #+cindex: match view
8719 If headlines in the agenda files are marked with /tags/ (see [[*Tags]]),
8720 or have properties (see [[*Properties and Columns]]), you can select
8721 headlines based on this metadata and collect them into an agenda
8722 buffer.  The match syntax described here also applies when creating
8723 sparse trees with {{{kbd(C-c / m)}}}.
8725 - {{{kbd(M-x org-agenda m)}}} (~org-tags-view~) ::
8727      #+kindex: m @r{(Agenda dispatcher)}
8728      #+findex: org-tags-view
8729      Produce a list of all headlines that match a given set of tags.
8730      The command prompts for a selection criterion, which is a boolean
8731      logic expression with tags, like =+work+urgent-withboss= or
8732      =work|home= (see [[*Tags]]).  If you often need a specific search,
8733      define a custom command for it (see [[*The Agenda Dispatcher]]).
8735 - {{{kbd(M-x org-agenda M)}}} (~org-tags-view~) ::
8737      #+kindex: M @r{(Agenda dispatcher)}
8738      #+findex: org-tags-view
8739      #+vindex: org-tags-match-list-sublevels
8740      #+vindex: org-agenda-tags-todo-honor-ignore-options
8741      Like {{{kbd(m)}}}, but only select headlines that are also TODO
8742      items and force checking subitems (see the variable
8743      ~org-tags-match-list-sublevels~).  To exclude scheduled/deadline
8744      items, see the variable
8745      ~org-agenda-tags-todo-honor-ignore-options~.  Matching specific
8746      TODO keywords together with a tags match is also possible, see
8747      [[*Tag Searches]].
8749 The commands available in the tags list are described in [[*Commands in
8750 the Agenda Buffer]].
8752 #+cindex: boolean logic, for agenda searches
8753 A search string can use Boolean operators =&= for AND and =|= for OR.
8754 =&= binds more strongly than =|=.  Parentheses are currently not
8755 implemented.  Each element in the search is either a tag, a regular
8756 expression matching tags, or an expression like =PROPERTY OPERATOR
8757 VALUE= with a comparison operator, accessing a property value.  Each
8758 element may be preceded by =-= to select against it, and =+= is
8759 syntactic sugar for positive selection.  The AND operator =&= is
8760 optional when =+= or =-= is present.  Here are some examples, using
8761 only tags.
8763 - ~+work-boss~ ::
8765      Select headlines tagged =work=, but discard those also tagged
8766      =boss=.
8768 - ~work|laptop~ ::
8770      Selects lines tagged =work= or =laptop=.
8772 - ~work|laptop+night~ ::
8774      Like before, but require the =laptop= lines to be tagged
8775      also =night=.
8777 #+cindex: regular expressions, with tags search
8778 Instead of a tag, you may also specify a regular expression enclosed
8779 in curly braces.  For example, =work+{^boss.*}= matches headlines that
8780 contain the tag =:work:= and any tag /starting/ with =boss=.
8782 #+cindex: group tags, as regular expressions
8783 Group tags (see [[*Tag Hierarchy]]) are expanded as regular expressions.
8784 E.g., if =work= is a group tag for the group =:work:lab:conf:=, then
8785 searching for =work= also searches for ={\(?:work\|lab\|conf\)}= and
8786 searching for =-work= searches for all headlines but those with one of
8787 the tags in the group (i.e., =-{\(?:work\|lab\|conf\)}=).
8789 #+cindex: TODO keyword matching, with tags search
8790 #+cindex: level, for tags/property match
8791 #+cindex: category, for tags/property match
8792 #+vindex: org-odd-levels-only
8793 You may also test for properties (see [[*Properties and Columns]]) at the
8794 same time as matching tags.  The properties may be real properties, or
8795 special properties that represent other metadata (see [[*Special
8796 Properties]]).  For example, the property =TODO= represents the TODO
8797 keyword of the entry.  Or, the property =LEVEL= represents the level
8798 of an entry.  So searching =+LEVEL=3+boss-TODO​="DONE"= lists all level
8799 three headlines that have the tag =boss= and are /not/ marked with the
8800 TODO keyword =DONE=.  In buffers with ~org-odd-levels-only~ set,
8801 =LEVEL= does not count the number of stars, but =LEVEL=2= corresponds
8802 to 3 stars etc.
8804 Here are more examples:
8806 - =work+TODO​="WAITING"= ::
8808      Select =work=-tagged TODO lines with the specific TODO keyword
8809      =WAITING=.
8811 - =work+TODO​="WAITING"|home+TODO​="WAITING"= ::
8813      Waiting tasks both at work and at home.
8815 When matching properties, a number of different operators can be used
8816 to test the value of a property.  Here is a complex example:
8818 #+begin_example
8819 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
8820          +With={Sarah|Denny}+SCHEDULED>="<2008-10-11>"
8821 #+end_example
8823 #+texinfo: @noindent
8824 The type of comparison depends on how the comparison value is written:
8826 - If the comparison value is a plain number, a numerical comparison is
8827   done, and the allowed operators are =<=, ===, =>=, =<==, =>==, and
8828   =<>=.
8830 - If the comparison value is enclosed in double-quotes, a string
8831   comparison is done, and the same operators are allowed.
8833 - If the comparison value is enclosed in double-quotes /and/ angular
8834   brackets (like =DEADLINE<​="<2008-12-24 18:30>"=), both values are
8835   assumed to be date/time specifications in the standard Org way, and
8836   the comparison is done accordingly.  Valid values also include
8837   ="<now>"= for now (including time), ="<today>"=, and ="<tomorrow>"=
8838   for these days at 0:00 hours, i.e., without a time specification.
8839   You can also use strings like ="<+5d>"= or ="<-2m>"= with units =d=,
8840   =w=, =m=, and =y= for day, week, month, and year, respectively.
8842 - If the comparison value is enclosed in curly braces, a regexp match
8843   is performed, with === meaning that the regexp matches the property
8844   value, and =<>= meaning that it does not match.
8846 So the search string in the example finds entries tagged =work= but
8847 not =boss=, which also have a priority value =A=, a =Coffee= property
8848 with the value =unlimited=, an =EFFORT= property that is numerically
8849 smaller than 2, a =With= property that is matched by the regular
8850 expression =Sarah|Denny=, and that are scheduled on or after October
8851 11, 2008.
8853 You can configure Org mode to use property inheritance during
8854 a search, but beware that this can slow down searches considerably.
8855 See [[*Property Inheritance]], for details.
8857 For backward compatibility, and also for typing speed, there is also
8858 a different way to test TODO states in a search.  For this, terminate
8859 the tags/property part of the search string (which may include several
8860 terms connected with =|=) with a =/= and then specify a Boolean
8861 expression just for TODO keywords.  The syntax is then similar to that
8862 for tags, but should be applied with care: for example, a positive
8863 selection on several TODO keywords cannot meaningfully be combined
8864 with boolean AND.  However, /negative selection/ combined with AND can
8865 be meaningful.  To make sure that only lines are checked that actually
8866 have any TODO keyword (resulting in a speed-up), use {{{kbd(M-x
8867 org-agenda M)}}}, or equivalently start the TODO part after the slash
8868 with =!=.  Using {{{kbd(M-x org-agenda M)}}} or =/!= does not match
8869 TODO keywords in a DONE state.  Examples:
8871 - =work/WAITING= ::
8873      Same as =work+TODO​="WAITING"=.
8875 - =work/!-WAITING-NEXT= ::
8877      Select =work=-tagged TODO lines that are neither =WAITING= nor
8878      =NEXT=.
8880 - =work/!+WAITING|+NEXT= ::
8882      Select =work=-tagged TODO lines that are either =WAITING= or
8883      =NEXT=.
8885 *** Search view
8886 :PROPERTIES:
8887 :DESCRIPTION: Find entries by searching for text.
8888 :END:
8889 #+cindex: search view
8890 #+cindex: text search
8891 #+cindex: searching, for text
8893 This agenda view is a general text search facility for Org mode
8894 entries.  It is particularly useful to find notes.
8896 - {{{kbd(M-x org-agenda s)}}} (~org-search-view~) ::
8898      #+kindex: s @r{(Agenda dispatcher)}
8899      #+findex: org-search-view
8900      This is a special search that lets you select entries by matching
8901      a substring or specific words using a boolean logic.
8903 For example, the search string =computer equipment= matches entries
8904 that contain =computer equipment= as a substring, even if the two
8905 words are separated by more space or a line break.
8907 Search view can also search for specific keywords in the entry, using
8908 Boolean logic.  The search string =+computer
8909 +wifi -ethernet -{8\.11[bg]}= matches note entries that contain the
8910 keywords =computer= and =wifi=, but not the keyword =ethernet=, and
8911 which are also not matched by the regular expression =8\.11[bg]=,
8912 meaning to exclude both =8.11b= and =8.11g=.  The first =+= is
8913 necessary to turn on boolean search, other =+= characters are
8914 optional.  For more details, see the docstring of the command
8915 ~org-search-view~.
8917 You can incrementally adjust a boolean search with the following keys
8919 #+attr_texinfo: :columns 0.1 0.6
8920 | {{{kbd([)}}} | Add a positive search word        |
8921 | {{{kbd(])}}} | Add a negative search word        |
8922 | {{{kbd({)}}} | Add a positive regular expression |
8923 | {{{kbd(})}}} | Add a negative regular expression |
8925 #+vindex: org-agenda-text-search-extra-files
8926 Note that in addition to the agenda files, this command also searches
8927 the files listed in ~org-agenda-text-search-extra-files~.
8929 *** Stuck projects
8930 :PROPERTIES:
8931 :DESCRIPTION: Find projects you need to review.
8932 :END:
8933 #+pindex: GTD, Getting Things Done
8935 If you are following a system like David Allen's GTD to organize your
8936 work, one of the "duties" you have is a regular review to make sure
8937 that all projects move along.  A /stuck/ project is a project that has
8938 no defined next actions, so it never shows up in the TODO lists Org
8939 mode produces.  During the review, you need to identify such projects
8940 and define next actions for them.
8942 - {{{kbd(M-x org-agenda #)}}} (~org-agenda-list-stuck-projects~) ::
8944      #+kindex: # @r{(Agenda dispatcher)}
8945      #+findex: org-agenda-list-stuck-projects
8946      List projects that are stuck.
8948 - {{{kbd(M-x org-agenda !)}}} ::
8950      #+kindex: ! @r{(Agenda dispatcher)}
8951      #+vindex: org-stuck-projects
8952      Customize the variable ~org-stuck-projects~ to define what
8953      a stuck project is and how to find it.
8955 You almost certainly need to configure this view before it works for
8956 you.  The built-in default assumes that all your projects are level-2
8957 headlines, and that a project is not stuck if it has at least one
8958 entry marked with a TODO keyword =TODO= or =NEXT= or =NEXTACTION=.
8960 Let's assume that you, in your own way of using Org mode, identify
8961 projects with a tag =:PROJECT:=, and that you use a TODO keyword
8962 =MAYBE= to indicate a project that should not be considered yet.
8963 Let's further assume that the TODO keyword =DONE= marks finished
8964 projects, and that =NEXT= and =TODO= indicate next actions.  The tag
8965 =:@shop:= indicates shopping and is a next action even without the
8966 NEXT tag.  Finally, if the project contains the special word =IGNORE=
8967 anywhere, it should not be listed either.  In this case you would
8968 start by identifying eligible projects with a tags/TODO match (see
8969 [[*Tag Searches]]) =+PROJECT/-MAYBE-DONE=, and then check for =TODO=,
8970 =NEXT=, =@shop=, and =IGNORE= in the subtree to identify projects that
8971 are not stuck.  The correct customization for this is:
8973 #+begin_src emacs-lisp
8974 (setq org-stuck-projects
8975       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@shop")
8976         "\\<IGNORE\\>"))
8977 #+end_src
8979 Note that if a project is identified as non-stuck, the subtree of this
8980 entry is searched for stuck projects.
8982 ** Presentation and Sorting
8983 :PROPERTIES:
8984 :DESCRIPTION: How agenda items are prepared for display.
8985 :END:
8986 #+cindex: presentation, of agenda items
8988 #+vindex: org-agenda-prefix-format
8989 #+vindex: org-agenda-tags-column
8990 Before displaying items in an agenda view, Org mode visually prepares
8991 the items and sorts them.  Each item occupies a single line.  The line
8992 starts with a /prefix/ that contains the /category/ (see [[*Categories]])
8993 of the item and other important information.  You can customize in
8994 which column tags are displayed through ~org-agenda-tags-column~.  You
8995 can also customize the prefix using the option
8996 ~org-agenda-prefix-format~.  This prefix is followed by a cleaned-up
8997 version of the outline headline associated with the item.
8999 *** Categories
9000 :PROPERTIES:
9001 :DESCRIPTION: Not all tasks are equal.
9002 :END:
9003 #+cindex: category
9004 #+cindex: @samp{CATEGORY}, keyword
9006 The category is a broad label assigned to each agenda item.  By
9007 default, the category is simply derived from the file name, but you
9008 can also specify it with a special line in the buffer, like
9009 this:
9011 : #+CATEGORY: Thesis
9013 #+texinfo: @noindent
9014 #+cindex: @samp{CATEGORY}, property
9015 If you would like to have a special category for a single entry or
9016 a (sub)tree, give the entry a =CATEGORY= property with the special
9017 category you want to apply as the value.
9019 #+texinfo: @noindent
9020 The display in the agenda buffer looks best if the category is not
9021 longer than 10 characters.
9023 #+texinfo: @noindent
9024 #+vindex: org-agenda-category-icon-alist
9025 You can set up icons for category by customizing the
9026 ~org-agenda-category-icon-alist~ variable.
9028 *** Time-of-day specifications
9029 :PROPERTIES:
9030 :DESCRIPTION: How the agenda knows the time.
9031 :END:
9032 #+cindex: time-of-day specification
9034 Org mode checks each agenda item for a time-of-day specification.  The
9035 time can be part of the timestamp that triggered inclusion into the
9036 agenda, for example
9038 : <2005-05-10 Tue 19:00>
9040 #+texinfo: @noindent
9041 Time ranges can be specified with two timestamps:
9043 : <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
9045 In the headline of the entry itself, a time(range) may also appear as
9046 plain text (like =12:45= or a =8:30-1pm=).  If the agenda integrates
9047 the Emacs diary (see [[*Weekly/daily agenda]]), time specifications in
9048 diary entries are recognized as well.
9050 For agenda display, Org mode extracts the time and displays it in
9051 a standard 24 hour format as part of the prefix.  The example times in
9052 the previous paragraphs would end up in the agenda like this:
9054 #+begin_example
9055  8:30-13:00 Arthur Dent lies in front of the bulldozer
9056 12:45...... Ford Prefect arrives and takes Arthur to the pub
9057 19:00...... The Vogon reads his poem
9058 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9059 #+end_example
9061 #+cindex: time grid
9062 If the agenda is in single-day mode, or for the display of today, the
9063 timed entries are embedded in a time grid, like
9065 #+begin_example
9066  8:00...... ------------------
9067  8:30-13:00 Arthur Dent lies in front of the bulldozer
9068 10:00...... ------------------
9069 12:00...... ------------------
9070 12:45...... Ford Prefect arrives and takes Arthur to the pub
9071 14:00...... ------------------
9072 16:00...... ------------------
9073 18:00...... ------------------
9074 19:00...... The Vogon reads his poem
9075 20:00...... ------------------
9076 20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9077 #+end_example
9079 #+vindex: org-agenda-use-time-grid
9080 #+vindex: org-agenda-time-grid
9081 The time grid can be turned on and off with the variable
9082 ~org-agenda-use-time-grid~, and can be configured with
9083 ~org-agenda-time-grid~.
9085 *** Sorting of agenda items
9086 :PROPERTIES:
9087 :DESCRIPTION: The order of things.
9088 :END:
9089 #+cindex: sorting, of agenda items
9090 #+cindex: priorities, of agenda items
9092 Before being inserted into a view, the items are sorted.  How this is
9093 done depends on the type of view.
9096   #+vindex: org-agenda-files
9097   For the daily/weekly agenda, the items for each day are sorted.  The
9098   default order is to first collect all items containing an explicit
9099   time-of-day specification.  These entries are shown at the beginning
9100   of the list, as a /schedule/ for the day.  After that, items remain
9101   grouped in categories, in the sequence given by ~org-agenda-files~.
9102   Within each category, items are sorted by priority (see
9103   [[*Priorities]]), which is composed of the base priority (2000 for
9104   priority =A=, 1000 for =B=, and 0 for =C=), plus additional
9105   increments for overdue scheduled or deadline items.
9107 - For the TODO list, items remain in the order of categories, but
9108   within each category, sorting takes place according to priority (see
9109   [[*Priorities]]).  The priority used for sorting derives from the
9110   priority cookie, with additions depending on how close an item is to
9111   its due or scheduled date.
9113 - For tags matches, items are not sorted at all, but just appear in
9114   the sequence in which they are found in the agenda files.
9116 #+vindex: org-agenda-sorting-strategy
9117 Sorting can be customized using the variable
9118 ~org-agenda-sorting-strategy~, and may also include criteria based on
9119 the estimated effort of an entry (see [[*Effort Estimates]]).
9121 *** Filtering/limiting agenda times
9122 :PROPERTIES:
9123 :DESCRIPTION: Dynamically narrow the agenda.
9124 :END:
9126 Agenda built-in or customized commands are statically defined.  Agenda
9127 filters and limits provide two ways of dynamically narrowing down the
9128 list of agenda entries: /filters/ and /limits/.  Filters only act on
9129 the display of the items, while limits take effect before the list of
9130 agenda entries is built.  Filters are more often used interactively,
9131 while limits are mostly useful when defined as local variables within
9132 custom agenda commands.
9134 **** Filtering in the agenda
9135 :PROPERTIES:
9136 :UNNUMBERED: notoc
9137 :END:
9138 #+cindex: agenda filtering
9139 #+cindex: filtering entries, in agenda
9140 #+cindex: tag filtering, in agenda
9141 #+cindex: category filtering, in agenda
9142 #+cindex: top headline filtering, in agenda
9143 #+cindex: effort filtering, in agenda
9144 #+cindex: query editing, in agenda
9146 - {{{kbd(/)}}} (~org-agenda-filter-by-tag~) ::
9148      #+findex: org-agenda-filter-by-tag
9149      #+vindex: org-agenda-tag-filter-preset
9150      Filter the agenda view with respect to a tag and/or effort
9151      estimates.  The difference between this and a custom agenda
9152      command is that filtering is very fast, so that you can switch
9153      quickly between different filters without having to recreate the
9154      agenda.[fn:93]
9156      You are prompted for a tag selection letter; {{{kbd(SPC)}}} means
9157      any tag at all.  Pressing {{{kbd(TAB)}}} at that prompt offers
9158      completion to select a tag, including any tags that do not have
9159      a selection character.  The command then hides all entries that
9160      do not contain or inherit this tag.  When called with prefix
9161      argument, remove the entries that /do/ have the tag.  A second
9162      {{{kbd(/)}}} at the prompt turns off the filter and shows any
9163      hidden entries.  Pressing {{{kbd(+)}}} or {{{kbd(-)}}} switches
9164      between filtering and excluding the next tag.
9166      #+vindex: org-agenda-auto-exclude-function
9167      Org also supports automatic, context-aware tag filtering.  If the
9168      variable ~org-agenda-auto-exclude-function~ is set to
9169      a user-defined function, that function can decide which tags
9170      should be excluded from the agenda automatically.  Once this is
9171      set, the {{{kbd(/)}}} command then accepts {{{kbd(RET)}}} as
9172      a sub-option key and runs the auto exclusion logic.  For example,
9173      let's say you use a =Net= tag to identify tasks which need
9174      network access, an =Errand= tag for errands in town, and a =Call=
9175      tag for making phone calls.  You could auto-exclude these tags
9176      based on the availability of the Internet, and outside of
9177      business hours, with something like this:
9179      #+begin_src emacs-lisp
9180      (defun org-my-auto-exclude-function (tag)
9181        (and (cond
9182              ((string= tag "Net")
9183               (/= 0 (call-process "/sbin/ping" nil nil nil
9184                                   "-c1" "-q" "-t1" "mail.gnu.org")))
9185              ((or (string= tag "Errand") (string= tag "Call"))
9186               (let ((hour (nth 2 (decode-time))))
9187                 (or (< hour 8) (> hour 21)))))
9188             (concat "-" tag)))
9190      (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9191      #+end_src
9193 - {{{kbd(<)}}} (~org-agenda-filter-by-category~) ::
9195      #+findex: org-agenda-filter-by-category
9196      Filter the current agenda view with respect to the category of
9197      the item at point.  Pressing {{{kbd(<)}}} another time removes
9198      this filter.  When called with a prefix argument exclude the
9199      category of the item at point from the agenda.
9201      #+vindex: org-agenda-category-filter-preset
9202      You can add a filter preset in custom agenda commands through the
9203      option ~org-agenda-category-filter-preset~.  See [[*Setting options
9204      for custom commands]].
9206 - {{{kbd(^)}}} (~org-agenda-filter-by-top-headline~) ::
9208      #+findex: org-agenda-filter-by-top-headline
9209      Filter the current agenda view and only display the siblings and
9210      the parent headline of the one at point.
9212 - {{{kbd(=)}}} (~org-agenda-filter-by-regexp~) ::
9214      #+findex: org-agenda-filter-by-regexp
9215      Filter the agenda view by a regular expression: only show agenda
9216      entries matching the regular expression the user entered.  When
9217      called with a prefix argument, it filters /out/ entries matching
9218      the regexp.  With two universal prefix arguments, it removes all
9219      the regexp filters, which can be accumulated.
9221      #+vindex: org-agenda-regexp-filter-preset
9222      You can add a filter preset in custom agenda commands through the
9223      option ~org-agenda-regexp-filter-preset~.  See [[*Setting options
9224      for custom commands]].
9226 - {{{kbd(_)}}} (~org-agenda-filter-by-effort~) ::
9228      #+findex: org-agenda-filter-by-effort
9229      Filter the agenda view with respect to effort estimates.  You
9230      first need to set up allowed efforts globally, for example
9232      #+begin_src emacs-lisp
9233      (setq org-global-properties
9234            '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9235      #+end_src
9237      #+vindex: org-sort-agenda-noeffort-is-high
9238      You can then filter for an effort by first typing an operator,
9239      one of {{{kbd(<)}}}, {{{kbd(>)}}} and {{{kbd(=)}}}, and then the
9240      one-digit index of an effort estimate in your array of allowed
9241      values, where {{{kbd(0)}}} means the 10th value.  The filter then
9242      restricts to entries with effort smaller-or-equal, equal, or
9243      larger-or-equal than the selected value.  For application of the
9244      operator, entries without a defined effort are treated according
9245      to the value of ~org-sort-agenda-noeffort-is-high~.
9247      When called with a prefix argument, it removes entries matching
9248      the condition.  With two universal prefix arguments, it clears
9249      effort filters, which can be accumulated.
9251      #+vindex: org-agenda-effort-filter-preset
9252      You can add a filter preset in custom agenda commands through the
9253      option ~org-agenda-effort-filter-preset~.  See [[*Setting options
9254      for custom commands]].
9256 - {{{kbd(|)}}} (~org-agenda-filter-remove-all~) ::
9258      Remove all filters in the current agenda view.
9260 **** Setting limits for the agenda
9261 :PROPERTIES:
9262 :UNNUMBERED: notoc
9263 :END:
9264 #+cindex: limits, in agenda
9266 Here is a list of options that you can set, either globally, or
9267 locally in your custom agenda views (see [[*Custom Agenda Views]]).
9269 - ~org-agenda-max-entries~ ::
9271      #+vindex: org-agenda-max-entries
9272      Limit the number of entries.
9274 - ~org-agenda-max-effort~ ::
9276      #+vindex: org-agenda-max-effort
9277      Limit the duration of accumulated efforts (as minutes).
9279 - ~org-agenda-max-todos~ ::
9281      #+vindex: org-agenda-max-todos
9282      Limit the number of entries with TODO keywords.
9284 - ~org-agenda-max-tags~ ::
9286      #+vindex: org-agenda-max-tags
9287      Limit the number of tagged entries.
9289 When set to a positive integer, each option excludes entries from
9290 other categories: for example, ~(setq org-agenda-max-effort 100)~
9291 limits the agenda to 100 minutes of effort and exclude any entry that
9292 has no effort property.  If you want to include entries with no effort
9293 property, use a negative value for ~org-agenda-max-effort~.  One
9294 useful setup is to use ~org-agenda-max-entries~ locally in a custom
9295 command.  For example, this custom command displays the next five
9296 entries with a =NEXT= TODO keyword.
9298 #+begin_src emacs-lisp
9299 (setq org-agenda-custom-commands
9300       '(("n" todo "NEXT"
9301          ((org-agenda-max-entries 5)))))
9302 #+end_src
9304 Once you mark one of these five entry as DONE, rebuilding the agenda
9305 will again the next five entries again, including the first entry that
9306 was excluded so far.
9308 You can also dynamically set temporary limits, which are lost when
9309 rebuilding the agenda:
9311 - {{{kbd(~ )}}} (~org-agenda-limit-interactively~) ::
9313      #+findex: org-agenda-limit-interactively
9314      This prompts for the type of limit to apply and its value.
9316 ** Commands in the Agenda Buffer
9317 :PROPERTIES:
9318 :DESCRIPTION: Remote editing of Org trees.
9319 :ALT_TITLE: Agenda Commands
9320 :END:
9321 #+cindex: commands, in agenda buffer
9323 Entries in the agenda buffer are linked back to the Org file or diary
9324 file where they originate.  You are not allowed to edit the agenda
9325 buffer itself, but commands are provided to show and jump to the
9326 original entry location, and to edit the Org files "remotely" from the
9327 agenda buffer.  In this way, all information is stored only once,
9328 removing the risk that your agenda and note files may diverge.
9330 Some commands can be executed with mouse clicks on agenda lines.  For
9331 the other commands, the cursor needs to be in the desired line.
9333 *** Motion
9334 :PROPERTIES:
9335 :UNNUMBERED: notoc
9336 :END:
9337 #+cindex: motion commands in agenda
9339 - {{{kbd(n)}}} (~org-agenda-next-line~) ::
9341      #+kindex: n
9342      #+findex: org-agenda-next-line
9343      Next line (same as {{{kbd(DOWN)}}} and {{{kbd(C-n)}}}).
9345 - {{{kbd(p)}}} (~org-agenda-previous-line~) ::
9347      #+kindex: p
9348      #+findex: org-agenda-previous-line
9349      Previous line (same as {{{kbd(UP)}}} and {{{kbd(C-p)}}}).
9351 *** View/Go to Org file
9352 :PROPERTIES:
9353 :UNNUMBERED: notoc
9354 :END:
9355 #+cindex: view file commands in agenda
9357 - {{{kbd(SPC)}}} or {{{kbd(mouse-3)}}} (~org-agenda-show-and-scroll-up~) ::
9359      #+kindex: SPC
9360      #+kindex: mouse-3
9361      #+findex: org-agenda-show-and-scroll-up
9362      Display the original location of the item in another window.
9363      With a prefix argument, make sure that drawers stay folded.
9365 - {{{kbd(L)}}} (~org-agenda-recenter~) ::
9367      #+findex: org-agenda-recenter
9368      Display original location and recenter that window.
9370 - {{{kbd(TAB)}}} or {{{kbd(mouse-2)}}} (~org-agenda-goto~) ::
9372      #+kindex: TAB
9373      #+kindex: mouse-2
9374      #+findex: org-agenda-goto
9375      Go to the original location of the item in another window.
9377 - {{{kbd(RET)}}} (~org-agenda-switch-to~) ::
9379      #+kindex: RET
9380      #+findex: org-agenda-switch-to
9381      Go to the original location of the item and delete other windows.
9383 - {{{kbd(F)}}} (~org-agenda-follow-mode~) ::
9385      #+kindex: F
9386      #+findex: org-agenda-follow-mode
9387      #+vindex: org-agenda-start-with-follow-mode
9388      Toggle Follow mode.  In Follow mode, as you move the cursor
9389      through the agenda buffer, the other window always shows the
9390      corresponding location in the Org file.  The initial setting for
9391      this mode in new agenda buffers can be set with the variable
9392      ~org-agenda-start-with-follow-mode~.
9394 - {{{kbd(C-c C-x b)}}} (~org-agenda-tree-to-indirect-buffer~) ::
9396      #+kindex: C-c C-x b
9397      #+findex: org-agenda-tree-to-indirect-buffer
9398      Display the entire subtree of the current item in an indirect
9399      buffer.  With a numeric prefix argument N, go up to level N and
9400      then take that tree.  If N is negative, go up that many levels.
9401      With a {{{kbd(C-u)}}} prefix, do not remove the previously used
9402      indirect buffer.
9404 - {{{kbd(C-c C-o)}}} (~org-agenda-open-link~) ::
9406      #+kindex: C-c C-o
9407      #+findex: org-agenda-open-link
9408      Follow a link in the entry.  This offers a selection of any links
9409      in the text belonging to the referenced Org node.  If there is
9410      only one link, follow it without a selection prompt.
9412 *** Change display
9413 :PROPERTIES:
9414 :UNNUMBERED: notoc
9415 :END:
9416 #+cindex: change agenda display
9417 #+cindex: display changing, in agenda
9419 #+attr_texinfo: :sep ,
9420 - {{{kbd(A)}}} ::
9422      #+kindex: A
9423      Interactively select another agenda view and append it to the
9424      current view.
9426 - {{{kbd(o)}}} ::
9428      #+kindex: o
9429      Delete other windows.
9431 - {{{kbd(v d)}}} or short {{{kbd(d)}}} (~org-agenda-day-view~) ::
9433      #+kindex: v d
9434      #+kindex: d
9435      #+findex: org-agenda-day-view
9436      Switch to day view.  When switching to day view, this setting
9437      becomes the default for subsequent agenda refreshes.  A numeric
9438      prefix argument may be used to jump directly to a specific day of
9439      the year.  For example, {{{kbd(32 d)}}} jumps to February 1st.
9440      When setting day view, a year may be encoded in the prefix
9441      argument as well.  For example, {{{kbd(200712 d)}}} jumps to
9442      January 12, 2007.  If such a year specification has only one or
9443      two digits, it is expanded into one of the 30 next years or the
9444      last 69 years.
9446 - {{{kbd(v w)}}} or short {{{kbd(w)}}} (~org-agenda-week-view~) ::
9448      #+kindex: v w
9449      #+kindex: w
9450      #+findex: org-agenda-week-view
9451      Switch to week view.  When switching week view, this setting
9452      becomes the default for subsequent agenda refreshes.  A numeric
9453      prefix argument may be used to jump directly to a specific day of
9454      the ISO week.  For example {{{kbd(9 w)}}} to ISO week number 9.
9455      When setting week view, a year may be encoded in the prefix
9456      argument as well.  For example, {{{kbd(200712 w)}}} jumps to week
9457      12 in 2007.  If such a year specification has only one or two
9458      digits, it is expanded into one of the 30 next years or the last
9459      69 years.
9461 - {{{kbd(v m)}}} (~org-agenda-month-view~) ::
9463      #+kindex: v m
9464      #+findex: org-agenda-month-view
9465      Switch to month view.  Because month views are slow to create,
9466      they do not become the default for subsequent agenda refreshes.
9467      A numeric prefix argument may be used to jump directly to
9468      a specific day of the month.  When setting month view, a year may
9469      be encoded in the prefix argument as well.  For example,
9470      {{{kbd(200712 m)}}} jumps to December, 2007.  If such a year
9471      specification has only one or two digits, it is expanded into one
9472      of the 30 next years or the last 69 years.
9474 - {{{kbd(v y)}}} (~org-agenda-year-view~) ::
9476      #+kindex: v y
9477      #+findex: org-agenda-year-view
9478      Switch to year view.  Because year views are slow to create, they
9479      do not become the default for subsequent agenda refreshes.
9480      A numeric prefix argument may be used to jump directly to
9481      a specific day of the year.
9483 - {{{kbd(v SPC)}}} (~org-agenda-reset-view~) ::
9485      #+kindex: v SPC
9486      #+findex: org-agenda-reset-view
9487      #+vindex: org-agenda-span
9488      Reset the current view to ~org-agenda-span~.
9490 - {{{kbd(f)}}} (~org-agenda-later~) ::
9492      #+kindex: f
9493      #+findex: org-agenda-later
9494      Go forward in time to display the span following the current one.
9495      For example, if the display covers a week, switch to the
9496      following week.  With a prefix argument, repeat that many times.
9498 - {{{kbd(b)}}} (~org-agenda-earlier~) ::
9500      #+kindex: b
9501      #+findex: org-agenda-earlier
9502      Go backward in time to display earlier dates.
9504 - {{{kbd(.)}}} (~org-agenda-goto-today~) ::
9506      #+kindex: .
9507      #+findex: org-agenda-goto-today
9508      Go to today.
9510 - {{{kbd(j)}}} (~org-agenda-goto-date~) ::
9512      #+kindex: j
9513      #+findex: org-agenda-goto-date
9514      Prompt for a date and go there.
9516 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9518      #+kindex: J
9519      #+findex: org-agenda-clock-goto
9520      Go to the currently clocked-in task /in the agenda buffer/.
9522 - {{{kbd(D)}}} (~org-agenda-toggle-diary~) ::
9524      #+kindex: D
9525      #+findex: org-agenda-toggle-diary
9526      Toggle the inclusion of diary entries.  See [[*Weekly/daily agenda]].
9528 - {{{kbd(v l)}}} or {{{kbd(v L)}}} or short {{{kbd(l)}}} (~org-agenda-log-mode~) ::
9530      #+kindex: v l
9531      #+kindex: l
9532      #+kindex: v L
9533      #+findex: org-agenda-log-mode
9534      #+vindex: org-log-done
9535      #+vindex: org-agenda-log-mode-items
9536      Toggle Logbook mode.  In Logbook mode, entries that were marked
9537      DONE while logging was on (see the variable ~org-log-done~) are
9538      shown in the agenda, as are entries that have been clocked on
9539      that day.  You can configure the entry types that should be
9540      included in log mode using the variable
9541      ~org-agenda-log-mode-items~.  When called with a {{{kbd(C-u)}}}
9542      prefix, show all possible logbook entries, including state
9543      changes.  When called with two prefix arguments {{{kbd(C-u
9544      C-u)}}}, show only logging information, nothing else.  {{{kbd(v
9545      L)}}} is equivalent to {{{kbd(C-u v l)}}}.
9547 - {{{kbd(v [)}}} or short {{{kbd([)}}} (~org-agenda-manipulate-query-add~) ::
9549      #+kindex: v [
9550      #+kindex: [
9551      #+findex: org-agenda-manipulate-query-add
9552      Include inactive timestamps into the current view.  Only for
9553      weekly/daily agenda and timeline views.
9555 - {{{kbd(v a)}}} (~org-agenda-archives-mode~) ::
9557      #+kindex: v a
9558      #+findex: org-agenda-archives-mode
9559      Toggle Archives mode.  In Archives mode, trees that are archived
9560      (see [[*Internal archiving]]) are also scanned when producing the
9561      agenda.  To exit archives mode, press {{{kbd(v a)}}} again.
9563 - {{{kbd(v A)}}} ::
9565      #+kindex: v A
9566      Toggle Archives mode.  Include all archive files as well.
9568 - {{{kbd(v R)}}} or short {{{kbd(R)}}} (~org-agenda-clockreport-mode~) ::
9570      #+kindex: v R
9571      #+kindex: R
9572      #+findex: org-agenda-clockreport-mode
9573      #+vindex: org-agenda-start-with-clockreport-mode
9574      #+vindex: org-clock-report-include-clocking-task
9575      Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
9576      agenda always shows a table with the clocked times for the time
9577      span and file scope covered by the current agenda view.  The
9578      initial setting for this mode in new agenda buffers can be set
9579      with the variable ~org-agenda-start-with-clockreport-mode~.  By
9580      using a prefix argument when toggling this mode (i.e., {{{kbd(C-u
9581      R)}}}), the clock table does not show contributions from entries
9582      that are hidden by agenda filtering[fn:94].  See also the
9583      variable ~org-clock-report-include-clocking-task~.
9585 - {{{kbd(v c)}}} ::
9587      #+kindex: v c
9588      #+vindex: org-agenda-clock-consistency-checks
9589      Show overlapping clock entries, clocking gaps, and other clocking
9590      problems in the current agenda range.  You can then visit
9591      clocking lines and fix them manually.  See the variable
9592      ~org-agenda-clock-consistency-checks~ for information on how to
9593      customize the definition of what constituted a clocking problem.
9594      To return to normal agenda display, press {{{kbd(l)}}} to exit
9595      Logbook mode.
9597 - {{{kbd(v E)}}} or short {{{kbd(E)}}} (~org-agenda-entry-text-mode~) ::
9599      #+kindex: v E
9600      #+kindex: E
9601      #+findex: org-agenda-entry-text-mode
9602      #+vindex: org-agenda-start-with-entry-text-mode
9603      #+vindex: org-agenda-entry-text-maxlines
9604      Toggle entry text mode.  In entry text mode, a number of lines
9605      from the Org outline node referenced by an agenda line are
9606      displayed below the line.  The maximum number of lines is given
9607      by the variable ~org-agenda-entry-text-maxlines~.  Calling this
9608      command with a numeric prefix argument temporarily modifies that
9609      number to the prefix value.
9611 - {{{kbd(G)}}} (~org-agenda-toggle-time-grid~) ::
9613      #+kindex: G
9614      #+vindex: org-agenda-use-time-grid
9615      #+vindex: org-agenda-time-grid
9616      Toggle the time grid on and off.  See also the variables
9617      ~org-agenda-use-time-grid~ and ~org-agenda-time-grid~.
9619 - {{{kbd(r)}}} (~org-agenda-redo~), {{{kbd(g)}}} ::
9621      #+kindex: r
9622      #+kindex: g
9623      #+findex: org-agenda-redo
9624      Recreate the agenda buffer, for example to reflect the changes
9625      after modification of the timestamps of items with
9626      {{{kbd(S-LEFT)}}} and {{{kbd(S-RIGHT)}}}.  When the
9627      buffer is the global TODO list, a prefix argument is interpreted
9628      to create a selective list for a specific TODO keyword.
9630 - {{{kbd(C-x C-s)}}} or short {{{kbd(s)}}} (~org-save-all-org-buffers~) ::
9632      #+kindex: C-x C-s
9633      #+findex: org-save-all-org-buffers
9634      #+kindex: s
9635      Save all Org buffers in the current Emacs session, and also the
9636      locations of IDs.
9638 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
9640      #+kindex: C-c C-x C-c
9641      #+findex: org-agenda-columns
9642      #+vindex: org-columns-default-format
9643      Invoke column view (see [[*Column View]]) in the agenda buffer.  The
9644      column view format is taken from the entry at point, or, if there
9645      is no entry at point, from the first entry in the agenda view.
9646      So whatever the format for that entry would be in the original
9647      buffer (taken from a property, from a =COLUMNS= keyword, or from
9648      the default variable ~org-columns-default-format~) is used in the
9649      agenda.
9651 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
9653      #+kindex: C-c C-x >
9654      #+findex: org-agenda-remove-restriction-lock
9655      Remove the restriction lock on the agenda, if it is currently
9656      restricted to a file or subtree (see [[*Agenda Files]]).
9658 - {{{kbd(M-UP)}}} (~org-agenda-drag-line-backward~) ::
9660      #+kindex: M-UP
9661      #+findex: org-agenda-drag-line-backward
9662      Drag the line at point backward one line.  With a numeric prefix
9663      argument, drag backward by that many lines.
9665      Moving agenda lines does not persist after an agenda refresh and
9666      does not modify the contributing Org files.
9668 - {{{kbd(M-DOWN)}}} (~org-agenda-drag-line-forward~) ::
9670      #+kindex: M-DOWN
9671      #+findex: org-agenda-drag-line-forward
9672      Drag the line at point forward one line.  With a numeric prefix
9673      argument, drag forward by that many lines.
9675 *** Remote editing
9676 :PROPERTIES:
9677 :UNNUMBERED: notoc
9678 :END:
9679 #+cindex: remote editing, from agenda
9681 - {{{kbd(0--9)}}} ::
9683      Digit argument.
9685 - {{{kbd(C-_)}}} (~org-agenda-undo~) ::
9687      #+kindex: C-_
9688      #+findex: org-agenda-undo
9689      #+cindex: undoing remote-editing events
9690      #+cindex: remote editing, undo
9691      Undo a change due to a remote editing command.  The change is
9692      undone both in the agenda buffer and in the remote buffer.
9694 - {{{kbd(t)}}} (~org-agenda-todo~) ::
9696      #+kindex: t
9697      #+findex: org-agenda-todo
9698      Change the TODO state of the item, both in the agenda and in the
9699      original Org file.
9701 - {{{kbd(C-S-RIGHT)}}} (~org-agenda-todo-nextset~) ::
9703      #+kindex: C-S-RIGHT
9704      #+findex: org-agenda-todo-nextset
9705      Switch to the next set of TODO keywords.
9707 - {{{kbd(C-S-LEFT)}}}, ~org-agenda-todo-previousset~ ::
9709      #+kindex: C-S-LEFT
9710      Switch to the previous set of TODO keywords.
9712 - {{{kbd(C-k)}}} (~org-agenda-kill~) ::
9714      #+kindex: C-k
9715      #+findex: org-agenda-kill
9716      #+vindex: org-agenda-confirm-kill
9717      Delete the current agenda item along with the entire subtree
9718      belonging to it in the original Org file.  If the text to be
9719      deleted remotely is longer than one line, the kill needs to be
9720      confirmed by the user.  See variable ~org-agenda-confirm-kill~.
9722 - {{{kbd(C-c C-w)}}} (~org-agenda-refile~) ::
9724      #+kindex: C-c C-w
9725      #+findex: org-agenda-refile
9726      Refile the entry at point.
9728 - {{{kbd(C-c C-x C-a)}}} or short {{{kbd(a)}}} (~org-agenda-archive-default-with-confirmation~) ::
9730      #+kindex: C-c C-x C-a
9731      #+kindex: a
9732      #+findex: org-agenda-archive-default-with-confirmation
9733      #+vindex: org-archive-default-command
9734      Archive the subtree corresponding to the entry at point using the
9735      default archiving command set in ~org-archive-default-command~.
9736      When using the {{{kbd(a)}}} key, confirmation is required.
9738 - {{{kbd(C-c C-x a)}}} (~org-agenda-toggle-archive-tag~) ::
9740      #+kindex: C-c C-x a
9741      #+findex: org-agenda-toggle-archive-tag
9742      Toggle the archive tag (see [[*Internal archiving]]) for the current
9743      headline.
9745 - {{{kbd(C-c C-x A)}}} (~org-agenda-archive-to-archive-sibling~) ::
9747      #+kindex: C-c C-x A
9748      #+findex: org-agenda-archive-to-archive-sibling
9749      Move the subtree corresponding to the current entry to its
9750      /archive sibling/.
9752 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd($)}}} (~org-agenda-archive~) ::
9754      #+kindex: C-c C-x C-s
9755      #+kindex: $
9756      #+findex: org-agenda-archive
9757      Archive the subtree corresponding to the current headline.  This
9758      means the entry is moved to the configured archive location, most
9759      likely a different file.
9761 - {{{kbd(T)}}} (~org-agenda-show-tags~) ::
9763      #+kindex: T
9764      #+findex: org-agenda-show-tags
9765      #+vindex: org-agenda-show-inherited-tags
9766      Show all tags associated with the current item.  This is useful
9767      if you have turned off ~org-agenda-show-inherited-tags~, but
9768      still want to see all tags of a headline occasionally.
9770 - {{{kbd(:)}}} (~org-agenda-set-tags~) ::
9772      #+kindex: :
9773      #+findex: org-agenda-set-tags
9774      Set tags for the current headline.  If there is an active region
9775      in the agenda, change a tag for all headings in the region.
9777 - {{{kbd(\,)}}} (~org-agenda-priority~) ::
9779      #+kindex: ,
9780      #+findex: org-agenda-priority
9781      Set the priority for the current item.  Org mode prompts for the
9782      priority character.  If you reply with {{{kbd(SPC)}}}, the
9783      priority cookie is removed from the entry.
9785 - {{{kbd(P)}}} (~org-agenda-show-priority~) ::
9787      #+kindex: P
9788      #+findex: org-agenda-show-priority
9789      Display weighted priority of current item.
9791 - {{{kbd(+)}}} or {{{kbd(S-UP)}}} (~org-agenda-priority-up~) ::
9793      #+kindex: +
9794      #+kindex: S-UP
9795      #+findex: org-agenda-priority-up
9796      Increase the priority of the current item.  The priority is
9797      changed in the original buffer, but the agenda is not resorted.
9798      Use the {{{kbd(r)}}} key for this.
9800 - {{{kbd(-)}}} or {{{kbd(S-DOWN)}}} (~org-agenda-priority-down~) ::
9802      #+kindex: -
9803      #+kindex: S-DOWN
9804      #+findex: org-agenda-priority-down
9805      Decrease the priority of the current item.
9807 - {{{kbd(C-c C-z)}}} or short {{{kbd(z)}}} (~org-agenda-add-note~) ::
9809      #+kindex: z
9810      #+kindex: C-c C-z
9811      #+findex: org-agenda-add-note
9812      #+vindex: org-log-into-drawer
9813      Add a note to the entry.  This note is recorded, and then filed
9814      to the same location where state change notes are put.  Depending
9815      on ~org-log-into-drawer~, this may be inside a drawer.
9817 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
9819      #+kindex: C-c C-a
9820      #+findex: org-attach
9821      Dispatcher for all command related to attachments.
9823 - {{{kbd(C-c C-s)}}} (~org-agenda-schedule~) ::
9825      #+kindex: C-c C-s
9826      #+findex: org-agenda-schedule
9827      Schedule this item.  With a prefix argument, remove the
9828      scheduling timestamp
9830 - {{{kbd(C-c C-d)}}} (~org-agenda-deadline~) ::
9832      #+kindex: C-c C-d
9833      #+findex: org-agenda-deadline
9834      Set a deadline for this item.  With a prefix argument, remove the
9835      deadline.
9837 - {{{kbd(S-RIGHT)}}} (~org-agenda-do-date-later~) ::
9839      #+kindex: S-RIGHT
9840      #+findex: org-agenda-do-date-later
9841      Change the timestamp associated with the current line by one day
9842      into the future.  If the date is in the past, the first call to
9843      this command moves it to today.  With a numeric prefix argument,
9844      change it by that many days.  For example, {{{kbd(3
9845      6 5 S-RIGHT)}}} changes it by a year.  With a {{{kbd(C-u)}}}
9846      prefix, change the time by one hour.  If you immediately repeat
9847      the command, it will continue to change hours even without the
9848      prefix argument.  With a double {{{kbd(C-u C-u)}}} prefix, do the
9849      same for changing minutes.  The stamp is changed in the original
9850      Org file, but the change is not directly reflected in the agenda
9851      buffer.  Use {{{kbd(r)}}} or {{{kbd(g)}}} to update the buffer.
9853 - {{{kbd(S-LEFT)}}} (~org-agenda-do-date-earlier~) ::
9855      #+kindex: S-LEFT
9856      #+findex: org-agenda-do-date-earlier
9857      Change the timestamp associated with the current line by one day
9858      into the past.
9860 - {{{kbd(>)}}} (~org-agenda-date-prompt~) ::
9862      #+kindex: >
9863      #+findex: org-agenda-date-prompt
9864      Change the timestamp associated with the current line.  The key
9865      {{{kbd(>)}}} has been chosen, because it is the same as
9866      {{{kbd(S-.)}}}  on my keyboard.
9868 - {{{kbd(I)}}} (~org-agenda-clock-in~) ::
9870      #+kindex: I
9871      #+findex: org-agenda-clock-in
9872      Start the clock on the current item.  If a clock is running
9873      already, it is stopped first.
9875 - {{{kbd(O)}}} (~org-agenda-clock-out~) ::
9877      #+kindex: O
9878      #+findex: org-agenda-clock-out
9879      Stop the previously started clock.
9881 - {{{kbd(X)}}} (~org-agenda-clock-cancel~) ::
9883      #+kindex: X
9884      #+findex: org-agenda-clock-cancel
9885      Cancel the currently running clock.
9887 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9889      #+kindex: J
9890      #+findex: org-agenda-clock-goto
9891      Jump to the running clock in another window.
9893 - {{{kbd(k)}}} (~org-agenda-capture~) ::
9895      #+kindex: k
9896      #+findex: org-agenda-capture
9897      #+cindex: capturing, from agenda
9898      #+vindex: org-capture-use-agenda-date
9899      Like ~org-capture~, but use the date at point as the default date
9900      for the capture template.  See ~org-capture-use-agenda-date~ to
9901      make this the default behavior of ~org-capture~.
9903 *** Bulk remote editing selected entries
9904 :PROPERTIES:
9905 :UNNUMBERED: notoc
9906 :END:
9907 #+cindex: remote editing, bulk, from agenda
9908 #+vindex: org-agenda-bulk-custom-functions
9910 - {{{kbd(m)}}} (~org-agenda-bulk-mark~) ::
9911      #+kindex: m
9912      #+findex: org-agenda-bulk-mark
9914      Mark the entry at point for bulk action.  If there is an active
9915      region in the agenda, mark the entries in the region.  With
9916      numeric prefix argument, mark that many successive entries.
9918 - {{{kbd(*)}}} (~org-agenda-bulk-mark-all~) ::
9919      #+kindex: *
9920      #+findex: org-agenda-bulk-mark-all
9922      Mark all visible agenda entries for bulk action.
9924 - {{{kbd(u)}}} (~org-agenda-bulk-unmark~) ::
9925      #+kindex: u
9926      #+findex: org-agenda-bulk-unmark
9928      Unmark entry for bulk action.
9930 - {{{kbd(U)}}} (~org-agenda-bulk-remove-all-marks~) ::
9931      #+kindex: U
9932      #+findex: org-agenda-bulk-remove-all-marks
9934      Unmark all marked entries for bulk action.
9936 - {{{kbd(M-m)}}} (~org-agenda-bulk-toggle~) ::
9937      #+kindex: M-m
9938      #+findex: org-agenda-bulk-toggle
9940      Toggle mark of the entry at point for bulk action.
9942 - {{{kbd(M-*)}}} (~org-agenda-bulk-toggle-all~) ::
9943      #+kindex: M-*
9944      #+findex: org-agenda-bulk-toggle-all
9946      Mark entries matching a regular expression for bulk action.
9948 - {{{kbd(%)}}} (~org-agenda-bulk-mark-regexp~) ::
9949      #+kindex: %
9950      #+findex: org-agenda-bulk-mark-regexp
9952      Mark entries matching a regular expression for bulk action.
9954 - {{{kbd(B)}}} (~org-agenda-bulk-action~) ::
9955      #+kindex: B
9956      #+findex: org-agenda-bulk-action
9957      #+vindex: org-agenda-bulk-persistent-marks
9959      Bulk action: act on all marked entries in the agenda.  This
9960      prompts for another key to select the action to be applied.  The
9961      prefix argument to {{{kbd(B)}}} is passed through to the
9962      {{{kbd(s)}}} and {{{kbd(d)}}} commands, to bulk-remove these
9963      special timestamps.  By default, marks are removed after the
9964      bulk.  If you want them to persist, set
9965      ~org-agenda-bulk-persistent-marks~ to ~t~ or hit {{{kbd(p)}}} at
9966      the prompt.
9968      - {{{kbd(*)}}} ::
9970           Toggle persistent marks.
9972      - {{{kbd($)}}} ::
9974           Archive all selected entries.
9976      - {{{kbd(A)}}} ::
9978           Archive entries by moving them to their respective archive
9979           siblings.
9981      - {{{kbd(t)}}} ::
9983           Change TODO state.  This prompts for a single TODO keyword and
9984           changes the state of all selected entries, bypassing blocking
9985           and suppressing logging notes---but not timestamps.
9987      - {{{kbd(+)}}} ::
9989           Add a tag to all selected entries.
9991      - {{{kbd(-)}}} ::
9993           Remove a tag from all selected entries.
9995      - {{{kbd(s)}}} ::
9997           Schedule all items to a new date.  To shift existing schedule
9998           dates by a fixed number of days, use something starting with
9999           double plus at the prompt, for example =++8d= or =++2w=.
10001      - {{{kbd(d)}}} ::
10003           Set deadline to a specific date.
10005      - {{{kbd(r)}}} ::
10007           Prompt for a single refile target and move all entries.  The
10008           entries are no longer in the agenda; refresh ({{{kbd(g)}}}) to
10009           bring them back.
10011      - {{{kbd(S)}}} ::
10013           Reschedule randomly into the coming N days.  N is prompted for.
10014           With a prefix argument ({{{kbd(C-u B S)}}}), scatter only
10015           across weekdays.
10017      - {{{kbd(f)}}} ::
10019           #+vindex: org-agenda-bulk-custom-functions
10020           Apply a function[fn:95] to marked entries.  For example, the
10021           function below sets the =CATEGORY= property of the entries to
10022           =web=.
10024           #+begin_src emacs-lisp
10025           (defun set-category ()
10026             (interactive "P")
10027             (let ((marker (or (org-get-at-bol 'org-hd-marker)
10028                               (org-agenda-error))))
10029               (org-with-point-at marker
10030                 (org-back-to-heading t)
10031                 (org-set-property "CATEGORY" "web"))))
10032           #+end_src
10034 *** Calendar commands
10035 :PROPERTIES:
10036 :UNNUMBERED: notoc
10037 :END:
10038 #+cindex: calendar commands, from agenda
10040 - {{{kbd(c)}}} (~org-agenda-goto-calendar~) ::
10042      #+kindex: c
10043      #+findex: org-agenda-goto-calendar
10044      Open the Emacs calendar and move to the date at the agenda
10045      cursor.
10047 - {{{kbd(c)}}} (~org-calendar-goto-agenda~) ::
10049      #+kindex: c
10050      #+findex: org-calendar-goto-agenda
10051      When in the calendar, compute and show the Org agenda for the
10052      date at the cursor.
10054 - {{{kbd(i)}}} (~org-agenda-diary-entry~) ::
10055      #+kindex: i
10056      #+findex: org-agenda-diary-entry
10058      #+cindex: diary entries, creating from agenda
10059      Insert a new entry into the diary, using the date at the cursor
10060      and (for block entries) the date at the mark.  This adds to the
10061      Emacs diary file[fn:96], in a way similar to the {{{kbd(i)}}}
10062      command in the calendar.  The diary file pops up in another
10063      window, where you can add the entry.
10065      #+vindex: org-agenda-diary-file
10066      If you configure ~org-agenda-diary-file~ to point to an Org file,
10067      Org creates entries in that file instead.  Most entries are
10068      stored in a date-based outline tree that will later make it easy
10069      to archive appointments from previous months/years.  The tree is
10070      built under an entry with a =DATE_TREE= property, or else with
10071      years as top-level entries.  Emacs prompts you for the entry
10072      text---if you specify it, the entry is created in
10073      ~org-agenda-diary-file~ without further interaction.  If you
10074      directly press {{{kbd(RET)}}} at the prompt without typing text,
10075      the target file is shown in another window for you to finish the
10076      entry there.  See also the {{{kbd(k r)}}} command.
10078 - {{{kbd(M)}}} (~org-agenda-phases-of-moon~) ::
10080      #+kindex: M
10081      #+findex: org-agenda-phases-of-moon
10082      Show the phases of the moon for the three months around current
10083      date.
10085 - {{{kbd(S)}}} (~org-agenda-sunrise-sunset~) ::
10087      #+kindex: S
10088      #+findex: org-agenda-sunrise-sunset
10089      Show sunrise and sunset times.  The geographical location must be
10090      set with calendar variables, see the documentation for the Emacs
10091      calendar.
10093 - {{{kbd(C)}}} (~org-agenda-convert-date~) ::
10095      #+kindex: C
10096      #+findex: org-agenda-convert-date
10097      Convert the date at cursor into many other cultural and historic
10098      calendars.
10100 - {{{kbd(H)}}} (~org-agenda-holidays~) ::
10102      #+kindex: H
10103      #+findex: org-agenda-holidays
10104      Show holidays for three months around the cursor date.
10106 *** Quit and exit
10107 :PROPERTIES:
10108 :UNNUMBERED: notoc
10109 :END:
10111 - {{{kbd(q)}}} (~org-agenda-quit~) ::
10112      #+kindex: q
10113      #+findex: org-agenda-quit
10115      Quit agenda, remove the agenda buffer.
10117 - {{{kbd(x)}}} (~org-agenda-exit~) ::
10118      #+kindex: x
10119      #+findex: org-agenda-exit
10121      #+cindex: agenda files, removing buffers
10122      Exit agenda, remove the agenda buffer and all buffers loaded by
10123      Emacs for the compilation of the agenda.  Buffers created by the
10124      user to visit Org files are not removed.
10126 ** Custom Agenda Views
10127 :PROPERTIES:
10128 :DESCRIPTION: Defining special searches and views.
10129 :END:
10130 #+cindex: custom agenda views
10131 #+cindex: agenda views, custom
10133 Custom agenda commands serve two purposes: to store and quickly access
10134 frequently used TODO and tags searches, and to create special
10135 composite agenda buffers.  Custom agenda commands are accessible
10136 through the dispatcher (see [[*The Agenda Dispatcher]]), just like the
10137 default commands.
10139 *** Storing searches
10140 :PROPERTIES:
10141 :DESCRIPTION: Type once, use often.
10142 :END:
10144 The first application of custom searches is the definition of keyboard
10145 shortcuts for frequently used searches, either creating an agenda
10146 buffer, or a sparse tree (the latter covering of course only the
10147 current buffer).
10149 #+kindex: C @r{(Agenda dispatcher)}
10150 #+vindex: org-agenda-custom-commands
10151 #+cindex: agenda views, main example
10152 #+cindex: agenda, as an agenda views
10153 #+cindex: agenda*, as an agenda views
10154 #+cindex: tags, as an agenda view
10155 #+cindex: todo, as an agenda view
10156 #+cindex: tags-todo
10157 #+cindex: todo-tree
10158 #+cindex: occur-tree
10159 #+cindex: tags-tree
10160 Custom commands are configured in the variable
10161 ~org-agenda-custom-commands~.  You can customize this variable, for
10162 example by pressing {{{kbd(C)}}} from the agenda dispatcher (see [[*The
10163 Agenda Dispatcher]]).  You can also directly set it with Emacs Lisp in
10164 the Emacs init file.  The following example contains all valid agenda
10165 views:
10167 #+begin_src emacs-lisp
10168 (setq org-agenda-custom-commands
10169       '(("x" agenda)
10170         ("y" agenda*)
10171         ("w" todo "WAITING")
10172         ("W" todo-tree "WAITING")
10173         ("u" tags "+boss-urgent")
10174         ("v" tags-todo "+boss-urgent")
10175         ("U" tags-tree "+boss-urgent")
10176         ("f" occur-tree "\\<FIXME\\>")
10177         ("h" . "HOME+Name tags searches") ;description for "h" prefix
10178         ("hl" tags "+home+Lisa")
10179         ("hp" tags "+home+Peter")
10180         ("hk" tags "+home+Kim")))
10181 #+end_src
10183 #+texinfo: @noindent
10184 The initial string in each entry defines the keys you have to press
10185 after the dispatcher command in order to access the command.  Usually
10186 this will be just a single character, but if you have many similar
10187 commands, you can also define two-letter combinations where the first
10188 character is the same in several combinations and serves as a prefix
10189 key[fn:97].  The second parameter is the search type, followed by the
10190 string or regular expression to be used for the matching.  The example
10191 above will therefore define:
10193 - {{{kbd(x)}}} ::
10195      as a global search for agenda entries planned[fn:98] this
10196      week/day.
10198 - {{{kbd(y)}}} ::
10200      as the same search, but only for entries with an hour
10201      specification like =[h]h:mm=---think of them as appointments.
10203 - {{{kbd(w)}}} ::
10205      as a global search for TODO entries with =WAITING= as the TODO
10206      keyword.
10208 - {{{kbd(W)}}} ::
10210      as the same search, but only in the current buffer and displaying
10211      the results as a sparse tree.
10213 - {{{kbd(u)}}} ::
10215      as a global tags search for headlines tagged =boss= but not
10216      =urgent=.
10218 - {{{kbd(v)}}} ::
10220      The same search, but limiting it to headlines that are also TODO
10221      items.
10223 - {{{kbd(U)}}} ::
10225      as the same search, but only in the current buffer and displaying
10226      the result as a sparse tree.
10228 - {{{kbd(f)}}} ::
10230      to create a sparse tree (again, current buffer only) with all
10231      entries containing the word =FIXME=.
10233 - {{{kbd(h)}}} ::
10235      as a prefix command for a =HOME= tags search where you have to
10236      press an additional key ({{{kbd(l)}}}, {{{kbd(p)}}} or
10237      {{{kbd(k)}}}) to select a name (Lisa, Peter, or Kim) as
10238      additional tag to match.
10240 Note that ~*-tree~ agenda views need to be called from an Org buffer
10241 as they operate on the current buffer only.
10243 *** Block agenda
10244 :PROPERTIES:
10245 :DESCRIPTION: All the stuff you need in a single buffer.
10246 :END:
10247 #+cindex: block agenda
10248 #+cindex: agenda, with block views
10250 Another possibility is the construction of agenda views that comprise
10251 the results of /several/ commands, each of which creates a block in
10252 the agenda buffer.  The available commands include ~agenda~ for the
10253 daily or weekly agenda (as created with {{{kbd(a)}}}) , ~alltodo~ for
10254 the global TODO list (as constructed with {{{kbd(t)}}}), and the
10255 matching commands discussed above: ~todo~, ~tags~, and ~tags-todo~.
10256 Here are two examples:
10258 #+begin_src emacs-lisp
10259 (setq org-agenda-custom-commands
10260       '(("h" "Agenda and Home-related tasks"
10261          ((agenda "")
10262           (tags-todo "home")
10263           (tags "garden")))
10264         ("o" "Agenda and Office-related tasks"
10265          ((agenda "")
10266           (tags-todo "work")
10267           (tags "office")))))
10268 #+end_src
10270 #+texinfo: @noindent
10271 This defines {{{kbd(h)}}} to create a multi-block view for stuff you
10272 need to attend to at home.  The resulting agenda buffer contains your
10273 agenda for the current week, all TODO items that carry the tag =home=,
10274 and also all lines tagged with =garden=.  Finally the command
10275 {{{kbd(o)}}} provides a similar view for office tasks.
10277 *** Setting options for custom commands
10278 :PROPERTIES:
10279 :DESCRIPTION: Changing the rules.
10280 :ALT_TITLE: Setting options
10281 :END:
10282 #+cindex: options, for custom agenda views
10284 #+vindex: org-agenda-custom-commands
10285 Org mode contains a number of variables regulating agenda construction
10286 and display.  The global variables define the behavior for all agenda
10287 commands, including the custom commands.  However, if you want to
10288 change some settings just for a single custom view, you can do so.
10289 Setting options requires inserting a list of variable names and values
10290 at the right spot in ~org-agenda-custom-commands~.  For example:
10292 #+begin_src emacs-lisp
10293 (setq org-agenda-custom-commands
10294       '(("w" todo "WAITING"
10295          ((org-agenda-sorting-strategy '(priority-down))
10296           (org-agenda-prefix-format "  Mixed: ")))
10297         ("U" tags-tree "+boss-urgent"
10298          ((org-show-context-detail 'minimal)))
10299         ("N" search ""
10300          ((org-agenda-files '("~org/notes.org"))
10301           (org-agenda-text-search-extra-files nil)))))
10302 #+end_src
10304 #+texinfo: @noindent
10305 Now the {{{kbd(w)}}} command sorts the collected entries only by
10306 priority, and the prefix format is modified to just say =Mixed:=
10307 instead of giving the category of the entry.  The sparse tags tree of
10308 {{{kbd(U)}}} now turns out ultra-compact, because neither the headline
10309 hierarchy above the match, nor the headline following the match are
10310 shown.  The command {{{kbd(N)}}} does a text search limited to only
10311 a single file.
10313 For command sets creating a block agenda, ~org-agenda-custom-commands~
10314 has two separate spots for setting options.  You can add options that
10315 should be valid for just a single command in the set, and options that
10316 should be valid for all commands in the set.  The former are just
10317 added to the command entry; the latter must come after the list of
10318 command entries.  Going back to the block agenda example (see [[*Block
10319 agenda]]), let's change the sorting strategy for the {{{kbd(h)}}}
10320 commands to ~priority-down~, but let's sort the results for GARDEN
10321 tags query in the opposite order, ~priority-up~.  This would look like
10322 this:
10324 #+begin_src emacs-lisp
10325 (setq org-agenda-custom-commands
10326       '(("h" "Agenda and Home-related tasks"
10327          ((agenda)
10328           (tags-todo "home")
10329           (tags "garden"
10330                 ((org-agenda-sorting-strategy '(priority-up)))))
10331          ((org-agenda-sorting-strategy '(priority-down))))
10332         ("o" "Agenda and Office-related tasks"
10333          ((agenda)
10334           (tags-todo "work")
10335           (tags "office")))))
10336 #+end_src
10338 As you see, the values and parentheses setting is a little complex.
10339 When in doubt, use the customize interface to set this variable---it
10340 fully supports its structure.  Just one caveat: when setting options
10341 in this interface, the /values/ are just Lisp expressions.  So if the
10342 value is a string, you need to add the double-quotes around the value
10343 yourself.
10345 #+vindex: org-agenda-custom-commands-contexts
10346 To control whether an agenda command should be accessible from
10347 a specific context, you can customize
10348 ~org-agenda-custom-commands-contexts~.  Let's say for example that you
10349 have an agenda command {{{kbd(o)}}} displaying a view that you only
10350 need when reading emails.  Then you would configure this option like
10351 this:
10353 #+begin_src emacs-lisp
10354 (setq org-agenda-custom-commands-contexts
10355       '(("o" (in-mode . "message-mode"))))
10356 #+end_src
10358 You can also tell that the command key {{{kbd(o)}}} should refer to
10359 another command key {{{kbd(r)}}}.  In that case, add this command key
10360 like this:
10362 #+begin_src emacs-lisp
10363 (setq org-agenda-custom-commands-contexts
10364       '(("o" "r" (in-mode . "message-mode"))))
10365 #+end_src
10367 See the docstring of the variable for more information.
10369 ** Exporting Agenda Views
10370 :PROPERTIES:
10371 :DESCRIPTION: Writing a view to a file.
10372 :END:
10373 #+cindex: agenda views, exporting
10375 If you are away from your computer, it can be very useful to have
10376 a printed version of some agenda views to carry around.  Org mode can
10377 export custom agenda views as plain text, HTML[fn:99], Postscript,
10378 PDF[fn:100], and iCalendar files.  If you want to do this only
10379 occasionally, use the following command:
10381 - {{{kbd(C-x C-w)}}} (~org-agenda-write~) ::
10382      #+kindex: C-x C-w
10383      #+findex: org-agenda-write
10384      #+cindex: exporting agenda views
10385      #+cindex: agenda views, exporting
10387      #+vindex: org-agenda-exporter-settings
10388      Write the agenda view to a file.
10390 If you need to export certain agenda views frequently, you can
10391 associate any custom agenda command with a list of output file
10392 names[fn:101].  Here is an example that first defines custom commands
10393 for the agenda and the global TODO list, together with a number of
10394 files to which to export them.  Then we define two block agenda
10395 commands and specify file names for them as well.  File names can be
10396 relative to the current working directory, or absolute.
10398 #+begin_src emacs-lisp
10399 (setq org-agenda-custom-commands
10400       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10401         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10402         ("h" "Agenda and Home-related tasks"
10403          ((agenda "")
10404           (tags-todo "home")
10405           (tags "garden"))
10406          nil
10407          ("~/views/home.html"))
10408         ("o" "Agenda and Office-related tasks"
10409          ((agenda)
10410           (tags-todo "work")
10411           (tags "office"))
10412          nil
10413          ("~/views/office.ps" "~/calendars/office.ics"))))
10414 #+end_src
10416 The extension of the file name determines the type of export.  If it
10417 is =.html=, Org mode uses the htmlize package to convert the buffer to
10418 HTML and save it to this file name.  If the extension is =.ps=,
10419 ~ps-print-buffer-with-faces~ is used to produce Postscript output.  If
10420 the extension is =.ics=, iCalendar export is run export over all files
10421 that were used to construct the agenda, and limit the export to
10422 entries listed in the agenda.  Any other extension produces a plain
10423 ASCII file.
10425 The export files are /not/ created when you use one of those
10426 commands interactively because this might use too much overhead.
10427 Instead, there is a special command to produce /all/ specified
10428 files in one step:
10430 - {{{kbd(e)}}} (~org-store-agenda-views~) ::
10432      #+kindex: e @r{(Agenda dispatcher)}
10433      #+findex: org-store-agenda-views
10434      Export all agenda views that have export file names associated
10435      with them.
10437 You can use the options section of the custom agenda commands to also
10438 set options for the export commands.  For example:
10440 #+begin_src emacs-lisp
10441 (setq org-agenda-custom-commands
10442       '(("X" agenda ""
10443          ((ps-number-of-columns 2)
10444           (ps-landscape-mode t)
10445           (org-agenda-prefix-format " [ ] ")
10446           (org-agenda-with-colors nil)
10447           (org-agenda-remove-tags t))
10448          ("theagenda.ps"))))
10449 #+end_src
10451 #+texinfo: @noindent
10452 #+vindex: org-agenda-exporter-settings
10453 This command sets two options for the Postscript exporter, to make it
10454 print in two columns in landscape format---the resulting page can be
10455 cut in two and then used in a paper agenda.  The remaining settings
10456 modify the agenda prefix to omit category and scheduling information,
10457 and instead include a checkbox to check off items.  We also remove the
10458 tags to make the lines compact, and we do not want to use colors for
10459 the black-and-white printer.  Settings specified in
10460 ~org-agenda-exporter-settings~ also apply, e.g.,
10462 #+begin_src emacs-lisp
10463 (setq org-agenda-exporter-settings
10464       '((ps-number-of-columns 2)
10465         (ps-landscape-mode t)
10466         (org-agenda-add-entry-text-maxlines 5)
10467         (htmlize-output-type 'css)))
10468 #+end_src
10470 #+texinfo: @noindent
10471 but the settings in ~org-agenda-custom-commands~ take precedence.
10473 #+texinfo: @noindent
10474 From the command line you may also use:
10476 #+begin_src shell
10477 emacs -eval (org-batch-store-agenda-views) -kill
10478 #+end_src
10480 #+texinfo: @noindent
10481 or, if you need to modify some parameters[fn:102]
10483 #+begin_src shell
10484 emacs -eval '(org-batch-store-agenda-views                      \
10485               org-agenda-span (quote month)                     \
10486               org-agenda-start-day "2007-11-01"                 \
10487               org-agenda-include-diary nil                      \
10488               org-agenda-files (quote ("~/org/project.org")))'  \
10489       -kill
10490 #+end_src
10492 #+texinfo: @noindent
10493 which creates the agenda views restricted to the file
10494 =~/org/project.org=, without diary entries and with a 30-day extent.
10496 You can also extract agenda information in a way that allows further
10497 processing by other programs.  See [[*Extracting Agenda Information]], for
10498 more information.
10500 ** Using Column View in the Agenda
10501 :PROPERTIES:
10502 :DESCRIPTION: Using column view for collected entries.
10503 :ALT_TITLE: Agenda Column View
10504 :END:
10505 #+cindex: column view, in agenda
10506 #+cindex: agenda, column view
10508 Column view (see [[*Column View]]) is normally used to view and edit
10509 properties embedded in the hierarchical structure of an Org file.  It
10510 can be quite useful to use column view also from the agenda, where
10511 entries are collected by certain criteria.
10513 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
10514      #+kindex: C-c C-x C-c
10515      #+findex: org-agenda-columns
10517      Turn on column view in the agenda.
10519 To understand how to use this properly, it is important to realize
10520 that the entries in the agenda are no longer in their proper outline
10521 environment.  This causes the following issues:
10524    #+vindex: org-columns-default-format
10525    #+vindex: org-overriding-columns-format
10526    Org needs to make a decision which columns format to use.  Since
10527    the entries in the agenda are collected from different files, and
10528    different files may have different columns formats, this is
10529    a non-trivial problem.  Org first checks if the variable
10530    ~org-agenda-overriding-columns-format~ is currently set, and if so,
10531    takes the format from there.  Otherwise it takes the format
10532    associated with the first item in the agenda, or, if that item does
10533    not have a specific format (defined in a property, or in its file),
10534    it uses ~org-columns-default-format~.
10537    #+cindex: @samp{CLOCKSUM}, special property
10538    If any of the columns has a summary type defined (see [[*Column
10539    attributes]]), turning on column view in the agenda visits all
10540    relevant agenda files and make sure that the computations of this
10541    property are up to date.  This is also true for the special
10542    =CLOCKSUM= property.  Org then sums the values displayed in the
10543    agenda.  In the daily/weekly agenda, the sums cover a single day;
10544    in all other views they cover the entire block.
10546    It is important to realize that the agenda may show the same entry
10547    /twice/---for example as scheduled and as a deadline---and it may
10548    show two entries from the same hierarchy (for example a /parent/
10549    and its /child/).  In these cases, the summation in the agenda
10550    leads to incorrect results because some values count double.
10552 3. When the column view in the agenda shows the =CLOCKSUM= property,
10553    that is always the entire clocked time for this item.  So even in
10554    the daily/weekly agenda, the clocksum listed in column view may
10555    originate from times outside the current view.  This has the
10556    advantage that you can compare these values with a column listing
10557    the planned total effort for a task---one of the major
10558    applications for column view in the agenda.  If you want
10559    information about clocked time in the displayed period use clock
10560    table mode (press {{{kbd(R)}}} in the agenda).
10563    #+cindex: @samp{CLOCKSUM_T}, special property
10564    When the column view in the agenda shows the =CLOCKSUM_T= property,
10565    that is always today's clocked time for this item.  So even in the
10566    weekly agenda, the clocksum listed in column view only originates
10567    from today.  This lets you compare the time you spent on a task for
10568    today, with the time already spent---via =CLOCKSUM=---and with
10569    the planned total effort for it.
10571 * Markup for Rich Export
10572 :PROPERTIES:
10573 :DESCRIPTION: Prepare text for rich export.
10574 :ALT_TITLE: Markup
10575 :END:
10577 When exporting Org documents, the exporter tries to reflect the
10578 structure of the document as accurately as possible in the back-end.
10579 Since export targets like HTML and LaTeX allow much richer formatting,
10580 Org mode has rules on how to prepare text for rich export.  This
10581 section summarizes the markup rules used in an Org mode buffer.
10583 ** Paragraphs
10584 :PROPERTIES:
10585 :DESCRIPTION: The basic unit of text.
10586 :END:
10587 #+cindex: paragraphs, markup rules
10589 Paragraphs are separated by at least one empty line.  If you need to
10590 enforce a line break within a paragraph, use ~\\~ at the end of
10591 a line.
10593 To preserve the line breaks, indentation and blank lines in a region,
10594 but otherwise use normal formatting, you can use this construct, which
10595 can also be used to format poetry.
10597 #+cindex: @samp{BEGIN_VERSE}
10598 #+cindex: verse blocks
10599 #+begin_example
10600 ,#+BEGIN_VERSE
10601  Great clouds overhead
10602  Tiny black birds rise and fall
10603  Snow covers Emacs
10605     ---AlexSchroeder
10606 ,#+END_VERSE
10607 #+end_example
10609 When quoting a passage from another document, it is customary to
10610 format this as a paragraph that is indented on both the left and the
10611 right margin.  You can include quotations in Org documents like this:
10613 #+cindex: @samp{BEGIN_QUOTE}
10614 #+cindex: quote blocks
10615 #+begin_example
10616 ,#+BEGIN_QUOTE
10617 Everything should be made as simple as possible,
10618 but not any simpler ---Albert Einstein
10619 ,#+END_QUOTE
10620 #+end_example
10622 If you would like to center some text, do it like this:
10624 #+cindex: @samp{BEGIN_CENTER}
10625 #+cindex: center blocks
10626 #+begin_example
10627 ,#+BEGIN_CENTER
10628 Everything should be made as simple as possible, \\
10629 but not any simpler
10630 ,#+END_CENTER
10631 #+end_example
10633 ** Emphasis and Monospace
10634 :PROPERTIES:
10635 :DESCRIPTION: Bold, italic, etc.
10636 :END:
10637 #+cindex: underlined text, markup rules
10638 #+cindex: bold text, markup rules
10639 #+cindex: italic text, markup rules
10640 #+cindex: verbatim text, markup rules
10641 #+cindex: code text, markup rules
10642 #+cindex: strike-through text, markup rules
10644 You can make words =*bold*=, =/italic/=, =_underlined_=, ==verbatim==
10645 and =~code~=, and, if you must, =+strike-through+=.  Text in the code
10646 and verbatim string is not processed for Org mode specific syntax; it
10647 is exported verbatim.
10649 #+vindex: org-fontify-emphasized-text
10650 To turn off fontification for marked up text, you can set
10651 ~org-fontify-emphasized-text~ to ~nil~.  To narrow down the list of
10652 available markup syntax, you can customize ~org-emphasis-alist~.
10654 ** Horizontal Rules
10655 :PROPERTIES:
10656 :DESCRIPTION: Make a line.
10657 :END:
10658 #+cindex: horizontal rules, markup rules
10660 A line consisting of only dashes, and at least 5 of them, is exported
10661 as a horizontal line.
10663 ** Images and Tables
10664 :PROPERTIES:
10665 :DESCRIPTION: Images, tables and caption mechanism.
10666 :END:
10667 #+cindex: tables, markup rules
10668 #+cindex: @samp{CAPTION}, keyword
10669 #+cindex: @samp{NAME}, keyword
10671 Both the native Org mode tables (see [[*Tables]]) and tables formatted
10672 with the =table.el= package are exported properly.  For Org mode
10673 tables, the lines before the first horizontal separator line become
10674 table header lines.  You can use the following lines somewhere before
10675 the table to assign a caption and a label for cross references, and in
10676 the text you can refer to the object with =[[tab:basic-data]]= (see
10677 [[*Internal Links]]):
10679 #+begin_example
10680 ,#+CAPTION: This is the caption for the next table (or link)
10681 ,#+NAME:   tab:basic-data
10682 | ... | ... |
10683 |-----+-----|
10684 #+end_example
10686 Optionally, the caption can take the form:
10688 : #+CAPTION[Caption for list of tables]: Caption for table.
10690 #+cindex: inlined images, markup rules
10691 Some back-ends allow you to directly include images into the exported
10692 document.  Org does this, if a link to an image file does not have
10693 a description part, for example =[[./img/a.jpg]]=.  If you wish to define
10694 a caption for the image and maybe a label for internal cross
10695 references, make sure that the link is on a line by itself and precede
10696 it with =CAPTION= and =NAME= keywords as follows:
10698 #+begin_example
10699 ,#+CAPTION: This is the caption for the next figure link (or table)
10700 ,#+NAME:   fig:SED-HR4049
10701 [[./img/a.jpg]]
10702 #+end_example
10704 #+texinfo: @noindent
10705 Such images can be displayed within the buffer.  See [[*Handling Links][the discussion of
10706 image links]].
10708 Even though images and tables are prominent examples of captioned
10709 structures, the same caption mechanism can apply to many
10710 others---e.g., LaTeX equations, source code blocks.  Depending on the
10711 export back-end, those may or may not be handled.
10713 ** Literal Examples
10714 :PROPERTIES:
10715 :DESCRIPTION: Source code examples with special formatting.
10716 :END:
10717 #+cindex: literal examples, markup
10718 #+cindex: code line references, markup
10720 You can include literal examples that should not be subjected to
10721 markup.  Such examples are typeset in monospace, so this is well
10722 suited for source code and similar examples.
10724 #+cindex: @samp{BEGIN_EXAMPLE}
10725 #+cindex: example block
10726 #+begin_example
10727 ,#+BEGIN_EXAMPLE
10728   Some example from a text file.
10729 ,#+END_EXAMPLE
10730 #+end_example
10732 Note that such blocks may be /indented/ in order to align nicely with
10733 indented text and in particular with plain list structure (see
10734 [[*Plain Lists]]).  For simplicity when using small examples, you can
10735 also start the example lines with a colon followed by a space.  There
10736 may also be additional whitespace before the colon:
10738 #+begin_example
10739 Here is an example
10740    : Some example from a text file.
10741 #+end_example
10743 #+cindex: formatting source code, markup rules
10744 #+vindex: org-latex-listings
10745 If the example is source code from a programming language, or any
10746 other text that can be marked up by Font Lock in Emacs, you can ask
10747 for the example to look like the fontified Emacs buffer[fn:103].  This
10748 is done with the code block, where you also need to specify the name
10749 of the major mode that should be used to fontify the example[fn:104],
10750 see [[*Structure Templates]] for shortcuts to easily insert code blocks.
10752 #+cindex: @samp{BEGIN_SRC}
10753 #+cindex: src block
10754 #+begin_example
10755 ,#+BEGIN_SRC emacs-lisp
10756   (defun org-xor (a b)
10757     "Exclusive or."
10758     (if a (not b) b))
10759  ,#+END_SRC
10760 #+end_example
10762 Both in =example= and in =src= snippets, you can add a =-n= switch to
10763 the end of the =#+BEGIN= line, to get the lines of the example
10764 numbered.  The =-n= takes an optional numeric argument specifying the
10765 starting line number of the block.  If you use a =+n= switch, the
10766 numbering from the previous numbered snippet is continued in the
10767 current one.  The =+n= switch can also take a numeric argument.  This
10768 adds the value of the argument to the last line of the previous block
10769 to determine the starting line number.
10771 #+begin_example
10772 ,#+BEGIN_SRC emacs-lisp -n 20
10773   ;; This exports with line number 20.
10774   (message "This is line 21")
10775 ,#+END_SRC
10777 ,#+BEGIN_SRC emacs-lisp +n 10
10778   ;; This is listed as line 31.
10779   (message "This is line 32")
10780 ,#+END_SRC
10781 #+end_example
10783 In literal examples, Org interprets strings like =(ref:name)= as
10784 labels, and use them as targets for special hyperlinks like
10785 =[[(name)]]=---i.e., the reference name enclosed in single parenthesis.
10786 In HTML, hovering the mouse over such a link remote-highlights the
10787 corresponding code line, which is kind of cool.
10789 You can also add a =-r= switch which /removes/ the labels from the
10790 source code[fn:105].  With the =-n= switch, links to these references
10791 are labeled by the line numbers from the code listing.  Otherwise
10792 links use the labels with no parentheses.  Here is an example:
10794 #+begin_example -l "(dumb-reference:%s)"
10795 ,#+BEGIN_SRC emacs-lisp -n -r
10796   (save-excursion                 (ref:sc)
10797      (goto-char (point-min))      (ref:jump)
10798 ,#+END_SRC
10799 In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
10800 jumps to point-min.
10801 #+end_example
10803 #+cindex: indentation, in source blocks
10804 Finally, you can use =-i= to preserve the indentation of a specific
10805 code block (see [[*Editing Source Code]]).
10807 #+vindex: org-coderef-label-format
10808 If the syntax for the label format conflicts with the language syntax,
10809 use a =-l= switch to change the format, for example
10811 : #+BEGIN_SRC pascal -n -r -l "((%s))"
10813 #+texinfo: @noindent
10814 See also the variable ~org-coderef-label-format~.
10816 HTML export also allows examples to be published as text areas (see
10817 [[*Text areas in HTML export]]).
10819 Because the =#+BEGIN= ... =#+END= patterns need to be added so often,
10820 a shortcut is provided (see [[*Structure Templates]]).
10822 - {{{kbd(C-c ')}}} (~org-edit-special~) ::
10824      #+kindex: C-c '
10825      #+findex: org-edit-special
10826      Edit the source code example at point in its native mode.  This
10827      works by switching to a temporary buffer with the source code.
10828      You need to exit by pressing {{{kbd(C-c ')}}} again[fn:106].  The
10829      edited version then replaces the old version in the Org buffer.
10830      Fixed-width regions---where each line starts with a colon
10831      followed by a space---are edited using ~artist-mode~[fn:107] to
10832      allow creating ASCII drawings easily.  Using this command in an
10833      empty line creates a new fixed-width region.
10835 #+cindex: storing link, in a source code buffer
10836 Calling ~org-store-link~ (see [[*Handling Links]]) while editing a source
10837 code example in a temporary buffer created with {{{kbd(C-c ')}}}
10838 prompts for a label.  Make sure that it is unique in the current
10839 buffer, and insert it with the proper formatting like =(ref:label)= at
10840 the end of the current line.  Then the label is stored as a link
10841 =(label)=, for retrieval with {{{kbd(C-c C-l)}}}.
10843 ** Special Symbols
10844 :PROPERTIES:
10845 :DESCRIPTION: Greek letters and other symbols.
10846 :END:
10847 #+cindex: math symbols
10848 #+cindex: special symbols
10849 #+cindex: @TeX{} macros
10850 #+cindex: @LaTeX{} fragments, markup rules
10851 #+cindex: HTML entities
10852 #+cindex: @LaTeX{} entities
10854 You can use LaTeX-like syntax to insert special symbols---named
10855 entities---like =\alpha= to indicate the Greek letter, or =\to= to indicate
10856 an arrow.  Completion for these symbols is available, just type =\=
10857 and maybe a few letters, and press {{{kbd(M-TAB)}}} to see possible
10858 completions.  If you need such a symbol inside a word, terminate it
10859 with a pair of curly brackets.  For example
10861 #+begin_example
10862 Pro tip: Given a circle \Gamma of diameter d, the length of its
10863 circumference is \pi{}d.
10864 #+end_example
10866 #+findex: org-entities-help
10867 #+vindex: org-entities-user
10868 A large number of entities is provided, with names taken from both
10869 HTML and LaTeX; you can comfortably browse the complete list from
10870 a dedicated buffer using the command ~org-entities-help~.  It is also
10871 possible to provide your own special symbols in the variable
10872 ~org-entities-user~.
10874 During export, these symbols are transformed into the native format of
10875 the exporter back-end.  Strings like =\alpha= are exported as =&alpha;= in
10876 the HTML output, and as =\(\alpha\)= in the LaTeX output.  Similarly, =\nbsp=
10877 becomes =&nbsp;= in HTML and =~= in LaTeX.
10879 #+cindex: escaping characters
10880 Entities may also be used as a way to escape markup in an Org
10881 document, e.g., =\under{}not underlined\under= exports as =_not underlined_=.
10883 #+cindex: special symbols, in-buffer display
10884 If you would like to see entities displayed as UTF-8 characters, use
10885 the following command[fn:108]:
10887 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10888      #+kindex: C-c C-x \
10889      #+findex: org-toggle-pretty-entities
10891      Toggle display of entities as UTF-8 characters.  This does not
10892      change the buffer content which remains plain ASCII, but it
10893      overlays the UTF-8 character for display purposes only.
10895 #+cindex: shy hyphen, special symbol
10896 #+cindex: dash, special symbol
10897 #+cindex: ellipsis, special symbol
10898 In addition to regular entities defined above, Org exports in
10899 a special way[fn:109] the following commonly used character
10900 combinations: =\-= is treated as a shy hyphen, =--= and =---= are
10901 converted into dashes, and =...= becomes a compact set of dots.
10903 ** Subscripts and Superscripts
10904 :PROPERTIES:
10905 :DESCRIPTION: Simple syntax for raising/lowering text.
10906 :END:
10907 #+cindex: subscript
10908 #+cindex: superscript
10910 =^= and =_= are used to indicate super- and subscripts.  To increase
10911 the readability of ASCII text, it is not necessary, but OK, to
10912 surround multi-character sub- and superscripts with curly braces.  For
10913 example
10915 #+begin_example
10916 The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
10917 the radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
10918 #+end_example
10920 #+vindex: org-use-sub-superscripts
10921 If you write a text where the underscore is often used in a different
10922 context, Org's convention to always interpret these as subscripts can
10923 get in your way.  Configure the variable ~org-use-sub-superscripts~ to
10924 change this convention.  For example, when setting this variable to
10925 ~{}~, =a_b= is not interpreted as a subscript, but =a_{b}= is.
10927 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~~) ::
10928      #+kindex: C-c C-x \
10929      #+findex: org-toggle-pretty-entities
10931      In addition to showing entities as UTF-8 characters, this command
10932      also formats sub- and superscripts in a WYSIWYM way.
10934 ** Embedded LaTeX
10935 :PROPERTIES:
10936 :DESCRIPTION: LaTeX can be freely used inside Org documents.
10937 :END:
10938 #+cindex: @TeX{} interpretation
10939 #+cindex: @LaTeX{} interpretation
10941 Plain ASCII is normally sufficient for almost all note taking.
10942 Exceptions include scientific notes, which often require mathematical
10943 symbols and the occasional formula.  LaTeX[fn:110] is widely used to
10944 typeset scientific documents.  Org mode supports embedding LaTeX code
10945 into its files, because many academics are used to writing and reading
10946 LaTeX source code, and because it can be readily processed to produce
10947 pretty output for a number of export back-ends.
10949 *** LaTeX fragments
10950 :PROPERTIES:
10951 :DESCRIPTION: Complex formulas made easy.
10952 :END:
10953 #+cindex: @LaTeX{} fragments
10955 #+vindex: org-format-latex-header
10956 Org mode can contain LaTeX math fragments, and it supports ways to
10957 process these for several export back-ends.  When exporting to LaTeX,
10958 the code is left as it is.  When exporting to HTML, Org can use either
10959 [[http://www.mathjax.org][MathJax]] (see [[*Math formatting in HTML export]]) or transcode the math
10960 into images (see [[*Previewing LaTeX fragments]]).
10962 LaTeX fragments do not need any special marking at all.  The following
10963 snippets are identified as LaTeX source code:
10965 - Environments of any kind[fn:111].  The only requirement is that the
10966   =\begin= statement appears on a new line, preceded by only
10967   whitespace.
10969 - Text within the usual LaTeX math delimiters.  To avoid conflicts
10970   with currency specifications, single =$= characters are only
10971   recognized as math delimiters if the enclosed text contains at most
10972   two line breaks, is directly attached to the =$= characters with no
10973   whitespace in between, and if the closing =$= is followed by
10974   whitespace, punctuation or a dash.  For the other delimiters, there
10975   is no such restriction, so when in doubt, use =\(...\)= as inline
10976   math delimiters.
10978 #+texinfo: @noindent
10979 For example:
10981 #+begin_example
10982 \begin{equation}                        % arbitrary environments,
10983 x=\sqrt{b}                              % even tables, figures
10984 \end{equation}                          % etc
10986 If $a^2=b$ and \( b=2 \), then the solution must be
10987 either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
10988 #+end_example
10990 #+vindex: org-export-with-latex
10991 LaTeX processing can be configured with the variable
10992 ~org-export-with-latex~.  The default setting is ~t~ which means
10993 MathJax for HTML, and no processing for ASCII and LaTeX back-ends.
10994 You can also set this variable on a per-file basis using one of these
10995 lines:
10997 | =#+OPTIONS: tex:t=        | Do the right thing automatically (MathJax) |
10998 | =#+OPTIONS: tex:nil=      | Do not process LaTeX fragments at all      |
10999 | =#+OPTIONS: tex:verbatim= | Verbatim export, for jsMath or so          |
11001 *** Previewing LaTeX fragments
11002 :PROPERTIES:
11003 :DESCRIPTION: What will this snippet look like?
11004 :END:
11005 #+cindex: @LaTeX{} fragments, preview
11007 #+vindex: org-preview-latex-default-process
11008 If you have a working LaTeX installation and =dvipng=, =dvisvgm= or
11009 =convert= installed[fn:112], LaTeX fragments can be processed to
11010 produce images of the typeset expressions to be used for inclusion
11011 while exporting to HTML (see [[*LaTeX fragments]]), or for inline
11012 previewing within Org mode.
11014 #+vindex: org-format-latex-options
11015 #+vindex: org-format-latex-header
11016 You can customize the variables ~org-format-latex-options~ and
11017 ~org-format-latex-header~ to influence some aspects of the preview.
11018 In particular, the ~:scale~ (and for HTML export, ~:html-scale~)
11019 property of the former can be used to adjust the size of the preview
11020 images.
11022 - {{{kbd(C-c C-x C-l)}}} (~org-toggle-latex-fragment~) ::
11023      #+kindex: C-c C-x C-l
11024      #+findex: org-toggle-latex-fragment
11026      Produce a preview image of the LaTeX fragment at point and
11027      overlay it over the source code.  If there is no fragment at
11028      point, process all fragments in the current entry (between two
11029      headlines).  When called with a prefix argument, process the
11030      entire subtree.  When called with two prefix arguments, or when
11031      the cursor is before the first headline, process the entire
11032      buffer.
11034 #+vindex: org-startup-with-latex-preview
11035 You can turn on the previewing of all LaTeX fragments in a file with
11037 : #+STARTUP: latexpreview
11039 To disable it, simply use
11041 : #+STARTUP: nolatexpreview
11043 *** Using CDLaTeX to enter math
11044 :PROPERTIES:
11045 :DESCRIPTION: Speed up entering of formulas.
11046 :ALT_TITLE: CDLaTeX mode
11047 :END:
11048 #+cindex: CD@LaTeX{}
11050 CDLaTeX mode is a minor mode that is normally used in combination with
11051 a major LaTeX mode like AUCTeX in order to speed-up insertion of
11052 environments and math templates.  Inside Org mode, you can make use of
11053 some of the features of CDLaTeX mode.  You need to install
11054 =cdlatex.el= and =texmathp.el= (the latter comes also with AUCTeX)
11055 from [[http://www.astro.uva.nl/~dominik/Tools/cdlatex]].  Do not use
11056 CDLaTeX mode itself under Org mode, but use the light version
11057 ~org-cdlatex-mode~ that comes as part of Org mode.  Turn it on for the
11058 current buffer with {{{kbd(M-x org-cdlatex-mode)}}}, or for all Org
11059 files with
11061 #+begin_src emacs-lisp
11062 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11063 #+end_src
11065 When this mode is enabled, the following features are present (for
11066 more details see the documentation of CDLaTeX mode):
11068 #+attr_texinfo: :sep ,
11069 - {{{kbd(C-c {)}}} ::
11070      #+kindex: C-c @{
11072      Insert an environment template.
11074 - {{{kbd(TAB)}}} ::
11075      #+kindex: TAB
11077      The {{{kbd(TAB)}}} key expands the template if the cursor is
11078      inside a LaTeX fragment[fn:113].  For example, {{{kbd(TAB)}}}
11079      expands =fr= to =\frac{}{}= and position the cursor correctly
11080      inside the first brace.  Another {{{kbd(TAB)}}} gets you into the
11081      second brace.
11083      Even outside fragments, {{{kbd(TAB)}}} expands environment
11084      abbreviations at the beginning of a line.  For example, if you
11085      write =equ= at the beginning of a line and press {{{kbd(TAB)}}},
11086      this abbreviation is expanded to an =equation= environment.  To
11087      get a list of all abbreviations, type {{{kbd(M-x
11088      cdlatex-command-help)}}}.
11090 - {{{kbd(^)}}}, {{{kbd(_)}}} ::
11091      #+kindex: _
11092      #+kindex: ^
11093      #+vindex: cdlatex-simplify-sub-super-scripts
11095      Pressing {{{kbd(_)}}} and {{{kbd(^)}}} inside a LaTeX fragment
11096      inserts these characters together with a pair of braces.  If you
11097      use {{{kbd(TAB)}}} to move out of the braces, and if the braces
11098      surround only a single character or macro, they are removed again
11099      (depending on the variable ~cdlatex-simplify-sub-super-scripts~).
11101 - {{{kbd(`)}}} ::
11102      #+kindex: `
11104      Pressing the backquote followed by a character inserts math
11105      macros, also outside LaTeX fragments.  If you wait more than 1.5
11106      seconds after the backquote, a help window pops up.
11108 - {{{kbd(')}}} ::
11109      #+kindex: '
11111      Pressing the single-quote followed by another character modifies
11112      the symbol before point with an accent or a font.  If you wait
11113      more than 1.5 seconds after the single-quote, a help window pops
11114      up.  Character modification works only inside LaTeX fragments;
11115      outside the quote is normal.
11117 * Exporting
11118 :PROPERTIES:
11119 :DESCRIPTION: Sharing and publishing notes.
11120 :END:
11121 #+cindex: exporting
11123 Sometimes, you may want to pretty print your notes, publish them on
11124 the web or even share them with people not using Org.  In these cases,
11125 the Org export facilities can be used to convert your documents to
11126 a variety of other formats, while retaining as much structure (see
11127 [[*Document Structure]]) and markup (see [[*Markup for Rich Export]]) as
11128 possible.
11130 #+cindex: export back-end
11131 Libraries responsible for such translation are called back-ends.  Org
11132 ships with the following ones
11134 - /ascii/ (ASCII format)
11135 - /beamer/ (LaTeX Beamer format)
11136 - /html/ (HTML format)
11137 - /icalendar/ (iCalendar format)
11138 - /latex/ (LaTeX format)
11139 - /md/ (Markdown format)
11140 - /odt/ (OpenDocument Text format)
11141 - /org/ (Org format)
11142 - /texinfo/ (Texinfo format)
11143 - /man/ (Man page format)
11145 #+texinfo: @noindent
11146 Org also uses additional libraries located in =contrib/= directory
11147 (see [[*Installation]]).  Users can install additional export libraries
11148 for additional formats from the Emacs packaging system.  For easy
11149 discovery, these packages have a common naming scheme: ~ox-NAME~,
11150 where {{{var(NAME)}}} is one of the formats.  For example,
11151 ~ox-koma-letter~ /koma-letter/ back-end.
11153 #+vindex: org-export-backends
11154 Org loads back-ends for the following formats by default: ASCII, HTML,
11155 iCalendar, LaTeX and ODT.  Org can load additional back-ends either of
11156 two ways: through the ~org-export-backends~ variable configuration;
11157 or, by requiring the library in the Emacs init file like this:
11159 #+begin_src emacs-lisp
11160 (require 'ox-md)
11161 #+end_src
11163 ** The Export Dispatcher
11164 :PROPERTIES:
11165 :DESCRIPTION: The main interface.
11166 :END:
11167 #+cindex: dispatcher, for export commands
11168 #+cindex: Export, dispatcher
11170 The export dispatcher is the main interface for Org's exports.
11171 A hierarchical menu presents the currently configured export formats.
11172 Options are shown as easy toggle switches on the same screen.
11174 #+vindex: org-export-dispatch-use-expert-ui
11175 Org also has a minimal prompt interface for the export dispatcher.
11176 When the variable ~org-export-dispatch-use-expert-ui~ is set to
11177 a non-~nil~ value, Org prompts in the minibuffer.  To switch back to
11178 the hierarchical menu, press {{{kbd(?)}}}.
11180 - {{{kbd(C-c C-e)}}} (~org-export~) ::
11181      #+kindex: C-c C-e
11182      #+findex: org-export
11184      Invokes the export dispatcher interface.  The options show
11185      default settings.  The {{{kbd(C-u)}}} prefix argument preserves
11186      options from the previous export, including any sub-tree
11187      selections.
11189 Org exports the entire buffer by default.  If the Org buffer has an
11190 active region, then Org exports just that region.
11192 Within the dispatcher interface, the following key combinations can
11193 further alter what is exported, and how.
11195 - {{{kbd(C-a)}}} ::
11196      #+kindex: C-c C-e C-a
11198      Toggle asynchronous export.  Asynchronous export uses an external
11199      Emacs process with a specially configured initialization file to
11200      complete the exporting process in the background thereby
11201      releasing the current interface.  This is particularly useful
11202      when exporting long documents.
11204      Output from an asynchronous export is saved on the "the export
11205      stack".  To view this stack, call the export dispatcher with
11206      a double {{{kbd(C-u)}}} prefix argument.  If already in the
11207      export dispatcher menu, {{{kbd(&)}}} displays the stack.
11209      #+vindex: org-export-async-init-file
11210      To make the background export process the default, customize the
11211      variable, ~org-export-in-background~.  Additionally, you can set
11212      the initialization file used by the background process with
11213      ~org-export-async-init-file~.
11215      #+vindex: org-export-in-background
11216      You can make asynchronous export the default by setting
11217      ~org-export-in-background~.
11219 - {{{kbd(C-b)}}} ::
11220      #+kindex: C-c C-e C-b
11222      Toggle body-only export.  Useful for excluding headers and
11223      footers in the export.  Affects only those back-end formats that
11224      have such sections---like =<head>...</head>= in HTML.
11226 - {{{kbd(C-s}}} ::
11227      #+kindex: C-c C-e C-s
11229      Toggle sub-tree export.  When turned on, Org exports only the
11230      sub-tree starting from the cursor position at the time the export
11231      dispatcher was invoked.  Org uses the top heading of this
11232      sub-tree as the document's title.  If the cursor is not on
11233      a heading, Org uses the nearest enclosing header.  If the cursor
11234      is in the document preamble, Org signals an error and aborts
11235      export.
11237      #+vindex: org-export-initial-scope
11238      To make the sub-tree export the default, customize the variable
11239      ~org-export-initial-scope~.
11241 - {{{kbd(C-v)}}} ::
11242      #+kindex: C-c C-e C-v
11244      Toggle visible-only export.  Useful for exporting only visible
11245      parts of an Org document by adjusting outline visibility
11246      settings.
11248 ** Export Settings
11249 :PROPERTIES:
11250 :DESCRIPTION: Common export settings.
11251 :END:
11252 #+cindex: options, for export
11253 #+cindex: Export, settings
11255 #+cindex: @samp{OPTIONS}, keyword
11256 Export options can be set: globally with variables; for an individual
11257 file by making variables buffer-local with in-buffer settings (see
11258 [[*Summary of In-Buffer Settings]]), by setting individual keywords, or by
11259 specifying them in a compact form with the =OPTIONS= keyword; or for
11260 a tree by setting properties (see [[*Properties and Columns]]).  Options
11261 set at a specific level override options set at a more general level.
11263 #+cindex: SETUPFILE, keyword
11264 In-buffer settings may appear anywhere in the file, either directly or
11265 indirectly through a file included using =#+SETUPFILE: filename or
11266 URL= syntax.  Option keyword sets tailored to a particular back-end
11267 can be inserted from the export dispatcher (see [[*The Export
11268 Dispatcher]]) using the =Insert template= command by pressing
11269 {{{kbd(#)}}}.  To insert keywords individually, a good way to make
11270 sure the keyword is correct is to type =#+= and then to use
11271 {{{kbd(M-TAB)}}}[fn:16] for completion.
11273 The export keywords available for every back-end, and their equivalent
11274 global variables, include:
11276 - =AUTHOR= ::
11278      #+cindex: @samp{AUTHOR}, keyword
11279      #+vindex: user-full-name
11280      The document author (~user-full-name~).
11282 - =CREATOR= ::
11284      #+cindex: @samp{CREATOR}, keyword
11285      #+vindex: org-expot-creator-string
11286      Entity responsible for output generation
11287      (~org-export-creator-string~).
11289 - =DATE= ::
11291      #+cindex: @samp{DATE}, keyword
11292      #+vindex: org-export-date-timestamp-format
11293      A date or a time-stamp[fn:114].
11295 - =EMAIL= ::
11297      #+cindex: @samp{EMAIL}, keyword
11298      #+vindex: user-mail-address
11299      The email address (~user-mail-address~).
11301 - =LANGUAGE= ::
11303      #+cindex: @samp{LANGUAGE}, keyword
11304      #+vindex: org-export-default-language
11305      Language to use for translating certain strings
11306      (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
11307      example, Org translates =Table of contents= to the French =Table
11308      des matières=.
11310 - =SELECT_TAGS= ::
11312      #+cindex: @samp{SELECT_TAGS}, keyword
11313      #+vindex: org-export-select-tags
11314      The default value is ~("export")~.  When a tree is tagged with
11315      =export= (~org-export-select-tags~), Org selects that tree and
11316      its sub-trees for export.  Org excludes trees with =noexport=
11317      tags, see below.  When selectively exporting files with =export=
11318      tags set, Org does not export any text that appears before the
11319      first headline.
11321 - =EXCLUDE_TAGS= ::
11323      #+cindex: @samp{EXCLUDE_TAGS}, keyword
11324      #+vindex: org-export-exclude-tags
11325      The default value is ~("noexport")~.  When a tree is tagged with
11326      =noexport= (~org-export-exclude-tags~), Org excludes that tree
11327      and its sub-trees from export.  Entries tagged with =noexport=
11328      are unconditionally excluded from the export, even if they have
11329      an =export= tag.  Even if a sub-tree is not exported, Org
11330      executes any code blocks contained there.
11332 - =TITLE= ::
11334      #+cindex: @samp{TITLE}, keyword
11335      #+cindex: document title
11336      Org displays this title.  For long titles, use multiple =#+TITLE=
11337      lines.
11339 - =EXPORT_FILE_NAME= ::
11341      #+cindex: @samp{EXPORT_FILE_NAME}, keyword
11342      The name of the output file to be generated.  Otherwise, Org
11343      generates the file name based on the buffer name and the
11344      extension based on the back-end format.
11346 The =OPTIONS= keyword is a compact form.  To configure multiple
11347 options, use several =OPTIONS= lines.  =OPTIONS= recognizes the
11348 following arguments.
11350 - ~'~ ::
11352      #+vindex: org-export-with-smart-quotes
11353      Toggle smart quotes (~org-export-with-smart-quotes~).  Depending
11354      on the language used, when activated, Org treats pairs of double
11355      quotes as primary quotes, pairs of single quotes as secondary
11356      quotes, and single quote marks as apostrophes.
11358 - ~*~ ::
11360      #+vindex: org-export-with-emphasize
11361      Toggle emphasized text (~org-export-with-emphasize~).
11363 - ~-~ ::
11365      #+vindex: org-export-with-special-strings
11366      Toggle conversion of special strings
11367      (~org-export-with-special-strings~).
11369 - ~:~ ::
11371      #+vindex: org-export-with-fixed-width
11372      Toggle fixed-width sections (~org-export-with-fixed-width~).
11374 - ~<~ ::
11376      #+vindex: org-export-with-timestamps
11377      Toggle inclusion of time/date active/inactive stamps
11378      (~org-export-with-timestamps~).
11380 - ~\n~ ::
11382      #+vindex: org-export-preserve-breaks
11383      Toggles whether to preserve line breaks
11384      (~org-export-preserve-breaks~).
11386 - ~^~ ::
11388      #+vindex: org-export-with-sub-superscripts
11389      Toggle TeX-like syntax for sub- and superscripts.  If you write
11390      =^:{}=, =a_{b}= is interpreted, but the simple =a_b= is left as
11391      it is (~org-export-with-sub-superscripts~).
11393 - ~arch~ ::
11395      #+vindex: org-export-with-archived-trees
11396      Configure how archived trees are exported.  When set to
11397      ~headline~, the export process skips the contents and processes
11398      only the headlines (~org-export-with-archived-trees~).
11400 - ~author~ ::
11402      #+vindex: org-export-with-author
11403      Toggle inclusion of author name into exported file
11404      (~org-export-with-author~).
11406 - ~broken-links~ ::
11408      #+vindex: org-export-with-broken-links
11409      Toggles if Org should continue exporting upon finding a broken
11410      internal link.  When set to ~mark~, Org clearly marks the problem
11411      link in the output (~org-export-with-broken-links~).
11413 - ~c~ ::
11415      #+vindex: org-export-with-clocks
11416      Toggle inclusion of CLOCK keywords (~org-export-with-clocks~).
11418 - ~creator~ ::
11420      #+vindex: org-export-with-creator
11421      Toggle inclusion of creator information in the exported file
11422      (~org-export-with-creator~).
11424 - ~d~ ::
11426      #+vindex: org-export-with-drawers
11427      Toggles inclusion of drawers, or list of drawers to include, or
11428      list of drawers to exclude (~org-export-with-drawers~).
11430 - ~date~ ::
11432      #+vindex: org-export-with-date
11433      Toggle inclusion of a date into exported file
11434      (~org-export-with-date~).
11436 - ~e~ ::
11438      #+vindex: org-export-with-entities
11439      Toggle inclusion of entities (~org-export-with-entities~).
11441 - ~email~ ::
11443      #+vindex: org-export-with-email
11444      Toggle inclusion of the author's e-mail into exported file
11445      (~org-export-with-email~).
11447 - ~f~ ::
11449      #+vindex: org-export-with-footnotes
11450      Toggle the inclusion of footnotes (~org-export-with-footnotes~).
11452 - ~H~ ::
11454      #+vindex: org-export-headline-levels
11455      Set the number of headline levels for export
11456      (~org-export-headline-levels~).  Below that level, headlines are
11457      treated differently.  In most back-ends, they become list items.
11459 - ~inline~ ::
11461      #+vindex: org-export-with-inlinetasks
11462      Toggle inclusion of inlinetasks (~org-export-with-inlinetasks~).
11464 - ~num~ ::
11466      #+vindex: org-export-with-section-numbers
11467      #+cindex: @samp{UNNUMBERED}, property
11468      Toggle section-numbers (~org-export-with-section-numbers~).  When
11469      set to number N, Org numbers only those headlines at level N or
11470      above.  Set =UNNUMBERED= property to non-~nil~ to disable
11471      numbering of heading and subheadings entirely.  Moreover, when
11472      the value is =notoc= the headline, and all its children, do not
11473      appear in the table of contents either (see [[*Table of Contents]]).
11475 - ~p~ ::
11477      #+vindex: org-export-with-planning
11478      Toggle export of planning information
11479      (~org-export-with-planning~).  "Planning information" comes from
11480      lines located right after the headline and contain any
11481      combination of these cookies: =SCHEDULED=, =DEADLINE=, or
11482      =CLOSED=.
11484 - ~pri~ ::
11486      #+vindex: org-export-with-priority
11487      Toggle inclusion of priority cookies
11488      (~org-export-with-priority~).
11490 - ~prop~ ::
11492      #+vindex: org-export-with-properties
11493      Toggle inclusion of property drawers, or list the properties to
11494      include (~org-export-with-properties~).
11496 - ~stat~ ::
11498      #+vindex: org-export-with-statistics-cookies
11499      Toggle inclusion of statistics cookies
11500      (~org-export-with-statistics-cookies~).
11502 - ~tags~ ::
11504      #+vindex: org-export-with-tags
11505      Toggle inclusion of tags, may also be ~not-in-toc~
11506      (~org-export-with-tags~).
11508 - ~tasks~ ::
11510      #+vindex: org-export-with-tasks
11511      Toggle inclusion of tasks (TODO items); or ~nil~ to remove all
11512      tasks; or ~todo~ to remove DONE tasks; or list the keywords to
11513      keep (~org-export-with-tasks~).
11515 - ~tex~ ::
11517      #+vindex: org-export-with-latex
11518      ~nil~ does not export; ~t~ exports; ~verbatim~ keeps everything
11519      in verbatim (~org-export-with-latex~).
11521 - ~timestamp~ ::
11523      #+vindex: org-export-time-stamp-file
11524      Toggle inclusion of the creation time in the exported file
11525      (~org-export-time-stamp-file~).
11527 - ~title~ ::
11529      #+vindex: org-export-with-title
11530      Toggle inclusion of title (~org-export-with-title~).
11532 - ~toc~ ::
11534      #+vindex: org-export-with-toc
11535      Toggle inclusion of the table of contents, or set the level limit
11536      (~org-export-with-toc~).
11538 - ~todo~ ::
11540      #+vindex: org-export-with-todo-keywords
11541      Toggle inclusion of TODO keywords into exported text
11542      (~org-export-with-todo-keywords~).
11544 - ~|~ ::
11546      #+vindex: org-export-with-tables
11547      Toggle inclusion of tables (~org-export-with-tables~).
11549 When exporting sub-trees, special node properties in them can override
11550 the above keywords.  They are special because they have an =EXPORT_=
11551 prefix.  For example, =DATE= and =EXPORT_FILE_NAME= keywords become,
11552 respectively, =EXPORT_DATE= and =EXPORT_FILE_NAME=.  Except for
11553 =SETUPFILE=, all other keywords listed above have an =EXPORT_=
11554 equivalent.
11556 #+cindex: @samp{BIND}, keyword
11557 #+vindex: org-export-allow-bind-keywords
11558 If ~org-export-allow-bind-keywords~ is non-~nil~, Emacs variables can
11559 become buffer-local during export by using the =BIND= keyword.  Its
11560 syntax is =#+BIND: variable value=.  This is particularly useful for
11561 in-buffer settings that cannot be changed using keywords.
11563 ** Table of Contents
11564 :PROPERTIES:
11565 :DESCRIPTION: The if and where of the table of contents.
11566 :END:
11567 #+cindex: table of contents
11568 #+cindex: list of tables
11569 #+cindex: list of listings
11571 #+cindex: @samp{toc}, in @samp{OPTIONS} keyword
11572 #+vindex: org-export-with-toc
11573 The table of contents includes all headlines in the document.  Its
11574 depth is therefore the same as the headline levels in the file.  If
11575 you need to use a different depth, or turn it off entirely, set the
11576 ~org-export-with-toc~ variable accordingly.  You can achieve the same
11577 on a per file basis, using the following =toc= item in =OPTIONS=
11578 keyword:
11580 #+begin_example
11581 ,#+OPTIONS: toc:2          (only include two levels in TOC)
11582 ,#+OPTIONS: toc:nil        (no default TOC at all)
11583 #+end_example
11585 #+cindex: excluding entries from table of contents
11586 #+cindex: table of contents, exclude entries
11587 Org includes both numbered and unnumbered headlines in the table of
11588 contents[fn:115].  If you need to exclude an unnumbered headline,
11589 along with all its children, set the =UNNUMBERED= property to =notoc=
11590 value.
11592 #+begin_example
11593 ,* Subtree not numbered, not in table of contents either
11594   :PROPERTIES:
11595   :UNNUMBERED: notoc
11596   :END:
11597 #+end_example
11599 #+cindex: @samp{TOC}, keyword
11600 Org normally inserts the table of contents directly before the first
11601 headline of the file.  To move the table of contents to a different
11602 location, first turn off the default with ~org-export-with-toc~
11603 variable or with =#+OPTIONS: toc:nil=.  Then insert =#+TOC: headlines
11604 N= at the desired location(s).
11606 #+begin_example
11607 ,#+OPTIONS: toc:nil
11609 ,#+TOC: headlines 2
11610 #+end_example
11612 To adjust the table of contents depth for a specific section of the
11613 Org document, append an additional =local= parameter.  This parameter
11614 becomes a relative depth for the current level.  The following example
11615 inserts a local table of contents, with direct children only.
11617 #+begin_example
11618 ,* Section
11619 ,#+TOC: headlines 1 local
11620 #+end_example
11622 Note that for this feature to work properly in LaTeX export, the Org
11623 file requires the inclusion of the titletoc package.  Because of
11624 compatibility issues, titletoc has to be loaded /before/ hyperref.
11625 Customize the ~org-latex-default-packages-alist~ variable.
11627 Use the =TOC= keyword to generate list of tables---respectively, all
11628 listings---with captions.
11630 #+begin_example
11631 ,#+TOC: listings
11632 ,#+TOC: tables
11633 #+end_example
11635 #+cindex: @samp{ALT_TITLE}, property
11636 Normally Org uses the headline for its entry in the table of contents.
11637 But with =ALT_TITLE= property, a different entry can be specified for
11638 the table of contents.
11640 ** Include Files
11641 :PROPERTIES:
11642 :DESCRIPTION: Include additional files into a document.
11643 :END:
11644 #+cindex: include files, during export
11645 #+cindex: Export, include files
11646 #+cindex: @samp{INCLUDE}, keyword
11648 During export, you can include the content of another file.  For
11649 example, to include your =.emacs= file, you could use:
11651 : #+INCLUDE: "~/.emacs" src emacs-lisp
11653 #+texinfo: @noindent
11654 The optional second and third parameter are the markup (e.g., =quote=,
11655 =example=, or =src=), and, if the markup is =src=, the language for
11656 formatting the contents.  The markup is optional; if it is not given,
11657 assume text is in Org syntax and process it normally.  The =INCLUDE=
11658 keyword also allows additional parameters =:prefix1= and =:prefix= to
11659 specify prefixes for the first line and for each following line,
11660 =:minlevel= in order to get Org mode content demoted to a specified
11661 level, as well as any options accepted by the selected markup.  For
11662 example, to include a file as an item, use:
11664 : #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
11666 You can also include a portion of a file by specifying a lines range
11667 using the =:lines= parameter.  The line at the upper end of the range
11668 is not included.  The start and/or the end of the range may be omitted
11669 to use the obvious defaults.
11671 - =#+INCLUDE: "~/.emacs" :lines "5-10"= ::
11673      Include lines 5 to 10, 10 excluded.
11675 - =#+INCLUDE: "~/.emacs" :lines "-10"=  ::
11677      Include lines 1 to 10, 10 excluded.
11679 - =#+INCLUDE: "~/.emacs" :lines "10-"=  ::
11681      Include lines from 10 to EOF.
11683 You can visit the file being included with the following command.
11685 - {{{kbd(C-c ')}}} (~org-edit~special~) ::
11686      #+kindex: C-c '
11687      #+findex: org-edit-special
11689      Visit the include file at point.
11691 ** Macro Replacement
11692 :PROPERTIES:
11693 :DESCRIPTION: Use macros to create templates.
11694 :END:
11695 #+cindex: macro replacement, during export
11696 #+cindex: @samp{MACRO}, keyword
11698 #+vindex: org-export-global-macros
11699 Macros replace text snippets during export.  Macros are defined
11700 globally in ~org-export-global-macros~, or document-wise with the
11701 following syntax:
11703 : #+MACRO: name   replacement text; $1, $2 are arguments
11705 #+texinfo: @noindent
11706 which can be referenced using ={{{name(arg1, arg2)}}}=[fn:116].  For
11707 example
11709 #+begin_example
11710 ,#+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
11711 {{{poem(red,blue)}}}
11712 #+end_example
11714 #+texinfo: @noindent
11715 becomes
11717 : The rose is red, The violet's blue. Life's ordered: Org assists you.
11719 As a special case, Org parses any replacement text starting with
11720 =(eval= as an Emacs Lisp expression and evaluates it accordingly.
11721 Within such templates, arguments become strings.  Thus, the following
11722 macro
11724 : #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
11726 #+texinfo: @noindent
11727 turns ={{{gnucheck(linux)}}}= into =GNU/Linux= during export.
11729 Org recognizes macro references in following Org markup areas:
11730 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
11731 recognizes macro references in keywords, such as =CAPTION=, =TITLE=,
11732 =AUTHOR=, =DATE=, and for some back-end specific export options.
11734 Org comes with following pre-defined macros:
11736 #+attr_texinfo: :sep ;
11737 - ={{{keyword(NAME)}}}=; ={{{title}}}=; ={{{author}}}=; ={{{email}}}= ::
11739      #+cindex: @samp{keyword}, macro
11740      #+cindex: @samp{title}, macro
11741      #+cindex: @samp{author}, macro
11742      #+cindex: @samp{email}, macro
11743      The =keyword= macro collects all values from {{{var(NAME)}}}
11744      keywords throughout the buffer, separated with white space.
11745      =title=, =author= and =email= macros are shortcuts for,
11746      respectively, ={{{keyword(TITLE)}}}=, ={{{keyword(AUTHOR)}}}= and
11747      ={{{keyword(EMAIL)}}}=.
11749 - ={{{date}}}=; ={{{date(FORMAT)}}}= ::
11751      #+cindex: @samp{date}, macro
11752      This macro refers to the =DATE= keyword.  {{{var(FORMAT)}}} is an
11753      optional argument to the =date= macro that is used only if =DATE=
11754      is a single timestamp.  {{{var(FORMAT)}}} should be a format
11755      string understood by ~format-time-string~.
11757 - ={{{time(FORMAT)}}}=; ={{{modification-time(FORMAT, VC)}}}= ::
11759      #+cindex: @samp{time}, macro
11760      #+cindex: @samp{modification-time}, macro
11761      These macros refer to the document's date and time of export and
11762      date and time of modification.  {{{var(FORMAT)}}} is a string
11763      understood by ~format-time-string~.  If the second argument to
11764      the ~modification-time~ macro is non-~nil~, Org uses =vc.el= to
11765      retrieve the document's modification time from the version
11766      control system.  Otherwise Org reads the file attributes.
11768 - ={{{input-file}}}= ::
11770      #+cindex: @samp{input-file}, macro
11771      This macro refers to the filename of the exported file.
11773 - ={{{property(PROPERTY-NAME)}}}=; ={{{property(PROPERTY-NAME, SEARCH OPTION)}}}= ::
11775      #+cindex: @samp{property}, macro
11776      This macro returns the value of property {{{var(PROPERTY-NAME)}}}
11777      in the current entry.  If {{{var(SEARCH-OPTION)}}} (see [[*Search
11778      Options in File Links]]) refers to a remote entry, use it instead.
11780 - ={{{n}}}=; ={{{n(NAME)}}}=; ={{{n(NAME, ACTION)}}}= ::
11782      #+cindex: @samp{n}, macro
11783      #+cindex: counter, macro
11784      This macro implements custom counters by returning the number of
11785      times the macro has been expanded so far while exporting the
11786      buffer.  You can create more than one counter using different
11787      {{{var(NAME)}}} values.  If {{{var(ACTION)}}} is =-=, previous
11788      value of the counter is held, i.e., the specified counter is not
11789      incremented.  If the value is a number, the specified counter is
11790      set to that value.  If it is any other non-empty string, the
11791      specified counter is reset to 1.  You may leave {{{var(NAME)}}}
11792      empty to reset the default counter.
11794 #+vindex: org-hide-macro-markers
11795 The surrounding brackets can be made invisible by setting
11796 ~org-hide-macro-markers~ non-~nil~.
11798 Org expands macros at the very beginning of the export process.
11800 ** Comment Lines
11801 :PROPERTIES:
11802 :DESCRIPTION: What will not be exported.
11803 :END:
11804 #+cindex: exporting, not
11806 #+cindex: comment lines
11807 Lines starting with zero or more whitespace characters followed by one
11808 =#= and a whitespace are treated as comments and, as such, are not
11809 exported.
11811 #+cindex: @samp{BEGIN_COMMENT}
11812 #+cindex: comment block
11813 Likewise, regions surrounded by =#+BEGIN_COMMENT= ... =#+END_COMMENT=
11814 are not exported.
11816 #+cindex: comment trees
11817 Finally, a =COMMENT= keyword at the beginning of an entry, but after
11818 any other keyword or priority cookie, comments out the entire subtree.
11819 In this case, the subtree is not exported and no code block within it
11820 is executed either[fn:117].  The command below helps changing the
11821 comment status of a headline.
11823 - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
11824      #+kindex: C-c ;
11825      #+findex: org-toggle-comment
11827      Toggle the =COMMENT= keyword at the beginning of an entry.
11829 ** ASCII/Latin-1/UTF-8 export
11830 :PROPERTIES:
11831 :DESCRIPTION: Exporting to flat files with encoding.
11832 :END:
11833 #+cindex: ASCII export
11834 #+cindex: Latin-1 export
11835 #+cindex: UTF-8 export
11837 ASCII export produces an output file containing only plain ASCII
11838 characters.  This is the simplest and most direct text output.  It
11839 does not contain any Org markup.  Latin-1 and UTF-8 export use
11840 additional characters and symbols available in these encoding
11841 standards.  All three of these export formats offer the most basic of
11842 text output for maximum portability.
11844 #+vindex: org-ascii-text-width
11845 On export, Org fills and justifies text according to the text width
11846 set in ~org-ascii-text-width~.
11848 #+vindex: org-ascii-links-to-notes
11849 Org exports links using a footnote-like style where the descriptive
11850 part is in the text and the link is in a note before the next heading.
11851 See the variable ~org-ascii-links-to-notes~ for details.
11853 *** ASCII export commands
11854 :PROPERTIES:
11855 :UNNUMBERED: notoc
11856 :END:
11858 #+attr_texinfo: :sep ,
11859 - {{{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)}}} ::
11860      #+kindex: C-c C-e t a
11861      #+kindex: C-c C-e t l
11862      #+kindex: C-c C-e t u
11863      #+findex: org-ascii-export-to-ascii
11865      Export as an ASCII file with a =.txt= extension.  For
11866      =myfile.org=, Org exports to =myfile.txt=, overwriting without
11867      warning.  For =myfile.txt=, Org exports to =myfile.txt.txt= in
11868      order to prevent data loss.
11870 #+attr_texinfo: :sep ,
11871 - {{{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)}}} ::
11872      #+kindex: C-c C-e t A
11873      #+kindex: C-c C-e t L
11874      #+kindex: C-c C-e t U
11875      #+findex: org-ascii-export-to-ascii
11877      Export to a temporary buffer.  Does not create a file.
11879 *** ASCII specific export settings
11880 :PROPERTIES:
11881 :UNNUMBERED: notoc
11882 :END:
11884 The ASCII export back-end has one extra keyword for customizing ASCII
11885 output.  Setting this keyword works similar to the general options
11886 (see [[*Export Settings]]).
11888 - =SUBTITLE= ::
11890      #+cindex: @samp{SUBTITLE}, keyword
11891      The document subtitle.  For long subtitles, use multiple
11892      =#+SUBTITLE= lines in the Org file.  Org prints them on one
11893      continuous line, wrapping into multiple lines if necessary.
11895 *** Header and sectioning structure
11896 :PROPERTIES:
11897 :UNNUMBERED: notoc
11898 :END:
11900 Org converts the first three outline levels into headlines for ASCII
11901 export.  The remaining levels are turned into lists.  To change this
11902 cut-off point where levels become lists, see [[*Export Settings]].
11904 *** Quoting ASCII text
11905 :PROPERTIES:
11906 :UNNUMBERED: notoc
11907 :END:
11909 To insert text within the Org file by the ASCII back-end, use one the
11910 following constructs, inline, keyword, or export block:
11912 #+cindex: @samp{ASCII}, keyword
11913 #+cindex: @samp{BEGIN_EXPORT ascii}
11914 #+begin_example
11915 Inline text @@ascii:and additional text@@ within a paragraph.
11917 ,#+ASCII: Some text
11919 ,#+BEGIN_EXPORT ascii
11920 Org exports text in this block only when using ASCII back-end.
11921 ,#+END_EXPORT
11922 #+end_example
11924 *** ASCII specific attributes
11925 :PROPERTIES:
11926 :UNNUMBERED: notoc
11927 :END:
11928 #+cindex: @samp{ATTR_ASCII}, keyword
11929 #+cindex: horizontal rules, in ASCII export
11931 ASCII back-end recognizes only one attribute, ~:width~, which
11932 specifies the width of an horizontal rule in number of characters.
11933 The keyword and syntax for specifying widths is:
11935 #+begin_example
11936 ,#+ATTR_ASCII: :width 10
11937 -----
11938 #+end_example
11940 *** ASCII special blocks
11941 :PROPERTIES:
11942 :UNNUMBERED: notoc
11943 :END:
11944 #+cindex: special blocks, in ASCII export
11945 #+cindex: @samp{BEGIN_JUSTIFYLEFT}
11946 #+cindex: @samp{BEGIN_JUSTIFYRIGHT}
11948 Besides =#+BEGIN_CENTER= blocks (see [[*Paragraphs]]), ASCII back-end has
11949 these two left and right justification blocks:
11951 #+begin_example
11952 ,#+BEGIN_JUSTIFYLEFT
11953 It's just a jump to the left...
11954 ,#+END_JUSTIFYLEFT
11956 ,#+BEGIN_JUSTIFYRIGHT
11957 ...and then a step to the right.
11958 ,#+END_JUSTIFYRIGHT
11959 #+end_example
11961 ** Beamer Export
11962 #+cindex: Beamer export
11964 Org uses Beamer export to convert an Org file tree structure into
11965 high-quality interactive slides for presentations.  Beamer is a LaTeX
11966 document class for creating presentations in PDF, HTML, and other
11967 popular display formats.
11969 *** Beamer export commands
11970 :PROPERTIES:
11971 :DESCRIPTION: For creating Beamer documents.
11972 :END:
11974 - {{{kbd(C-c C-e l b)}}} (~org-beamer-export-to-latex~) ::
11975      #+kindex: C-c C-e l b
11976      #+findex: org-beamer-export-to-latex
11978      Export as LaTeX file with a =.tex= extension.  For =myfile.org=,
11979      Org exports to =myfile.tex=, overwriting without warning.
11981 - {{{kbd(C-c C-e l B)}}} (~org-beamer-export-as-latex~) ::
11982      #+kindex: C-c C-e l B
11983      #+findex: org-beamer-export-as-latex
11985      Export to a temporary buffer.  Does not create a file.
11987 - {{{kbd(C-c C-e l P)}}} (~org-beamer-export-to-pdf~) ::
11988      #+kindex: C-c C-e l P
11989      #+findex: org-beamer-export-to-pdf
11991      Export as LaTeX file and then convert it to PDF format.
11993 - {{{kbd(C-c C-e l O)}}} ::
11994      #+kindex: C-c C-e l O
11996      Export as LaTeX file, convert it to PDF format, and then open the
11997      PDF file.
11999 *** Beamer specific export settings
12000 :PROPERTIES:
12001 :DESCRIPTION: For customizing Beamer export.
12002 :END:
12004 Beamer export back-end has several additional keywords for customizing
12005 Beamer output.  These keywords work similar to the general options
12006 settings (see [[*Export Settings]]).
12008 - =BEAMER_THEME= ::
12010      #+cindex: @samp{BEAMER_THEME}, keyword
12011      #+vindex: org-beamer-theme
12012      The Beamer layout theme (~org-beamer-theme~).  Use square
12013      brackets for options.  For example:
12015      : #+BEAMER_THEME: Rochester [height=20pt]
12017 - =BEAMER_FONT_THEME= ::
12019      #+cindex: @samp{BEAMER_FONT_THEME}, keyword
12020      The Beamer font theme.
12022 - =BEAMER_INNER_THEME= ::
12024      #+cindex: @samp{BEAMER_INNER_THEME}, keyword
12025      The Beamer inner theme.
12027 - =BEAMER_OUTER_THEME= ::
12029      #+cindex: @samp{BEAMER_OUTER_THEME}, keyword
12030      The Beamer outer theme.
12032 - =BEAMER_HEADER= ::
12034      #+cindex: @samp{BEAMER_HEADER}, keyword
12035      Arbitrary lines inserted in the preamble, just before the
12036      =hyperref= settings.
12038 - =DESCRIPTION= ::
12040      #+cindex: @samp{DESCRIPTION}, keyword
12041      The document description.  For long descriptions, use multiple
12042      =DESCRIPTION= keywords.  By default, =hyperref= inserts
12043      =DESCRIPTION= as metadata.  Use ~org-latex-hyperref-template~ to
12044      configure document metadata.  Use ~org-latex-title-command~ to
12045      configure typesetting of description as part of front matter.
12047 - =KEYWORDS= ::
12049      #+cindex: @samp{KEYWORDS}, keyword
12050      The keywords for defining the contents of the document.  Use
12051      multiple =KEYWORDS= lines if necessary.  By default, =hyperref=
12052      inserts =KEYWORDS= as metadata.  Use
12053      ~org-latex-hyperref-template~ to configure document metadata.
12054      Use ~org-latex-title-command~ to configure typesetting of
12055      keywords as part of front matter.
12057 - =SUBTITLE= ::
12059      #+cindex: @samp{SUBTITLE}, keyword
12060      Document's subtitle.  For typesetting, use
12061      ~org-beamer-subtitle-format~ string.  Use
12062      ~org-latex-hyperref-template~ to configure document metadata.
12063      Use ~org-latex-title-command~ to configure typesetting of
12064      subtitle as part of front matter.
12066 *** Frames and Blocks in Beamer
12067 :PROPERTIES:
12068 :DESCRIPTION: For composing Beamer slides.
12069 :END:
12071 Org transforms heading levels into Beamer's sectioning elements,
12072 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12073 should in principle be exportable as a Beamer presentation.
12076   #+vindex: org-beamer-frame-level
12077   Org headlines become Beamer frames when the heading level in Org is
12078   equal to ~org-beamer-frame-level~ or =H= value in a =OPTIONS= line
12079   (see [[*Export Settings]]).
12081   #+cindex: @samp{BEAMER_ENV}, property
12082   Org overrides headlines to frames conversion for the current tree of
12083   an Org file if it encounters the =BEAMER_ENV= property set to
12084   =frame= or =fullframe=.  Org ignores whatever
12085   ~org-beamer-frame-level~ happens to be for that headline level in
12086   the Org tree.  In Beamer terminology, a full frame is a frame
12087   without its title.
12089 - Org exports a Beamer frame's objects as block environments.  Org can
12090   enforce wrapping in special block types when =BEAMER_ENV= property
12091   is set[fn:118].  For valid values see
12092   ~org-beamer-environments-default~.  To add more values, see
12093   ~org-beamer-environments-extra~.
12094   #+vindex: org-beamer-environments-default
12095   #+vindex: org-beamer-environments-extra
12098   #+cindex: @samp{BEAMER_REF}, property
12099   If =BEAMER_ENV= is set to =appendix=, Org exports the entry as an
12100   appendix.  When set to =note=, Org exports the entry as a note
12101   within the frame or between frames, depending on the entry's heading
12102   level.  When set to =noteNH=, Org exports the entry as a note
12103   without its title.  When set to =againframe=, Org exports the entry
12104   with =\againframe= command, which makes setting the =BEAMER_REF=
12105   property mandatory because =\againframe= needs frame to resume.
12107   When =ignoreheading= is set, Org export ignores the entry's headline
12108   but not its content.  This is useful for inserting content between
12109   frames.  It is also useful for properly closing a =column=
12110   environment.  @end itemize
12112   #+cindex: @samp{BEAMER_ACT}, property
12113   #+cindex: @samp{BEAMER_OPT}, property
12114   When =BEAMER_ACT= is set for a headline, Org export translates that
12115   headline as an overlay or action specification.  When enclosed in
12116   square brackets, Org export makes the overlay specification
12117   a default.  Use =BEAMER_OPT= to set any options applicable to the
12118   current Beamer frame or block.  The Beamer export back-end wraps
12119   with appropriate angular or square brackets.  It also adds the
12120   =fragile= option for any code that may require a verbatim block.
12122   #+cindex: @samp{BEAMER_COL}, property
12123   To create a column on the Beamer slide, use the =BEAMER_COL=
12124   property for its headline in the Org file.  Set the value of
12125   =BEAMER_COL= to a decimal number representing the fraction of the
12126   total text width.  Beamer export uses this value to set the column's
12127   width and fills the column with the contents of the Org entry.  If
12128   the Org entry has no specific environment defined, Beamer export
12129   ignores the heading.  If the Org entry has a defined environment,
12130   Beamer export uses the heading as title.  Behind the scenes, Beamer
12131   export automatically handles LaTeX column separations for contiguous
12132   headlines.  To manually adjust them for any unique configurations
12133   needs, use the =BEAMER_ENV= property.
12135 *** Beamer specific syntax
12136 :PROPERTIES:
12137 :DESCRIPTION: For using in Org documents.
12138 :END:
12140 Since Org's Beamer export back-end is an extension of the LaTeX
12141 back-end, it recognizes other LaTeX specific syntax---for example,
12142 =#+LATEX:= or =#+ATTR_LATEX:=.  See [[*LaTeX Export]], for details.
12144 Beamer export wraps the table of contents generated with =toc:t=
12145 =OPTION= keyword in a =frame= environment.  Beamer export does not
12146 wrap the table of contents generated with =TOC= keyword (see [[*Table of
12147 Contents]]).  Use square brackets for specifying options.
12149 : #+TOC: headlines [currentsection]
12151 Insert Beamer-specific code using the following constructs:
12153 #+cindex: @samp{BEAMER}, keyword
12154 #+cindex: @samp{BEGIN_EXPORT beamer}
12155 #+begin_example
12156 ,#+BEAMER: \pause
12158 ,#+BEGIN_EXPORT beamer
12159   Only Beamer export back-end exports this.
12160 ,#+END_BEAMER
12162 Text @@beamer:some code@@ within a paragraph.
12163 #+end_example
12165 Inline constructs, such as the last one above, are useful for adding
12166 overlay specifications to objects with ~bold~, ~item~, ~link~,
12167 ~radio-target~ and ~target~ types.  Enclose the value in angular
12168 brackets and place the specification at the beginning of the object as
12169 shown in this example:
12171 :  A *@@beamer:<2->@@useful* feature
12173 #+cindex: @samp{ATTR_BEAMER}, keyword
12174 Beamer export recognizes the =ATTR_BEAMER= keyword with the following
12175 attributes from Beamer configurations: =:environment= for changing
12176 local Beamer environment, =:overlay= for specifying Beamer overlays in
12177 angular or square brackets, and =:options= for inserting optional
12178 arguments.
12180 #+begin_example
12181 ,#+ATTR_BEAMER: :environment nonindentlist
12182 - item 1, not indented
12183 - item 2, not indented
12184 - item 3, not indented
12185 #+end_example
12187 #+begin_example
12188 ,#+ATTR_BEAMER: :overlay <+->
12189 - item 1
12190 - item 2
12191 #+end_example
12193 #+begin_example
12194 ,#+ATTR_BEAMER: :options [Lagrange]
12195 Let $G$ be a finite group, and let $H$ be
12196 a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12197 #+end_example
12199 *** Editing support
12200 :PROPERTIES:
12201 :DESCRIPTION: Editing support.
12202 :END:
12204 The ~org-beamer-mode~ is a special minor mode for faster editing of
12205 Beamer documents.
12207 : #+STARTUP: beamer
12209 - {{{kbd(C-c C-b)}}} (~org-beamer-select-environment~) ::
12210      #+kindex: C-c C-b
12211      #+findex: org-beamer-select-environment
12213      The ~org-beamer-mode~ provides this key for quicker selections in
12214      Beamer normal environments, and for selecting the =BEAMER_COL=
12215      property.
12217 *** A Beamer example
12218 :PROPERTIES:
12219 :DESCRIPTION: A complete presentation.
12220 :END:
12222 Here is an example of an Org document ready for Beamer export.
12224 #+begin_example
12225 ;#+TITLE: Example Presentation
12226 ;#+AUTHOR: Carsten Dominik
12227 ;#+OPTIONS: H:2 toc:t num:t
12228 ;#+LATEX_CLASS: beamer
12229 ;#+LATEX_CLASS_OPTIONS: [presentation]
12230 ;#+BEAMER_THEME: Madrid
12231 ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12233 ,* This is the first structural section
12235 ,** Frame 1
12236 ,*** Thanks to Eric Fraga                                           :B_block:
12237     :PROPERTIES:
12238     :BEAMER_COL: 0.48
12239     :BEAMER_ENV: block
12240     :END:
12241     for the first viable Beamer setup in Org
12242 ,*** Thanks to everyone else                                        :B_block:
12243     :PROPERTIES:
12244     :BEAMER_COL: 0.48
12245     :BEAMER_ACT: <2->
12246     :BEAMER_ENV: block
12247     :END:
12248     for contributing to the discussion
12249 ,**** This will be formatted as a beamer note                       :B_note:
12250      :PROPERTIES:
12251      :BEAMER_env: note
12252      :END:
12253 ,** Frame 2 (where we will not use columns)
12254 ,*** Request
12255     Please test this stuff!
12256 #+end_example
12258 ** HTML Export
12259 :PROPERTIES:
12260 :DESCRIPTION: Exporting to HTML.
12261 :END:
12262 #+cindex: HTML export
12264 Org mode contains an HTML exporter with extensive HTML formatting
12265 compatible with XHTML 1.0 strict standard.
12267 *** HTML export commands
12268 :PROPERTIES:
12269 :DESCRIPTION: Invoking HTML export.
12270 :END:
12272 - {{{kbd(C-c C-e h h)}}} (~org-html-export-to-html~) ::
12273      #+kindex: C-c C-e h h
12274      #+kindex: C-c C-e h o
12275      #+findex: org-html-export-to-html
12277      Export as HTML file with a =.html= extension.  For =myfile.org=,
12278      Org exports to =myfile.html=, overwriting without warning.
12279      {{{kbd{C-c C-e h o)}}} exports to HTML and opens it in a web
12280      browser.
12282 - {{{kbd(C-c C-e h H)}}} (~org-html-export-as-html~) ::
12283      #+kindex: C-c C-e h H
12284      #+findex: org-html-export-as-html
12286      Exports to a temporary buffer.  Does not create a file.
12288 *** HTML specific export settings
12289 :PROPERTIES:
12290 :DESCRIPTION: Settings for HTML export.
12291 :END:
12293 HTML export has a number of keywords, similar to the general options
12294 settings described in [[*Export Settings]].
12296 - =DESCRIPTION= ::
12298      #+cindex: @samp{DESCRIPTION}, keyword
12299      This is the document's description, which the HTML exporter
12300      inserts it as a HTML meta tag in the HTML file.  For long
12301      descriptions, use multiple =DESCRIPTION= lines.  The exporter
12302      takes care of wrapping the lines properly.
12304 - =HTML_DOCTYPE= ::
12306      #+cindex: @samp{HTML_DOCTYPE}, keyword
12307      #+vindex: org-html-doctype
12308      Specify the document type, for example: HTML5
12309      (~org-html-doctype~).
12311 - =HTML_CONTAINER= ::
12313      #+cindex: @samp{HTML_CONTAINER}, keyword
12314      #+vindex: org-html-container-element
12315      Specify the HTML container, such as =div=, for wrapping sections
12316      and elements (~org-html-container-element~).
12318 - =HTML_LINK_HOME= ::
12320      #+cindex: @samp{HTML_LINK_HOME}, keyword
12321      #+vindex: org-html-link-home
12322      The URL for home link (~org-html-link-home~).
12324 - =HTML_LINK_UP= ::
12326      #+cindex: @samp{HTML_LINK_UP}, keyword
12327      #+vindex: org-html-link-up
12328      The URL for the up link of exported HTML pages
12329      (~org-html-link-up~).
12331 - =HTML_MATHJAX= ::
12333      #+cindex: @samp{HTML_MATHJAX}, keyword
12334      #+vindex: org-html-mathjax-options
12335      Options for MathJax (~org-html-mathjax-options~).  MathJax is
12336      used to typeset LaTeX math in HTML documents.  See [[*Math
12337      formatting in HTML export]], for an example.
12339 - =HTML_HEAD= ::
12341      #+cindex: @samp{HTML_HEAD}, keyword
12342      #+vindex: org-html-head
12343      Arbitrary lines for appending to the HTML document's head
12344      (~org-html-head~).
12346 - =HTML_HEAD_EXTRA= ::
12348      #+cindex: @samp{HTML_HEAD_EXTRA}, keyword
12349      #+vindex: org-html-head-extra
12350      More arbitrary lines for appending to the HTML document's head
12351      (~org-html-head-extra~).
12353 - =KEYWORDS= ::
12355      #+cindex: @samp{KEYWORDS}, keyword
12356      Keywords to describe the document's content.  HTML exporter
12357      inserts these keywords as HTML meta tags.  For long keywords, use
12358      multiple =KEYWORDS= lines.
12360 - =LATEX_HEADER= ::
12362      #+cindex: @samp{LATEX_HEADER}, keyword
12363      Arbitrary lines for appending to the preamble; HTML exporter
12364      appends when transcoding LaTeX fragments to images (see [[*Math
12365      formatting in HTML export]]).
12367 - =SUBTITLE= ::
12369      #+cindex: @samp{SUBTITLE}, keyword
12370      The document's subtitle.  HTML exporter formats subtitle if
12371      document type is =HTML5= and the CSS has a =subtitle= class.
12373 Some of these keywords are explained in more detail in the following
12374 sections of the manual.
12376 *** HTML doctypes
12377 :PROPERTIES:
12378 :DESCRIPTION: Exporting various (X)HTML flavors.
12379 :END:
12381 Org can export to various (X)HTML flavors.
12383 #+vindex: org-html-doctype
12384 #+vindex: org-html-doctype-alist
12385 Set the ~org-html-doctype~ variable for different (X)HTML variants.
12386 Depending on the variant, the HTML exporter adjusts the syntax of HTML
12387 conversion accordingly.  Org includes the following ready-made
12388 variants:
12390 - ~"html4-strict"~
12391 - ~"html4-transitional"~
12392 - ~"html4-frameset"~
12393 - ~"xhtml-strict"~
12394 - ~"xhtml-transitional"~
12395 - ~"xhtml-frameset"~
12396 - ~"xhtml-11"~
12397 - ~"html5"~
12398 - ~"xhtml5"~
12400 #+texinfo: @noindent
12401 See the variable ~org-html-doctype-alist~ for details.  The default is
12402 ~"xhtml-strict"~.
12404 #+vindex: org-html-html5-fancy
12405 #+cindex: @samp{HTML5}, export new elements
12406 Org's HTML exporter does not by default enable new block elements
12407 introduced with the HTML5 standard.  To enable them, set
12408 ~org-html-html5-fancy~ to non-~nil~.  Or use an =OPTIONS= line in the
12409 file to set =html5-fancy=.
12411 HTML5 documents can now have arbitrary =#+BEGIN= ... =#+END= blocks.
12412 For example:
12414 #+begin_example
12415 ,#+BEGIN_aside
12416   Lorem ipsum
12417 ,#+END_aside
12418 #+end_example
12420 #+texinfo: @noindent
12421 exports to:
12423 #+begin_src html
12424 <aside>
12425   <p>Lorem ipsum</p>
12426 </aside>
12427 #+end_src
12429 #+texinfo: @noindent
12430 while this:
12432 #+begin_example
12433 ,#+ATTR_HTML: :controls controls :width 350
12434 ,#+BEGIN_video
12435 ,#+HTML: <source src="movie.mp4" type="video/mp4">
12436 ,#+HTML: <source src="movie.ogg" type="video/ogg">
12437 Your browser does not support the video tag.
12438 ,#+END_video
12439 #+end_example
12441 #+texinfo: @noindent
12442 exports to:
12444 #+begin_src html
12445 <video controls="controls" width="350">
12446   <source src="movie.mp4" type="video/mp4">
12447     <source src="movie.ogg" type="video/ogg">
12448       <p>Your browser does not support the video tag.</p>
12449 </video>
12450 #+end_src
12452 #+vindex: org-html-html5-elements
12453 When special blocks do not have a corresponding HTML5 element, the
12454 HTML exporter reverts to standard translation (see
12455 ~org-html-html5-elements~).  For example, =#+BEGIN_lederhosen= exports
12456 to ~<div class="lederhosen">~.
12458 Special blocks cannot have headlines.  For the HTML exporter to wrap
12459 the headline and its contents in ~<section>~ or ~<article>~ tags, set
12460 the =HTML_CONTAINER= property for the headline.
12462 *** HTML preamble and postamble
12463 :PROPERTIES:
12464 :DESCRIPTION: Inserting preamble and postamble.
12465 :END:
12466 #+vindex: org-html-preamble
12467 #+vindex: org-html-postamble
12468 #+vindex: org-html-preamble-format
12469 #+vindex: org-html-postamble-format
12470 #+vindex: org-html-validation-link
12471 #+vindex: org-export-creator-string
12472 #+vindex: org-export-time-stamp-file
12474 The HTML exporter has delineations for preamble and postamble.  The
12475 default value for ~org-html-preamble~ is ~t~, which makes the HTML
12476 exporter insert the preamble.  See the variable
12477 ~org-html-preamble-format~ for the format string.
12479 Set ~org-html-preamble~ to a string to override the default format
12480 string.  If the string is a function, the HTML exporter expects the
12481 function to return a string upon execution.  The HTML exporter inserts
12482 this string in the preamble.  The HTML exporter does not insert
12483 a preamble if ~org-html-preamble~ is set ~nil~.
12485 The default value for ~org-html-postamble~ is ~auto~, which makes the
12486 HTML exporter build a postamble from looking up author's name, email
12487 address, creator's name, and date.  Set ~org-html-postamble~ to ~t~ to
12488 insert the postamble in the format specified in the
12489 ~org-html-postamble-format~ variable.  The HTML exporter does not
12490 insert a postamble if ~org-html-postamble~ is set to ~nil~.
12492 *** Quoting HTML tags
12493 :PROPERTIES:
12494 :DESCRIPTION: Using direct HTML in Org files.
12495 :END:
12497 The HTML export back-end transforms =<= and =>= to =&lt;= and =&gt;=.
12499 To include raw HTML code in the Org file so the HTML export back-end
12500 can insert that HTML code in the output, use this inline syntax:
12501 =@@html:...@@=.  For example:
12503 : @@html:<b>@@bold text@@html:</b>@@
12505 #+cindex: @samp{HTML}, keyword
12506 #+cindex: @samp{BEGIN_EXPORT html}
12507 For larger raw HTML code blocks, use these HTML export code blocks:
12509 #+begin_example
12510 ,#+HTML: Literal HTML code for export
12512 ,#+BEGIN_EXPORT html
12513   All lines between these markers are exported literally
12514 ,#+END_EXPORT
12515 #+end_example
12517 *** Links in HTML export
12518 :PROPERTIES:
12519 :DESCRIPTION: Inserting and formatting links.
12520 :END:
12521 #+cindex: links, in HTML export
12522 #+cindex: internal links, in HTML export
12523 #+cindex: external links, in HTML export
12525 The HTML export back-end transforms Org's internal links (see
12526 [[*Internal Links]]) to equivalent HTML links in the output.  The back-end
12527 similarly handles Org's automatic links created by radio targets (see
12528 [[*Radio Targets]]) similarly.  For Org links to external files, the
12529 back-end transforms the links to /relative/ paths.
12531 #+vindex: org-html-link-org-files-as-html
12532 For Org links to other =.org= files, the back-end automatically
12533 changes the file extension to =.html= and makes file paths relative.
12534 If the =.org= files have an equivalent =.html= version at the same
12535 location, then the converted links should work without any further
12536 manual intervention.  However, to disable this automatic path
12537 translation, set ~org-html-link-org-files-as-html~ to ~nil~.  When
12538 disabled, the HTML export back-end substitutes the ID-based links in
12539 the HTML output.  For more about linking files when publishing to
12540 a directory, see [[*Publishing links]].
12542 Org files can also have special directives to the HTML export
12543 back-end.  For example, by using =#+ATTR_HTML= lines to specify new
12544 format attributes to ~<a>~ or ~<img>~ tags.  This example shows
12545 changing the link's title and style:
12547 #+cindex: @samp{ATTR_HTML}, keyword
12548 #+begin_example
12549 ,#+ATTR_HTML: :title The Org mode homepage :style color:red;
12550 [[https://orgmode.org]]
12551 #+end_example
12553 *** Tables in HTML export
12554 :PROPERTIES:
12555 :DESCRIPTION: How to modify the formatting of tables.
12556 :END:
12557 #+cindex: tables, in HTML
12558 #+vindex: org-export-html-table-tag
12560 The HTML export back-end uses ~org-html-table-default-attributes~ when
12561 exporting Org tables to HTML.  By default, the exporter does not draw
12562 frames and cell borders.  To change for this for a table, use the
12563 following lines before the table in the Org file:
12565 #+cindex: @samp{CAPTION}, keyword
12566 #+cindex: @samp{ATTR_HTML}, keyword
12567 #+begin_example
12568 ,#+CAPTION: This is a table with lines around and between cells
12569 ,#+ATTR_HTML: border="2" rules="all" frame="border"
12570 #+end_example
12572 The HTML export back-end preserves column groupings in Org tables (see
12573 [[*Column Groups]]) when exporting to HTML.
12575 Additional options for customizing tables for HTML export.
12577 - ~org-html-table-align-individual-fields~ ::
12579      #+vindex: org-html-table-align-individual-fields
12580      Non-~nil~ attaches style attributes for alignment to each table
12581      field.
12583 - ~org-html-table-caption-above~ ::
12585      #+vindex: org-html-table-caption-above
12586      Non-~nil~ places caption string at the beginning of the table.
12588 - ~org-html-table-data-tags~ ::
12590      #+vindex: org-html-table-data-tags
12591      Opening and ending tags for table data fields.
12593 - ~org-html-table-default-attributes~ ::
12595      #+vindex: org-html-table-default-attributes
12596      Default attributes and values for table tags.
12598 - ~org-html-table-header-tags~ ::
12600      #+vindex: org-html-table-header-tags
12601      Opening and ending tags for table's header fields.
12603 - ~org-html-table-row-tags~ ::
12605      #+vindex: org-html-table-row-tags
12606      Opening and ending tags for table rows.
12608 - ~org-html-table-use-header-tags-for-first-column~ ::
12610      #+vindex: org-html-table-use-header-tags-for-first-column
12611      Non-~nil~ formats column one in tables with header tags.
12613 *** Images in HTML export
12614 :PROPERTIES:
12615 :DESCRIPTION: How to insert figures into HTML output.
12616 :END:
12617 #+cindex: images, inline in HTML
12618 #+cindex: inlining images in HTML
12620 The HTML export back-end has features to convert Org image links to
12621 HTML inline images and HTML clickable image links.
12623 #+vindex: org-html-inline-images
12624 When the link in the Org file has no description, the HTML export
12625 back-end by default in-lines that image.  For example:
12626 =[[file:myimg.jpg]]= is in-lined, while =[[file:myimg.jpg][the image]]= links to the text,
12627 =the image=.  For more details, see the variable
12628 ~org-html-inline-images~.
12630 On the other hand, if the description part of the Org link is itself
12631 another link, such as =file:= or =http:= URL pointing to an image, the
12632 HTML export back-end in-lines this image and links to the main image.
12633 This Org syntax enables the back-end to link low-resolution thumbnail
12634 to the high-resolution version of the image, as shown in this example:
12636 : [[file:highres.jpg][file:thumb.jpg]]
12638 To change attributes of in-lined images, use =#+ATTR_HTML= lines in
12639 the Org file.  This example shows realignment to right, and adds ~alt~
12640 and ~title~ attributes in support of text viewers and modern web
12641 accessibility standards.
12643 #+cindex: @samp{CAPTION}, keyword
12644 #+cindex: @samp{ATTR_HTML}, keyword
12645 #+begin_example
12646 ,#+CAPTION: A black cat stalking a spider
12647 ,#+ATTR_HTML: :alt cat/spider image :title Action! :align right
12648 [[./img/a.jpg]]
12649 #+end_example
12651 #+texinfo: @noindent
12652 The HTML export back-end copies the =http= links from the Org file as
12655 *** Math formatting in HTML export
12656 :PROPERTIES:
12657 :DESCRIPTION: Beautiful math also on the web.
12658 :END:
12659 #+cindex: MathJax
12660 #+cindex: dvipng
12661 #+cindex: dvisvgm
12662 #+cindex: ImageMagick
12664 #+vindex: org-html-mathjax-options~
12665 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
12666 different ways on HTML pages.  The default is to use the [[http://www.mathjax.org][MathJax]],
12667 which should work out of the box with Org[fn:119].  Some MathJax
12668 display options can be configured via ~org-html-mathjax-options~, or
12669 in the buffer.  For example, with the following settings,
12671 #+begin_example
12672 ,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
12673 ,#+HTML_MATHJAX: cancel.js noErrors.js
12674 #+end_example
12676 #+texinfo: @noindent
12677 equation labels are displayed on the left margin and equations are
12678 five em from the left margin.  In addition, it loads the two MathJax
12679 extensions =cancel.js= and =noErrors.js=[fn:120].
12681 #+vindex: org-html-mathjax-template
12682 See the docstring of ~org-html-mathjax-options~ for all supported
12683 variables.  The MathJax template can be configure via
12684 ~org-html-mathjax-template~.
12686 If you prefer, you can also request that LaTeX fragments are processed
12687 into small images that will be inserted into the browser page.  Before
12688 the availability of MathJax, this was the default method for Org
12689 files.  This method requires that the dvipng program, dvisvgm or
12690 ImageMagick suite is available on your system.  You can still get this
12691 processing with
12693 : #+OPTIONS: tex:dvipng
12695 : #+OPTIONS: tex:dvisvgm
12697 #+texinfo: @noindent
12700 : #+OPTIONS: tex:imagemagick
12702 *** Text areas in HTML export
12703 :PROPERTIES:
12704 :DESCRIPTION: An alternate way to show an example.
12705 :END:
12707 #+cindex: text areas, in HTML
12708 Before Org mode's Babel, one popular approach to publishing code in
12709 HTML was by using =:textarea=.  The advantage of this approach was
12710 that copying and pasting was built into browsers with simple
12711 JavaScript commands.  Even editing before pasting was made simple.
12713 The HTML export back-end can create such text areas.  It requires an
12714 =#+ATTR_HTML= line as shown in the example below with the =:textarea=
12715 option.  This must be followed by either an example or a source code
12716 block.  Other Org block types do not honor the =:textarea= option.
12718 By default, the HTML export back-end creates a text area 80 characters
12719 wide and height just enough to fit the content.  Override these
12720 defaults with =:width= and =:height= options on the =#+ATTR_HTML=
12721 line.
12723 #+begin_example
12724 ,#+ATTR_HTML: :textarea t :width 40
12725 ,#+BEGIN_EXAMPLE
12726   (defun org-xor (a b)
12727      "Exclusive or."
12728      (if a (not b) b))
12729 ,#+END_EXAMPLE
12730 #+end_example
12732 *** CSS support
12733 :PROPERTIES:
12734 :DESCRIPTION: Changing the appearance of the output.
12735 :END:
12736 #+cindex: CSS, for HTML export
12737 #+cindex: HTML export, CSS
12739 #+vindex: org-export-html-todo-kwd-class-prefix
12740 #+vindex: org-export-html-tag-class-prefix
12741 You can modify the CSS style definitions for the exported file.  The
12742 HTML exporter assigns the following special CSS classes[fn:121] to
12743 appropriate parts of the document---your style specifications may
12744 change these, in addition to any of the standard classes like for
12745 headlines, tables, etc.
12747 | ~p.author~           | author information, including email                    |
12748 | ~p.date~             | publishing date                                        |
12749 | ~p.creator~          | creator info, about org mode version                   |
12750 | ~.title~             | document title                                         |
12751 | ~.subtitle~          | document subtitle                                      |
12752 | ~.todo~              | TODO keywords, all not-done states                     |
12753 | ~.done~              | the DONE keywords, all states that count as done       |
12754 | ~.WAITING~           | each TODO keyword also uses a class named after itself |
12755 | ~.timestamp~         | timestamp                                              |
12756 | ~.timestamp-kwd~     | keyword associated with a timestamp, like =SCHEDULED=  |
12757 | ~.timestamp-wrapper~ | span around keyword plus timestamp                     |
12758 | ~.tag~               | tag in a headline                                      |
12759 | ~._HOME~             | each tag uses itself as a class, "@" replaced by "_"   |
12760 | ~.target~            | target for links                                       |
12761 | ~.linenr~            | the line number in a code example                      |
12762 | ~.code-highlighted~  | for highlighting referenced code lines                 |
12763 | ~div.outline-N~      | div for outline level N (headline plus text)           |
12764 | ~div.outline-text-N~ | extra div for text at outline level N                  |
12765 | ~.section-number-N~  | section number in headlines, different for each level  |
12766 | ~.figure-number~     | label like "Figure 1:"                                 |
12767 | ~.table-number~      | label like "Table 1:"                                  |
12768 | ~.listing-number~    | label like "Listing 1:"                                |
12769 | ~div.figure~         | how to format an in-lined image                        |
12770 | ~pre.src~            | formatted source code                                  |
12771 | ~pre.example~        | normal example                                         |
12772 | ~p.verse~            | verse paragraph                                        |
12773 | ~div.footnotes~      | footnote section headline                              |
12774 | ~p.footnote~         | footnote definition paragraph, containing a footnote   |
12775 | ~.footref~           | a footnote reference number (always a <sup>)           |
12776 | ~.footnum~           | footnote number in footnote definition (always <sup>)  |
12777 | ~.org-svg~           | default class for a linked =.svg= image                |
12779 #+vindex: org-html-style-default
12780 #+vindex: org-html-head
12781 #+vindex: org-html-head-extra
12782 #+cindex: @samp{HTML_INCLUDE_STYLE}, keyword
12783 The HTML export back-end includes a compact default style in each
12784 exported HTML file.  To override the default style with another style,
12785 use these keywords in the Org file.  They will replace the global
12786 defaults the HTML exporter uses.
12788 #+cindex: @samp{HTML_HEAD}, keyword
12789 #+cindex: @samp{HTML_HEAD_EXTRA}, keyword
12790 #+begin_example
12791 ,#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
12792 ,#+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
12793 #+end_example
12795 #+vindex: org-html-head-include-default-style
12796 To just turn off the default style, customize
12797 ~org-html-head-include-default-style~ variable, or use this option
12798 line in the Org file.
12800 #+cindex: @samp{html-style}, @samp{OPTIONS} item
12801 : #+OPTIONS: html-style:nil
12803 For longer style definitions, either use several =HTML_HEAD= and
12804 =HTML_HEAD_EXTRA= keywords, or use ~<style> ... </style>~ blocks
12805 around them.  Both of these approaches can avoid referring to an
12806 external file.
12808 #+cindex: @samp{HTML_CONTAINER_CLASS}, property
12809 In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS=
12810 property to assign a class to the tree.  In order to specify CSS
12811 styles for a particular headline, you can use the id specified in
12812 a =CUSTOM_ID= property.
12814 Never change the ~org-html-style-default~ constant.  Instead use other
12815 simpler ways of customizing as described above.
12817 *** JavaScript supported display of web pages
12818 :PROPERTIES:
12819 :DESCRIPTION: Info and folding in a web browser.
12820 :ALT_TITLE: JavaScript support
12821 :END:
12823 Sebastian Rose has written a JavaScript program especially designed to
12824 enhance the web viewing experience of HTML files created with Org.
12825 This program enhances large files in two different ways of viewing.
12826 One is an /Info/-like mode where each section is displayed separately
12827 and navigation can be done with the {{{kbd(n)}}} and {{{kbd(p)}}}
12828 keys, and some other keys as well, press {{{kbd(?)}}} for an overview
12829 of the available keys.  The second one has a /folding/ view, much like
12830 Org provides inside Emacs.  The script is available at
12831 https://orgmode.org/org-info.js and the documentation at
12832 https://orgmode.org/worg/code/org-info-js/.  The script is hosted on
12833 https://orgmode.org, but for reliability, prefer installing it on your
12834 own web server.
12836 To use this program, just add this line to the Org file:
12838 #+cindex: @samp{INFOJS_OPT}, keyword
12839 : #+INFOJS_OPT: view:info toc:nil
12841 #+texinfo: @noindent
12842 The HTML header now has the code needed to automatically invoke the
12843 script.  For setting options, use the syntax from the above line for
12844 options described below:
12846 - =path:= ::
12848      The path to the script.  The default is to grab the script from
12849      [[https://orgmode.org/org-info.js]], but you might want to have
12850      a local copy and use a path like =../scripts/org-info.js=.
12852 - =view:= ::
12854      Initial view when the website is first shown.  Possible values are:
12856      | =info=     | Info-like interface with one section per page          |
12857      | =overview= | Folding interface, initially showing only top-level    |
12858      | =content=  | Folding interface, starting with all headlines visible |
12859      | =showall=  | Folding interface, all headlines and text visible      |
12861 - =sdepth:= ::
12863      Maximum headline level still considered as an independent section
12864      for info and folding modes.  The default is taken from
12865      ~org-export-headline-levels~, i.e., the =H= switch in =OPTIONS=.
12866      If this is smaller than in ~org-export-headline-levels~, each
12867      info/folding section can still contain child headlines.
12869 - =toc:= ::
12871      Should the table of contents /initially/ be visible?  Even when
12872      =nil=, you can always get to the "toc" with {{{kbd(i)}}}.
12874 - =tdepth:= ::
12876      The depth of the table of contents.  The defaults are taken from
12877      the variables ~org-export-headline-levels~ and
12878      ~org-export-with-toc~.
12880 - =ftoc:= ::
12882      Does the CSS of the page specify a fixed position for the "toc"?
12883      If yes, the toc is displayed as a section.
12885 - =ltoc:= ::
12887      Should there be short contents (children) in each section?  Make
12888      this =above= if the section should be above initial text.
12890 - =mouse:= ::
12892      Headings are highlighted when the mouse is over them.  Should be
12893      =underline= (default) or a background color like =#cccccc=.
12895 - =buttons:= ::
12897      Should view-toggle buttons be everywhere?  When =nil= (the
12898      default), only one such button is present.
12900 #+texinfo: @noindent
12901 #+vindex: org-infojs-options
12902 #+vindex: org-export-html-use-infojs
12903 You can choose default values for these options by customizing the
12904 variable ~org-infojs-options~.  If you always want to apply the script
12905 to your pages, configure the variable ~org-export-html-use-infojs~.
12907 ** LaTeX Export
12908 :PROPERTIES:
12909 :DESCRIPTION: Exporting to @LaTeX{} and processing to PDF.
12910 :END:
12911 #+cindex: @LaTeX{} export
12912 #+cindex: PDF export
12914 The LaTeX export back-end can handle complex documents, incorporate
12915 standard or custom LaTeX document classes, generate documents using
12916 alternate LaTeX engines, and produce fully linked PDF files with
12917 indexes, bibliographies, and tables of contents, destined for
12918 interactive online viewing or high-quality print publication.
12920 While the details are covered in-depth in this section, here are some
12921 quick references to variables for the impatient: for engines, see
12922 ~org-latex-compiler~; for build sequences, see
12923 ~org-latex-pdf-process~; for packages, see
12924 ~org-latex-default-packages-alist~ and ~org-latex-packages-alist~.
12926 An important note about the LaTeX export back-end: it is sensitive to
12927 blank lines in the Org document.  That's because LaTeX itself depends
12928 on blank lines to tell apart syntactical elements, such as paragraphs.
12930 *** LaTeX/PDF export commands
12931 :PROPERTIES:
12932 :DESCRIPTION: For producing @LaTeX{} and PDF documents.
12933 :END:
12935 - {{{kbd(C-c C-e l l)}}} (~org-latex-export-to-latex~) ::
12937      #+kindex: C-c C-e l l
12938      #+findex: org-latex-export-to-latex~
12939      Export to a LaTeX file with a =.tex= extension.  For
12940      =myfile.org=, Org exports to =myfile.tex=, overwriting without
12941      warning.
12943 - {{{kbd(C-c C-e l L)}}} (~org-latex-export-as-latex~) ::
12945      #+kindex: C-c C-e l L
12946      #+findex: org-latex-export-as-latex
12947      Export to a temporary buffer.  Do not create a file.
12949 - {{{kbd(C-c C-e l p)}}} (~org-latex-export-to-pdf~) ::
12951      #+kindex: C-c C-e l p
12952      #+findex: org-latex-export-to-pdf
12953      Export as LaTeX file and convert it to PDF file.
12955 - {{{kbd(C-c C-e l o)}}} ::
12957      #+kindex: C-c C-e l o
12958      Export as LaTeX file and convert it to PDF, then open the PDF
12959      using the default viewer.
12961 - {{{kbd(M-x org-export-region-as-latex)}}} ::
12963      Convert the region to LaTeX under the assumption that it was in Org
12964      mode syntax before.  This is a global command that can be invoked in
12965      any buffer.
12967 #+vindex: org-latex-compiler
12968 #+vindex: org-latex-bibtex-compiler
12969 #+vindex: org-latex-default-packages-alist
12970 #+cindex: pdflatex
12971 #+cindex: xelatex
12972 #+cindex: lualatex
12973 #+cindex: @samp{LATEX_COMPILER}, keyword
12974 The LaTeX export back-end can use any of these LaTeX engines:
12975 =pdflatex=, =xelatex=, and =lualatex=.  These engines compile LaTeX
12976 files with different compilers, packages, and output options.  The
12977 LaTeX export back-end finds the compiler version to use from
12978 ~org-latex-compiler~ variable or the =#+LATEX_COMPILER= keyword in the
12979 Org file.  See the docstring for the
12980 ~org-latex-default-packages-alist~ for loading packages with certain
12981 compilers.  Also see ~org-latex-bibtex-compiler~ to set the
12982 bibliography compiler[fn:122].
12984 *** LaTeX specific export settings
12985 :PROPERTIES:
12986 :DESCRIPTION: Unique to this @LaTeX{} back-end.
12987 :END:
12989 The LaTeX export back-end has several additional keywords for
12990 customizing LaTeX output.  Setting these keywords works similar to the
12991 general options (see [[*Export Settings]]).
12993 #+attr_texinfo: :sep ,
12994 - =DESCRIPTION= ::
12995      #+cindex: @samp{DESCRIPTION}, keyword
12996      #+vindex: org-latex-hyperref-template
12997      #+vindex: org-latex-title-command
12998      The document's description.  The description along with author
12999      name, keywords, and related file metadata are inserted in the
13000      output file by the hyperref package.  See
13001      ~org-latex-hyperref-template~ for customizing metadata items.
13002      See ~org-latex-title-command~ for typesetting description into
13003      the document's front matter.  Use multiple =DESCRIPTION= keywords
13004      for long descriptions.
13006 - =LATEX_CLASS= ::
13008      #+cindex: @samp{LATEX_CLASS}, keyword
13009      #+vindex: org-latex-default-class
13010      #+vindex: org-latex-classes
13011      This is LaTeX document class, such as /article/, /report/,
13012      /book/, and so on, which contain predefined preamble and headline
13013      level mapping that the LaTeX export back-end needs.  The back-end
13014      reads the default class name from the ~org-latex-default-class~
13015      variable.  Org has /article/ as the default class.  A valid
13016      default class must be an element of ~org-latex-classes~.
13018 - =LATEX_CLASS_OPTIONS= ::
13020      #+cindex: @samp{LATEX_CLASS_OPTIONS}, keyword
13021      Options the LaTeX export back-end uses when calling the LaTeX
13022      document class.
13024 - =LATEX_COMPILER= ::
13026      #+cindex: @samp{LATEX_COMPILER}, keyword
13027      #+vindex: org-latex-compiler
13028      The compiler, such as =pdflatex=, =xelatex=, =lualatex=, for
13029      producing the PDF.  See ~org-latex-compiler~.
13031 - =LATEX_HEADER=, =LATEX_HEADER_EXTRA= ::
13033      #+cindex: @samp{LATEX_HEADER}, keyword
13034      #+cindex: @samp{LATEX_HEADER_EXTRA}, keyword
13035      #+vindex: org-latex-classes
13036      Arbitrary lines to add to the document's preamble, before the
13037      hyperref settings.  See ~org-latex-classes~ for adjusting the
13038      structure and order of the LaTeX headers.
13040 - =KEYWORDS= ::
13042      #+cindex: @samp{KEYWORDS}, keyword
13043      #+vindex: org-latex-hyperref-template
13044      #+vindex: org-latex-title-command
13045      The keywords for the document.  The description along with author
13046      name, keywords, and related file metadata are inserted in the
13047      output file by the hyperref package.  See
13048      ~org-latex-hyperref-template~ for customizing metadata items.
13049      See ~org-latex-title-command~ for typesetting description into
13050      the document's front matter.  Use multiple =KEYWORDS= lines if
13051      necessary.
13053 - =SUBTITLE= ::
13055      #+cindex: @samp{SUBTITLE}, keyword
13056      #+vindex: org-latex-subtitle-separate
13057      #+vindex: org-latex-subtitle-format
13058      The document's subtitle.  It is typeset as per
13059      ~org-latex-subtitle-format~.  If ~org-latex-subtitle-separate~ is
13060      non-~nil~, it is typed as part of the ~\title~ macro.  See
13061      ~org-latex-hyperref-template~ for customizing metadata items.
13062      See ~org-latex-title-command~ for typesetting description
13063      into the document's front matter.
13065 The following sections have further details.
13067 *** LaTeX header and sectioning structure
13068 :PROPERTIES:
13069 :DESCRIPTION: Setting up the export file structure.
13070 :ALT_TITLE: LaTeX header and sectioning
13071 :END:
13072 #+cindex: @LaTeX{} class
13073 #+cindex: @LaTeX{} sectioning structure
13074 #+cindex: @LaTeX{} header
13075 #+cindex: header, for @LaTeX{} files
13076 #+cindex: sectioning structure, for @LaTeX{} export
13078 The LaTeX export back-end converts the first three of Org's outline
13079 levels into LaTeX headlines.  The remaining Org levels are exported as
13080 lists.  To change this globally for the cut-off point between levels
13081 and lists, (see [[*Export Settings]]).
13083 By default, the LaTeX export back-end uses the /article/ class.
13085 #+vindex: org-latex-default-class
13086 #+vindex: org-latex-classes
13087 #+vindex: org-latex-default-packages-alist
13088 #+vindex: org-latex-packages-alist
13089 To change the default class globally, edit ~org-latex-default-class~.
13090 To change the default class locally in an Org file, add option lines
13091 =#+LATEX_CLASS: myclass=.  To change the default class for just a part
13092 of the Org file, set a sub-tree property, =EXPORT_LATEX_CLASS=.  The
13093 class name entered here must be valid member of ~org-latex-classes~.
13094 This variable defines a header template for each class into which the
13095 exporter splices the values of ~org-latex-default-packages-alist~ and
13096 ~org-latex-packages-alist~.  Use the same three variables to define
13097 custom sectioning or custom classes.
13099 #+cindex: @samp{LATEX_CLASS}, keyword
13100 #+cindex: @samp{LATEX_CLASS_OPTIONS}, keyword
13101 #+cindex: @samp{EXPORT_LATEX_CLASS}, property
13102 #+cindex: @samp{EXPORT_LATEX_CLASS_OPTIONS}, property
13103 The LaTeX export back-end sends the =LATEX_CLASS_OPTIONS= keyword and
13104 =EXPORT_LATEX_CLASS_OPTIONS= property as options to the LaTeX
13105 ~\documentclass~ macro.  The options and the syntax for specifying
13106 them, including enclosing them in square brackets, follow LaTeX
13107 conventions.
13109 : #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13111 #+cindex: @samp{LATEX_HEADER}, keyword
13112 #+cindex: @samp{LATEX_HEADER_EXTRA}, keyword
13113 The LaTeX export back-end appends values from =LATEX_HEADER= and
13114 =LATEX_HEADER_EXTRA= keywords to the LaTeX header.  The docstring for
13115 ~org-latex-classes~ explains in more detail.  Also note that LaTeX
13116 export back-end does not append =LATEX_HEADER_EXTRA= to the header
13117 when previewing LaTeX snippets (see [[*Previewing LaTeX fragments]]).
13119 A sample Org file with the above headers:
13121 #+begin_example
13122 ,#+LATEX_CLASS: article
13123 ,#+LATEX_CLASS_OPTIONS: [a4paper]
13124 ,#+LATEX_HEADER: \usepackage{xyz}
13126 ,* Headline 1
13127   some text
13128 ,* Headline 2
13129   some more text
13130 #+end_example
13132 *** Quoting LaTeX code
13133 :PROPERTIES:
13134 :DESCRIPTION: Incorporating literal @LaTeX{} code.
13135 :END:
13137 The LaTeX export back-end can insert any arbitrary LaTeX code, see
13138 [[*Embedded LaTeX]].  There are three ways to embed such code in the Org
13139 file and they all use different quoting syntax.
13141 #+cindex: inline, in @LaTeX{} export
13142 Inserting in-line quoted with @ symbols:
13144 : Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
13146 #+cindex: @samp{LATEX}, keyword
13147 Inserting as one or more keyword lines in the Org file:
13149 : #+LATEX: any arbitrary LaTeX code
13151 #+cindex: @samp{BEGIN_EXPORT latex}
13152 Inserting as an export block in the Org file, where the back-end
13153 exports any code between begin and end markers:
13155 #+begin_example
13156 ,#+BEGIN_EXPORT latex
13157   any arbitrary LaTeX code
13158 ,#+END_EXPORT
13159 #+end_example
13161 *** Tables in LaTeX export
13162 :PROPERTIES:
13163 :DESCRIPTION: Options for exporting tables to @LaTeX{}.
13164 :END:
13165 #+cindex: tables, in @LaTeX{} export
13167 The LaTeX export back-end can pass several LaTeX attributes for table
13168 contents and layout.  Besides specifying label and caption (see
13169 [[*Images and Tables]]), the other valid LaTeX attributes include:
13171 #+attr_texinfo: :sep ,
13172 - =:mode= ::
13174      #+vindex: org-latex-default-table-mode
13175      The LaTeX export back-end wraps the table differently depending
13176      on the mode for accurate rendering of math symbols.  Mode is
13177      either =table=, =math=, =inline-math= or =verbatim=.
13179      For =math= or =inline-math= mode, LaTeX export back-end wraps the
13180      table in a math environment, but every cell in it is exported
13181      as-is.  The LaTeX export back-end determines the default mode
13182      from ~org-latex-default-table-mode~.  The LaTeX export back-end
13183      merges contiguous tables in the same mode into a single
13184      environment.
13186 - =:environment= ::
13188      #+vindex: org-latex-default-table-environment
13189      Set the default LaTeX table environment for the LaTeX export
13190      back-end to use when exporting Org tables.  Common LaTeX table
13191      environments are provided by these packages: tabularx, longtable,
13192      array, tabu, and bmatrix.  For packages, such as tabularx and
13193      tabu, or any newer replacements, include them in the
13194      ~org-latex-packages-alist~ variable so the LaTeX export back-end
13195      can insert the appropriate load package headers in the converted
13196      LaTeX file.  Look in the docstring for the
13197      ~org-latex-packages-alist~ variable for configuring these
13198      packages for LaTeX snippet previews, if any.
13200 - =:caption= ::
13202      Use =CAPTION= keyword to set a simple caption for a table (see
13203      [[*Images and Tables]]).  For custom captions, use =:caption=
13204      attribute, which accepts raw LaTeX code.  =:caption= value
13205      overrides =CAPTION= value.
13207 - =:float=, =:placement= ::
13209      The table environments by default are not floats in LaTeX.  To
13210      make them floating objects use =:float= with one of the following
13211      options: =sideways=, =multicolumn=, =t=, and =nil=.
13213      LaTeX floats can also have additional layout =:placement=
13214      attributes.  These are the usual =[h t b p ! H]= permissions
13215      specified in square brackets.  Note that for =:float sideways=
13216      tables, the LaTeX export back-end ignores =:placement=
13217      attributes.
13219 - =:align=, =:font=, =:width= ::
13221      The LaTeX export back-end uses these attributes for regular
13222      tables to set their alignments, fonts, and widths.
13224 - =:spread= ::
13226      When =:spread= is non-~nil~, the LaTeX export back-end spreads or
13227      shrinks the table by the =:width= for tabu and longtabu
13228      environments.  =:spread= has no effect if =:width= is not set.
13230 - =:booktabs=, =:center=, =:rmlines= ::
13232      #+vindex: org-latex-tables-booktabs
13233      #+vindex: org-latex-tables-centered
13234      All three commands are toggles.  =:booktabs= brings in modern
13235      typesetting enhancements to regular tables.  The booktabs package
13236      has to be loaded through ~org-latex-packages-alist~.  =:center=
13237      is for centering the table.  =:rmlines= removes all but the very
13238      first horizontal line made of ASCII characters from "table.el"
13239      tables only.
13241 - =:math-prefix=, =:math-suffix=, =:math-arguments= ::
13243      The LaTeX export back-end inserts =:math-prefix= string value in
13244      a math environment before the table.  The LaTeX export back-end
13245      inserts =:math-suffix= string value in a math environment after
13246      the table.  The LaTeX export back-end inserts =:math-arguments=
13247      string value between the macro name and the table's contents.
13248      =:math-arguments= comes in use for matrix macros that require
13249      more than one argument, such as =qbordermatrix=.
13251 LaTeX table attributes help formatting tables for a wide range of
13252 situations, such as matrix product or spanning multiple pages:
13254 #+begin_example
13255 ,#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
13256 | ... | ... |
13257 | ... | ... |
13259 ,#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13260 | a | b |
13261 | c | d |
13262 ,#+ATTR_LATEX: :mode math :environment bmatrix
13263 | 1 | 2 |
13264 | 3 | 4 |
13265 #+end_example
13267 Set the caption with the LaTeX command
13268 =\bicaption{HeadingA}{HeadingB}=:
13270 #+begin_example
13271 ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13272 | ... | ... |
13273 | ... | ... |
13274 #+end_example
13276 *** Images in LaTeX export
13277 :PROPERTIES:
13278 :DESCRIPTION: How to insert figures into @LaTeX{} output.
13279 :END:
13280 #+cindex: images, inline in LaTeX
13281 #+cindex: inlining images in LaTeX
13282 #+cindex: @samp{ATTR_LATEX}, keyword
13284 The LaTeX export back-end processes image links in Org files that do
13285 not have descriptions, such as these links =[[file:img.jpg]]= or
13286 =[[./img.jpg]]=, as direct image insertions in the final PDF output.  In
13287 the PDF, they are no longer links but actual images embedded on the
13288 page.  The LaTeX export back-end uses =\includegraphics= macro to
13289 insert the image.  But for TikZ (http://sourceforge.net/projects/pgf/)
13290 images, the back-end uses an ~\input~ macro wrapped within
13291 a ~tikzpicture~ environment.
13293 For specifying image =:width=, =:height=, and other =:options=, use
13294 this syntax:
13296 #+begin_example
13297 ,#+ATTR_LATEX: :width 5cm :options angle=90
13298 [[./img/sed-hr4049.pdf]]
13299 #+end_example
13301 For custom commands for captions, use the =:caption= attribute.  It
13302 overrides the default =#+CAPTION= value:
13304 #+begin_example
13305 ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13306 [[./img/sed-hr4049.pdf]]
13307 #+end_example
13309 When captions follow the method as described in [[*Images and Tables]],
13310 the LaTeX export back-end wraps the picture in a floating =figure=
13311 environment.  To float an image without specifying a caption, set the
13312 =:float= attribute to one of the following:
13314 - =t= ::
13316      For a standard =figure= environment; used by default whenever an
13317      image has a caption.
13319 - =multicolumn= ::
13321      To span the image across multiple columns of a page; the back-end
13322      wraps the image in a =figure*= environment.
13324 - =wrap= ::
13326      For text to flow around the image on the right; the figure
13327      occupies the left half of the page.
13329 - =sideways= ::
13331      For a new page with the image sideways, rotated ninety degrees,
13332      in a =sidewaysfigure= environment; overrides =:placement=
13333      setting.
13335 - =nil= ::
13337      To avoid a =:float= even if using a caption.
13339 #+texinfo: @noindent
13340 Use the =placement= attribute to modify a floating environment's
13341 placement.
13343 #+begin_example
13344 ,#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth}
13345 [[./img/hst.png]]
13346 #+end_example
13348 #+vindex: org-latex-images-centered
13349 #+cindex: center image in LaTeX export
13350 #+cindex: image, centering in LaTeX export
13351 The LaTeX export back-end centers all images by default.  Setting
13352 =:center= to =nil= disables centering.  To disable centering globally,
13353 set ~org-latex-images-centered~ to =t=.
13355 Set the =:comment-include= attribute to non-~nil~ value for the LaTeX
13356 export back-end to comment out the =\includegraphics= macro.
13358 *** Plain lists in LaTeX export
13359 :PROPERTIES:
13360 :DESCRIPTION: Attributes specific to lists.
13361 :END:
13363 #+cindex: plain lists, in @LaTeX{} export
13364 #+cindex: @samp{ATTR_LATEX}, keyword
13365 The LaTeX export back-end accepts the =environment= and =options=
13366 attributes for plain lists.  Both attributes work together for
13367 customizing lists, as shown in the examples:
13369 #+begin_example
13370 ,#+LATEX_HEADER: \usepackage[inline]{enumitem}
13371 Some ways to say "Hello":
13372 ,#+ATTR_LATEX: :environment itemize*
13373 ,#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}]
13374 - Hola
13375 - Bonjour
13376 - Guten Tag.
13377 #+end_example
13379 Since LaTeX supports only four levels of nesting for lists, use an
13380 external package, such as =enumitem= in LaTeX, for levels deeper than
13381 four:
13383 #+begin_example
13384 ,#+LATEX_HEADER: \usepackage{enumitem}
13385 ,#+LATEX_HEADER: \renewlist{itemize}{itemize}{9}
13386 ,#+LATEX_HEADER: \setlist[itemize]{label=$\circ$}
13387 - One
13388   - Two
13389     - Three
13390       - Four
13391         - Five
13392 #+end_example
13394 *** Source blocks in LaTeX export
13395 :PROPERTIES:
13396 :DESCRIPTION: Attributes specific to source code blocks.
13397 :END:
13398 #+cindex: source blocks, in @LaTeX{} export
13399 #+cindex: @samp{ATTR_LATEX}, keyword
13401 The LaTeX export back-end can make source code blocks into floating
13402 objects through the attributes =:float= and =:options=.  For =:float=:
13404 - =t= ::
13406      Makes a source block float; by default floats any source block
13407      with a caption.
13409 - =multicolumn= ::
13411      Spans the source block across multiple columns of a page.
13413 - =nil= ::
13415      Avoids a =:float= even if using a caption; useful for source code
13416      blocks that may not fit on a page.
13418 #+begin_example
13419 ,#+ATTR_LATEX: :float nil
13420 ,#+BEGIN_SRC emacs-lisp
13421   Lisp code that may not fit in a single page.
13422 ,#+END_SRC
13423 #+end_example
13425 #+vindex: org-latex-listings-options
13426 #+vindex: org-latex-minted-options
13427 The LaTeX export back-end passes string values in =:options= to LaTeX
13428 packages for customization of that specific source block.  In the
13429 example below, the =:options= are set for Minted.  Minted is a source
13430 code highlighting LaTeX package with many configurable options.
13432 #+begin_example
13433 ,#+ATTR_LATEX: :options commentstyle=\bfseries
13434 ,#+BEGIN_SRC emacs-lisp
13435   (defun Fib (n)
13436     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
13437 ,#+END_SRC
13438 #+end_example
13440 To apply similar configuration options for all source blocks in
13441 a file, use the ~org-latex-listings-options~ and
13442 ~org-latex-minted-options~ variables.
13444 *** Example blocks in LaTeX export
13445 :PROPERTIES:
13446 :DESCRIPTION: Attributes specific to example blocks.
13447 :END:
13448 #+cindex: example blocks, in @LaTeX{} export
13449 #+cindex: verbatim blocks, in @LaTeX{} export
13450 #+cindex: @samp{ATTR_LATEX}, keyword
13452 The LaTeX export back-end wraps the contents of example blocks in
13453 a =verbatim= environment.  To change this behavior to use another
13454 environment globally, specify an appropriate export filter (see
13455 [[*Advanced Configuration]]).  To change this behavior to use another
13456 environment for each block, use the =:environment= parameter to
13457 specify a custom environment.
13459 #+begin_example
13460 ,#+ATTR_LATEX: :environment myverbatim
13461 ,#+BEGIN_EXAMPLE
13462   This sentence is false.
13463 ,#+END_EXAMPLE
13464 #+end_example
13466 *** Special blocks in LaTeX export
13467 :PROPERTIES:
13468 :DESCRIPTION: Attributes specific to special blocks.
13469 :END:
13471 #+cindex: special blocks, in @LaTeX{} export
13472 #+cindex: abstract, in @LaTeX{} export
13473 #+cindex: proof, in @LaTeX{} export
13474 #+cindex: @samp{ATTR_LATEX}, keyword
13476 For other special blocks in the Org file, the LaTeX export back-end
13477 makes a special environment of the same name.  The back-end also takes
13478 =:options=, if any, and appends as-is to that environment's opening
13479 string.  For example:
13481 #+begin_example
13482 ,#+BEGIN_abstract
13483   We demonstrate how to solve the Syracuse problem.
13484 ,#+END_abstract
13486 ,#+ATTR_LATEX: :options [Proof of important theorem]
13487 ,#+BEGIN_proof
13488   ...
13489   Therefore, any even number greater than 2 is the sum of two primes.
13490 ,#+END_proof
13491 #+end_example
13493 #+texinfo: @noindent
13494 exports to
13496 #+begin_example
13497 \begin{abstract}
13498   We demonstrate how to solve the Syracuse problem.
13499 \end{abstract}
13501 \begin{proof}[Proof of important theorem]
13502   ...
13503   Therefore, any even number greater than 2 is the sum of two primes.
13504 \end{proof}
13505 #+end_example
13507 If you need to insert a specific caption command, use =:caption=
13508 attribute.  It overrides standard =CAPTION= value, if any.  For
13509 example:
13511 #+begin_example
13512 ,#+ATTR_LATEX: :caption \MyCaption{HeadingA}
13513 ,#+BEGIN_proof
13514   ...
13515 ,#+END_proof
13516 #+end_example
13518 *** Horizontal rules in LaTeX export
13519 :PROPERTIES:
13520 :DESCRIPTION: Attributes specific to horizontal rules.
13521 :END:
13522 #+cindex: horizontal rules, in @LaTeX{} export
13523 #+cindex: @samp{ATTR_LATEX}, keyword
13525 The LaTeX export back-end converts horizontal rules by the specified
13526 =:width= and =:thickness= attributes.  For example:
13528 #+begin_example
13529 ,#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
13530 -----
13531 #+end_example
13533 ** Markdown Export
13534 :PROPERTIES:
13535 :DESCRIPTION: Exporting to Markdown.
13536 :END:
13537 #+cindex: Markdown export
13539 The Markdown export back-end, "md", converts an Org file to Markdown
13540 format, as defined at http://daringfireball.net/projects/markdown/.
13542 Since it is built on top of the HTML back-end (see [[*HTML Export]]), it
13543 converts every Org construct not defined in Markdown syntax, such as
13544 tables, to HTML.
13546 *** Markdown export commands
13547 :PROPERTIES:
13548 :UNNUMBERED: notoc
13549 :END:
13551 - {{{kbd(C-c C-e m m)}}} (~org-md-export-to-markdown~) ::
13553      #+kindex: C-c C-c m m
13554      #+findex: org-md-export-to-markdown
13555      Export to a text file with Markdown syntax.  For =myfile.org=,
13556      Org exports to =myfile.md=, overwritten without warning.
13558 - {{{kbd(C-c C-e m M)}}} (~org-md-export-as-markdown~) ::
13560      #+kindex: C-c C-c m M
13561      #+findex: org-md-export-as-markdown
13562      Export to a temporary buffer.  Does not create a file.
13564 - {{{kbd(C-c C-e m o)}}} ::
13566      #+kindex: C-c C-e m o
13567      Export as a text file with Markdown syntax, then open it.
13569 *** Header and sectioning structure
13570 :PROPERTIES:
13571 :UNNUMBERED: notoc
13572 :END:
13574 #+vindex: org-md-headline-style
13575 Based on ~org-md-headline-style~, Markdown export can generate
13576 headlines of both /atx/ and /setext/ types.  /atx/ limits headline
13577 levels to two whereas /setext/ limits headline levels to six.  Beyond
13578 these limits, the export back-end converts headlines to lists.  To set
13579 a limit to a level before the absolute limit (see [[*Export Settings]]).
13581 ** OpenDocument Text Export
13582 :PROPERTIES:
13583 :DESCRIPTION: Exporting to OpenDocument Text.
13584 :END:
13585 #+cindex: ODT
13586 #+cindex: OpenDocument
13587 #+cindex: export, OpenDocument
13588 #+cindex: LibreOffice
13590 The ODT export back-end handles creating of OpenDocument Text (ODT)
13591 format.  Documents created by this exporter use the
13592 {{{cite(OpenDocument-v1.2 specification)}}}[fn:123] and are compatible
13593 with LibreOffice 3.4.
13595 *** Pre-requisites for ODT export
13596 :PROPERTIES:
13597 :DESCRIPTION: Required packages.
13598 :END:
13599 #+cindex: zip
13601 The ODT export back-end relies on the zip program to create the final
13602 compressed ODT output.  Check if =zip= is locally available and
13603 executable.  Without it, export cannot finish.
13605 *** ODT export commands
13606 :PROPERTIES:
13607 :DESCRIPTION: Invoking export.
13608 :END:
13610 - {{{kbd(C-c C-e o o)}}} (~org-export-to-odt~) ::
13612      #+kindex: C-c C-e o o
13613      #+findex: org-export-to-odt
13614      Export as OpenDocument Text file.
13616      #+cindex: @samp{EXPORT_FILE_NAME}, property
13617      #+vindex: org-odt-preferred-output-format
13619      If ~org-odt-preferred-output-format~ is specified, the ODT export
13620      back-end automatically converts the exported file to that format.
13622      For =myfile.org=, Org exports to =myfile.odt=, overwriting
13623      without warning.  The ODT export back-end exports a region only
13624      if a region was active.
13626      If the selected region is a single tree, the ODT export back-end
13627      makes the tree head the document title.  Incidentally, {{{kbd(C-c
13628      @)}}} selects the current sub-tree.  If the tree head entry has,
13629      or inherits, an =EXPORT_FILE_NAME= property, the ODT export
13630      back-end uses that for file name.
13632 - {{{kbd(C-c C-e o O)}}} ::
13634      #+kindex: C-c C-e o O
13635      Export as an OpenDocument Text file and open the resulting file.
13637      #+vindex: org-export-odt-preferred-output-format
13638      If ~org-export-odt-preferred-output-format~ is specified, open
13639      the converted file instead.  See [[*Automatically exporting to
13640      other formats]].
13642 *** ODT specific export settings
13643 :PROPERTIES:
13644 :DESCRIPTION: Configuration options.
13645 :END:
13647 The ODT export back-end has several additional keywords for
13648 customizing ODT output.  Setting these keywords works similar to the
13649 general options (see [[*Export Settings]]).
13651 - =DESCRIPTION= ::
13653      #+cindex: @samp{DESCRIPTION}, keyword
13654      This is the document's description, which the ODT export back-end
13655      inserts as document metadata.  For long descriptions, use
13656      multiple lines, prefixed with =DESCRIPTION=.
13658 - =KEYWORDS= ::
13660      #+cindex: @samp{KEYWORDS}, keyword
13661      The keywords for the document.  The ODT export back-end inserts
13662      the description along with author name, keywords, and related
13663      file metadata as metadata in the output file.  Use multiple
13664      =KEYWORDS= if necessary.
13666 - =ODT_STYLES_FILE= ::
13668      #+cindex: @samp{ODT_STYLES_FILE}, keyword
13669      #+vindex: org-odt-styles-file
13670      The ODT export back-end uses the ~org-odt-styles-file~ by
13671      default.  See [[*Applying custom styles]] for details.
13673 - =SUBTITLE= ::
13675      #+cindex: @samp{SUBTITLE}, keyword
13676      The document subtitle.
13678 *** Extending ODT export
13679 :PROPERTIES:
13680 :DESCRIPTION: Producing DOC, PDF files.
13681 :END:
13683 The ODT export back-end can produce documents in other formats besides
13684 ODT using a specialized ODT converter process.  Its common interface
13685 works with popular converters to produce formats such as =doc=, or
13686 convert a document from one format, say =csv=, to another format, say
13687 =xls=.
13689 #+cindex: @file{unoconv}
13690 #+vindex: org-odt-convert-process
13691 Customize ~org-odt-convert-process~ variable to point to =unoconv=,
13692 which is the ODT's preferred converter.  Working installations of
13693 LibreOffice would already have =unoconv= installed.  Alternatively,
13694 other converters may be substituted here.  See [[*Configuring
13695 a document converter]].
13697 **** Automatically exporting to other formats
13698 :PROPERTIES:
13699 :UNNUMBERED: notoc
13700 :END:
13702 #+vindex: org-odt-preferred-output-format
13703 If ODT format is just an intermediate step to get to other formats,
13704 such as =doc=, =docx=, =rtf=, or =pdf=, etc., then extend the ODT
13705 export back-end to directly produce that format.  Specify the final
13706 format in the ~org-odt-preferred-output-format~ variable.  This is one
13707 way to extend (see [[*ODT export commands]]).
13709 **** Converting between document formats
13710 :PROPERTIES:
13711 :UNNUMBERED: notoc
13712 :END:
13714 The Org export back-end is made to be inter-operable with a wide range
13715 of text document format converters.  Newer generation converters, such
13716 as LibreOffice and Pandoc, can handle hundreds of formats at once.
13717 Org provides a consistent interaction with whatever converter is
13718 installed.  Here are some generic commands:
13720 - {{{kbd(M-x org-odt-convert)}}} ::
13722      #+findex: org-odt-convert
13723      Convert an existing document from one format to another.  With
13724      a prefix argument, opens the newly produced file.
13726 *** Applying custom styles
13727 :PROPERTIES:
13728 :DESCRIPTION: Styling the output.
13729 :END:
13730 #+cindex: styles, custom
13731 #+cindex: template, custom
13733 The ODT export back-end comes with many OpenDocument styles (see
13734 [[*Working with OpenDocument style files]]).  To expand or further
13735 customize these built-in style sheets, either edit the style sheets
13736 directly or generate them using an application such as LibreOffice.
13737 The example here shows creating a style using LibreOffice.
13739 **** Applying custom styles: the easy way
13740 :PROPERTIES:
13741 :UNNUMBERED: notoc
13742 :END:
13744 1. Create a sample =example.org= file with settings as shown below,
13745    and export it to ODT format.
13747    : #+OPTIONS: H:10 num:t
13749 2. Open the above =example.odt= using LibreOffice.  Use the /Stylist/
13750    to locate the target styles, which typically have the "Org" prefix.
13751    Open one, modify, and save as either OpenDocument Text (ODT) or
13752    OpenDocument Template (OTT) file.
13755    #+vindex: org-odt-styles-file
13756    Customize the variable ~org-odt-styles-file~ and point it to the
13757    newly created file.  For additional configuration options, see
13758    [[x-overriding-factory-styles][Overriding factory styles]].
13760    #+cindex: @samp{ODT_STYLES_FILE}, keyword
13761    To apply an ODT style to a particular file, use the
13762    =ODT_STYLES_FILE= keyword as shown in the example below:
13764    : #+ODT_STYLES_FILE: "/path/to/example.ott"
13766    #+texinfo: @noindent
13767    or
13769    : #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
13771 **** Using third-party styles and templates
13772 :PROPERTIES:
13773 :UNNUMBERED: notoc
13774 :END:
13776 The ODT export back-end relies on many templates and style names.
13777 Using third-party styles and templates can lead to mismatches.
13778 Templates derived from built in ODT templates and styles seem to have
13779 fewer problems.
13781 *** Links in ODT export
13782 :PROPERTIES:
13783 :DESCRIPTION: Handling and formatting links.
13784 :END:
13785 #+cindex: links, in ODT export
13787 ODT exporter creates native cross-references for internal links.  It
13788 creates Internet-style links for all other links.
13790 A link with no description and pointing to a regular, un-itemized,
13791 outline heading is replaced with a cross-reference and section number
13792 of the heading.
13794 A =\ref{label}=-style reference to an image, table etc., is replaced
13795 with a cross-reference and sequence number of the labeled entity.  See
13796 [[*Labels and captions in ODT export]].
13798 *** Tables in ODT export
13799 :PROPERTIES:
13800 :DESCRIPTION: Org tables conversions.
13801 :END:
13803 #+cindex: tables, in ODT export
13805 The ODT export back-end handles native Org mode tables (see [[*Tables]])
13806 and simple =table.el= tables.  Complex =table.el= tables having column
13807 or row spans are not supported.  Such tables are stripped from the
13808 exported document.
13810 By default, the ODT export back-end exports a table with top and
13811 bottom frames and with ruled lines separating row and column groups
13812 (see [[*Column Groups]]).  All tables are typeset to occupy the same
13813 width.  The ODT export back-end honors any table alignments and
13814 relative widths for columns (see [[*Column Width and Alignment]]).
13816 Note that the ODT export back-end interprets column widths as weighted
13817 ratios, the default weight being 1.
13819 #+cindex: @samp{ATTR_ODT}, keyword
13820 Specifying =:rel-width= property on an =ATTR_ODT= line controls the
13821 width of the table.  For example:
13823 #+begin_example
13824 ,#+ATTR_ODT: :rel-width 50
13825 | Area/Month    |   Jan |   Feb |   Mar |   Sum |
13826 |---------------+-------+-------+-------+-------|
13827 | /             |     < |       |       |     < |
13828 | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
13829 | North America |     1 |    21 |   926 |   948 |
13830 | Middle East   |     6 |    75 |   844 |   925 |
13831 | Asia Pacific  |     9 |    27 |   790 |   826 |
13832 |---------------+-------+-------+-------+-------|
13833 | Sum           |    16 |   123 |  2560 |  2699 |
13834 #+end_example
13836 On export, the above table takes 50% of text width area.  The exporter
13837 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
13838 left-aligned and rest of the columns, right-aligned.  Vertical rules
13839 separate the header and the last column.  Horizontal rules separate
13840 the header and the last row.
13842 For even more customization, create custom table styles and associate
13843 them with a table using the =ATTR_ODT= keyword.  See [[*Customizing
13844 tables in ODT export]].
13846 *** Images in ODT export
13847 :PROPERTIES:
13848 :DESCRIPTION: Inserting images.
13849 :END:
13850 #+cindex: images, embedding in ODT
13851 #+cindex: embedding images in ODT
13853 **** Embedding images
13854 :PROPERTIES:
13855 :UNNUMBERED: notoc
13856 :END:
13858 The ODT export back-end processes image links in Org files that do not
13859 have descriptions, such as these links =[[file:img.jpg]]= or =[[./img.jpg]]=,
13860 as direct image insertions in the final output.  Either of these
13861 examples works:
13863 : [[file:img.png]]
13865 : [[./img.png]]
13867 **** Embedding clickable images
13868 :PROPERTIES:
13869 :UNNUMBERED: notoc
13870 :END:
13872 For clickable images, provide a link whose description is another link
13873 to an image file.  For example, to embed an image
13874 =org-mode-unicorn.png= which when clicked jumps to https://orgmode.org
13875 website, do the following
13877 : [[https://orgmode.org][./org-mode-unicorn.png]]
13879 **** Sizing and scaling of embedded images
13880 :PROPERTIES:
13881 :UNNUMBERED: notoc
13882 :END:
13884 #+cindex: @samp{ATTR_ODT}, keyword
13886 Control the size and scale of the embedded images with the =ATTR_ODT=
13887 attribute.
13889 #+cindex: identify, ImageMagick
13890 #+vindex: org-odt-pixels-per-inch
13891 The ODT export back-end starts with establishing the size of the image
13892 in the final document.  The dimensions of this size are measured in
13893 centimeters.  The back-end then queries the image file for its
13894 dimensions measured in pixels.  For this measurement, the back-end
13895 relies on ImageMagick's identify program or Emacs ~create-image~ and
13896 ~image-size~ API.  ImageMagick is the preferred choice for large file
13897 sizes or frequent batch operations.  The back-end then converts the
13898 pixel dimensions using ~org-odt-pixels-per-inch~ into the familiar 72
13899 dpi or 96 dpi.  The default value for this is in
13900 ~display-pixels-per-inch~, which can be tweaked for better results
13901 based on the capabilities of the output device.  Here are some common
13902 image scaling operations:
13904 - Explicitly size the image ::
13906      To embed =img.png= as a 10 cm x 10 cm image, do the following:
13908      #+begin_example
13909      ,#+ATTR_ODT: :width 10 :height 10
13910      [[./img.png]]
13911      #+end_example
13913 - Scale the image ::
13915      To embed =img.png= at half its size, do the following:
13917      #+begin_example
13918      ,#+ATTR_ODT: :scale 0.5
13919      [[./img.png]]
13920      #+end_example
13922 - Scale the image to a specific width ::
13924      To embed =img.png= with a width of 10 cm while retaining the
13925      original height:width ratio, do the following:
13927      #+begin_example
13928      ,#+ATTR_ODT: :width 10
13929      [[./img.png]]
13930      #+end_example
13932 - Scale the image to a specific height ::
13934      To embed =img.png= with a height of 10 cm while retaining the
13935      original height:width ratio, do the following:
13937      #+begin_example
13938      ,#+ATTR_ODT: :height 10
13939      [[./img.png]]
13940      #+end_example
13942 **** Anchoring of images
13943 :PROPERTIES:
13944 :UNNUMBERED: notoc
13945 :END:
13947 #+cindex: @samp{ATTR_ODT}, keyword
13948 The ODT export back-end can anchor images to ="as-char"=,
13949 ="paragraph"=, or ="page"=.  Set the preferred anchor using the
13950 =:anchor= property of the =ATTR_ODT= line.
13952 To create an image that is anchored to a page:
13954 #+begin_example
13955 ,#+ATTR_ODT: :anchor "page"
13956 [[./img.png]]
13957 #+end_example
13959 *** Math formatting in ODT export
13960 :PROPERTIES:
13961 :DESCRIPTION: Formatting @LaTeX{} fragments.
13962 :END:
13964 The ODT exporter has special support for handling math.
13966 **** LaTeX math snippets
13967 :PROPERTIES:
13968 :DESCRIPTION: Embedding in @LaTeX{} format.
13969 :END:
13971 LaTeX math snippets (see [[*LaTeX fragments]]) can be embedded in the ODT
13972 document in one of the following ways:
13974 - MathML ::
13976      #+cindex: MathML
13977      Add this line to the Org file.  This option is activated on
13978      a per-file basis.
13980      : #+OPTIONS: tex:t
13982      With this option, LaTeX fragments are first converted into MathML
13983      fragments using an external LaTeX-to-MathML converter program.
13984      The resulting MathML fragments are then embedded as an
13985      OpenDocument Formula in the exported document.
13987      #+vindex: org-latex-to-mathml-convert-command
13988      #+vindex: org-latex-to-mathml-jar-file
13989      You can specify the LaTeX-to-MathML converter by customizing the
13990      variables ~org-latex-to-mathml-convert-command~ and
13991      ~org-latex-to-mathml-jar-file~.
13993      If you prefer to use MathToWeb[fn:124] as your converter, you can
13994      configure the above variables as shown below.
13996      #+begin_src emacs-lisp
13997      (setq org-latex-to-mathml-convert-command
13998            "java -jar %j -unicode -force -df %o %I"
13999            org-latex-to-mathml-jar-file
14000            "/path/to/mathtoweb.jar")
14001      #+end_src
14003      To use LaTeX​ML[fn:125] use
14005      #+begin_src emacs-lisp
14006      (setq org-latex-to-mathml-convert-command
14007            "latexmlmath \"%i\" --presentationmathml=%o")
14008      #+end_src
14010      To quickly verify the reliability of the LaTeX-to-MathML
14011      converter, use the following commands:
14013      - {{{kbd(M-x org-export-as-odf)}}} ::
14015           Convert a LaTeX math snippet to an OpenDocument formula
14016           (=.odf=) file.
14018      - {{{kbd(M-x org-export-as-odf-and-open)}}} ::
14020           Convert a LaTeX math snippet to an OpenDocument formula
14021           (=.odf=) file and open the formula file with the
14022           system-registered application.
14024 - PNG images ::
14026      #+cindex: dvipng
14027      #+cindex: dvisvgm
14028      #+cindex: ImageMagick
14029      Add this line to the Org file.  This option is activated on
14030      a per-file basis.
14032      : #+OPTIONS: tex:dvipng
14034      : #+OPTIONS: tex:dvisvgm
14036      #+texinfo: @noindent
14037      or
14039      : #+OPTIONS: tex:imagemagick
14041      Under this option, LaTeX fragments are processed into PNG or SVG
14042      images and the resulting images are embedded in the exported
14043      document.  This method requires dvipng program, dvisvgm or
14044      ImageMagick programs.
14046 **** MathML and OpenDocument formula files
14047 :PROPERTIES:
14048 :DESCRIPTION: Embedding in native format.
14049 :END:
14051 When embedding LaTeX math snippets in ODT documents is not reliable,
14052 there is one more option to try.  Embed an equation by linking to its
14053 MathML (=.mml=) source or its OpenDocument formula (=.odf=) file as
14054 shown below:
14056 : [[./equation.mml]]
14058 #+texinfo: @noindent
14061 : [[./equation.odf]]
14063 *** Labels and captions in ODT export
14064 :PROPERTIES:
14065 :DESCRIPTION: Rendering objects.
14066 :END:
14068 ODT format handles labeling and captioning of objects based on their
14069 types.  Inline images, tables, LaTeX fragments, and Math formulas are
14070 numbered and captioned separately.  Each object also gets a unique
14071 sequence number based on its order of first appearance in the Org
14072 file.  Each category has its own sequence.  A caption is just a label
14073 applied to these objects.
14075 #+begin_example
14076 ,#+CAPTION: Bell curve
14077 ,#+NAME:   fig:SED-HR4049
14078 [[./img/a.png]]
14079 #+end_example
14081 When rendered, it may show as follows in the exported document:
14083 : Figure 2: Bell curve
14085 #+vindex: org-odt-category-map-alist
14086 To modify the category component of the caption, customize the option
14087 ~org-odt-category-map-alist~.  For example, to tag embedded images
14088 with the string "Illustration" instead of the default string "Figure",
14089 use the following setting:
14091 #+begin_src emacs-lisp
14092 (setq org-odt-category-map-alist
14093       '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14094 #+end_src
14096 With the above modification, the previous example changes to:
14098 : Illustration 2: Bell curve
14100 *** Literal examples in ODT export
14101 :PROPERTIES:
14102 :DESCRIPTION: For source code and example blocks.
14103 :END:
14105 The ODT export back-end supports literal examples (see [[*Literal
14106 Examples]]) with full fontification.  Internally, the ODT export
14107 back-end relies on =htmlfontify.el= to generate the style definitions
14108 needed for fancy listings.  The auto-generated styles get =OrgSrc=
14109 prefix and inherit colors from the faces used by Emacs Font Lock
14110 library for that source language.
14112 #+vindex: org-odt-fontify-srcblocks
14113 For custom fontification styles, customize the
14114 ~org-odt-create-custom-styles-for-srcblocks~ option.
14116 #+vindex: org-odt-create-custom-styles-for-srcblocks
14117 To turn off fontification of literal examples, customize the
14118 ~org-odt-fontify-srcblocks~ option.
14120 *** Advanced topics in ODT export
14121 :PROPERTIES:
14122 :DESCRIPTION: For power users.
14123 :END:
14125 The ODT export back-end has extensive features useful for power users
14126 and frequent uses of ODT formats.
14128 **** Configuring a document converter
14129 :PROPERTIES:
14130 :DESCRIPTION: Registering a document converter.
14131 :UNNUMBERED: notoc
14132 :END:
14133 #+cindex: convert
14134 #+cindex: doc, docx, rtf
14135 #+cindex: converter
14137 The ODT export back-end works with popular converters with little or
14138 no extra configuration.  See [[*Extending ODT export]].  The following is
14139 for unsupported converters or tweaking existing defaults.
14141 - Register the converter ::
14143      #+vindex: org-export-odt-convert-processes
14144      Add the name of the converter to the ~org-odt-convert-processes~
14145      variable.  Note that it also requires how the converter is
14146      invoked on the command line.  See the variable's docstring for
14147      details.
14149 - Configure its capabilities ::
14151      #+vindex: org-export-odt-convert-capabilities
14152      Specify which formats the converter can handle by customizing the
14153      variable ~org-odt-convert-capabilities~.  Use the entry for the
14154      default values in this variable for configuring the new
14155      converter.  Also see its docstring for details.
14157 - Choose the converter ::
14159      #+vindex: org-export-odt-convert-process
14160      Select the newly added converter as the preferred one by
14161      customizing the option ~org-odt-convert-process~.
14163 **** Working with OpenDocument style files
14164 :PROPERTIES:
14165 :DESCRIPTION: Exploring internals.
14166 :UNNUMBERED: notoc
14167 :END:
14168 #+cindex: styles, custom
14169 #+cindex: template, custom
14171 This section explores the internals of the ODT exporter; the means by which
14172 it produces styled documents; the use of automatic and custom OpenDocument
14173 styles.
14175 The ODT exporter relies on two files for generating its output.  These
14176 files are bundled with the distribution under the directory pointed to
14177 by the variable ~org-odt-styles-dir~.  The two files are:
14179 - =OrgOdtStyles.xml= <<x-orgodtstyles-xml>> ::
14181      This file contributes to the =styles.xml= file of the final ODT
14182      document.  This file gets modified for the following purposes:
14184      1. To control outline numbering based on user settings;
14186      2. To add styles generated by =htmlfontify.el= for fontification of
14187         code blocks.
14189 - =OrgOdtContentTemplate.xml= <<x-orgodtcontenttemplate-xml>> ::
14191      This file contributes to the =content.xml= file of the final ODT
14192      document.  The contents of the Org outline are inserted between the
14193      =<office:text>= ... =</office:text>= elements of this file.
14195      Apart from serving as a template file for the final =content.xml=,
14196      the file serves the following purposes:
14198      1. It contains automatic styles for formatting of tables which are
14199         referenced by the exporter;
14201      2. It contains =<text:sequence-decl>= ... =</text:sequence-decl>=
14202         elements that control numbering of tables, images, equations, and
14203         similar entities.
14205 <<x-overriding-factory-styles>> The following two variables control
14206 the location from where the ODT exporter picks up the custom styles
14207 and content template files.  Customize these variables to override the
14208 factory styles used by the exporter.
14210 - ~org-odt-styles-file~ ::
14212      The ODT export back-end uses the file pointed to by this
14213      variable, such as =styles.xml=, for the final output.  It can
14214      take one of the following values:
14216      - =FILE.xml= ::
14218           Use this file instead of the default =styles.xml=
14220      - =FILE.odt= or =FILE.ott= ::
14222           Use the =styles.xml= contained in the specified OpenDocument
14223           Text or Template file
14225      - =FILE.odt= or =FILE.ott= and a subset of included files ::
14227           Use the =styles.xml= contained in the specified OpenDocument
14228           Text or Template file.  Additionally extract the specified
14229           member files and embed those within the final ODT document.
14231           Use this option if the =styles.xml= file references additional
14232           files like header and footer images.
14234      - ~nil~ ::
14236           Use the default =styles.xml=.
14238 - ~org-odt-content-template-file~ ::
14240      Use this variable to specify the blank =content.xml= used in the
14241      final output.
14243 **** Creating one-off styles
14244 :PROPERTIES:
14245 :DESCRIPTION: Customizing styles, highlighting...
14246 :UNNUMBERED: notoc
14247 :END:
14249 The ODT export back-end can read embedded raw OpenDocument XML from
14250 the Org file.  Such direct formatting is useful for one-off instances.
14252 - Embedding ODT tags as part of regular text ::
14254      Enclose OpenDocument syntax in =@@odt:...@@= for inline markup.
14255      For example, to highlight a region of text do the following:
14257      #+begin_example
14258      @@odt:<text:span text:style-name="Highlight">This is highlighted
14259      text</text:span>@@.  But this is regular text.
14260      #+end_example
14262      *Hint:* To see the above example in action, edit the =styles.xml=
14263      (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom /Highlight/ style as shown
14264      below:
14266      #+begin_example
14267      <style:style style:name="Highlight" style:family="text">
14268        <style:text-properties fo:background-color="#ff0000"/>
14269      </style:style>
14270      #+end_example
14272 - Embedding a one-line OpenDocument XML ::
14274      #+cindex: @samp{ODT}, keyword
14275      The ODT export back-end can read one-liner options with =#+ODT:=
14276      in the Org file.  For example, to force a page break:
14278      #+begin_example
14279      ,#+ODT: <text:p text:style-name="PageBreak"/>
14280      #+end_example
14282      *Hint:* To see the above example in action, edit your
14283      =styles.xml= (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom =PageBreak=
14284      style as shown below.
14286      #+begin_example
14287      <style:style style:name="PageBreak" style:family="paragraph"
14288                   style:parent-style-name="Text_20_body">
14289        <style:paragraph-properties fo:break-before="page"/>
14290      </style:style>
14291      #+end_example
14293 - Embedding a block of OpenDocument XML ::
14295      The ODT export back-end can also read ODT export blocks for
14296      OpenDocument XML.  Such blocks use the =#+BEGIN_EXPORT odt=
14297      ... =#+END_EXPORT= constructs.
14299      For example, to create a one-off paragraph that uses bold text,
14300      do the following:
14302      #+begin_example
14303      ,#+BEGIN_EXPORT odt
14304        <text:p text:style-name="Text_20_body_20_bold">
14305        This paragraph is specially formatted and uses bold text.
14306        </text:p>
14307      ,#+END_EXPORT
14308      #+end_example
14310 **** Customizing tables in ODT export
14311 :PROPERTIES:
14312 :DESCRIPTION: Defining table templates.
14313 :UNNUMBERED: notoc
14314 :END:
14315 #+cindex: tables, in ODT export
14316 #+cindex: @samp{ATTR_ODT}, keyword
14318 Override the default table format by specifying a custom table style
14319 with the =#+ATTR_ODT= line.  For a discussion on default formatting of
14320 tables, see [[*Tables in ODT export]].
14322 This feature closely mimics the way table templates are defined in the
14323 OpenDocument-v1.2 specification.[fn:126]
14325 #+vindex: org-odt-table-styles
14326 For quick preview of this feature, install the settings below and export the
14327 table that follows:
14329 #+begin_src emacs-lisp
14330 (setq org-export-odt-table-styles
14331       (append org-export-odt-table-styles
14332               '(("TableWithHeaderRowAndColumn" "Custom"
14333                  ((use-first-row-styles . t)
14334                   (use-first-column-styles . t)))
14335                 ("TableWithFirstRowandLastRow" "Custom"
14336                  ((use-first-row-styles . t)
14337                   (use-last-row-styles . t))))))
14338 #+end_src
14340 #+begin_example
14341 ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14342 | Name  | Phone | Age |
14343 | Peter |  1234 |  17 |
14344 | Anna  |  4321 |  25 |
14345 #+end_example
14347 The example above used =Custom= template and installed two table
14348 styles =TableWithHeaderRowAndColumn= and
14349 =TableWithFirstRowandLastRow=.  *Important:* The OpenDocument styles
14350 needed for producing the above template were pre-defined.  They are
14351 available in the section marked =Custom Table Template= in
14352 =OrgOdtContentTemplate.xml= (see [[x-orgodtcontenttemplate-xml][Factory styles]]).  For adding new
14353 templates, define new styles there.
14355 To use this feature proceed as follows:
14357 1. Create a table template[fn:127].
14359    A table template is set of =table-cell= and =paragraph= styles for
14360    each of the following table cell categories:
14362    - Body
14363    - First column
14364    - Last column
14365    - First row
14366    - Last row
14367    - Even row
14368    - Odd row
14369    - Even column
14370    - Odd Column
14372    The names for the above styles must be chosen based on the name of
14373    the table template using a well-defined convention.
14375    The naming convention is better illustrated with an example.  For
14376    a table template with the name =Custom=, the needed style names are
14377    listed in the following table.
14379    | Cell type    | Cell style                   | Paragraph style                   |
14380    |--------------+------------------------------+-----------------------------------|
14381    | Body         | =CustomTableCell=            | =CustomTableParagraph=            |
14382    | First column | =CustomFirstColumnTableCell= | =CustomFirstColumnTableParagraph= |
14383    | Last column  | =CustomLastColumnTableCell=  | =CustomLastColumnTableParagraph=  |
14384    | First row    | =CustomFirstRowTableCell=    | =CustomFirstRowTableParagraph=    |
14385    | Last row     | =CustomLastRowTableCell=     | =CustomLastRowTableParagraph=     |
14386    | Even row     | =CustomEvenRowTableCell=     | =CustomEvenRowTableParagraph=     |
14387    | Odd row      | =CustomOddRowTableCell=      | =CustomOddRowTableParagraph=      |
14388    | Even column  | =CustomEvenColumnTableCell=  | =CustomEvenColumnTableParagraph=  |
14389    | Odd column   | =CustomOddColumnTableCell=   | =CustomOddColumnTableParagraph=   |
14391    To create a table template with the name =Custom=, define the above
14392    styles in the =<office:automatic-styles>= ...
14393    =</office:automatic-styles>= element of the content template file
14394    (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
14396 2. Define a table style[fn:128].
14398    #+vindex: org-odt-table-styles
14399    To define a table style, create an entry for the style in the
14400    variable ~org-odt-table-styles~ and specify the following:
14402    - the name of the table template created in step (1),
14403    - the set of cell styles in that template that are to be activated.
14405    For example, the entry below defines two different table styles
14406    =TableWithHeaderRowAndColumn= and =TableWithFirstRowandLastRow=
14407    based on the same template =Custom=.  The styles achieve their
14408    intended effect by selectively activating the individual cell
14409    styles in that template.
14411    #+begin_src emacs-lisp
14412    (setq org-export-odt-table-styles
14413          (append org-export-odt-table-styles
14414                  '(("TableWithHeaderRowAndColumn" "Custom"
14415                     ((use-first-row-styles . t)
14416                      (use-first-column-styles . t)))
14417                    ("TableWithFirstRowandLastRow" "Custom"
14418                     ((use-first-row-styles . t)
14419                      (use-last-row-styles . t))))))
14420    #+end_src
14422 3. Associate a table with the table style.
14424    To do this, specify the table style created in step (2) as part of
14425    the =ATTR_ODT= line as shown below.
14427    #+begin_example
14428    ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14429    | Name  | Phone | Age |
14430    | Peter |  1234 |  17 |
14431    | Anna  |  4321 |  25 |
14432    #+end_example
14434 **** Validating OpenDocument XML
14435 :PROPERTIES:
14436 :DESCRIPTION: Debugging corrupted OpenDocument files.
14437 :UNNUMBERED: notoc
14438 :END:
14440 Sometimes ODT format files may not open due to =.odt= file corruption.
14441 To verify if such a file is corrupt, validate it against the
14442 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
14443 =.odt= files have to be decompressed using =zip=.  Note that =.odt=
14444 files are ZIP archives: [[info:emacs::File Archives]].  The contents of
14445 ODT files are in XML.  For general help with validation---and
14446 schema-sensitive editing---of XML files:
14447 [[info:nxml-mode::Introduction]].
14449 #+vindex: org-export-odt-schema-dir
14450 Customize ~org-odt-schema-dir~ to point to a directory with
14451 OpenDocument RNC files and the needed schema-locating rules.  The ODT
14452 export back-end takes care of updating the
14453 ~rng-schema-locating-files~.
14455 ** Org Export
14456 :PROPERTIES:
14457 :DESCRIPTION: Exporting to Org.
14458 :END:
14460 #+cindex: Org export
14461 /org/ export back-end creates a normalized version of the Org document
14462 in current buffer.  The exporter evaluates Babel code (see [[*Evaluating
14463 Code Blocks]]) and removes content specific to other back-ends.
14465 *** Org export commands
14466 :PROPERTIES:
14467 :UNNUMBERED: notoc
14468 :END:
14470 - {{{kbd(C-c C-e O o)}}} (~org-org-export-to-org~) ::
14472      #+kindex: C-c C-e O o
14473      #+findex: org-org-export-to-org
14474      Export as an Org file with a =.org= extension.  For =myfile.org=,
14475      Org exports to =myfile.org.org=, overwriting without warning.
14477 - {{{kbd(C-c C-e O v)}}} (~~) ::
14479      #+kindex: C-c C-e O v
14480      Export to an Org file, then open it.
14482 ** Texinfo Export
14483 :PROPERTIES:
14484 :DESCRIPTION: Exporting to Texinfo.
14485 :END:
14487 *** Texinfo export commands
14488 :PROPERTIES:
14489 :DESCRIPTION: Invoking commands.
14490 :END:
14492 - {{{kbd(C-c C-e i t)}}} (~org-texinfo-export-to-texinfo~) ::
14494      #+kindex: C-c C-e i t
14495      #+findex: org-texinfo-export-to-texinfo
14496      Export as a Texinfo file with =.texi= extension.  For
14497      =myfile.org=, Org exports to =myfile.texi=, overwriting without
14498      warning.
14500 - {{{kbd(C-c C-e i i)}}} (~org-texinfo-export-to-info~) ::
14502      #+kindex: C-c C-e i i
14503      #+findex: org-texinfo-export-to-info
14504      #+vindex: org-texinfo-info-process
14505      Export to Texinfo format first and then process it to make an
14506      Info file.  To generate other formats, such as DocBook, customize
14507      the ~org-texinfo-info-process~ variable.
14509 *** Texinfo specific export settings
14510 :PROPERTIES:
14511 :DESCRIPTION: Setting the environment.
14512 :END:
14514 The Texinfo export back-end has several additional keywords for
14515 customizing Texinfo output.  Setting these keywords works similar to
14516 the general options (see [[*Export Settings]]).
14518 - =SUBTITLE= ::
14520      #+cindex: @samp{SUBTITLE}, keyword
14521      The document subtitle.
14523 - =SUBAUTHOR= ::
14525      #+cindex: @samp{SUBAUTHOR}, keyword
14526      Additional authors for the document.
14528 - =TEXINFO_FILENAME= ::
14530      #+cindex: @samp{TEXINFO_FILENAME}, keyword
14531      The Texinfo filename.
14533 - =TEXINFO_CLASS= ::
14535      #+cindex: @samp{TEXINFO_CLASS}, keyword
14536      #+vindex: org-texinfo-default-class
14537      The default document class (~org-texinfo-default-class~), which
14538      must be a member of ~org-texinfo-classes~.
14540 - =TEXINFO_HEADER= ::
14542      #+cindex: @samp{TEXINFO_HEADER}, keyword
14543      Arbitrary lines inserted at the end of the header.
14545 - =TEXINFO_POST_HEADER= ::
14547      #+cindex: @samp{TEXINFO_POST_HEADER}, keyword
14548      Arbitrary lines inserted after the end of the header.
14550 - =TEXINFO_DIR_CATEGORY= ::
14552      #+cindex: @samp{TEXINFO_DIR_CATEGORY}, keyword
14553      The directory category of the document.
14555 - =TEXINFO_DIR_TITLE= ::
14557      #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword
14558      The directory title of the document.
14560 - =TEXINFO_DIR_DESC= ::
14562      #+cindex: @samp{TEXINFO_DIR_DESC}, keyword
14563      The directory description of the document.
14565 - =TEXINFO_PRINTED_TITLE= ::
14567      #+cindex: @samp{TEXINFO_PRINTED_TITLE}, keyword
14568      The printed title of the document.
14570 *** Texinfo file header
14571 :PROPERTIES:
14572 :DESCRIPTION: Generating the header.
14573 :END:
14575 #+cindex: @samp{TEXINFO_FILENAME}, keyword
14576 After creating the header for a Texinfo file, the Texinfo back-end
14577 automatically generates a name and destination path for the Info file.
14578 To override this default with a more sensible path and name, specify
14579 the =TEXINFO_FILENAME= keyword.
14581 #+vindex: org-texinfo-coding-system
14582 #+cindex: @samp{TEXINFO_HEADER}, keyword
14583 Along with the output's file name, the Texinfo header also contains
14584 language details (see [[*Export Settings]]) and encoding system as set in
14585 the ~org-texinfo-coding-system~ variable.  Insert =TEXINFO_HEADER=
14586 keywords for each additional command in the header, for example:
14588 : #+TEXINFO_HEADER: @synindex
14590 #+cindex: @samp{TEXINFO_CLASS}, keyword
14591 #+vindex: org-texinfo-classes
14592 Instead of repeatedly installing the same set of commands, define
14593 a class in ~org-texinfo-classes~ once, and then activate it in the
14594 document by setting the =TEXINFO_CLASS= keyword to that class.
14596 *** Texinfo title and copyright page
14597 :PROPERTIES:
14598 :DESCRIPTION: Creating preamble pages.
14599 :END:
14601 #+cindex: @samp{TEXINFO_PRINTED_TITLE}, keyword
14602 The default template for hard copy output has a title page with
14603 =TITLE= and =AUTHOR= keywords (see [[*Export Settings]]).  To replace the
14604 regular title with something different for the printed version, use
14605 the =TEXINFO_PRINTED_TITLE= and =SUBTITLE= keywords.  Both expect raw
14606 Texinfo code for setting their values.
14608 #+cindex: @samp{SUBAUTHOR}, keyword
14609 If one =AUTHOR= line is not sufficient, add multiple =SUBAUTHOR=
14610 keywords.  They have to be set in raw Texinfo code.
14612 #+begin_example
14613 ,#+AUTHOR: Jane Smith
14614 ,#+SUBAUTHOR: John Doe
14615 ,#+TEXINFO_PRINTED_TITLE: This Long Title@@inlinefmt{tex,@*} Is Broken in @TeX{}
14616 #+end_example
14618 #+cindex: @samp{COPYING}, property
14619 Copying material is defined in a dedicated headline with a non-~nil~
14620 =COPYING= property.  The back-end inserts the contents within
14621 a =@copying= command at the beginning of the document.  The heading
14622 itself does not appear in the structure of the document.
14624 Copyright information is printed on the back of the title page.
14626 #+begin_example
14627 ,* Legalese
14628   :PROPERTIES:
14629   :COPYING: t
14630   :END:
14632   This is a short example of a complete Texinfo file, version 1.0.
14634   Copyright \copy 2016 Free Software Foundation, Inc.
14635 #+end_example
14637 *** Info directory file
14638 :PROPERTIES:
14639 :DESCRIPTION: Installing a manual in Info file hierarchy.
14640 :END:
14642 #+cindex: @samp{dir} file, in Texinfo export
14643 #+cindex: Info directory file, in Texinfo export
14644 #+cindex: @code{install-info}, in Texinfo export
14646 #+cindex: @samp{TEXINFO_DIR_CATEGORY}, keyword
14647 #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword
14648 #+cindex: @samp{TEXINFO_DIR_DESC}, keyword
14649 The end result of the Texinfo export process is the creation of an
14650 Info file.  This Info file's metadata has variables for category,
14651 title, and description: =TEXINFO_DIR_CATEGORY=, =TEXINFO_DIR_TITLE=,
14652 and =TEXINFO_DIR_DESC= keywords that establish where in the Info
14653 hierarchy the file fits.
14655 Here is an example that writes to the Info directory file:
14657 #+begin_example
14658 ,#+TEXINFO_DIR_CATEGORY: Emacs
14659 ,#+TEXINFO_DIR_TITLE: Org Mode: (org)
14660 ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer
14661 #+end_example
14663 *** Headings and sectioning structure
14664 :PROPERTIES:
14665 :DESCRIPTION: Building document structure.
14666 :END:
14668 #+vindex: org-texinfo-classes
14669 #+vindex: org-texinfo-default-class
14670 #+cindex: @samp{TEXINFO_CLASS}, keyword
14671 The Texinfo export back-end uses a pre-defined scheme to convert Org
14672 headlines to equivalent Texinfo structuring commands.  A scheme like
14673 this maps top-level headlines to numbered chapters tagged as
14674 ~@chapter~ and lower-level headlines to unnumbered chapters tagged as
14675 ~@unnumbered~.  To override such mappings to introduce ~@part~ or
14676 other Texinfo structuring commands, define a new class in
14677 ~org-texinfo-classes~.  Activate the new class with the
14678 =TEXINFO_CLASS= keyword.  When no new class is defined and activated,
14679 the Texinfo export back-end defaults to the
14680 ~org-texinfo-default-class~.
14682 If an Org headline's level has no associated Texinfo structuring
14683 command, or is below a certain threshold (see [[*Export Settings]]), then
14684 the Texinfo export back-end makes it into a list item.
14686 #+cindex: @samp{APPENDIX}, property
14687 The Texinfo export back-end makes any headline with a non-~nil~
14688 =APPENDIX= property into an appendix.  This happens independent of the
14689 Org headline level or the =TEXINFO_CLASS= keyword.
14691 #+cindex: @samp{ALT_TITLE}, property
14692 #+cindex: @samp{DESCRIPTION}, property
14693 The Texinfo export back-end creates a menu entry after the Org
14694 headline for each regular sectioning structure.  To override this with
14695 a shorter menu entry, use the =ALT_TITLE= property (see [[*Table of
14696 Contents]]).  Texinfo menu entries also have an option for a longer
14697 =DESCRIPTION= property.  Here's an example that uses both to override
14698 the default menu entry:
14700 #+begin_example
14701 ,* Controlling Screen Display
14702   :PROPERTIES:
14703   :ALT_TITLE: Display
14704   :DESCRIPTION: Controlling Screen Display
14705   :END:
14706 #+end_example
14708 #+cindex: Top node, in Texinfo export
14709 The text before the first headline belongs to the /Top/ node, i.e.,
14710 the node in which a reader enters an Info manual.  As such, it is
14711 expected not to appear in printed output generated from the =.texi=
14712 file.  See [[info:texinfo::The%20Top%20Node]], for more information.
14714 *** Indices
14715 :PROPERTIES:
14716 :DESCRIPTION: Creating indices.
14717 :END:
14719 #+cindex: @samp{CINDEX}, keyword
14720 #+cindex: concept index, in Texinfo export
14721 #+cindex: @samp{FINDEX}, keyword
14722 #+cindex: function index, in Texinfo export
14723 #+cindex: @samp{KINDEX}, keyword
14724 #+cindex: keystroke index, in Texinfo export
14725 #+cindex: @samp{PINDEX}, keyword
14726 #+cindex: program index, in Texinfo export
14727 #+cindex: @samp{TINDEX}, keyword
14728 #+cindex: data type index, in Texinfo export
14729 #+cindex: @samp{VINDEX}, keyword
14730 #+cindex: variable index, in Texinfo export
14731 The Texinfo export back-end recognizes these indexing keywords if used
14732 in the Org file: =CINDEX=, =FINDEX=, =KINDEX=, =PINDEX=, =TINDEX= and
14733 =VINDEX=.  Write their value as verbatim Texinfo code; in particular,
14734 ={=, =}= and =@= characters need to be escaped with =@= if they do not
14735 belong to a Texinfo command.
14737 : #+CINDEX: Defining indexing entries
14739 #+cindex: @samp{INDEX}, property
14740 For the back-end to generate an index entry for a headline, set the
14741 =INDEX= property to =cp= or =vr=.  These abbreviations come from
14742 Texinfo that stand for concept index and variable index.  The Texinfo
14743 manual has abbreviations for all other kinds of indexes.  The back-end
14744 exports the headline as an unnumbered chapter or section command, and
14745 then inserts the index after its contents.
14747 #+begin_example
14748 ,* Concept Index
14749   :PROPERTIES:
14750   :INDEX: cp
14751   :END:
14752 #+end_example
14754 *** Quoting Texinfo code
14755 :PROPERTIES:
14756 :DESCRIPTION: Incorporating literal Texinfo code.
14757 :END:
14759 Use any of the following three methods to insert or escape raw Texinfo
14760 code:
14762 #+cindex: @samp{TEXINFO}, keyword
14763 #+cindex: @samp{BEGIN_EXPORT texinfo}
14764 #+begin_example
14765 Richard @@texinfo:@sc{@@Stallman@@texinfo:}@@ commence' GNU.
14767 ,#+TEXINFO: @need800
14768 This paragraph is preceded by...
14770 ,#+BEGIN_EXPORT texinfo
14771   @auindex Johnson, Mark
14772   @auindex Lakoff, George
14773 ,#+END_EXPORT
14774 #+end_example
14776 *** Plain lists in Texinfo export
14777 :PROPERTIES:
14778 :DESCRIPTION: List attributes.
14779 :END:
14781 #+cindex: @samp{ATTR_TEXINFO}, keyword
14782 #+cindex: two-column tables, in Texinfo export
14784 #+cindex: table types, in Texinfo export
14785 The Texinfo export back-end by default converts description lists in
14786 the Org file using the default command =@table=, which results in
14787 a table with two columns.  To change this behavior, specify
14788 =:table-type= with =ftable= or =vtable= attributes.  For more
14789 information, see [[info:texinfo::Two-column Tables]].
14791 #+vindex: org-texinfo-table-default-markup
14792 The Texinfo export back-end by default also applies a text highlight
14793 based on the defaults stored in ~org-texinfo-table-default-markup~.
14794 To override the default highlight command, specify another one with
14795 the =:indic= attribute.
14797 #+cindex: multiple items in Texinfo lists
14798 Org syntax is limited to one entry per list item.  Nevertheless, the
14799 Texinfo export back-end can split that entry according to any text
14800 provided through the =:sep= attribute.  Each part then becomes a new
14801 entry in the first column of the table.
14803 The following example illustrates all the attributes above:
14805 #+begin_example
14806 ,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
14807 - foo, bar :: This is the common text for variables foo and bar.
14808 #+end_example
14810 #+texinfo: @noindent
14811 becomes
14813 #+begin_example
14814 @vtable @asis
14815 @item foo
14816 @itemx bar
14817 This is the common text for variables foo and bar.
14818 @end table
14819 #+end_example
14821 *** Tables in Texinfo export
14822 :PROPERTIES:
14823 :DESCRIPTION: Table attributes.
14824 :END:
14826 #+cindex: @samp{ATTR_TEXINFO}, keyword
14827 When exporting tables, the Texinfo export back-end uses the widest
14828 cell width in each column.  To override this and instead specify as
14829 fractions of line length, use the =:columns= attribute.  See example
14830 below.
14832 #+begin_example
14833 ,#+ATTR_TEXINFO: :columns .5 .5
14834 | a cell | another cell |
14835 #+end_example
14837 *** Images in Texinfo export
14838 :PROPERTIES:
14839 :DESCRIPTION: Image attributes.
14840 :END:
14842 #+cindex: @samp{ATTR_TEXINFO}, keyword
14843 Insert a file link to the image in the Org file, and the Texinfo
14844 export back-end inserts the image.  These links must have the usual
14845 supported image extensions and no descriptions.  To scale the image,
14846 use =:width= and =:height= attributes.  For alternate text, use =:alt=
14847 and specify the text using Texinfo code, as shown in the example:
14849 #+begin_example
14850 ,#+ATTR_TEXINFO: :width 1in :alt Alternate @i{text}
14851 [[ridt.pdf]]
14852 #+end_example
14854 *** Special blocks in Texinfo export
14855 :PROPERTIES:
14856 :DESCRIPTION: Special block attributes.
14857 :END:
14859 #+cindex: @samp{ATTR_TEXINFO}, keyword
14861 The Texinfo export back-end converts special blocks to commands with
14862 the same name.  It also adds any =:options= attributes to the end of
14863 the command, as shown in this example:
14865 #+begin_example
14866 ,#+ATTR_TEXINFO: :options org-org-export-to-org ...
14867 ,#+BEGIN_defun
14868   A somewhat obsessive function name.
14869 ,#+END_defun
14870 #+end_example
14872 #+texinfo: @noindent
14873 becomes
14875 #+begin_example
14876 @defun org-org-export-to-org ...
14877   A somewhat obsessive function name.
14878 @end defun
14879 #+end_example
14881 *** A Texinfo example
14882 :PROPERTIES:
14883 :DESCRIPTION: Processing Org to Texinfo.
14884 :END:
14886 Here is a more detailed example Org file.  See
14887 [[info:texinfo::GNU%20Sample%20Texts]] for an equivalent example using
14888 Texinfo code.
14890 #+begin_example
14891 ,#+TITLE: GNU Sample {{{version}}}
14892 ,#+SUBTITLE: for version {{{version}}}, {{{updated}}}
14893 ,#+AUTHOR: A.U. Thor
14894 ,#+EMAIL: bug-sample@gnu.org
14896 ,#+OPTIONS: ':t toc:t author:t email:t
14897 ,#+LANGUAGE: en
14899 ,#+MACRO: version 2.0
14900 ,#+MACRO: updated last updated 4 March 2014
14902 ,#+TEXINFO_FILENAME: sample.info
14903 ,#+TEXINFO_HEADER: @syncodeindex pg cp
14905 ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system
14906 ,#+TEXINFO_DIR_TITLE: sample: (sample)
14907 ,#+TEXINFO_DIR_DESC: Invoking sample
14909 ,#+TEXINFO_PRINTED_TITLE: GNU Sample
14911 This manual is for GNU Sample (version {{{version}}},
14912 {{{updated}}}).
14914 ,* Copying
14915   :PROPERTIES:
14916   :COPYING:  t
14917   :END:
14919   This manual is for GNU Sample (version {{{version}}},
14920   {{{updated}}}), which is an example in the Texinfo documentation.
14922   Copyright \copy 2016 Free Software Foundation, Inc.
14924   ,#+BEGIN_QUOTE
14925   Permission is granted to copy, distribute and/or modify this
14926   document under the terms of the GNU Free Documentation License,
14927   Version 1.3 or any later version published by the Free Software
14928   Foundation; with no Invariant Sections, with no Front-Cover Texts,
14929   and with no Back-Cover Texts.  A copy of the license is included in
14930   the section entitled "GNU Free Documentation License".
14931   ,#+END_QUOTE
14933 ,* Invoking sample
14935   ,#+PINDEX: sample
14936   ,#+CINDEX: invoking @command{sample}
14938   This is a sample manual.  There is no sample program to invoke, but
14939   if there were, you could see its basic usage and command line
14940   options here.
14942 ,* GNU Free Documentation License
14943   :PROPERTIES:
14944   :APPENDIX: t
14945   :END:
14947   ,#+TEXINFO: @include fdl.texi
14949 ,* Index
14950   :PROPERTIES:
14951   :INDEX:    cp
14952   :END:
14953 #+end_example
14955 ** iCalendar Export
14956 :PROPERTIES:
14957 :DESCRIPTION: Exporting to iCalendar.
14958 :END:
14959 #+cindex: iCalendar export
14961 A large part of Org mode's interoperability success is its ability to
14962 easily export to or import from external applications.  The iCalendar
14963 export back-end takes calendar data from Org files and exports to the
14964 standard iCalendar format.
14966 #+vindex: org-icalendar-include-todo
14967 #+vindex: org-icalendar-use-deadline
14968 #+vindex: org-icalendar-use-scheduled
14969 The iCalendar export back-end can also incorporate TODO entries based
14970 on the configuration of the ~org-icalendar-include-todo~ variable.
14971 The back-end exports plain timestamps as =VEVENT=, TODO items as
14972 =VTODO=, and also create events from deadlines that are in non-TODO
14973 items.  The back-end uses the deadlines and scheduling dates in Org
14974 TODO items for setting the start and due dates for the iCalendar TODO
14975 entry.  Consult the ~org-icalendar-use-deadline~ and
14976 ~org-icalendar-use-scheduled~ variables for more details.
14978 #+vindex: org-icalendar-categories
14979 #+vindex: org-icalendar-alarm-time
14980 For tags on the headline, the iCalendar export back-end makes them
14981 into iCalendar categories.  To tweak the inheritance of tags and TODO
14982 states, configure the variable ~org-icalendar-categories~.  To assign
14983 clock alarms based on time, configure the ~org-icalendar-alarm-time~
14984 variable.
14986 #+vindex: org-icalendar-store-UID
14987 #+cindex: @samp{ID}, property
14988 The iCalendar format standard requires globally unique identifier---or
14989 UID---for each entry.  The iCalendar export back-end creates UIDs
14990 during export.  To save a copy of the UID in the Org file set the
14991 variable ~org-icalendar-store-UID~.  The back-end looks for the =ID=
14992 property of the entry for re-using the same UID for subsequent
14993 exports.
14995 Since a single Org entry can result in multiple iCalendar
14996 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
14997 prefixes to the UID, depending on which part of the Org entry
14998 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
14999 remains unique, yet enable synchronization programs trace the
15000 connections.
15002 - {{{kbd(C-c C-e c f)}}} (~org-icalendar-export-to-ics~) ::
15004      #+kindex: C-c C-e c f
15005      #+findex: org-icalendar-export-to-ics
15006      Create iCalendar entries from the current Org buffer and store
15007      them in the same directory, using a file extension =.ics=.
15009 - {{{kbd(C-c C-e c a)}}} (~org-icalendar-export-agenda-files~) ::
15011      #+kindex: C-c C-e c a
15012      #+findex: org-icalendar-export-agenda-files
15013      Create iCalendar entries from Org files in ~org-agenda-files~ and
15014      store in a separate iCalendar file for each Org file.
15016 - {{{kbd(C-c C-e c c)}}} (~org-icalendar-combine-agenda-files~) ::
15018      #+kindex: C-c C-e c c
15019      #+findex: org-icalendar-combine-agenda-files
15020      #+vindex: org-icalendar-combined-agenda-file
15021      Create a combined iCalendar file from Org files in
15022      ~org-agenda-files~ and write it to
15023      ~org-icalendar-combined-agenda-file~ file name.
15025 #+cindex: @samp{SUMMARY}, property
15026 #+cindex: @samp{DESCRIPTION}, property
15027 #+cindex: @samp{LOCATION}, property
15028 #+cindex: @samp{TIMEZONE}, property
15029 The iCalendar export back-end includes =SUMMARY=, =DESCRIPTION=,
15030 =LOCATION= and =TIMEZONE= properties from the Org entries when
15031 exporting.  To force the back-end to inherit the =LOCATION= and
15032 =TIMEZONE= properties, configure the ~org-use-property-inheritance~
15033 variable.
15035 #+vindex: org-icalendar-include-body
15036 When Org entries do not have =SUMMARY=, =DESCRIPTION= and =LOCATION=
15037 properties, the iCalendar export back-end derives the summary from the
15038 headline, and derives the description from the body of the Org item.
15039 The ~org-icalendar-include-body~ variable limits the maximum number of
15040 characters of the content are turned into its description.
15042 The =TIMEZONE= property can be used to specify a per-entry time zone,
15043 and is applied to any entry with timestamp information.  Time zones
15044 should be specified as per the IANA time zone database format, e.g.,
15045 =Asia/Almaty=.  Alternately, the property value can be =UTC=, to force
15046 UTC time for this entry only.
15048 Exporting to iCalendar format depends in large part on the
15049 capabilities of the destination application.  Some are more lenient
15050 than others.  Consult the Org mode FAQ for advice on specific
15051 applications.
15053 ** Other Built-in Back-ends
15054 :PROPERTIES:
15055 :DESCRIPTION: Exporting to a man page.
15056 :END:
15058 Other export back-ends included with Org are:
15060 - =ox-man.el=: Export to a man page.
15062 To activate such back-ends, either customize ~org-export-backends~ or
15063 load directly with ~(require 'ox-man)~.  On successful load, the
15064 back-end adds new keys in the export dispatcher (see [[*The Export
15065 Dispatcher]]).
15067 Follow the comment section of such files, for example, =ox-man.el=,
15068 for usage and configuration details.
15070 ** Advanced Configuration
15071 :PROPERTIES:
15072 :DESCRIPTION: Fine-tuning the export output.
15073 :END:
15075 *** Hooks
15076 :PROPERTIES:
15077 :UNNUMBERED: notoc
15078 :END:
15080 #+vindex: org-export-before-processing-hook
15081 #+vindex: org-export-before-parsing-hook
15082 The export process executes two hooks before the actual exporting
15083 begins.  The first hook, ~org-export-before-processing-hook~, runs
15084 before any expansions of macros, Babel code, and include keywords in
15085 the buffer.  The second hook, ~org-export-before-parsing-hook~, runs
15086 before the buffer is parsed.
15088 Functions added to these hooks are called with a single argument: the
15089 export back-end actually used, as a symbol.  You may use them for
15090 heavy duty structural modifications of the document.  For example, you
15091 can remove every headline in the buffer during export like this:
15093 #+begin_src emacs-lisp
15094 (defun my-headline-removal (backend)
15095   "Remove all headlines in the current buffer.
15096 BACKEND is the export back-end being used, as a symbol."
15097   (org-map-entries
15098    (lambda () (delete-region (point) (line-beginning-position 2)))))
15100 (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15101 #+end_src
15103 *** Filters
15104 :PROPERTIES:
15105 :UNNUMBERED: notoc
15106 :END:
15108 #+cindex: Filters, exporting
15109 Filters are lists of functions to be applied to certain parts for
15110 a given back-end.  The output from the first function in the filter is
15111 passed on to the next function in the filter.  The final output is the
15112 output from the final function in the filter.
15114 The Org export process has many filter sets applicable to different
15115 types of objects, plain text, parse trees, export options, and final
15116 output formats.  The filters are named after the element type or
15117 object type: ~org-export-filter-TYPE-functions~, where {{{var(TYPE)}}}
15118 is the type targeted by the filter.  Valid types are:
15120 #+attr_texinfo: :columns 0.33 0.33 0.33
15121 | body                | bold               | babel-call       |
15122 | center-block        | clock              | code             |
15123 | diary-sexp          | drawer             | dynamic-block    |
15124 | entity              | example-block      | export-block     |
15125 | export-snippet      | final-output       | fixed-width      |
15126 | footnote-definition | footnote-reference | headline         |
15127 | horizontal-rule     | inline-babel-call  | inline-src-block |
15128 | inlinetask          | italic             | item             |
15129 | keyword             | latex-environment  | latex-fragment   |
15130 | line-break          | link               | node-property    |
15131 | options             | paragraph          | parse-tree       |
15132 | plain-list          | plain-text         | planning         |
15133 | property-drawer     | quote-block        | radio-target     |
15134 | section             | special-block      | src-block        |
15135 | statistics-cookie   | strike-through     | subscript        |
15136 | superscript         | table              | table-cell       |
15137 | table-row           | target             | timestamp        |
15138 | underline           | verbatim           | verse-block      |
15140 Here is an example filter that replaces non-breaking spaces ~ ~ in the
15141 Org buffer with =~= for the LaTeX back-end.
15143 #+begin_src emacs-lisp
15144 (defun my-latex-filter-nobreaks (text backend info)
15145   "Ensure \" \" are properly handled in LaTeX export."
15146   (when (org-export-derived-backend-p backend 'latex)
15147     (replace-regexp-in-string " " "~" text)))
15149 (add-to-list 'org-export-filter-plain-text-functions
15150              'my-latex-filter-nobreaks)
15151 #+end_src
15153 A filter requires three arguments: the code to be transformed, the
15154 name of the back-end, and some optional information about the export
15155 process.  The third argument can be safely ignored.  Note the use of
15156 ~org-export-derived-backend-p~ predicate that tests for /latex/
15157 back-end or any other back-end, such as /beamer/, derived from
15158 /latex/.
15160 *** Defining filters for individual files
15161 :PROPERTIES:
15162 :UNNUMBERED: notoc
15163 :END:
15165 The Org export can filter not just for back-ends, but also for
15166 specific files through the =BIND= keyword.  Here is an example with
15167 two filters; one removes brackets from time stamps, and the other
15168 removes strike-through text.  The filter functions are defined in
15169 a code block in the same Org file, which is a handy location for
15170 debugging.
15172 #+begin_example
15173 ,#+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15174 ,#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15175 ,#+BEGIN_SRC emacs-lisp :exports results :results none
15176   (defun tmp-f-timestamp (s backend info)
15177     (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15178   (defun tmp-f-strike-through (s backend info) "")
15179 ,#+END_SRC
15180 #+end_example
15182 *** Extending an existing back-end
15183 :PROPERTIES:
15184 :UNNUMBERED: notoc
15185 :END:
15187 Some parts of the conversion process can be extended for certain
15188 elements so as to introduce a new or revised translation.  That is how
15189 the HTML export back-end was extended to handle Markdown format.  The
15190 extensions work seamlessly so any aspect of filtering not done by the
15191 extended back-end is handled by the original back-end.  Of all the
15192 export customization in Org, extending is very powerful as it operates
15193 at the parser level.
15195 For this example, make the /ascii/ back-end display the language used
15196 in a source code block.  Also make it display only when some attribute
15197 is non-~nil~, like the following:
15199 : #+ATTR_ASCII: :language t
15201 Then extend ASCII back-end with a custom "my-ascii" back-end.
15203 #+begin_src emacs-lisp
15204 (defun my-ascii-src-block (src-block contents info)
15205   "Transcode a SRC-BLOCK element from Org to ASCII.
15206 CONTENTS is nil.  INFO is a plist used as a communication
15207 channel."
15208   (if (not (org-export-read-attribute :attr_ascii src-block :language))
15209       (org-export-with-backend 'ascii src-block contents info)
15210     (concat
15211      (format ",--[ %s ]--\n%s`----"
15212              (org-element-property :language src-block)
15213              (replace-regexp-in-string
15214               "^" "| "
15215               (org-element-normalize-string
15216                (org-export-format-code-default src-block info)))))))
15218 (org-export-define-derived-backend 'my-ascii 'ascii
15219   :translate-alist '((src-block . my-ascii-src-block)))
15220 #+end_src
15222 The ~my-ascii-src-block~ function looks at the attribute above the
15223 current element.  If not true, hands over to /ascii/ back-end.  If
15224 true, which it is in this example, it creates a box around the code
15225 and leaves room for the inserting a string for language.  The last
15226 form creates the new back-end that springs to action only when
15227 translating ~src-block~ type elements.
15229 To use the newly defined back-end, evaluate the following from an Org
15230 buffer:
15232 #+begin_src emacs-lisp
15233 (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15234 #+end_src
15236 Further steps to consider would be an interactive function,
15237 self-installing an item in the export dispatcher menu, and other
15238 user-friendly improvements.
15240 ** Export in Foreign Buffers
15241 :PROPERTIES:
15242 :DESCRIPTION: Author tables and lists in Org syntax.
15243 :END:
15245 The export back-ends in Org often include commands to convert selected
15246 regions.  A convenient feature of this in-place conversion is that the
15247 exported output replaces the original source.  Here are such
15248 functions:
15250 - ~org-html-convert-region-to-html~ ::
15252      #+findex: org-html-convert-region-to-html
15253      Convert the selected region into HTML.
15255 - ~org-latex-convert-region-to-latex~ ::
15257      #+findex: org-latex-convert-region-to-latex
15258      Convert the selected region into LaTeX.
15260 - ~org-texinfo-convert-region-to-texinfo~ ::
15262      #+findex: org-texinfo-convert-region-to-texinfo
15263      Convert the selected region into Texinfo.
15265 - ~org-md-convert-region-to-md~ ::
15267      #+findex: org-md-convert-region-to-md
15268      Convert the selected region into Markdown.
15270 In-place conversions are particularly handy for quick conversion of
15271 tables and lists in foreign buffers.  For example, turn on the minor
15272 mode {{{kbd(M-x orgstruct-mode)}}} in an HTML buffer, then use the
15273 convenient Org keyboard commands to create a list, select it, and
15274 covert it to HTML with {{{kbd(M-x org-html-convert-region-to-html)}}}.
15276 * Publishing
15277 :PROPERTIES:
15278 :DESCRIPTION: Create a web site of linked Org files.
15279 :END:
15280 #+cindex: publishing
15282 Org includes a publishing management system that allows you to
15283 configure automatic HTML conversion of /projects/ composed of
15284 interlinked Org files.  You can also configure Org to automatically
15285 upload your exported HTML pages and related attachments, such as
15286 images and source code files, to a web server.
15288 You can also use Org to convert files into PDF, or even combine HTML
15289 and PDF conversion so that files are available in both formats on the
15290 server.
15292 Publishing has been contributed to Org by David O'Toole.
15294 ** Configuration
15295 :PROPERTIES:
15296 :DESCRIPTION: Defining projects.
15297 :END:
15298 Publishing needs significant configuration to specify files,
15299 destination and many other properties of a project.
15301 *** The variable ~org-publish-project-alist~
15302 :PROPERTIES:
15303 :DESCRIPTION: The central configuration variable.
15304 :ALT_TITLE: Project alist
15305 :END:
15306 #+cindex: projects, for publishing
15308 #+vindex: org-publish-project-alist
15309 Publishing is configured almost entirely through setting the value of
15310 one variable, called ~org-publish-project-alist~.  Each element of the
15311 list configures one project, and may be in one of the two following
15312 forms:
15314 #+begin_src emacs-lisp
15315 ("project-name" :property value :property value ...)
15316 #+end_src
15318 #+texinfo: @noindent
15319 i.e., a well-formed property list with alternating keys and values,
15322 #+begin_src emacs-lisp
15323 ("project-name" :components ("project-name" "project-name" ...))
15324 #+end_src
15326 In both cases, projects are configured by specifying property values.
15327 A project defines the set of files that are to be published, as well
15328 as the publishing configuration to use when publishing those files.
15329 When a project takes the second form listed above, the individual
15330 members of the ~:components~ property are taken to be sub-projects,
15331 which group together files requiring different publishing options.
15332 When you publish such a "meta-project", all the components are also
15333 published, in the sequence given.
15335 *** Sources and destinations for files
15336 :PROPERTIES:
15337 :DESCRIPTION: From here to there.
15338 :ALT_TITLE: Sources and destinations
15339 :END:
15340 #+cindex: directories, for publishing
15342 Most properties are optional, but some should always be set.  In
15343 particular, Org needs to know where to look for source files, and
15344 where to put published files.
15346 - ~:base-directory~ ::
15348      Directory containing publishing source files.
15350 - ~:publishing-directory~ ::
15352      Directory where output files are published.  You can directly
15353      publish to a webserver using a file name syntax appropriate for
15354      the Emacs tramp package.  Or you can publish to a local directory
15355      and use external tools to upload your website (see [[*Uploading
15356      Files]]).
15358 - ~:preparation-function~ ::
15360      Function or list of functions to be called before starting the
15361      publishing process, for example, to run =make= for updating files
15362      to be published.  Each preparation function is called with
15363      a single argument, the project property list.
15365 - ~:completion-function~ ::
15367      Function or list of functions called after finishing the
15368      publishing process, for example, to change permissions of the
15369      resulting files.  Each completion function is called with
15370      a single argument, the project property list.
15372 *** Selecting files
15373 :PROPERTIES:
15374 :DESCRIPTION: What files are part of the project?
15375 :END:
15376 #+cindex: files, selecting for publishing
15378 By default, all files with extension =.org= in the base directory are
15379 considered part of the project.  This can be modified by setting the
15380 following properties
15382 - ~:base-extension~ ::
15384      Extension---without the dot---of source files.  This actually
15385      is a regular expression.  Set this to the symbol ~any~ if you
15386      want to get all files in ~:base-directory~, even without
15387      extension.
15389 - ~:exclude~ ::
15391      Regular expression to match file names that should not be published,
15392      even though they have been selected on the basis of their extension.
15394 - ~:include~ ::
15396      List of files to be included regardless of ~:base-extension~ and
15397      ~:exclude~.
15399 - ~:recursive~ ::
15401      Non-~nil~ means, check base-directory recursively for files to
15402      publish.
15404 *** Publishing action
15405 :PROPERTIES:
15406 :DESCRIPTION: Setting the function doing the publishing.
15407 :END:
15408 #+cindex: action, for publishing
15410 Publishing means that a file is copied to the destination directory
15411 and possibly transformed in the process.  The default transformation
15412 is to export Org files as HTML files, and this is done by the function
15413 ~org-publish-org-to-html~ which calls the HTML exporter (see [[*HTML
15414 Export]]).  But you can also publish your content as PDF files using
15415 ~org-publish-org-to-pdf~, or as ASCII, Texinfo, etc., using the
15416 corresponding functions.
15418 If you want to publish the Org file as an =.org= file but with
15419 /archived/, /commented/, and /tag-excluded/ trees removed, use
15420 ~org-publish-org-to-org~.  This produces =file.org= and put it in the
15421 publishing directory.  If you want a htmlized version of this file,
15422 set the parameter ~:htmlized-source~ to ~t~.  It produces
15423 =file.org.html= in the publishing directory[fn:129].
15425 Other files like images only need to be copied to the publishing
15426 destination; for this you can use ~org-publish-attachment~.  For
15427 non-Org files, you always need to specify the publishing function:
15429 - ~:publishing-function~ ::
15431      Function executing the publication of a file.  This may also be
15432      a list of functions, which are all called in turn.
15434 - ~:plain-source~ ::
15436      Non-~nil~ means, publish plain source.
15438 - ~:htmlized-source~ ::
15440      Non-~nil~ means, publish htmlized source.
15442 The function must accept three arguments: a property list containing
15443 at least a ~:publishing-directory~ property, the name of the file to
15444 be published, and the path to the publishing directory of the output
15445 file.  It should take the specified file, make the necessary
15446 transformation, if any, and place the result into the destination
15447 folder.
15449 *** Options for the exporters
15450 :PROPERTIES:
15451 :DESCRIPTION: Tweaking HTML/@LaTeX{} export.
15452 :ALT_TITLE: Publishing options
15453 :END:
15454 #+cindex: options, for publishing
15455 #+cindex: publishing options
15457 The property list can be used to set many export options for the HTML
15458 and LaTeX exporters.  In most cases, these properties correspond to
15459 user variables in Org.  The table below lists these properties along
15460 with the variable they belong to.  See the documentation string for
15461 the respective variable for details.
15463 #+vindex: org-publish-project-alist
15464 When a property is given a value in ~org-publish-project-alist~, its
15465 setting overrides the value of the corresponding user variable, if
15466 any, during publishing.  Options set within a file (see [[*Export
15467 Settings]]), however, override everything.
15469 **** Generic properties
15470 :PROPERTIES:
15471 :UNNUMBERED: notoc
15472 :END:
15474 | ~:archived-trees~       | ~org-export-with-archived-trees~   |
15475 | ~:exclude-tags~         | ~org-export-exclude-tags~          |
15476 | ~:headline-levels~      | ~org-export-headline-levels~       |
15477 | ~:language~             | ~org-export-default-language~      |
15478 | ~:preserve-breaks~      | ~org-export-preserve-breaks~       |
15479 | ~:section-numbers~      | ~org-export-with-section-numbers~  |
15480 | ~:select-tags~          | ~org-export-select-tags~           |
15481 | ~:with-author~          | ~org-export-with-author~           |
15482 | ~:with-broken-links~    | ~org-export-with-broken-links~     |
15483 | ~:with-clocks~          | ~org-export-with-clocks~           |
15484 | ~:with-creator~         | ~org-export-with-creator~          |
15485 | ~:with-date~            | ~org-export-with-date~             |
15486 | ~:with-drawers~         | ~org-export-with-drawers~          |
15487 | ~:with-email~           | ~org-export-with-email~            |
15488 | ~:with-emphasize~       | ~org-export-with-emphasize~        |
15489 | ~:with-fixed-width~     | ~org-export-with-fixed-width~      |
15490 | ~:with-footnotes~       | ~org-export-with-footnotes~        |
15491 | ~:with-latex~           | ~org-export-with-latex~            |
15492 | ~:with-planning~        | ~org-export-with-planning~         |
15493 | ~:with-priority~        | ~org-export-with-priority~         |
15494 | ~:with-properties~      | ~org-export-with-properties~       |
15495 | ~:with-special-strings~ | ~org-export-with-special-strings~  |
15496 | ~:with-sub-superscript~ | ~org-export-with-sub-superscripts~ |
15497 | ~:with-tables~          | ~org-export-with-tables~           |
15498 | ~:with-tags~            | ~org-export-with-tags~             |
15499 | ~:with-tasks~           | ~org-export-with-tasks~            |
15500 | ~:with-timestamps~      | ~org-export-with-timestamps~       |
15501 | ~:with-title~           | ~org-export-with-title~            |
15502 | ~:with-toc~             | ~org-export-with-toc~              |
15503 | ~:with-todo-keywords~   | ~org-export-with-todo-keywords~    |
15505 **** ASCII specific properties
15506 :PROPERTIES:
15507 :UNNUMBERED: notoc
15508 :END:
15510 | ~:ascii-bullets~                       | ~org-ascii-bullets~                       |
15511 | ~:ascii-caption-above~                 | ~org-ascii-caption-above~                 |
15512 | ~:ascii-charset~                       | ~org-ascii-charset~                       |
15513 | ~:ascii-global-margin~                 | ~org-ascii-global-margin~                 |
15514 | ~:ascii-format-drawer-function~        | ~org-ascii-format-drawer-function~        |
15515 | ~:ascii-format-inlinetask-function~    | ~org-ascii-format-inlinetask-function~    |
15516 | ~:ascii-headline-spacing~              | ~org-ascii-headline-spacing~              |
15517 | ~:ascii-indented-line-width~           | ~org-ascii-indented-line-width~           |
15518 | ~:ascii-inlinetask-width~              | ~org-ascii-inlinetask-width~              |
15519 | ~:ascii-inner-margin~                  | ~org-ascii-inner-margin~                  |
15520 | ~:ascii-links-to-notes~                | ~org-ascii-links-to-notes~                |
15521 | ~:ascii-list-margin~                   | ~org-ascii-list-margin~                   |
15522 | ~:ascii-paragraph-spacing~             | ~org-ascii-paragraph-spacing~             |
15523 | ~:ascii-quote-margin~                  | ~org-ascii-quote-margin~                  |
15524 | ~:ascii-table-keep-all-vertical-lines~ | ~org-ascii-table-keep-all-vertical-lines~ |
15525 | ~:ascii-table-use-ascii-art~           | ~org-ascii-table-use-ascii-art~           |
15526 | ~:ascii-table-widen-columns~           | ~org-ascii-table-widen-columns~           |
15527 | ~:ascii-text-width~                    | ~org-ascii-text-width~                    |
15528 | ~:ascii-underline~                     | ~org-ascii-underline~                     |
15529 | ~:ascii-verbatim-format~               | ~org-ascii-verbatim-format~               |
15531 **** Beamer specific properties
15532 :PROPERTIES:
15533 :UNNUMBERED: notoc
15534 :END:
15536 | ~:beamer-theme~                 | ~org-beamer-theme~                 |
15537 | ~:beamer-column-view-format~    | ~org-beamer-column-view-format~    |
15538 | ~:beamer-environments-extra~    | ~org-beamer-environments-extra~    |
15539 | ~:beamer-frame-default-options~ | ~org-beamer-frame-default-options~ |
15540 | ~:beamer-outline-frame-options~ | ~org-beamer-outline-frame-options~ |
15541 | ~:beamer-outline-frame-title~   | ~org-beamer-outline-frame-title~   |
15542 | ~:beamer-subtitle-format~       | ~org-beamer-subtitle-format~       |
15544 **** HTML specific properties
15545 :PROPERTIES:
15546 :UNNUMBERED: notoc
15547 :END:
15549 | ~:html-allow-name-attribute-in-anchors~        | ~org-html-allow-name-attribute-in-anchors~        |
15550 | ~:html-checkbox-type~                          | ~org-html-checkbox-type~                          |
15551 | ~:html-container~                              | ~org-html-container-element~                      |
15552 | ~:html-divs~                                   | ~org-html-divs~                                   |
15553 | ~:html-doctype~                                | ~org-html-doctype~                                |
15554 | ~:html-extension~                              | ~org-html-extension~                              |
15555 | ~:html-footnote-format~                        | ~org-html-footnote-format~                        |
15556 | ~:html-footnote-separator~                     | ~org-html-footnote-separator~                     |
15557 | ~:html-footnotes-section~                      | ~org-html-footnotes-section~                      |
15558 | ~:html-format-drawer-function~                 | ~org-html-format-drawer-function~                 |
15559 | ~:html-format-headline-function~               | ~org-html-format-headline-function~               |
15560 | ~:html-format-inlinetask-function~             | ~org-html-format-inlinetask-function~             |
15561 | ~:html-head-extra~                             | ~org-html-head-extra~                             |
15562 | ~:html-head-include-default-style~             | ~org-html-head-include-default-style~             |
15563 | ~:html-head-include-scripts~                   | ~org-html-head-include-scripts~                   |
15564 | ~:html-head~                                   | ~org-html-head~                                   |
15565 | ~:html-home/up-format~                         | ~org-html-home/up-format~                         |
15566 | ~:html-html5-fancy~                            | ~org-html-html5-fancy~                            |
15567 | ~:html-indent~                                 | ~org-html-indent~                                 |
15568 | ~:html-infojs-options~                         | ~org-html-infojs-options~                         |
15569 | ~:html-infojs-template~                        | ~org-html-infojs-template~                        |
15570 | ~:html-inline-image-rules~                     | ~org-html-inline-image-rules~                     |
15571 | ~:html-inline-images~                          | ~org-html-inline-images~                          |
15572 | ~:html-link-home~                              | ~org-html-link-home~                              |
15573 | ~:html-link-org-files-as-html~                 | ~org-html-link-org-files-as-html~                 |
15574 | ~:html-link-up~                                | ~org-html-link-up~                                |
15575 | ~:html-link-use-abs-url~                       | ~org-html-link-use-abs-url~                       |
15576 | ~:html-mathjax-options~                        | ~org-html-mathjax-options~                        |
15577 | ~:html-mathjax-template~                       | ~org-html-mathjax-template~                       |
15578 | ~:html-metadata-timestamp-format~              | ~org-html-metadata-timestamp-format~              |
15579 | ~:html-postamble-format~                       | ~org-html-postamble-format~                       |
15580 | ~:html-postamble~                              | ~org-html-postamble~                              |
15581 | ~:html-preamble-format~                        | ~org-html-preamble-format~                        |
15582 | ~:html-preamble~                               | ~org-html-preamble~                               |
15583 | ~:html-table-align-individual-field~           | ~de{org-html-table-align-individual-fields~       |
15584 | ~:html-table-attributes~                       | ~org-html-table-default-attributes~               |
15585 | ~:html-table-caption-above~                    | ~org-html-table-caption-above~                    |
15586 | ~:html-table-data-tags~                        | ~org-html-table-data-tags~                        |
15587 | ~:html-table-header-tags~                      | ~org-html-table-header-tags~                      |
15588 | ~:html-table-row-tags~                         | ~org-html-table-row-tags~                         |
15589 | ~:html-table-use-header-tags-for-first-column~ | ~org-html-table-use-header-tags-for-first-column~ |
15590 | ~:html-tag-class-prefix~                       | ~org-html-tag-class-prefix~                       |
15591 | ~:html-text-markup-alist~                      | ~org-html-text-markup-alist~                      |
15592 | ~:html-todo-kwd-class-prefix~                  | ~org-html-todo-kwd-class-prefix~                  |
15593 | ~:html-toplevel-hlevel~                        | ~org-html-toplevel-hlevel~                        |
15594 | ~:html-use-infojs~                             | ~org-html-use-infojs~                             |
15595 | ~:html-validation-link~                        | ~org-html-validation-link~                        |
15596 | ~:html-viewport~                               | ~org-html-viewport~                               |
15597 | ~:html-xml-declaration~                        | ~org-html-xml-declaration~                        |
15599 **** LaTeX specific properties
15600 :PROPERTIES:
15601 :UNNUMBERED: notoc
15602 :END:
15604 | ~:latex-active-timestamp-format~       | ~org-latex-active-timestamp-format~       |
15605 | ~:latex-caption-above~                 | ~org-latex-caption-above~                 |
15606 | ~:latex-classes~                       | ~org-latex-classes~                       |
15607 | ~:latex-class~                         | ~org-latex-default-class~                 |
15608 | ~:latex-compiler~                      | ~org-latex-compiler~                      |
15609 | ~:latex-default-figure-position~       | ~org-latex-default-figure-position~       |
15610 | ~:latex-default-table-environment~     | ~org-latex-default-table-environment~     |
15611 | ~:latex-default-table-mode~            | ~org-latex-default-table-mode~            |
15612 | ~:latex-diary-timestamp-format~        | ~org-latex-diary-timestamp-format~        |
15613 | ~:latex-footnote-defined-format~       | ~org-latex-footnote-defined-format~       |
15614 | ~:latex-footnote-separator~            | ~org-latex-footnote-separator~            |
15615 | ~:latex-format-drawer-function~        | ~org-latex-format-drawer-function~        |
15616 | ~:latex-format-headline-function~      | ~org-latex-format-headline-function~      |
15617 | ~:latex-format-inlinetask-function~    | ~org-latex-format-inlinetask-function~    |
15618 | ~:latex-hyperref-template~             | ~org-latex-hyperref-template~             |
15619 | ~:latex-image-default-height~          | ~org-latex-image-default-height~          |
15620 | ~:latex-image-default-option~          | ~org-latex-image-default-option~          |
15621 | ~:latex-image-default-width~           | ~org-latex-image-default-width~           |
15622 | ~:latex-images-centered~               | ~org-latex-images-centered~               |
15623 | ~:latex-inactive-timestamp-format~     | ~org-latex-inactive-timestamp-format~     |
15624 | ~:latex-inline-image-rules~            | ~org-latex-inline-image-rules~            |
15625 | ~:latex-link-with-unknown-path-format~ | ~org-latex-link-with-unknown-path-format~ |
15626 | ~:latex-listings-langs~                | ~org-latex-listings-langs~                |
15627 | ~:latex-listings-options~              | ~org-latex-listings-options~              |
15628 | ~:latex-listings~                      | ~org-latex-listings~                      |
15629 | ~:latex-minted-langs~                  | ~org-latex-minted-langs~                  |
15630 | ~:latex-minted-options~                | ~org-latex-minted-options~                |
15631 | ~:latex-prefer-user-labels~            | ~org-latex-prefer-user-labels~            |
15632 | ~:latex-subtitle-format~               | ~org-latex-subtitle-format~               |
15633 | ~:latex-subtitle-separate~             | ~org-latex-subtitle-separate~             |
15634 | ~:latex-table-scientific-notation~     | ~org-latex-table-scientific-notation~     |
15635 | ~:latex-tables-booktabs~               | ~org-latex-tables-booktabs~               |
15636 | ~:latex-tables-centered~               | ~org-latex-tables-centered~               |
15637 | ~:latex-text-markup-alist~             | ~org-latex-text-markup-alist~             |
15638 | ~:latex-title-command~                 | ~org-latex-title-command~                 |
15639 | ~:latex-toc-command~                   | ~org-latex-toc-command~                   |
15641 **** Markdown specific properties
15642 :PROPERTIES:
15643 :UNNUMBERED: notoc
15644 :END:
15646 | ~:md-footnote-format~   | ~org-md-footnote-format~   |
15647 | ~:md-footnotes-section~ | ~org-md-footnotes-section~ |
15648 | ~:md-headline-style~    | ~org-md-headline-style~    |
15650 **** ODT specific properties
15651 :PROPERTIES:
15652 :UNNUMBERED: notoc
15653 :END:
15655 | ~:odt-content-template-file~      | ~org-odt-content-template-file~      |
15656 | ~:odt-display-outline-level~      | ~org-odt-display-outline-level~      |
15657 | ~:odt-fontify-srcblocks~          | ~org-odt-fontify-srcblocks~          |
15658 | ~:odt-format-drawer-function~     | ~org-odt-format-drawer-function~     |
15659 | ~:odt-format-headline-function~   | ~org-odt-format-headline-function~   |
15660 | ~:odt-format-inlinetask-function~ | ~org-odt-format-inlinetask-function~ |
15661 | ~:odt-inline-formula-rules~       | ~org-odt-inline-formula-rules~       |
15662 | ~:odt-inline-image-rules~         | ~org-odt-inline-image-rules~         |
15663 | ~:odt-pixels-per-inch~            | ~org-odt-pixels-per-inch~            |
15664 | ~:odt-styles-file~                | ~org-odt-styles-file~                |
15665 | ~:odt-table-styles~               | ~org-odt-table-styles~               |
15666 | ~:odt-use-date-fields~            | ~org-odt-use-date-fields~            |
15668 **** Texinfo specific properties
15669 :PROPERTIES:
15670 :UNNUMBERED: notoc
15671 :END:
15673 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
15674 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
15675 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
15676 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
15677 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
15678 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |
15679 | ~:texinfo-format-drawer-function~        | ~org-texinfo-format-drawer-function~        |
15680 | ~:texinfo-format-headline-function~      | ~org-texinfo-format-headline-function~      |
15681 | ~:texinfo-format-inlinetask-function~    | ~org-texinfo-format-inlinetask-function~    |
15682 | ~:texinfo-inactive-timestamp-format~     | ~org-texinfo-inactive-timestamp-format~     |
15683 | ~:texinfo-link-with-unknown-path-format~ | ~org-texinfo-link-with-unknown-path-format~ |
15684 | ~:texinfo-node-description-column~       | ~org-texinfo-node-description-column~       |
15685 | ~:texinfo-table-scientific-notation~     | ~org-texinfo-table-scientific-notation~     |
15686 | ~:texinfo-tables-verbatim~               | ~org-texinfo-tables-verbatim~               |
15687 | ~:texinfo-text-markup-alist~             | ~org-texinfo-text-markup-alist~             |
15689 *** Publishing links
15690 :PROPERTIES:
15691 :DESCRIPTION: Which links keep working after publishing?
15692 :END:
15693 #+cindex: links, publishing
15695 To create a link from one Org file to another, you would use something
15696 like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]).  When
15697 published, this link becomes a link to =foo.html=.  You can thus
15698 interlink the pages of your "Org web" project and the links will work
15699 as expected when you publish them to HTML.  If you also publish the
15700 Org source file and want to link to it, use an =http= link instead of
15701 a =file:= link, because =file= links are converted to link to the
15702 corresponding =.html= file.
15704 You may also link to related files, such as images.  Provided you are
15705 careful with relative file names, and provided you have also
15706 configured Org to upload the related files, these links will work too.
15707 See [[*Example: complex publishing configuration]], for an example of this
15708 usage.
15710 Eventually, links between published documents can contain some search
15711 options (see [[*Search Options in File Links]]), which will be resolved to
15712 the appropriate location in the linked file.  For example, once
15713 published to HTML, the following links all point to a dedicated anchor
15714 in =foo.html=.
15716 #+begin_example
15717 [[file:foo.org::*heading]]
15718 [[file:foo.org::#custom-id]]
15719 [[file:foo.org::target]]
15720 #+end_example
15722 *** Generating a sitemap
15723 :PROPERTIES:
15724 :DESCRIPTION: Generating a list of all pages.
15725 :ALT_TITLE: Site map
15726 :END:
15727 #+cindex: sitemap, of published pages
15729 The following properties may be used to control publishing of
15730 a map of files for a given project.
15732 - ~:auto-sitemap~ ::
15734      When non-~nil~, publish a sitemap during
15735      ~org-publish-current-project~ or ~org-publish-all~.
15737 - ~:sitemap-filename~ ::
15739      Filename for output of sitemap.  Defaults to =sitemap.org=, which
15740      becomes =sitemap.html=.
15742 - ~:sitemap-title~ ::
15744      Title of sitemap page.  Defaults to name of file.
15746 - ~:sitemap-format-entry~ ::
15748      #+findex: org-publish-find-date
15749      #+findex: org-publish-find-property
15750      #+findex: org-publish-find-title
15751      With this option one can tell how a site-map entry is formatted
15752      in the site-map.  It is a function called with three arguments:
15753      the file or directory name relative to base directory of the
15754      project, the site-map style and the current project.  It is
15755      expected to return a string.  Default value turns file names into
15756      links and use document titles as descriptions.  For specific
15757      formatting needs, one can use ~org-publish-find-date~,
15758      ~org-publish-find-title~ and ~org-publish-find-property~, to
15759      retrieve additional information about published documents.
15761 - ~:sitemap-function~ ::
15763      Plug-in function to use for generation of the sitemap.  It is
15764      called with two arguments: the title of the site-map and
15765      a representation of the files and directories involved in the
15766      project as a nested list, which can further be transformed using
15767      ~org-list-to-generic~, ~org-list-to-subtree~ and alike.  Default
15768      value generates a plain list of links to all files in the
15769      project.
15771 - ~:sitemap-sort-folders~ ::
15773      Where folders should appear in the sitemap.  Set this to ~first~
15774      (default) or ~last~ to display folders first or last,
15775      respectively.  When set to ~ignore~, folders are ignored
15776      altogether.  Any other value mixes files and folders.  This
15777      variable has no effect when site-map style is ~tree~.
15779 - ~:sitemap-sort-files~ ::
15781      How the files are sorted in the site map.  Set this to
15782      ~alphabetically~ (default), ~chronologically~ or
15783      ~anti-chronologically~.  ~chronologically~ sorts the files with
15784      older date first while ~anti-chronologically~ sorts the files
15785      with newer date first.  ~alphabetically~ sorts the files
15786      alphabetically.  The date of a file is retrieved with
15787      ~org-publish-find-date~.
15789 - ~:sitemap-ignore-case~ ::
15791      Should sorting be case-sensitive?  Default ~nil~.
15793 - ~:sitemap-file-entry-format~ ::
15795      With this option one can tell how a sitemap's entry is formatted
15796      in the sitemap.  This is a format string with some escape
15797      sequences: ~%t~ stands for the title of the file, ~%a~ stands for
15798      the author of the file and ~%d~ stands for the date of the file.
15799      The date is retrieved with the ~org-publish-find-date~ function
15800      and formatted with ~org-publish-sitemap-date-format~.  Default
15801      ~%t~.
15803 - ~:sitemap-date-format~ ::
15805      Format string for the ~format-time-string~ function that tells
15806      how a sitemap entry's date is to be formatted.  This property
15807      bypasses ~org-publish-sitemap-date-format~ which defaults to
15808      ~%Y-%m-%d~.
15810 *** Generating an index
15811 :PROPERTIES:
15812 :DESCRIPTION: An index that reaches across pages.
15813 :END:
15814 #+cindex: index, in a publishing project
15816 Org mode can generate an index across the files of a publishing project.
15818 - ~:makeindex~ ::
15820      When non-~nil~, generate in index in the file =theindex.org= and
15821      publish it as =theindex.html=.
15823 The file is created when first publishing a project with the
15824 ~:makeindex~ set.  The file only contains a statement =#+INCLUDE:
15825 "theindex.inc"=.  You can then build around this include statement by
15826 adding a title, style information, etc.
15828 #+cindex: @samp{INDEX}, keyword
15829 Index entries are specified with =INDEX= keyword.  An entry that
15830 contains an exclamation mark creates a sub item.
15832 #+begin_example
15833 ,*** Curriculum Vitae
15834 ,#+INDEX: CV
15835 ,#+INDEX: Application!CV
15836 #+end_example
15838 ** Uploading Files
15839 :PROPERTIES:
15840 :DESCRIPTION: How to get files up on the server.
15841 :END:
15842 #+cindex: rsync
15843 #+cindex: unison
15845 For those people already utilizing third party sync tools such as
15846 Rsync or Unison, it might be preferable not to use the built-in remote
15847 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
15848 while very useful and powerful, tends not to be so efficient for
15849 multiple file transfer and has been known to cause problems under
15850 heavy usage.
15852 Specialized synchronization utilities offer several advantages.  In
15853 addition to timestamp comparison, they also do content and
15854 permissions/attribute checks.  For this reason you might prefer to
15855 publish your web to a local directory---possibly even /in place/ with
15856 your Org files---and then use Unison or Rsync to do the
15857 synchronization with the remote host.
15859 Since Unison, for example, can be configured as to which files to
15860 transfer to a certain remote destination, it can greatly simplify the
15861 project publishing definition.  Simply keep all files in the correct
15862 location, process your Org files with ~org-publish~ and let the
15863 synchronization tool do the rest.  You do not need, in this scenario,
15864 to include attachments such as JPG, CSS or PNG files in the project
15865 definition since the third-party tool syncs them.
15867 Publishing to a local directory is also much faster than to a remote
15868 one, so that you can afford more easily to republish entire projects.
15869 If you set ~org-publish-use-timestamps-flag~ to ~nil~, you gain the
15870 main benefit of re-including any changed external files such as source
15871 example files you might include with =INCLUDE= keyword.  The timestamp
15872 mechanism in Org is not smart enough to detect if included files have
15873 been modified.
15875 ** Sample Configuration
15876 :PROPERTIES:
15877 :DESCRIPTION: Example projects.
15878 :END:
15880 Below we provide two example configurations.  The first one is
15881 a simple project publishing only a set of Org files.  The second
15882 example is more complex, with a multi-component project.
15884 *** Example: simple publishing configuration
15885 :PROPERTIES:
15886 :DESCRIPTION: One-component publishing.
15887 :ALT_TITLE: Simple example
15888 :END:
15890 This example publishes a set of Org files to the =public_html=
15891 directory on the local machine.
15893 #+begin_src emacs-lisp
15894 (setq org-publish-project-alist
15895       '(("org"
15896          :base-directory "~/org/"
15897          :publishing-directory "~/public_html"
15898          :section-numbers nil
15899          :table-of-contents nil
15900          :style "<link rel=\"stylesheet\"
15901                 href=\"../other/mystyle.css\"
15902                 type=\"text/css\"/>")))
15903 #+end_src
15905 *** Example: complex publishing configuration
15906 :PROPERTIES:
15907 :DESCRIPTION: A multi-component publishing example.
15908 :ALT_TITLE: Complex example
15909 :END:
15911 This more complicated example publishes an entire website, including
15912 Org files converted to HTML, image files, Emacs Lisp source code, and
15913 style sheets.  The publishing directory is remote and private files
15914 are excluded.
15916 To ensure that links are preserved, care should be taken to replicate
15917 your directory structure on the web server, and to use relative file
15918 paths.  For example, if your Org files are kept in =~/org/= and your
15919 publishable images in =~/images/=, you would link to an image with
15921 : file:../images/myimage.png
15923 On the web server, the relative path to the image should be the same.
15924 You can accomplish this by setting up an =images/= folder in the right
15925 place on the web server, and publishing images to it.
15927 #+begin_src emacs-lisp
15928 (setq org-publish-project-alist
15929       '(("orgfiles"
15930          :base-directory "~/org/"
15931          :base-extension "org"
15932          :publishing-directory "/ssh:user@host:~/html/notebook/"
15933          :publishing-function org-html-publish-to-html
15934          :exclude "PrivatePage.org" ;; regexp
15935          :headline-levels 3
15936          :section-numbers nil
15937          :with-toc nil
15938          :html-head "<link rel=\"stylesheet\"
15939                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
15940          :html-preamble t)
15942         ("images"
15943          :base-directory "~/images/"
15944          :base-extension "jpg\\|gif\\|png"
15945          :publishing-directory "/ssh:user@host:~/html/images/"
15946          :publishing-function org-publish-attachment)
15948         ("other"
15949          :base-directory "~/other/"
15950          :base-extension "css\\|el"
15951          :publishing-directory "/ssh:user@host:~/html/other/"
15952          :publishing-function org-publish-attachment)
15953         ("website" :components ("orgfiles" "images" "other"))))
15954 #+end_src
15956 ** Triggering Publication
15957 :PROPERTIES:
15958 :DESCRIPTION: Publication commands.
15959 :END:
15961 Once properly configured, Org can publish with the following commands:
15963 - {{{kbd(C-c C-e X)}}} (~org-publish~) ::
15965      #+kindex: C-c C-e X
15966      #+findex: org-publish
15967      Prompt for a specific project and publish all files that belong
15968      to it.
15970 - {{{kbd(C-c C-e P)}}} (~org-publish-current-project~) ::
15972      #+kindex: C-c C-e P
15973      #+findex: org-publish-current-project
15974      Publish the project containing the current file.
15976 - {{{kbd(C-c C-e F)}}} (~org-publish-current-file~) ::
15978      #+kindex: C-c C-e F
15979      #+findex: org-publish-current-file
15980      Publish only the current file.
15982 - {{{kbd(C-c C-e E)}}} (~org-publish-all~) ::
15984      #+kindex: C-c C-e E
15985      #+findex: org-publish-all
15986      Publish every project.
15988 #+vindex: org-publish-use-timestamps-flag
15989 Org uses timestamps to track when a file has changed.  The above
15990 functions normally only publish changed files.  You can override this
15991 and force publishing of all files by giving a prefix argument to any
15992 of the commands above, or by customizing the variable
15993 ~org-publish-use-timestamps-flag~.  This may be necessary in
15994 particular if files include other files via =SETUPFILE= or =INCLUDE=
15995 keywords.
15997 * Working with Source Code
15998 :PROPERTIES:
15999 :DESCRIPTION: Export, evaluate, and tangle code blocks.
16000 :END:
16001 #+cindex: source code, working with
16003 Source code here refers to any plain text collection of computer
16004 instructions, possibly with comments, written using a human-readable
16005 programming language.  Org can manage source code in an Org document
16006 when the source code is identified with begin and end markers.
16007 Working with source code begins with identifying source code blocks.
16008 A source code block can be placed almost anywhere in an Org document;
16009 it is not restricted to the preamble or the end of the document.
16010 However, Org cannot manage a source code block if it is placed inside
16011 an Org comment or within a fixed width section.
16013 Here is an example source code block in the Emacs Lisp language:
16015 #+begin_example
16016 ,#+BEGIN_SRC emacs-lisp
16017   (defun org-xor (a b)
16018      "Exclusive or."
16019      (if a (not b) b))
16020 ,#+END_SRC
16021 #+end_example
16023 Org can manage the source code in the block delimited by =#+BEGIN_SRC=
16024 ... =#+END_SRC= in several ways that can simplify housekeeping tasks
16025 essential to modern source code maintenance.  Org can edit, format,
16026 extract, export, and publish source code blocks.  Org can also compile
16027 and execute a source code block, then capture the results.  The Org
16028 mode literature sometimes refers to source code blocks as /live code/
16029 blocks because they can alter the content of the Org document or the
16030 material that it exports.  Users can control how live they want each
16031 source code block by tweaking the header arguments (see [[*Using
16032 Header Arguments]]) for compiling, execution, extraction, and
16033 exporting.
16035 Source code blocks are one of many Org block types, which also include
16036 =quote=, =export=, =verse=, =latex=, =example=, and =verbatim=.  This
16037 section pertains to blocks between =#+BEGIN_SRC= and =#+END_SRC=.
16039 For editing and formatting a source code block, Org uses an
16040 appropriate Emacs major mode that includes features specifically
16041 designed for source code in that language.
16043 Org can extract one or more source code blocks and write them to one
16044 or more source files---a process known as /tangling/ in literate
16045 programming terminology.
16047 For exporting and publishing, Org's back-ends can format a source code
16048 block appropriately, often with native syntax highlighting.
16050 For executing and compiling a source code block, the user can
16051 configure Org to select the appropriate compiler.  Org provides
16052 facilities to collect the result of the execution or compiler output,
16053 insert it into the Org document, and/or export it.  In addition to
16054 text results, Org can insert links to other data types, including
16055 audio, video, and graphics.  Org can also link a compiler error
16056 message to the appropriate line in the source code block.
16058 An important feature of Org's management of source code blocks is the
16059 ability to pass variables, functions, and results to one another using
16060 a common syntax for source code blocks in any language.  Although most
16061 literate programming facilities are restricted to one language or
16062 another, Org's language-agnostic approach lets the literate programmer
16063 match each programming task with the appropriate computer language and
16064 to mix them all together in a single Org document.  This
16065 interoperability among languages explains why Org's source code
16066 management facility was named /Org Babel/ by its originators, Eric
16067 Schulte and Dan Davison.
16069 Org mode fulfills the promise of easy verification and maintenance of
16070 publishing reproducible research by keeping text, data, code,
16071 configuration settings of the execution environment, the results of
16072 the execution, and associated narratives, claims, references, and
16073 internal and external links in a single Org document.
16075 Details of Org's facilities for working with source code are described
16076 in the following sections.
16078 ** Structure of Code Blocks
16079 :PROPERTIES:
16080 :DESCRIPTION: Code block syntax described.
16081 :END:
16082 #+cindex: code block, structure
16083 #+cindex: source code, block structure
16084 #+cindex: @samp{NAME} keyword, in source blocks
16085 #+cindex: @samp{BEGIN_SRC}
16087 Org offers two ways to structure source code in Org documents: in
16088 a source code block, and directly inline.  Both specifications are
16089 shown below.
16091 A source code block conforms to this structure:
16093 #+begin_example
16094 ,#+NAME: <name>
16095 ,#+BEGIN_SRC <language> <switches> <header arguments>
16096   <body>
16097 ,#+END_SRC
16098 #+end_example
16100 Do not be put-off by having to remember the source block syntax.  Org
16101 mode offers a command for wrapping existing text in a block (see
16102 [[*Structure Templates]]).  Org also works with other completion systems
16103 in Emacs, some of which predate Org and have custom domain-specific
16104 languages for defining templates.  Regular use of templates reduces
16105 errors, increases accuracy, and maintains consistency.
16107 #+cindex: source code, inline
16108 An inline code block conforms to this structure:
16110 : src_<language>{<body>}
16112 #+texinfo: @noindent
16115 : src_<language>[<header arguments>]{<body>}
16117 - =#+NAME: <name>= ::
16119      Optional.  Names the source block so it can be called, like
16120      a function, from other source blocks or inline code to evaluate
16121      or to capture the results.  Code from other blocks, other files,
16122      and from table formulas (see [[*The spreadsheet]]) can use the name
16123      to reference a source block.  This naming serves the same purpose
16124      as naming Org tables.  Org mode requires unique names.  For
16125      duplicate names, Org mode's behavior is undefined.
16127 - =#+BEGIN_SRC= ... =#+END_SRC= ::
16129      Mandatory.  They mark the start and end of a block that Org
16130      requires.  The =#+BEGIN_SRC= line takes additional arguments, as
16131      described next.
16133 - =<language>= ::
16135      #+cindex: language, in code blocks
16136      Mandatory.  It is the identifier of the source code language in
16137      the block.  See [[*Languages]], for identifiers of supported
16138      languages.
16140 - =<switches>= ::
16142      #+cindex: switches, in code blocks
16143      Optional.  Switches provide finer control of the code execution,
16144      export, and format (see the discussion of switches in [[*Literal
16145      Examples]]).
16147 - =<header arguments>= ::
16149      #+cindex: header arguments, in code blocks
16150      Optional.  Heading arguments control many aspects of evaluation,
16151      export and tangling of code blocks (see [[*Using Header Arguments]]).
16152      Using Org's properties feature, header arguments can be
16153      selectively applied to the entire buffer or specific sub-trees of
16154      the Org document.
16156 - =<body>= ::
16158      Source code in the dialect of the specified language identifier.
16160 ** Using Header Arguments
16161 :PROPERTIES:
16162 :DESCRIPTION: Different ways to set header arguments.
16163 :END:
16165 Org comes with many header arguments common to all languages.  New
16166 header arguments are added for specific languages as they become
16167 available for use in source code blocks.  A header argument is
16168 specified with an initial colon followed by the argument's name in
16169 lowercase.
16171 Since header arguments can be set in several ways, Org prioritizes
16172 them in case of overlaps or conflicts by giving local settings
16173 a higher priority.  Header values in function calls, for example,
16174 override header values from global defaults.
16176 *** System-wide header arguments
16177 :PROPERTIES:
16178 :UNNUMBERED: notoc
16179 :END:
16180 #+vindex: org-babel-default-header-args
16182 #+vindex: org-babel-default-header-args
16183 System-wide values of header arguments can be specified by customizing
16184 the ~org-babel-default-header-args~ variable, which defaults to the
16185 following values:
16187 #+begin_example
16188 :session    => "none"
16189 :results    => "replace"
16190 :exports    => "code"
16191 :cache      => "no"
16192 :noweb      => "no"
16193 #+end_example
16195 The example below sets =:noweb= header arguments to =yes=, which makes
16196 Org expand =:noweb= references by default.
16198 #+begin_src emacs-lisp
16199 (setq org-babel-default-header-args
16200       (cons '(:noweb . "yes")
16201             (assq-delete-all :noweb org-babel-default-header-args)))
16202 #+end_src
16204 #+cindex: language specific default header arguments
16205 #+cindex: default header arguments per language
16206 Each language can have separate default header arguments by
16207 customizing the variable ~org-babel-default-header-args:<LANG>~, where
16208 {{{var(<LANG>)}}} is the name of the language.  For details, see the
16209 language-specific online documentation at
16210 https://orgmode.org/worg/org-contrib/babel/.
16212 *** Header arguments in Org mode properties
16213 :PROPERTIES:
16214 :UNNUMBERED: notoc
16215 :END:
16217 For header arguments applicable to the buffer, use =PROPERTY= keyword
16218 anywhere in the Org file (see [[*Property Syntax]]).
16220 The following example makes all the R code blocks execute in the same
16221 session.  Setting =:results= to =silent= ignores the results of
16222 executions for all blocks, not just R code blocks; no results inserted
16223 for any block.
16225 #+begin_example
16226 ,#+PROPERTY: header-args:R  :session *R*
16227 ,#+PROPERTY: header-args    :results silent
16228 #+end_example
16230 #+vindex: org-use-property-inheritance
16231 Header arguments set through Org's property drawers (see [[*Property
16232 Syntax]]) apply at the sub-tree level on down.  Since these property
16233 drawers can appear anywhere in the file hierarchy, Org uses outermost
16234 call or source block to resolve the values.  Org ignores
16235 ~org-use-property-inheritance~ setting.
16237 In this example, =:cache= defaults to =yes= for all code blocks in the
16238 sub-tree.
16240 #+begin_example
16241 ,* sample header
16242   :PROPERTIES:
16243   :header-args:    :cache yes
16244   :END:
16245 #+end_example
16247 #+kindex: C-c C-x p
16248 #+findex: org-set-property
16249 Properties defined through ~org-set-property~ function, bound to
16250 {{{kbd(C-c C-x p)}}}, apply to all active languages.  They override
16251 properties set in ~org-babel-default-header-args~.
16253 #+cindex: language specific header arguments properties
16254 #+cindex: header arguments per language
16255 Language-specific header arguments are also read from properties
16256 =header-args:<LANG>= where {{{var(<LANG>)}}} is the language
16257 identifier.  For example,
16259 #+begin_example
16260 ,* Heading
16261   :PROPERTIES:
16262   :header-args:clojure:    :session *clojure-1*
16263   :header-args:R:          :session *R*
16264   :END:
16265 ,** Subheading
16266   :PROPERTIES:
16267   :header-args:clojure:    :session *clojure-2*
16268   :END:
16269 #+end_example
16271 #+texinfo: @noindent
16272 would force separate sessions for Clojure blocks in =Heading= and
16273 =Subheading=, but use the same session for all R blocks.  Blocks in
16274 =Subheading= inherit settings from =Heading=.
16276 *** Code block specific header arguments
16277 :PROPERTIES:
16278 :UNNUMBERED: notoc
16279 :END:
16281 Header arguments are most commonly set at the source code block level,
16282 on the =#+BEGIN_SRC= line.  Arguments set at this level take
16283 precedence over those set in the ~org-babel-default-header-args~
16284 variable, and also those set as header properties.
16286 In the following example, setting =:results= to =silent= makes it
16287 ignore results of the code execution.  Setting =:exports= to =code=
16288 exports only the body of the code block to HTML or LaTeX.
16290 #+begin_example
16291 ,#+NAME: factorial
16292 ,#+BEGIN_SRC haskell :results silent :exports code :var n=0
16293   fac 0 = 1
16294   fac n = n * fac (n-1)
16295 ,#+END_SRC
16296 #+end_example
16298 The same header arguments in an inline code block:
16300 : src_haskell[:exports both]{fac 5}
16302 #+cindex: @samp{HEADER}, keyword
16303 Code block header arguments can span multiple lines using =#+HEADER:=
16304 on each line.  Note that Org currently accepts the plural spelling of
16305 =#+HEADER:= only as a convenience for backward-compatibility.  It may
16306 be removed at some point.
16308 Multi-line header arguments on an unnamed code block:
16310 #+begin_example
16311 ,#+HEADER: :var data1=1
16312 ,#+BEGIN_SRC emacs-lisp :var data2=2
16313    (message "data1:%S, data2:%S" data1 data2)
16314 ,#+END_SRC
16316 ,#+RESULTS:
16317 : data1:1, data2:2
16318 #+end_example
16320 Multi-line header arguments on a named code block:
16322 #+begin_example
16323 ,#+NAME: named-block
16324 ,#+HEADER: :var data=2
16325 ,#+BEGIN_SRC emacs-lisp
16326   (message "data:%S" data)
16327 ,#+END_SRC
16329 ,#+RESULTS: named-block
16330   : data:2
16331 #+end_example
16333 *** Header arguments in function calls
16334 :PROPERTIES:
16335 :UNNUMBERED: notoc
16336 :END:
16338 Header arguments in function calls are the most specific and override
16339 all other settings in case of an overlap.  They get the highest
16340 priority.  Two =#+CALL:= examples are shown below.  For the complete
16341 syntax of =CALL= keyword, see [[*Evaluating Code Blocks]].
16343 In this example, =:exports results= header argument is applied to the
16344 evaluation of the =#+CALL:= line.
16346 : #+CALL: factorial(n=5) :exports results
16348 In this example, =:session special= header argument is applied to the
16349 evaluation of =factorial= code block.
16351 : #+CALL: factorial[:session special](n=5)
16353 ** Environment of a Code Block
16354 :PROPERTIES:
16355 :DESCRIPTION: Arguments, sessions, working directory...
16356 :END:
16358 *** Passing arguments
16359 :PROPERTIES:
16360 :UNNUMBERED: notoc
16361 :END:
16363 #+cindex: passing arguments to code blocks
16364 #+cindex: arguments, in code blocks
16365 #+cindex: @samp{var}, header argument
16366 Use =var= for passing arguments to source code blocks.  The specifics
16367 of variables in code blocks vary by the source language and are
16368 covered in the language-specific documentation.  The syntax for =var=,
16369 however, is the same for all languages.  This includes declaring
16370 a variable, and assigning a default value.
16372 The following syntax is used to pass arguments to code blocks using
16373 the =var= header argument.
16375 : :var NAME=ASSIGN
16377 #+texinfo: @noindent
16378 {{{var(NAME)}}} is the name of the variable bound in the code block
16379 body.  {{{var(ASSIGN)}}} is a literal value, such as a string,
16380 a number, a reference to a table, a list, a literal example, another
16381 code block---with or without arguments---or the results of evaluating
16382 a code block.
16384 Here are examples of passing values by reference:
16386 - table ::
16388      A table named with a =NAME= keyword.
16390      #+begin_example
16391      ,#+NAME: example-table
16392      | 1 |
16393      | 2 |
16394      | 3 |
16395      | 4 |
16397      ,#+NAME: table-length
16398      ,#+BEGIN_SRC emacs-lisp :var table=example-table
16399        (length table)
16400      ,#+END_SRC
16402      ,#+RESULTS: table-length
16403      : 4
16404      #+end_example
16406      When passing a table, you can treat specially the row, or the
16407      column, containing labels for the columns, or the rows, in the
16408      table.
16410      #+cindex: @samp{colnames}, header argument
16411      The =colnames= header argument accepts =yes=, =no=, or =nil=
16412      values.  The default value is =nil=: if an input table has column
16413      names---because the second row is a horizontal rule---then Org
16414      removes the column names, processes the table, puts back the
16415      column names, and then writes the table to the results block.
16416      Using =yes=, Org does the same to the first row, even if the
16417      initial table does not contain any horizontal rule.  When set to
16418      =no=, Org does not pre-process column names at all.
16420      #+begin_example
16421      ,#+NAME: less-cols
16422      | a |
16423      |---|
16424      | b |
16425      | c |
16427      ,#+BEGIN_SRC python :var tab=less-cols :colnames nil
16428        return [[val + '*' for val in row] for row in tab]
16429      ,#+END_SRC
16431      ,#+RESULTS:
16432      | a  |
16433      |----|
16434      | b* |
16435      | c* |
16436      #+end_example
16438      #+cindex: @samp{rownames}, header argument
16439      Similarly, the =rownames= header argument can take two values:
16440      =yes= or =no=.  When set to =yes=, Org removes the first column,
16441      processes the table, puts back the first column, and then writes
16442      the table to the results block.  The default is =no=, which means
16443      Org does not pre-process the first column.  Note that Emacs Lisp
16444      code blocks ignore =rownames= header argument because of the ease
16445      of table-handling in Emacs.
16447      #+begin_example
16448      ,#+NAME: with-rownames
16449      | one | 1 | 2 | 3 | 4 |  5 |
16450      | two | 6 | 7 | 8 | 9 | 10 |
16452      ,#+BEGIN_SRC python :var tab=with-rownames :rownames yes
16453        return [[val + 10 for val in row] for row in tab]
16454      ,#+END_SRC
16456      ,#+RESULTS:
16457      | one | 11 | 12 | 13 | 14 | 15 |
16458      | two | 16 | 17 | 18 | 19 | 20 |
16459      #+end_example
16461 - list ::
16463      A simple named list.
16465      #+begin_example
16466      ,#+NAME: example-list
16467      - simple
16468        - not
16469        - nested
16470      - list
16472      ,#+BEGIN_SRC emacs-lisp :var x=example-list
16473        (print x)
16474      ,#+END_SRC
16476      ,#+RESULTS:
16477      | simple | list |
16478      #+end_example
16480      Note that only the top level list items are passed along.  Nested
16481      list items are ignored.
16483 - code block without arguments ::
16485      A code block name, as assigned by =NAME= keyword from the example
16486      above, optionally followed by parentheses.
16488      #+begin_example
16489      ,#+BEGIN_SRC emacs-lisp :var length=table-length()
16490        (* 2 length)
16491      ,#+END_SRC
16493      ,#+RESULTS:
16494      : 8
16495      #+end_example
16497 - code block with arguments ::
16499      A code block name, as assigned by =NAME= keyword, followed by
16500      parentheses and optional arguments passed within the parentheses.
16502      #+begin_example
16503      ,#+NAME: double
16504      ,#+BEGIN_SRC emacs-lisp :var input=8
16505        (* 2 input)
16506      ,#+END_SRC
16508      ,#+RESULTS: double
16509      : 16
16511      ,#+NAME: squared
16512      ,#+BEGIN_SRC emacs-lisp :var input=double(input=1)
16513        (* input input)
16514      ,#+END_SRC
16516      ,#+RESULTS: squared
16517      : 4
16518      #+end_example
16520 - literal example ::
16522      A literal example block named with a =NAME= keyword.
16524      #+begin_example
16525      ,#+NAME: literal-example
16526      ,#+BEGIN_EXAMPLE
16527        A literal example
16528        on two lines
16529      ,#+END_EXAMPLE
16531      ,#+NAME: read-literal-example
16532      ,#+BEGIN_SRC emacs-lisp :var x=literal-example
16533        (concatenate #'string x " for you.")
16534      ,#+END_SRC
16536      ,#+RESULTS: read-literal-example
16537      : A literal example
16538      : on two lines for you.
16539      #+end_example
16541 Indexing variable values enables referencing portions of a variable.
16542 Indexes are 0 based with negative values counting backwards from the
16543 end.  If an index is separated by commas then each subsequent section
16544 indexes as the next dimension.  Note that this indexing occurs
16545 /before/ other table-related header arguments are applied, such as
16546 =hlines=, =colnames= and =rownames=.  The following example assigns
16547 the last cell of the first row the table =example-table= to the
16548 variable =data=:
16550 #+begin_example
16551 ,#+NAME: example-table
16552 | 1 | a |
16553 | 2 | b |
16554 | 3 | c |
16555 | 4 | d |
16557 ,#+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
16558   data
16559 ,#+END_SRC
16561 ,#+RESULTS:
16562 : a
16563 #+end_example
16565 Two integers separated by a colon reference a range of variable
16566 values.  In that case the entire inclusive range is referenced.  For
16567 example the following assigns the middle three rows of =example-table=
16568 to =data=.
16570 #+begin_example
16571 ,#+NAME: example-table
16572 | 1 | a |
16573 | 2 | b |
16574 | 3 | c |
16575 | 4 | d |
16576 | 5 | 3 |
16578 ,#+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
16579   data
16580 ,#+END_SRC
16582 ,#+RESULTS:
16583 | 2 | b |
16584 | 3 | c |
16585 | 4 | d |
16586 #+end_example
16588 To pick the entire range, use an empty index, or the single character
16589 =*=.  =0:-1= does the same thing.  Example below shows how to
16590 reference the first column only.
16592 #+begin_example
16593 ,#+NAME: example-table
16594 | 1 | a |
16595 | 2 | b |
16596 | 3 | c |
16597 | 4 | d |
16599 ,#+BEGIN_SRC emacs-lisp :var data=example-table[,0]
16600   data
16601 ,#+END_SRC
16603 ,#+RESULTS:
16604 | 1 | 2 | 3 | 4 |
16605 #+end_example
16607 Index referencing can be used for tables and code blocks.  Index
16608 referencing can handle any number of dimensions.  Commas delimit
16609 multiple dimensions, as shown below.
16611 #+begin_example
16612 ,#+NAME: 3D
16613 ,#+BEGIN_SRC emacs-lisp
16614   '(((1  2  3)  (4  5  6)  (7  8  9))
16615     ((10 11 12) (13 14 15) (16 17 18))
16616     ((19 20 21) (22 23 24) (25 26 27)))
16617 ,#+END_SRC
16619 ,#+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
16620   data
16621 ,#+END_SRC
16623 ,#+RESULTS:
16624 | 11 | 14 | 17 |
16625 #+end_example
16627 Note that row names and column names are not removed prior to variable
16628 indexing.  You need to take them into account, even when =colnames= or
16629 =rownames= header arguments remove them.
16631 Emacs lisp code can also set the values for variables.  To
16632 differentiate a value from Lisp code, Org interprets any value
16633 starting with =(=, =[=, ='= or =`= as Emacs Lisp code.  The result of
16634 evaluating that code is then assigned to the value of that variable.
16635 The following example shows how to reliably query and pass the file
16636 name of the Org mode buffer to a code block using headers.  We need
16637 reliability here because the file's name could change once the code in
16638 the block starts executing.
16640 #+begin_example
16641 ,#+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
16642   wc -w $filename
16643 ,#+END_SRC
16644 #+end_example
16646 Note that values read from tables and lists are not mistakenly
16647 evaluated as Emacs Lisp code, as illustrated in the following example.
16649 #+begin_example
16650 ,#+NAME: table
16651 | (a b c) |
16653 ,#+HEADER: :var data=table[0,0]
16654 ,#+BEGIN_SRC perl
16655   $data
16656 ,#+END_SRC
16658 ,#+RESULTS:
16659 : (a b c)
16660 #+end_example
16662 *** Using sessions
16663 :PROPERTIES:
16664 :UNNUMBERED: notoc
16665 :END:
16667 #+cindex: using sessions in code blocks
16668 #+cindex: @samp{session}, header argument
16669 Two code blocks can share the same environment.  The =session= header
16670 argument is for running multiple source code blocks under one session.
16671 Org runs code blocks with the same session name in the same
16672 interpreter process.
16674 - =none= ::
16676      Default.  Each code block gets a new interpreter process to
16677      execute.  The process terminates once the block is evaluated.
16679 - {{{var(STRING)}}} ::
16681      Any string besides =none= turns that string into the name of that
16682      session.  For example, =:session STRING= names it =STRING=.  If
16683      =session= has no value, then the session name is derived from the
16684      source language identifier.  Subsequent blocks with the same
16685      source code language use the same session.  Depending on the
16686      language, state variables, code from other blocks, and the
16687      overall interpreted environment may be shared.  Some interpreted
16688      languages support concurrent sessions when subsequent source code
16689      language blocks change session names.
16691 Only languages that provide interactive evaluation can have session
16692 support.  Not all languages provide this support, such as C and ditaa.
16693 Even languages, such as Python and Haskell, that do support
16694 interactive evaluation impose limitations on allowable language
16695 constructs that can run interactively.  Org inherits those limitations
16696 for those code blocks running in a session.
16698 *** Choosing a working directory
16699 :PROPERTIES:
16700 :UNNUMBERED: notoc
16701 :END:
16703 #+cindex: working directory, in a code block
16704 #+cindex: @samp{dir}, header argument
16705 The =dir= header argument specifies the default directory during code
16706 block execution.  If it is absent, then the directory associated with
16707 the current buffer is used.  In other words, supplying =:dir PATH=
16708 temporarily has the same effect as changing the current directory with
16709 {{{kbd(M-x cd PATH)}}}, and then not setting =dir=.  Under the
16710 surface, =dir= simply sets the value of the Emacs variable
16711 ~default-directory~.
16713 For example, to save the plot file in the =Work/= folder of the home
16714 directory---notice tilde is expanded:
16716 #+begin_example
16717 ,#+BEGIN_SRC R :file myplot.png :dir ~/Work
16718   matplot(matrix(rnorm(100), 10), type="l")
16719 ,#+END_SRC
16720 #+end_example
16722 To evaluate the code block on a remote machine, supply a remote
16723 directory name using Tramp syntax.  For example:
16725 #+begin_example
16726 ,#+BEGIN_SRC R :file plot.png :dir /scp:dand@yakuba.princeton.edu:
16727   plot(1:10, main=system("hostname", intern=TRUE))
16728 ,#+END_SRC
16729 #+end_example
16731 Org first captures the text results as usual for insertion in the Org
16732 file.  Then Org also inserts a link to the remote file, thanks to
16733 Emacs Tramp.  Org constructs the remote path to the file name from
16734 =dir= and ~default-directory~, as illustrated here:
16736 : [[file:/scp:dand@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
16738 When =dir= is used with =session=, Org sets the starting directory for
16739 a new session.  But Org does not alter the directory of an already
16740 existing session.
16742 Do not use =dir= with =:exports results= or with =:exports both= to
16743 avoid Org inserting incorrect links to remote files.  That is because
16744 Org does not expand ~default directory~ to avoid some underlying
16745 portability issues.
16747 *** Inserting headers and footers
16748 :PROPERTIES:
16749 :UNNUMBERED: notoc
16750 :END:
16752 #+cindex: headers, in code blocks
16753 #+cindex: footers, in code blocks
16754 #+cindex: @samp{prologue}, header argument
16755 The =prologue= header argument is for appending to the top of the code
16756 block for execution, like a reset instruction.  For example, you may
16757 use =:prologue "reset"= in a Gnuplot code block or, for every such
16758 block:
16760 #+begin_src emacs-lisp
16761 (add-to-list 'org-babel-default-header-args:gnuplot
16762              '((:prologue . "reset")))
16764 #+end_src
16766 #+cindex: @samp{epilogue}, header argument
16767 Likewise, the value of the =epilogue= header argument is for appending
16768 to the end of the code block for execution.
16770 ** Evaluating Code Blocks
16771 :PROPERTIES:
16772 :DESCRIPTION: Place results of evaluation in the Org buffer.
16773 :END:
16774 #+cindex: code block, evaluating
16775 #+cindex: source code, evaluating
16776 #+cindex: @samp{RESULTS}, keyword
16778 A note about security: With code evaluation comes the risk of harm.
16779 Org safeguards by prompting for user's permission before executing any
16780 code in the source block.  To customize this safeguard, or disable it,
16781 see [[*Code Evaluation and Security Issues]].
16783 *** How to evaluate source code
16784 :PROPERTIES:
16785 :UNNUMBERED: notoc
16786 :END:
16788 Org captures the results of the code block evaluation and inserts them
16789 in the Org file, right after the code block.  The insertion point is
16790 after a newline and the =RESULTS= keyword.  Org creates the =RESULTS=
16791 keyword if one is not already there.
16793 By default, Org enables only Emacs Lisp code blocks for execution.
16794 See [[*Languages]] to enable other languages.
16796 #+kindex: C-c C-c
16797 #+kindex: C-c C-v e
16798 #+findex: org-babel-execute-src-block
16799 Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
16800 {{{kbd(C-c C-v e)}}} with the point on a code block[fn:130] calls the
16801 ~org-babel-execute-src-block~ function, which executes the code in the
16802 block, collects the results, and inserts them in the buffer.
16804 #+cindex: @samp{CALL}, keyword
16805 #+vindex: org-babel-inline-result-wrap
16806 By calling a named code block[fn:131] from an Org mode buffer or
16807 a table.  Org can call the named code blocks from the current Org mode
16808 buffer or from the "Library of Babel" (see [[*Library of Babel]]).
16810 The syntax for =CALL= keyword is:
16812 #+begin_example
16813 ,#+CALL: <name>(<arguments>)
16814 ,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
16815 #+end_example
16817 The syntax for inline named code blocks is:
16819 #+begin_example
16820 ... call_<name>(<arguments>) ...
16821 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
16822 #+end_example
16824 When inline syntax is used, the result is wrapped based on the
16825 variable ~org-babel-inline-result-wrap~, which by default is set to
16826 ~"=%s="~ to produce verbatim text suitable for markup.
16828 - =<name>= ::
16830      This is the name of the code block (see [[*Structure of Code
16831      Blocks]]) to be evaluated in the current document.  If the block is
16832      located in another file, start =<name>= with the file name
16833      followed by a colon. For example, in order to execute a block
16834      named =clear-data= in =file.org=, you can write the following:
16836      : #+CALL: file.org:clear-data()
16838 - =<arguments>= ::
16840      Org passes arguments to the code block using standard function
16841      call syntax.  For example, a =#+CALL:= line that passes =4= to
16842      a code block named =double=, which declares the header argument
16843      =:var n=2=, would be written as:
16845      : #+CALL: double(n=4)
16847      #+texinfo: @noindent
16848      Note how this function call syntax is different from the header
16849      argument syntax.
16851 - =<inside header arguments>= ::
16853      Org passes inside header arguments to the named code block using
16854      the header argument syntax.  Inside header arguments apply to
16855      code block evaluation.  For example, =[:results output]= collects
16856      results printed to stdout during code execution of that block.
16857      Note how this header argument syntax is different from the
16858      function call syntax.
16860 - =<end header arguments>= ::
16862      End header arguments affect the results returned by the code
16863      block.  For example, =:results html= wraps the results in
16864      a =#+BEGIN_EXPORT html= block before inserting the results in the
16865      Org buffer.
16867 *** Limit code block evaluation
16868 :PROPERTIES:
16869 :UNNUMBERED: notoc
16870 :END:
16872 #+cindex: @samp{eval}, header argument
16873 #+cindex: control code block evaluation
16874 The =eval= header argument can limit evaluation of specific code
16875 blocks and =CALL= keyword.  It is useful for protection against
16876 evaluating untrusted code blocks by prompting for a confirmation.
16878 - =never= or =no= ::
16880      Org never evaluates the source code.
16882 - =query= ::
16884      Org prompts the user for permission to evaluate the source code.
16886 - =never-export= or =no-export= ::
16888      Org does not evaluate the source code when exporting, yet the
16889      user can evaluate it interactively.
16891 - =query-export= ::
16893      Org prompts the user for permission to evaluate the source code
16894      during export.
16896 If =eval= header argument is not set, then Org determines whether to
16897 evaluate the source code from the ~org-confirm-babel-evaluate~
16898 variable (see [[*Code Evaluation and Security Issues]]).
16900 *** Cache results of evaluation
16901 :PROPERTIES:
16902 :UNNUMBERED: notoc
16903 :END:
16905 #+cindex: @samp{cache}, header argument
16906 #+cindex: cache results of code evaluation
16907 The =cache= header argument is for caching results of evaluating code
16908 blocks.  Caching results can avoid re-evaluating a code block that
16909 have not changed since the previous run.  To benefit from the cache
16910 and avoid redundant evaluations, the source block must have a result
16911 already present in the buffer, and neither the header
16912 arguments---including the value of =var= references---nor the text of
16913 the block itself has changed since the result was last computed.  This
16914 feature greatly helps avoid long-running calculations.  For some edge
16915 cases, however, the cached results may not be reliable.
16917 The caching feature is best for when code blocks are pure functions,
16918 that is functions that return the same value for the same input
16919 arguments (see [[*Environment of a Code Block]]), and that do not have
16920 side effects, and do not rely on external variables other than the
16921 input arguments.  Functions that depend on a timer, file system
16922 objects, and random number generators are clearly unsuitable for
16923 caching.
16925 A note of warning: when =cache= is used in a session, caching may
16926 cause unexpected results.
16928 When the caching mechanism tests for any source code changes, it does
16929 not expand Noweb style references (see [[*Noweb Reference Syntax]]).  For
16930 reasons why, see http://thread.gmane.org/gmane.emacs.orgmode/79046.
16932 The =cache= header argument can have one of two values: =yes= or =no=.
16934 - =no= ::
16936      Default.  No caching of results; code block evaluated every
16937      time.
16939 - =yes= ::
16941      Whether to run the code or return the cached results is
16942      determined by comparing the SHA1 hash value of the combined code
16943      block and arguments passed to it.  This hash value is packed on
16944      the =#+RESULTS:= line from previous evaluation.  When hash values
16945      match, Org does not evaluate the code block.  When hash values
16946      mismatch, Org evaluates the code block, inserts the results,
16947      recalculates the hash value, and updates =#+RESULTS:= line.
16949 In this example, both functions are cached.  But =caller= runs only if
16950 the result from =random= has changed since the last run.
16952 #+begin_example
16953 ,#+NAME: random
16954 ,#+BEGIN_SRC R :cache yes
16955   runif(1)
16956 ,#+END_SRC
16958 ,#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
16959 0.4659510825295
16961 ,#+NAME: caller
16962 ,#+BEGIN_SRC emacs-lisp :var x=random :cache yes
16963   x
16964 ,#+END_SRC
16966 ,#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
16967 0.254227238707244
16968 #+end_example
16970 ** Results of Evaluation
16971 :PROPERTIES:
16972 :DESCRIPTION: Choosing a results type, post-processing...
16973 :END:
16974 #+cindex: code block, results of evaluation
16975 #+cindex: source code, results of evaluation
16977 #+cindex: @samp{results}, header argument
16978 How Org handles results of a code block execution depends on many
16979 header arguments working together.  The primary determinant, however,
16980 is the =results= header argument.  It accepts four classes of options.
16981 Each code block can take only one option per class:
16983 - collection ::
16985      For how the results should be collected from the code block;
16987 - type ::
16989      For which type of result the code block will return; affects how
16990      Org processes and inserts results in the Org buffer;
16992 - format ::
16994      For the result; affects how Org processes and inserts results in
16995      the Org buffer;
16997 - handling ::
16999      For processing results after evaluation of the code block;
17001 *** Collection
17002 :PROPERTIES:
17003 :UNNUMBERED: notoc
17004 :END:
17006 Collection options specify the results.  Choose one of the options;
17007 they are mutually exclusive.
17009 - =value= ::
17011      Default.  Functional mode.  Org gets the value by wrapping the
17012      code in a function definition in the language of the source
17013      block.  That is why when using =:results value=, code should
17014      execute like a function and return a value.  For languages like
17015      Python, an explicit ~return~ statement is mandatory when using
17016      =:results value=.  Result is the value returned by the last
17017      statement in the code block.
17019      When evaluating the code block in a session (see [[*Environment of
17020      a Code Block]]), Org passes the code to an interpreter running as
17021      an interactive Emacs inferior process. Org gets the value from
17022      the source code interpreter's last statement output.  Org has to
17023      use language-specific methods to obtain the value.  For example,
17024      from the variable ~_~ in Python and Ruby, and the value of
17025      ~.Last.value~ in R.
17027 - =output= ::
17029      Scripting mode.  Org passes the code to an external process
17030      running the interpreter.  Org returns the contents of the
17031      standard output stream as text results.
17033      When using a session, Org passes the code to the interpreter
17034      running as an interactive Emacs inferior process.  Org
17035      concatenates any text output from the interpreter and returns the
17036      collection as a result.
17038      Note that this collection is not the same as that would be
17039      collected from stdout of a non-interactive interpreter running as
17040      an external process.  Compare for example these two blocks:
17042      #+begin_example
17043      ,#+BEGIN_SRC python :results output
17044        print "hello"
17045        2
17046        print "bye"
17047      ,#+END_SRC
17049      ,#+RESULTS:
17050      : hello
17051      : bye
17052      #+end_example
17054      In the above non-session mode, the "2" is not printed; so it does
17055      not appear in results.
17057      #+begin_example
17058      ,#+BEGIN_SRC python :results output :session
17059        print "hello"
17060        2
17061        print "bye"
17062      ,#+END_SRC
17064      ,#+RESULTS:
17065      : hello
17066      : 2
17067      : bye
17068      #+end_example
17070      In the above session, the interactive interpreter receives and
17071      prints "2".  Results show that.
17073 *** Type
17074 :PROPERTIES:
17075 :UNNUMBERED: notoc
17076 :END:
17078 Type tells what result types to expect from the execution of the code
17079 block.  Choose one of the options; they are mutually exclusive.  The
17080 default behavior is to automatically determine the result type.
17082 #+attr_texinfo: :sep ,
17083 - =table=, =vector= ::
17085      Interpret the results as an Org table.  If the result is a single
17086      value, create a table with one row and one column.  Usage
17087      example: =:results value table=.
17089      #+cindex: @samp{hlines}, header argument
17090      In-between each table row or below the table headings, sometimes
17091      results have horizontal lines, which are also known as "hlines".
17092      The =hlines= argument with the default =no= value strips such
17093      lines from the input table.  For most code, this is desirable, or
17094      else those =hline= symbols raise unbound variable errors.
17095      A =yes= accepts such lines, as demonstrated in the following
17096      example.
17098      #+begin_example
17099      ,#+NAME: many-cols
17100      | a | b | c |
17101      |---+---+---|
17102      | d | e | f |
17103      |---+---+---|
17104      | g | h | i |
17106      ,#+NAME: no-hline
17107      ,#+BEGIN_SRC python :var tab=many-cols :hlines no
17108        return tab
17109      ,#+END_SRC
17111      ,#+RESULTS: no-hline
17112      | a | b | c |
17113      | d | e | f |
17114      | g | h | i |
17116      ,#+NAME: hlines
17117      ,#+BEGIN_SRC python :var tab=many-cols :hlines yes
17118        return tab
17119      ,#+END_SRC
17121      ,#+RESULTS: hlines
17122      | a | b | c |
17123      |---+---+---|
17124      | d | e | f |
17125      |---+---+---|
17126      | g | h | i |
17127      #+end_example
17129 - =list= ::
17131      Interpret the results as an Org list.  If the result is a single
17132      value, create a list of one element.
17134 - =scalar=, =verbatim= ::
17136      Interpret literally and insert as quoted text.  Do not create
17137      a table.  Usage example: =:results value verbatim=.
17139 - =file= ::
17141      Interpret as a filename.  Save the results of execution of the
17142      code block to that file, then insert a link to it.  You can
17143      control both the filename and the description associated to the
17144      link.
17146      #+cindex: @samp{file}, header argument
17147      #+cindex: @samp{output-dir}, header argument
17148      Org first tries to generate the filename from the value of the
17149      =file= header argument and the directory specified using the
17150      =output-dir= header arguments.  If =output-dir= is not specified,
17151      Org assumes it is the current directory.
17153      #+begin_example
17154      ,#+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
17155        size(2cm);
17156        draw(unitcircle);
17157      ,#+END_SRC
17158      #+end_example
17160      #+cindex: @samp{file-ext}, header argument
17161      If =file= is missing, Org generates the base name of the output
17162      file from the name of the code block, and its extension from the
17163      =file-ext= header argument.  In that case, both the name and the
17164      extension are mandatory.
17166      #+begin_example
17167      ,#+name: circle
17168      ,#+BEGIN_SRC asymptote :results value file :file-ext pdf
17169        size(2cm);
17170        draw(unitcircle);
17171      ,#+END_SRC
17172      #+end_example
17174      #+cindex: @samp{file-desc}, header argument
17175      The =file-desc= header argument defines the description (see
17176      [[*Link Format]]) for the link.  If =file-desc= has no value, Org
17177      uses the generated file name for both the "link" and
17178      "description" parts of the link.
17180 *** Format
17181 :PROPERTIES:
17182 :UNNUMBERED: notoc
17183 :END:
17185 Format pertains to the type of the result returned by the code block.
17186 Choose one of the options; they are mutually exclusive.  The default
17187 follows from the type specified above.
17189 #+attr_texinfo: :sep ,
17190 - =code= ::
17192      Result enclosed in a code block.  Useful for parsing.  Usage
17193      example: =:results value code=.
17195 - =drawer= ::
17197      Result wrapped in a =RESULTS= drawer.  Useful for containing
17198      =raw= or =org= results for later scripting and automated
17199      processing.  Usage example: =:results value drawer=.
17201 - =html= ::
17203      Results enclosed in a =BEGIN_EXPORT html= block.  Usage example:
17204      =:results value html=.
17206 - =latex= ::
17208      Results enclosed in a =BEGIN_EXPORT latex= block.  Usage example:
17209      =:results value latex=.
17211 - =link=, =graphics= ::
17213      Result is a link to the file specified in =:file= header
17214      argument.  However, unlike plain =:file=, nothing is written to
17215      the disk.  The block is used for its side-effects only, as in the
17216      following example:
17218      #+begin_example
17219      ,#+begin_src shell :results link :file "download.tar.gz"
17220      wget -c "http://example.com/download.tar.gz"
17221      ,#+end_src
17222      #+end_example
17224 - =org= ::
17226      Results enclosed in a =BEGIN_SRC org= block.  For comma-escape,
17227      either {{{kbd(TAB)}}} in the block, or export the file.  Usage
17228      example: =:results value org=.
17230 - =pp= ::
17232      Result converted to pretty-print source code.  Enclosed in a code
17233      block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
17234      example: =:results value pp=.
17236 - =raw= ::
17238      Interpreted as raw Org mode.  Inserted directly into the buffer.
17239      Aligned if it is a table.  Usage example: =:results value raw=.
17241 *** Handling
17242 :PROPERTIES:
17243 :UNNUMBERED: notoc
17244 :END:
17246 Handling options after collecting the results.
17248 - =silent= ::
17250      Do not insert results in the Org mode buffer, but echo them in
17251      the minibuffer.  Usage example: =:results output silent=.
17253 - =replace= ::
17255      Default.  Insert results in the Org buffer.  Remove previous
17256      results.  Usage example: =:results output replace=.
17258 - =append= ::
17260      Append results to the Org buffer.  Latest results are at the
17261      bottom.  Does not remove previous results.  Usage example:
17262      =:results output append=.
17264 - =prepend= ::
17266      Prepend results to the Org buffer.  Latest results are at the
17267      top.  Does not remove previous results.  Usage example: =:results
17268      output prepend=.
17270 *** Post-processing
17271 :PROPERTIES:
17272 :UNNUMBERED: notoc
17273 :END:
17275 #+cindex: @samp{post}, header argument
17276 #+cindex: @samp{*this*}, in @samp{post} header argument
17277 The =post= header argument is for post-processing results from block
17278 evaluation.  When =post= has any value, Org binds the results to
17279 ~*this*~ variable for easy passing to =var= header argument
17280 specifications (see [[*Environment of a Code Block]]).  That makes results
17281 available to other code blocks, or even for direct Emacs Lisp code
17282 execution.
17284 The following two examples illustrate =post= header argument in
17285 action.  The first one shows how to attach an =ATTR_LATEX= keyword
17286 using =post=.
17288 #+begin_example
17289 ,#+NAME: attr_wrap
17290 ,#+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
17291   echo "#+ATTR_LATEX: :width $width"
17292   echo "$data"
17293 ,#+END_SRC
17295 ,#+HEADER: :file /tmp/it.png
17296 ,#+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
17297   digraph{
17298           a -> b;
17299           b -> c;
17300           c -> a;
17301   }
17302 ,#+end_src
17304 ,#+RESULTS:
17305 :RESULTS:
17306 ,#+ATTR_LATEX :width 5cm
17307 [[file:/tmp/it.png]]
17308 :END:
17309 #+end_example
17311 The second example shows use of =colnames= header argument in =post=
17312 to pass data between code blocks.
17314 #+begin_example
17315 ,#+NAME: round-tbl
17316 ,#+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
17317   (mapcar (lambda (row)
17318             (mapcar (lambda (cell)
17319                       (if (numberp cell)
17320                           (format fmt cell)
17321                         cell))
17322                     row))
17323           tbl)
17324 ,#+end_src
17326 ,#+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
17327   set.seed(42)
17328   data.frame(foo=rnorm(1))
17329 ,#+END_SRC
17331 ,#+RESULTS:
17332 |   foo |
17333 |-------|
17334 | 1.371 |
17335 #+end_example
17337 ** Exporting Code Blocks
17338 :PROPERTIES:
17339 :DESCRIPTION: Export contents and/or results.
17340 :END:
17341 #+cindex: code block, exporting
17342 #+cindex: source code, exporting
17344 It is possible to export the /code/ of code blocks, the /results/ of
17345 code block evaluation, /both/ the code and the results of code block
17346 evaluation, or /none/.  Org defaults to exporting /code/ for most
17347 languages.  For some languages, such as ditaa, Org defaults to
17348 /results/.  To export just the body of code blocks, see [[*Literal
17349 Examples]].  To selectively export sub-trees of an Org document, see
17350 [[*Exporting]].
17352 #+cindex: @samp{export}, header argument
17353 The =exports= header argument is to specify if that part of the Org
17354 file is exported to, say, HTML or LaTeX formats.
17356 - =code= ::
17358      The default.  The body of code is included into the exported
17359      file.  Example: =:exports code=.
17361 - =results= ::
17363      The results of evaluation of the code is included in the exported
17364      file.  Example: =:exports results=.
17366 - =both= ::
17368      Both the code and results of evaluation are included in the
17369      exported file.  Example: =:exports both=.
17371 - =none= ::
17373      Neither the code nor the results of evaluation is included in the
17374      exported file.  Whether the code is evaluated at all depends on
17375      other options.  Example: =:exports none=.
17377 #+vindex: org-export-use-babel
17378 To stop Org from evaluating code blocks to speed exports, use the
17379 header argument =:eval never-export= (see [[*Evaluating Code Blocks]]).
17380 To stop Org from evaluating code blocks for greater security, set the
17381 ~org-export-use-babel~ variable to ~nil~, but understand that header
17382 arguments will have no effect.
17384 Turning off evaluation comes in handy when batch processing.  For
17385 example, markup languages for wikis, which have a high risk of
17386 untrusted code.  Stopping code block evaluation also stops evaluation
17387 of all header arguments of the code block.  This may not be desirable
17388 in some circumstances.  So during export, to allow evaluation of just
17389 the header arguments but not any code evaluation in the source block,
17390 set =:eval never-export= (see [[*Evaluating Code Blocks]]).
17392 Org never evaluates code blocks in commented sub-trees when exporting
17393 (see [[*Comment Lines]]).  On the other hand, Org does evaluate code
17394 blocks in sub-trees excluded from export (see [[*Export Settings]]).
17396 ** Extracting Source Code
17397 :PROPERTIES:
17398 :DESCRIPTION: Create pure source code files.
17399 :END:
17400 #+cindex: tangling
17401 #+cindex: source code, extracting
17402 #+cindex: code block, extracting source code
17404 Extracting source code from code blocks is a basic task in literate
17405 programming.  Org has features to make this easy.  In literate
17406 programming parlance, documents on creation are /woven/ with code and
17407 documentation, and on export, the code is tangled for execution by
17408 a computer.  Org facilitates weaving and tangling for producing,
17409 maintaining, sharing, and exporting literate programming documents.
17410 Org provides extensive customization options for extracting source
17411 code.
17413 When Org tangles code blocks, it expands, merges, and transforms them.
17414 Then Org recomposes them into one or more separate files, as
17415 configured through the options.  During this tangling process, Org
17416 expands variables in the source code, and resolves any Noweb style
17417 references (see [[*Noweb Reference Syntax]]).
17419 *** Header arguments
17420 :PROPERTIES:
17421 :UNNUMBERED: notoc
17422 :END:
17424 #+cindex: @samp{tangle}, header argument
17425 The =tangle= header argument specifies if the code block is exported
17426 to source file(s).
17428 - =yes= ::
17430      Export the code block to source file.  The file name for the
17431      source file is derived from the name of the Org file, and the
17432      file extension is derived from the source code language
17433      identifier.  Example: =:tangle yes=.
17435 - =no= ::
17437      The default.  Do not extract the code in a source code file.
17438      Example: =:tangle no=.
17440 - {{{var(FILENAME)}}} ::
17442      Export the code block to source file whose file name is derived
17443      from any string passed to the =tangle= header argument.  Org
17444      derives the file name as being relative to the directory of the
17445      Org file's location.  Example: =:tangle FILENAME=.
17447 #+cindex: @samp{mkdirp}, header argument
17448 The =mkdirp= header argument creates parent directories for tangled
17449 files if the directory does not exist.  =yes= enables directory
17450 creation and =no= inhibits directory creation.
17452 #+cindex: @samp{comments}, header argument
17453 The =comments= header argument controls inserting comments into
17454 tangled files.  These are above and beyond whatever comments may
17455 already exist in the code block.
17457 - =no= ::
17459      The default.  Do not insert any extra comments during tangling.
17461 - =link= ::
17463      Wrap the code block in comments.  Include links pointing back to
17464      the place in the Org file from where the code was tangled.
17466 - =yes= ::
17468      Kept for backward compatibility; same as =link=.
17470 - =org= ::
17472      Nearest headline text from Org file is inserted as comment.  The
17473      exact text that is inserted is picked from the leading context of
17474      the source block.
17476 - =both= ::
17478      Includes both =link= and =org= options.
17480 - =noweb= ::
17482      Includes =link= option, expands Noweb references (see [[*Noweb
17483      Reference Syntax]]), and wraps them in link comments inside the
17484      body of the code block.
17486 #+cindex: @samp{padline}, header argument
17487 The =padline= header argument controls insertion of newlines to pad
17488 source code in the tangled file.
17490 - =yes= ::
17492      Default.  Insert a newline before and after each code block in
17493      the tangled file.
17495 - =no= ::
17497      Do not insert newlines to pad the tangled code blocks.
17499 #+cindex: @samp{shebang}, header argument
17500 The =shebang= header argument can turn results into executable script
17501 files.  By setting it to a string value---for example, =:shebang
17502 "#!/bin/bash"=---Org inserts that string as the first line of the
17503 tangled file that the code block is extracted to.  Org then turns on
17504 the tangled file's executable permission.
17506 #+cindex: @samp{no-expand}, header argument
17507 By default Org expands code blocks during tangling.  The =no-expand=
17508 header argument turns off such expansions.  Note that one side-effect
17509 of expansion by ~org-babel-expand-src-block~ also assigns values (see
17510 [[*Environment of a Code Block]]) to variables.  Expansions also replace
17511 Noweb references with their targets (see [[*Noweb Reference Syntax]]).
17512 Some of these expansions may cause premature assignment, hence this
17513 option.  This option makes a difference only for tangling.  It has no
17514 effect when exporting since code blocks for execution have to be
17515 expanded anyway.
17517 *** Functions
17518 :PROPERTIES:
17519 :UNNUMBERED: notoc
17520 :END:
17522 - ~org-babel-tangle~ ::
17524      #+findex: org-babel-tangle
17525      #+kindex: C-c C-v t
17526      Tangle the current file.  Bound to {{{kbd(C-c C-v t)}}}.
17528      With prefix argument only tangle the current code block.
17530 - ~org-babel-tangle-file~ ::
17532      #+findex: org-babel-tangle-file
17533      #+kindex: C-c C-v f
17534      Choose a file to tangle.  Bound to {{{kbd(C-c C-v f)}}}.
17536 *** Hooks
17537 :PROPERTIES:
17538 :UNNUMBERED: notoc
17539 :END:
17541 - ~org-babel-post-tangle-hook~ ::
17543      #+vindex: org-babel-post-tangle-hook
17544      This hook is run from within code files tangled by
17545      ~org-babel-tangle~, making it suitable for post-processing,
17546      compilation, and evaluation of code in the tangled files.
17548 *** Jumping between code and Org
17549 :PROPERTIES:
17550 :UNNUMBERED: notoc
17551 :END:
17553 #+findex: org-babel-tangle-jump-to-org
17554 Debuggers normally link errors and messages back to the source code.
17555 But for tangled files, we want to link back to the Org file, not to
17556 the tangled source file.  To make this extra jump, Org uses
17557 ~org-babel-tangle-jump-to-org~ function with two additional source
17558 code block header arguments:
17560 1. Set =padline= to true---this is the default setting.
17561 2. Set =comments= to =link=, which makes Org insert links to the Org
17562    file.
17564 ** Languages
17565 :PROPERTIES:
17566 :DESCRIPTION: List of supported code block languages.
17567 :END:
17568 #+cindex: babel, languages
17569 #+cindex: source code, languages
17570 #+cindex: code block, languages
17572 Code blocks in the following languages are supported.
17574 | Language   | Identifier | Language       | Identifier |
17575 |------------+------------+----------------+------------|
17576 | Asymptote  | asymptote  | Awk            | awk        |
17577 | C          | C          | C++            | C++        |
17578 | Clojure    | clojure    | CSS            | css        |
17579 | D          | d          | ditaa          | ditaa      |
17580 | Graphviz   | dot        | Emacs Calc     | calc       |
17581 | Emacs Lisp | emacs-lisp | Fortran        | fortran    |
17582 | Gnuplot    | gnuplot    | Haskell        | haskell    |
17583 | Java       | java       | Javascript     | js         |
17584 | LaTeX      | latex      | Ledger         | ledger     |
17585 | Lisp       | lisp       | Lilypond       | lilypond   |
17586 | Lua        | lua        | MATLAB         | matlab     |
17587 | Mscgen     | mscgen     | Objective Caml | ocaml      |
17588 | Octave     | octave     | Org mode       | org        |
17589 | Oz         | oz         | Perl           | perl       |
17590 | Plantuml   | plantuml   | Processing.js  | processing |
17591 | Python     | python     | R              | R          |
17592 | Ruby       | ruby       | Sass           | sass       |
17593 | Scheme     | scheme     | GNU Screen     | screen     |
17594 | Sed        | sed        | shell          | sh         |
17595 | SQL        | sql        | SQLite         | sqlite     |
17596 | Vala       | vala       |                |            |
17598 Additional documentation for some languages is at
17599 https://orgmode.org/worg/org-contrib/babel/languages.html.
17601 #+vindex: org-babel-load-languages
17602 By default, only Emacs Lisp is enabled for evaluation.  To enable or
17603 disable other languages, customize the ~org-babel-load-languages~
17604 variable either through the Emacs customization interface, or by
17605 adding code to the init file as shown next.
17607 In this example, evaluation is disabled for Emacs Lisp, and enabled
17608 for R.
17610 #+begin_src emacs-lisp
17611 (org-babel-do-load-languages
17612  'org-babel-load-languages
17613  '((emacs-lisp . nil)
17614    (R . t)))
17615 #+end_src
17617 Note that this is not the only way to enable a language.  Org also
17618 enables languages when loaded with ~require~ statement.  For example,
17619 the following enables execution of Clojure code blocks:
17621 #+begin_src emacs-lisp
17622 (require 'ob-clojure)
17623 #+end_src
17625 ** Editing Source Code
17626 :PROPERTIES:
17627 :DESCRIPTION: Language major-mode editing.
17628 :END:
17629 #+cindex: code block, editing
17630 #+cindex: source code, editing
17632 #+kindex: C-c '
17633 Use {{{kbd(C-c ')}}} to edit the current code block.  It opens a new
17634 major-mode edit buffer containing the body of the source code block,
17635 ready for any edits.  Use {{{kbd(C-c ')}}} again to close the buffer
17636 and return to the Org buffer.
17638 #+kindex: C-x C-s
17639 #+vindex: org-edit-src-auto-save-idle-delay
17640 #+cindex: auto-save, in code block editing
17641 {{{kbd(C-x C-s)}}} saves the buffer and updates the contents of the
17642 Org buffer.  Set ~org-edit-src-auto-save-idle-delay~ to save the base
17643 buffer after a certain idle delay time.  Set
17644 ~org-edit-src-turn-on-auto-save~ to auto-save this buffer into
17645 a separate file using Auto-save mode.
17647 While editing the source code in the major mode, the Org Src minor
17648 mode remains active.  It provides these customization variables as
17649 described below.  For even more variables, look in the customization
17650 group ~org-edit-structure~.
17652 - ~org-src-lang-modes~ ::
17654      #+vindex: org-src-lang-modes
17655      If an Emacs major-mode named ~<LANG>-mode~ exists, where
17656      {{{var(<LANG>)}}} is the language identifier from code block's
17657      header line, then the edit buffer uses that major mode.  Use this
17658      variable to arbitrarily map language identifiers to major modes.
17660 - ~org-src-window-setup~ ::
17662      #+vindex: org-src-window-setup
17663      For specifying Emacs window arrangement when the new edit buffer
17664      is created.
17666 - ~org-src-preserve-indentation~ ::
17668      #+cindex: indentation, in code blocks
17669      #+vindex: org-src-preserve-indentation
17670      Default is ~nil~.  Source code is indented.  This indentation
17671      applies during export or tangling, and depending on the context,
17672      may alter leading spaces and tabs.  When non-~nil~, source code
17673      is aligned with the leftmost column.  No lines are modified
17674      during export or tangling, which is very useful for white-space
17675      sensitive languages, such as Python.
17677 - ~org-src-ask-before-returning-to-edit-buffer~ ::
17679      #+vindex: org-src-ask-before-returning-to-edit-buffer
17680      When ~nil~, Org returns to the edit buffer without further
17681      prompts.  The default prompts for a confirmation.
17683 #+vindex: org-src-fontify-natively
17684 #+vindex: org-src-block-faces
17685 Set ~org-src-fontify-natively~ to non-~nil~ to turn on native code
17686 fontification in the /Org/ buffer.  Fontification of code blocks can
17687 give visual separation of text and code on the display page.  To
17688 further customize the appearance of ~org-block~ for specific
17689 languages, customize ~org-src-block-faces~.  The following example
17690 shades the background of regular blocks, and colors source blocks only
17691 for Python and Emacs Lisp languages.
17693 #+begin_src emacs-lisp
17694 (require 'color)
17695 (set-face-attribute 'org-block nil :background
17696                     (color-darken-name
17697                      (face-attribute 'default :background) 3))
17699 (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
17700                             ("python" (:background "#E5FFB8"))))
17701 #+end_src
17703 ** Noweb Reference Syntax
17704 :PROPERTIES:
17705 :DESCRIPTION: Literate programming in Org mode.
17706 :END:
17707 #+cindex: code block, Noweb reference
17708 #+cindex: syntax, Noweb
17709 #+cindex: source code, Noweb reference
17711 Org supports named blocks in Noweb[fn:132] style syntax:
17713 : <<CODE-BLOCK-ID>>
17715 Org can replace the construct with the source code, or the results of
17716 evaluation, of the code block identified as {{{var(CODE-BLOCK-ID)}}}.
17718 #+cindex: @samp{noweb}, header argument
17719 The =noweb= header argument controls expansion of Noweb syntax
17720 references.  Expansions occur when source code blocks are evaluated,
17721 tangled, or exported.
17723 - =no= ::
17725      Default.  No expansion of Noweb syntax references in the body of
17726      the code when evaluating, tangling, or exporting.
17728 - =yes= ::
17730      Expansion of Noweb syntax references in the body of the code
17731      block when evaluating, tangling, or exporting.
17733 - =tangle= ::
17735      Expansion of Noweb syntax references in the body of the code
17736      block when tangling.  No expansion when evaluating or exporting.
17738 - =no-export= ::
17740      Expansion of Noweb syntax references in the body of the code
17741      block when evaluating or tangling.  No expansion when exporting.
17743 - =strip-export= ::
17745      Expansion of Noweb syntax references in the body of the code
17746      block when expanding prior to evaluating or tangling.  Removes
17747      Noweb syntax references when exporting.
17749 - =eval= ::
17751      Expansion of Noweb syntax references in the body of the code
17752      block only before evaluating.
17754 In the following example,
17756 #+begin_example
17757 ,#+NAME: initialization
17758 ,#+BEGIN_SRC emacs-lisp
17759   (setq sentence "Never a foot too far, even.")
17760 ,#+END_SRC
17762 ,#+BEGIN_SRC emacs-lisp :noweb yes
17763   <<initialization>>
17764   (reverse sentence)
17765 ,#+END_SRC
17766 #+end_example
17768 #+texinfo: @noindent
17769 the second code block is expanded as
17771 #+begin_example
17772 ,#+BEGIN_SRC emacs-lisp :noweb yes
17773   (setq sentence "Never a foot too far, even.")
17774   (reverse sentence)
17775 ,#+END_SRC
17776 #+end_example
17778 Noweb insertions honor prefix characters that appear before the Noweb
17779 syntax reference.  This behavior is illustrated in the following
17780 example.  Because the =<<example>>= Noweb reference appears behind the
17781 SQL comment syntax, each line of the expanded Noweb reference is
17782 commented.  With:
17784 #+begin_example
17785 ,#+NAME: example
17786 ,#+BEGIN_SRC text
17787   this is the
17788   multi-line body of example
17789 ,#+END_SRC
17790 #+end_example
17792 #+texinfo: @noindent
17793 this code block:
17795 #+begin_example
17796 ,#+BEGIN_SRC sql :noweb yes
17797  ---<<example>>
17798 ,#+END_SRC
17799 #+end_example
17801 #+texinfo: @noindent
17802 expands to:
17804 #+begin_example
17805 ,#+BEGIN_SRC sql :noweb yes
17806  ---this is the
17807  ---multi-line body of example
17808 ,#+END_SRC
17809 #+end_example
17811 Since this change does not affect Noweb replacement text without
17812 newlines in them, inline Noweb references are acceptable.
17814 This feature can also be used for management of indentation in
17815 exported code snippets.  With:
17817 #+begin_example
17818 ,#+NAME: if-true
17819 ,#+BEGIN_SRC python :exports none
17820   print('do things when true')
17821 ,#+end_src
17823 ,#+name: if-false
17824 ,#+begin_src python :exports none
17825   print('do things when false')
17826 ,#+end_src
17827 #+end_example
17829 #+texinfo: @noindent
17830 this code block:
17832 #+begin_example
17833 ,#+begin_src python :noweb yes :results output
17834   if true:
17835       <<if-true>>
17836   else:
17837       <<if-false>>
17838 ,#+end_src
17839 #+end_example
17841 #+texinfo: @noindent
17842 expands to:
17844 #+begin_example
17845 if true:
17846     print('do things when true')
17847 else:
17848     print('do things when false')
17849 #+end_example
17851 #+cindex: @samp{noweb-ref}, header argument
17852 When expanding Noweb style references, Org concatenates code blocks by
17853 matching the reference name to either the code block name or, if none
17854 is found, to the =noweb-ref= header argument.
17856 For simple concatenation, set this =noweb-ref= header argument at the
17857 sub-tree or file level.  In the example Org file shown next, the body
17858 of the source code in each block is extracted for concatenation to
17859 a pure code file when tangled.
17861 #+begin_example
17862 ,#+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
17863   <<fullest-disk>>
17864 ,#+END_SRC
17865 ,* the mount point of the fullest disk
17866   :PROPERTIES:
17867   :header-args: :noweb-ref fullest-disk
17868   :END:
17870 ,** query all mounted disks
17871 ,#+BEGIN_SRC sh
17872   df \
17873 ,#+END_SRC
17875 ,** strip the header row
17876 ,#+BEGIN_SRC sh
17877   |sed '1d' \
17878 ,#+END_SRC
17880 ,** output mount point of fullest disk
17881 ,#+BEGIN_SRC sh
17882   |awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}'
17883 ,#+END_SRC
17884 #+end_example
17886 #+cindex: @samp{noweb-sep}, header argument
17887 By default a newline separates each noweb reference concatenation.  To
17888 change this newline separator, edit the =noweb-sep= header argument.
17890 Eventually, Org can include the results of a code block rather than
17891 its body.  To that effect, append parentheses, possibly including
17892 arguments, to the code block name, as shown below.
17894 : <<code-block-name(optional arguments)>>
17896 Note that when using the above approach to a code block's results, the
17897 code block name set by =NAME= keyword is required; the reference set
17898 by =noweb-ref= does not work in that case.
17900 Here is an example that demonstrates how the exported content changes
17901 when Noweb style references are used with parentheses versus without.
17902 With:
17904 #+begin_example
17905 ,#+NAME: some-code
17906 ,#+BEGIN_SRC python :var num=0 :results output :exports none
17907   print(num*10)
17908 ,#+END_SRC
17909 #+end_example
17911 #+texinfo: @noindent
17912 this code block:
17914 #+begin_example
17915 ,#+BEGIN_SRC text :noweb yes
17916   <<some-code>>
17917 ,#+END_SRC
17918 #+end_example
17920 #+texinfo: @noindent
17921 expands to:
17923 : print(num*10)
17925 Below, a similar Noweb style reference is used, but with parentheses,
17926 while setting a variable =num= to 10:
17928 #+begin_example
17929 ,#+BEGIN_SRC text :noweb yes
17930   <<some-code(num=10)>>
17931 ,#+END_SRC
17932 #+end_example
17934 #+texinfo: @noindent
17935 Note that now the expansion contains the results of the code block
17936 =some-code=, not the code block itself:
17938 : 100
17940 ** Library of Babel
17941 :PROPERTIES:
17942 :DESCRIPTION: Use and contribute to a library of useful code blocks.
17943 :END:
17944 #+cindex: babel, library of
17945 #+cindex: source code, library
17946 #+cindex: code block, library
17948 The "Library of Babel" is a collection of code blocks.  Like
17949 a function library, these code blocks can be called from other Org
17950 files.  A collection of useful code blocks is available on [[https://orgmode.org/worg/library-of-babel.html][Worg]].  For
17951 remote code block evaluation syntax, see [[*Evaluating Code Blocks]].
17953 #+kindex: C-c C-v i
17954 #+findex: org-babel-lob-ingest
17955 For any user to add code to the library, first save the code in
17956 regular code blocks of an Org file, and then load the Org file with
17957 ~org-babel-lob-ingest~, which is bound to {{{kbd(C-c C-v i)}}}.
17959 ** Key bindings and Useful Functions
17960 :PROPERTIES:
17961 :DESCRIPTION: Work quickly with code blocks.
17962 :END:
17963 #+cindex: code block, key bindings
17965 Many common Org mode key sequences are re-bound depending on
17966 the context.
17968 Active key bindings in code blocks:
17970 #+kindex: C-c C-c
17971 #+findex: org-babel-execute-src-block
17972 #+kindex: C-c C-o
17973 #+findex: org-babel-open-src-block-result
17974 #+kindex: M-UP
17975 #+findex: org-babel-load-in-session
17976 #+kindex: M-DOWN
17977 #+findex: org-babel-pop-to-session
17978 #+attr_texinfo: :columns 0.2 0.55
17979 | Key binding        | Function                          |
17980 |--------------------+-----------------------------------|
17981 | {{{kbd(C-c C-c)}}} | ~org-babel-execute-src-block~     |
17982 | {{{kbd(C-c C-o)}}} | ~org-babel-open-src-block-result~ |
17983 | {{{kbd(M-UP)}}}    | ~org-babel-load-in-session~       |
17984 | {{{kbd(M-DOWN)}}}  | ~org-babel-pop-to-session~        |
17986 Active key bindings in Org mode buffer:
17988 #+kindex: C-c C-v p
17989 #+kindex: C-c C-v C-p
17990 #+kindex: C-c C-v n
17991 #+kindex: C-c C-v C-n
17992 #+kindex: C-c C-v e
17993 #+kindex: C-c C-v C-e
17994 #+kindex: C-c C-v o
17995 #+kindex: C-c C-v C-o
17996 #+kindex: C-c C-v v
17997 #+kindex: C-c C-v C-v
17998 #+kindex: C-c C-v u
17999 #+kindex: C-c C-v C-u
18000 #+kindex: C-c C-v g
18001 #+kindex: C-c C-v C-g
18002 #+kindex: C-c C-v r
18003 #+kindex: C-c C-v C-r
18004 #+kindex: C-c C-v b
18005 #+kindex: C-c C-v C-b
18006 #+kindex: C-c C-v s
18007 #+kindex: C-c C-v C-s
18008 #+kindex: C-c C-v d
18009 #+kindex: C-c C-v C-d
18010 #+kindex: C-c C-v t
18011 #+kindex: C-c C-v C-t
18012 #+kindex: C-c C-v f
18013 #+kindex: C-c C-v C-f
18014 #+kindex: C-c C-v c
18015 #+kindex: C-c C-v C-c
18016 #+kindex: C-c C-v j
18017 #+kindex: C-c C-v C-j
18018 #+kindex: C-c C-v l
18019 #+kindex: C-c C-v C-l
18020 #+kindex: C-c C-v i
18021 #+kindex: C-c C-v C-i
18022 #+kindex: C-c C-v I
18023 #+kindex: C-c C-v C-I
18024 #+kindex: C-c C-v z
18025 #+kindex: C-c C-v C-z
18026 #+kindex: C-c C-v a
18027 #+kindex: C-c C-v C-a
18028 #+kindex: C-c C-v h
18029 #+kindex: C-c C-v C-h
18030 #+kindex: C-c C-v x
18031 #+kindex: C-c C-v C-x
18032 #+findex: org-babel-previous-src-block
18033 #+findex: org-babel-next-src-block
18034 #+findex: org-babel-execute-maybe
18035 #+findex: org-babel-open-src-block-result
18036 #+findex: org-babel-expand-src-block
18037 #+findex: org-babel-goto-src-block-head
18038 #+findex: org-babel-goto-named-src-block
18039 #+findex: org-babel-goto-named-result
18040 #+findex: org-babel-execute-buffer
18041 #+findex: org-babel-execute-subtree
18042 #+findex: org-babel-demarcate-block
18043 #+findex: org-babel-tangle
18044 #+findex: org-babel-tangle-file
18045 #+findex: org-babel-check-src-block
18046 #+findex: org-babel-insert-header-arg
18047 #+findex: org-babel-load-in-session
18048 #+findex: org-babel-lob-ingest
18049 #+findex: org-babel-view-src-block-info
18050 #+findex: org-babel-switch-to-session-with-code
18051 #+findex: org-babel-sha1-hash
18052 #+findex: org-babel-describe-bindings
18053 #+findex: org-babel-do-key-sequence-in-edit-buffer
18054 #+attr_texinfo: :columns 0.45 0.55
18055 | Key binding                                    | Function                                   |
18056 |------------------------------------------------+--------------------------------------------|
18057 | {{{kbd(C-c C-v p)}}} or {{{kbd(C-c C-v C-p)}}} | ~org-babel-previous-src-block~             |
18058 | {{{kbd(C-c C-v n)}}} or {{{kbd(C-c C-v C-n)}}} | ~org-babel-next-src-block~                 |
18059 | {{{kbd(C-c C-v e)}}} or {{{kbd(C-c C-v C-e)}}} | ~org-babel-execute-maybe~                  |
18060 | {{{kbd(C-c C-v o)}}} or {{{kbd(C-c C-v C-o)}}} | ~org-babel-open-src-block-result~          |
18061 | {{{kbd(C-c C-v v)}}} or {{{kbd(C-c C-v C-v)}}} | ~org-babel-expand-src-block~               |
18062 | {{{kbd(C-c C-v u)}}} or {{{kbd(C-c C-v C-u)}}} | ~org-babel-goto-src-block-head~            |
18063 | {{{kbd(C-c C-v g)}}} or {{{kbd(C-c C-v C-g)}}} | ~org-babel-goto-named-src-block~           |
18064 | {{{kbd(C-c C-v r)}}} or {{{kbd(C-c C-v C-r)}}} | ~org-babel-goto-named-result~              |
18065 | {{{kbd(C-c C-v b)}}} or {{{kbd(C-c C-v C-b)}}} | ~org-babel-execute-buffer~                 |
18066 | {{{kbd(C-c C-v s)}}} or {{{kbd(C-c C-v C-s)}}} | ~org-babel-execute-subtree~                |
18067 | {{{kbd(C-c C-v d)}}} or {{{kbd(C-c C-v C-d)}}} | ~org-babel-demarcate-block~                |
18068 | {{{kbd(C-c C-v t)}}} or {{{kbd(C-c C-v C-t)}}} | ~org-babel-tangle~                         |
18069 | {{{kbd(C-c C-v f)}}} or {{{kbd(C-c C-v C-f)}}} | ~org-babel-tangle-file~                    |
18070 | {{{kbd(C-c C-v c)}}} or {{{kbd(C-c C-v C-c)}}} | ~org-babel-check-src-block~                |
18071 | {{{kbd(C-c C-v j)}}} or {{{kbd(C-c C-v C-j)}}} | ~org-babel-insert-header-arg~              |
18072 | {{{kbd(C-c C-v l)}}} or {{{kbd(C-c C-v C-l)}}} | ~org-babel-load-in-session~                |
18073 | {{{kbd(C-c C-v i)}}} or {{{kbd(C-c C-v C-i)}}} | ~org-babel-lob-ingest~                     |
18074 | {{{kbd(C-c C-v I)}}} or {{{kbd(C-c C-v C-I)}}} | ~org-babel-view-src-block-info~            |
18075 | {{{kbd(C-c C-v z)}}} or {{{kbd(C-c C-v C-z)}}} | ~org-babel-switch-to-session-with-code~    |
18076 | {{{kbd(C-c C-v a)}}} or {{{kbd(C-c C-v C-a)}}} | ~org-babel-sha1-hash~                      |
18077 | {{{kbd(C-c C-v h)}}} or {{{kbd(C-c C-v C-h)}}} | ~org-babel-describe-bindings~              |
18078 | {{{kbd(C-c C-v x)}}} or {{{kbd(C-c C-v C-x)}}} | ~org-babel-do-key-sequence-in-edit-buffer~ |
18080 ** Batch Execution
18081 :PROPERTIES:
18082 :DESCRIPTION: Call functions from the command line.
18083 :END:
18084 #+cindex: code block, batch execution
18085 #+cindex: source code, batch execution
18087 Org mode features, including working with source code facilities can
18088 be invoked from the command line.  This enables building shell scripts
18089 for batch processing, running automated system tasks, and expanding
18090 Org mode's usefulness.
18092 The sample script shows batch processing of multiple files using
18093 ~org-babel-tangle~.
18095 #+begin_example
18096 #!/bin/sh
18097 # Tangle files with Org mode
18099 emacs -Q --batch --eval "
18100     (progn
18101       (require 'ob-tangle)
18102       (dolist (file command-line-args-left)
18103         (with-current-buffer (find-file-noselect file)
18104           (org-babel-tangle))))
18105   " "$@"
18106 #+end_example
18108 * Miscellaneous
18109 :PROPERTIES:
18110 :DESCRIPTION: All the rest which did not fit elsewhere.
18111 :END:
18113 ** Completion
18114 :PROPERTIES:
18115 :DESCRIPTION: M-@key{TAB} guesses completions.
18116 :END:
18117 #+cindex: completion, of @TeX{} symbols
18118 #+cindex: completion, of TODO keywords
18119 #+cindex: completion, of dictionary words
18120 #+cindex: completion, of option keywords
18121 #+cindex: completion, of tags
18122 #+cindex: completion, of property keys
18123 #+cindex: completion, of link abbreviations
18124 #+cindex: @TeX{} symbol completion
18125 #+cindex: TODO keywords completion
18126 #+cindex: dictionary word completion
18127 #+cindex: option keyword completion
18128 #+cindex: tag completion
18129 #+cindex: link abbreviations, completion of
18131 Org has in-buffer completions.  Unlike minibuffer completions, which
18132 are useful for quick command interactions, Org's in-buffer completions
18133 are more suitable for content creation in Org documents.  Type one or
18134 more letters and invoke the hot key to complete the text in-place.
18135 Depending on the context and the keys, Org offers different types of
18136 completions.  No minibuffer is involved.  Such mode-specific hot keys
18137 have become an integral part of Emacs and Org provides several
18138 shortcuts.
18140 - {{{kbd(M-TAB)}}} ::
18141      #+kindex: M-TAB
18143      Complete word at point.
18145      - At the beginning of a headline, complete TODO keywords.
18147      - After =\=, complete TeX symbols supported by the exporter.
18149      - After =*=, complete headlines in the current buffer so that
18150        they can be used in search links like:
18152        : [[*find this headline]]
18154      - After =:= in a headline, complete tags.  Org deduces the list
18155        of tags from the =TAGS= in-buffer option (see [[*Setting Tags]]),
18156        the variable ~org-tag-alist~, or from all tags used in the
18157        current buffer.
18159      - After =:= and not in a headline, complete property keys.  The
18160        list of keys is constructed dynamically from all keys used in
18161        the current buffer.
18163      - After =[=, complete link abbreviations (see [[*Link
18164        Abbreviations]]).
18166      - After =#+=, complete the special keywords like =TYP_TODO= or
18167        file-specific =OPTIONS=.  After option keyword is complete,
18168        pressing {{{kbd(M-TAB)}}} again inserts example settings for
18169        this keyword.
18171      - After =STARTUP= keyword, complete startup items.
18173      - When point is anywhere else, complete dictionary words using
18174        Ispell.
18176 ** Structure Templates
18177 :PROPERTIES:
18178 :DESCRIPTION: Quick insertion of structural elements.
18179 :END:
18180 #+cindex: template insertion
18181 #+cindex: insertion, of templates
18183 With just a few keystrokes, it is possible to insert empty structural
18184 blocks, such as =#+BEGIN_SRC= ... =#+END_SRC=, or to wrap existing
18185 text in such a block.
18187 - {{{kbd(C-c C-\,)}}} (~org-insert-structure-template~) ::
18189      #+findex: org-insert-structure-template
18190      #+kindex: C-c C-,
18191      Prompt for a type of block structure, and insert the block at
18192      point.  If the region is active, it is wrapped in the block.
18193      First prompts the user for keys, which are used to look up
18194      a structure type from the variable below.  If the key is
18195      {{{kbd(TAB)}}}, {{{kbd(RET)}}}, or {{{kbd(SPC)}}}, the user is
18196      prompted to enter a block type.
18198 #+vindex: org-structure-template-alist
18199 Available structure types are defined in
18200 ~org-structure-template-alist~, see the docstring for adding or
18201 changing values.
18203 #+cindex: Tempo
18204 #+cindex: template expansion
18205 #+cindex: insertion, of templates
18206 #+vindex: org-tempo-keywords-alist
18207 Org Tempo expands snippets to structures defined in
18208 ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
18209 example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
18210 customizing ~org-modules~ or add ~(require 'org-tempo)~ to your Emacs
18211 init file[fn:133].
18214 #+attr_texinfo: :columns 0.1 0.9
18215 | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
18216 | {{{kbd(c)}}} | =#+BEGIN_CENTER= ... =#+END_CENTER=       |
18217 | {{{kbd(C)}}} | =#+BEGIN_COMMENT= ... =#+END_COMMENT=     |
18218 | {{{kbd(e)}}} | =#+BEGIN_EXAMPLE= ... =#+END_EXAMPLE=     |
18219 | {{{kbd(h)}}} | =#+BEGIN_EXPORT html= ... =#+END_EXPORT=  |
18220 | {{{kbd(l)}}} | =#+BEGIN_EXPORT latex= ... =#+END_EXPORT= |
18221 | {{{kbd(q)}}} | =#+BEGIN_QUOTE= ... =#+END_QUOTE=         |
18222 | {{{kbd(s)}}} | =#+BEGIN_SRC= ... =#+END_SRC=             |
18223 | {{{kbd(v)}}} | =#+BEGIN_VERSE= ... =#+END_VERSE=         |
18224 #+TBLFM: 
18226 ** Speed Keys
18227 :PROPERTIES:
18228 :DESCRIPTION: Electric commands at the beginning of a headline.
18229 :END:
18230 #+cindex: speed keys
18232 Single keystrokes can execute custom commands in an Org file when the
18233 cursor is on a headline.  Without the extra burden of a meta or
18234 modifier key, Speed Keys can speed navigation or execute custom
18235 commands.  Besides faster navigation, Speed Keys may come in handy on
18236 small mobile devices that do not have full keyboards.  Speed Keys may
18237 also work on TTY devices known for their problems when entering Emacs
18238 key chords.
18240 #+vindex: org-use-speed-commands
18241 By default, Org has Speed Keys disabled.  To activate Speed Keys, set
18242 the variable ~org-use-speed-commands~ to a non-~nil~ value.  To
18243 trigger a Speed Key, the cursor must be at the beginning of an Org
18244 headline, before any of the stars.
18246 #+vindex: org-speed-commands-user
18247 #+findex: org-speed-command-help
18248 Org comes with a pre-defined list of Speed Keys.  To add or modify
18249 Speed Keys, customize the variable, ~org-speed-commands-user~.  For
18250 more details, see the variable's docstring.  With Speed Keys
18251 activated, {{{kbd(M-x org-speed-command-help)}}}, or {{{kbd(?)}}} when
18252 cursor is at the beginning of an Org headline, shows currently active
18253 Speed Keys, including the user-defined ones.
18255 ** Code Evaluation and Security Issues
18256 :PROPERTIES:
18257 :DESCRIPTION: Org files evaluate in-line code.
18258 :ALT_TITLE: Code Evaluation Security
18259 :END:
18261 Unlike plain text, running code comes with risk.  Each =src= code
18262 block, in terms of risk, is equivalent to an executable file.  Org
18263 therefore puts a few confirmation prompts by default.  This is to
18264 alert the casual user from accidentally running untrusted code.
18266 For users who do not run code blocks or write code regularly, Org's
18267 default settings should suffice.  However, some users may want to
18268 tweak the prompts for fewer interruptions.  To weigh the risks of
18269 automatic execution of code blocks, here are some details about code
18270 evaluation.
18272 Org evaluates code in the following circumstances:
18274 - /Source code blocks/ ::
18276      Org evaluates =src= code blocks in an Org file during export.
18277      Org also evaluates a =src= code block with the {{{kbd(C-c C-c)}}}
18278      key chord.  Users exporting or running code blocks must load
18279      files only from trusted sources.  Be wary of customizing
18280      variables that remove or alter default security measures.
18282      #+attr_texinfo: :options org-confirm-babel-evaluate
18283      #+begin_defopt
18284      When ~t~, Org prompts the user for confirmation before executing
18285      each code block.  When ~nil~, Org executes code blocks without
18286      prompting the user for confirmation.  When this option is set to
18287      a custom function, Org invokes the function with these two
18288      arguments: the source code language and the body of the code
18289      block.  The custom function must return either a ~t~ or ~nil~,
18290      which determines if the user is prompted.  Each source code
18291      language can be handled separately through this function
18292      argument.
18293      #+end_defopt
18295      For example, here is how to execute ditaa code blocks without
18296      prompting:
18298      #+begin_src emacs-lisp
18299      (defun my-org-confirm-babel-evaluate (lang body)
18300        (not (string= lang "ditaa")))  ;don't ask for ditaa
18301      (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
18302      #+end_src
18304 - /Following =shell= and =elisp= links/ ::
18306      Org has two link types that can directly evaluate code (see
18307      [[*External Links]]).  Because such code is not visible, these links
18308      have a potential risk.  Org therefore prompts the user when it
18309      encounters such links.  The customization variables are:
18311      #+attr_texinfo: :options org-confirm-shell-link-function
18312      #+begin_defopt
18313      Function that prompts the user before executing a shell link.
18314      #+end_defopt
18316      #+attr_texinfo: :options org-confirm-elisp-link-function
18317      #+begin_defopt
18318      Function that prompts the user before executing an Emacs Lisp link.
18319      #+end_defopt
18321 - /Formulas in tables/ ::
18323      Formulas in tables (see [[*The spreadsheet]]) are code that is
18324      evaluated either by the Calc interpreter, or by the Emacs Lisp
18325      interpreter.
18327 ** Customization
18328 :PROPERTIES:
18329 :DESCRIPTION: Adapting Org to your taste.
18330 :END:
18331 #+cindex: customization
18332 #+cindex: options, for customization
18333 #+cindex: variables, for customization
18335 Org has more than 500 variables for customization.  They can be
18336 accessed through the usual {{{kbd(M-x org-customize)}}} command.  Or
18337 through the Org menu: Org \rarr Customization \rarr Browse Org Group.
18339 Org also has per-file settings for some variables (see [[*Summary of
18340 In-Buffer Settings]]).
18342 ** Summary of In-Buffer Settings
18343 :PROPERTIES:
18344 :DESCRIPTION: Overview of keywords.
18345 :ALT_TITLE: In-buffer Settings
18346 :END:
18347 #+cindex: in-buffer settings
18348 #+cindex: special keywords
18350 In-buffer settings start with =#+=, followed by a keyword, a colon,
18351 and then a word for each setting.  Org accepts multiple settings on
18352 the same line.  Org also accepts multiple lines for a keyword.  This
18353 manual describes these settings throughout.  A summary follows here.
18355 #+cindex: refresh set-up
18356 {{{kbd(C-c C-c)}}} activates any changes to the in-buffer settings.
18357 Closing and reopening the Org file in Emacs also activates the
18358 changes.
18360 #+attr_texinfo: :sep ,
18361 - =#+ARCHIVE: %s_done= ::
18363      #+cindex: @samp{ARCHIVE}, keyword
18364      #+vindex: org-archive-location
18365      Sets the archive location of the agenda file.  The corresponding
18366      variable is ~org-archive-location~.
18368 - =#+CATEGORY= ::
18370      #+cindex: @samp{CATEGORY}, keyword
18371      Sets the category of the agenda file, which applies to the entire
18372      document.
18374 - =#+COLUMNS: %25ITEM ...= ::
18376      #+cindex: @samp{COLUMNS}, property
18377      Set the default format for columns view.  This format applies
18378      when columns view is invoked in locations where no =COLUMNS=
18379      property applies.
18381 - =#+CONSTANTS: name1=value1 ...= ::
18383      #+cindex: @samp{CONSTANTS}, keyword
18384      #+vindex: org-table-formula-constants
18385      #+vindex: org-table-formula
18386      Set file-local values for constants that table formulas can use.
18387      This line sets the local variable
18388      ~org-table-formula-constants-local~.  The global version of this
18389      variable is ~org-table-formula-constants~.
18391 - =#+FILETAGS: :tag1:tag2:tag3:= ::
18393      #+cindex: @samp{FILETAGS}, keyword
18394      Set tags that all entries in the file inherit from, including the
18395      top-level entries.
18397 - =#+LINK: linkword replace= ::
18399      #+cindex: @samp{LINK}, keyword
18400      #+vindex: org-link-abbrev-alist
18401      Each line specifies one abbreviation for one link.  Use multiple
18402      =LINK= keywords for more, see [[*Link Abbreviations]].  The
18403      corresponding variable is ~org-link-abbrev-alist~.
18405 - =#+PRIORITIES: highest lowest default= ::
18407      #+cindex: @samp{PRIORITIES}, keyword
18408      #+vindex: org-highest-priority
18409      #+vindex: org-lowest-priority
18410      #+vindex: org-default-priority
18411      This line sets the limits and the default for the priorities.
18412      All three must be either letters A--Z or numbers 0--9.  The
18413      highest priority must have a lower ASCII number than the lowest
18414      priority.
18416 - =#+PROPERTY: Property_Name Value= ::
18418      #+cindex: @samp{PROPERTY}, keyword
18419      This line sets a default inheritance value for entries in the
18420      current buffer, most useful for specifying the allowed values of
18421      a property.
18423 - =#+SETUPFILE: file= ::
18425      #+cindex: @samp{SETUPFILE}, keyword
18426      The setup file or a URL pointing to such file is for additional
18427      in-buffer settings.  Org loads this file and parses it for any
18428      settings in it only when Org opens the main file.  If URL is
18429      specified, the contents are downloaded and stored in a temporary
18430      file cache.  {{{kbd(C-c C-c)}}} on the settings line parses and
18431      loads the file, and also resets the temporary file cache.  Org
18432      also parses and loads the document during normal exporting
18433      process.  Org parses the contents of this document as if it was
18434      included in the buffer.  It can be another Org file.  To visit
18435      the file---not a URL---use {{{kbd(C-c ')}}} while the cursor is
18436      on the line with the file name.
18438 - =#+STARTUP:= ::
18440      #+cindex: @samp{STARTUP}, keyword
18441      Startup options Org uses when first visiting a file.
18443      #+vindex: org-startup-folded
18444      The first set of options deals with the initial visibility of the
18445      outline tree.  The corresponding variable for global default
18446      settings is ~org-startup-folded~ with a default value of ~t~,
18447      which is the same as ~overview~.
18449      - =overview= ::
18451           Top-level headlines only.
18453      - =content= ::
18455           All headlines.
18457      - =showall= ::
18459           No folding on any entry.
18461      - =showeverything= ::
18463           Show even drawer contents.
18465      #+vindex: org-startup-indented
18466      Dynamic virtual indentation is controlled by the variable
18467      ~org-startup-indented~.[fn:134]
18469      - =indent= ::
18471           Start with ~org-indent-mode~ turned on.
18473      - =noindent= ::
18475           Start with ~org-indent-mode~ turned off.
18477      #+vindex: org-startup-align-all-tables
18478      Aligns tables consistently upon visiting a file.  The corresponding
18479      variable is ~org-startup-align-all-tables~ with ~nil~ as default
18480      value.
18482      - =align= ::
18484           Align all tables.
18486      - =noalign= ::
18488           Do not align tables on startup.
18490      #+vindex: org-startup-shrink-all-tables
18491      Shrink table columns with a width cookie.  The corresponding
18492      variable is ~org-startup-shrink-all-tables~ with ~nil~ as default
18493      value.
18495      #+vindex: org-startup-with-inline-images
18496      When visiting a file, inline images can be automatically displayed.
18497      The corresponding variable is ~org-startup-with-inline-images~,
18498      with a default value ~nil~ to avoid delays when visiting a file.
18500      - =inlineimages= ::
18502           Show inline images.
18504      - =noinlineimages= ::
18506           Do not show inline images on startup.
18508      #+vindex: org-log-done
18509      #+vindex: org-log-note-clock-out
18510      #+vindex: org-log-repeat
18511      Logging the closing and reopening of TODO items and clock
18512      intervals can be configured using these options (see variables
18513      ~org-log-done~, ~org-log-note-clock-out~, and ~org-log-repeat~).
18515      - =logdone= ::
18517           Record a timestamp when an item is marked DONE.
18519      - =lognotedone= ::
18521           Record timestamp and a note when DONE.
18523      - =nologdone= ::
18525           Do not record when items are marked DONE.
18527      - =logrepeat= ::
18529           Record a time when reinstating a repeating item.
18531      - =lognoterepeat= ::
18533           Record a note when reinstating a repeating item.
18535      - =nologrepeat= ::
18537           Do not record when reinstating repeating item.
18539      - =lognoteclock-out= ::
18541           Record a note when clocking out.
18543      - =nolognoteclock-out= ::
18545           Do not record a note when clocking out.
18547      - =logreschedule= ::
18549           Record a timestamp when scheduling time changes.
18551      - =lognotereschedule= ::
18553           Record a note when scheduling time changes.
18555      - =nologreschedule= ::
18557           Do not record when a scheduling date changes.
18559      - =logredeadline= ::
18561           Record a timestamp when deadline changes.
18563      - =lognoteredeadline= ::
18565           Record a note when deadline changes.
18567      - =nologredeadline= ::
18569           Do not record when a deadline date changes.
18571      - =logrefile= ::
18573           Record a timestamp when refiling.
18575      - =lognoterefile= ::
18577           Record a note when refiling.
18579      - =nologrefile= ::
18581           Do not record when refiling.
18583      #+vindex: org-hide-leading-stars
18584      #+vindex: org-odd-levels-only
18585      Here are the options for hiding leading stars in outline headings,
18586      and for indenting outlines.  The corresponding variables are
18587      ~org-hide-leading-stars~ and ~org-odd-levels-only~, both with
18588      a default setting ~nil~ (meaning =showstars= and =oddeven=).
18590      - =hidestars= ::
18592           Make all but one of the stars starting a headline invisible.
18594      - =showstars= ::
18596           Show all stars starting a headline.
18598      - =indent= ::
18600           Virtual indentation according to outline level.
18602      - =noindent= ::
18604           No virtual indentation according to outline level.
18606      - =odd= ::
18608           Allow only odd outline levels (1, 3, ...).
18610      - =oddeven= ::
18612           Allow all outline levels.
18614      #+vindex: org-put-time-stamp-overlays
18615      #+vindex: org-time-stamp-overlay-formats
18616      To turn on custom format overlays over timestamps (variables
18617      ~org-put-time-stamp-overlays~ and ~org-time-stamp-overlay-formats~),
18618      use:
18620      - =customtime= ::
18622           Overlay custom time format.
18624      #+vindex: constants-unit-system
18625      The following options influence the table spreadsheet (variable
18626      ~constants-unit-system~).
18628      - =constcgs= ::
18630           =constants.el= should use the c-g-s unit system.
18632      - =constSI= ::
18634           =constants.el= should use the SI unit system.
18636      #+vindex: org-footnote-define-inline
18637      #+vindex: org-footnote-auto-label
18638      #+vindex: org-footnote-auto-adjust
18639      To influence footnote settings, use the following keywords.  The
18640      corresponding variables are ~org-footnote-define-inline~,
18641      ~org-footnote-auto-label~, and ~org-footnote-auto-adjust~.
18643      - =fninline= ::
18645           Define footnotes inline.
18647      - =fnnoinline= ::
18649           Define footnotes in separate section.
18651      - =fnlocal= ::
18653           Define footnotes near first reference, but not inline.
18655      - =fnprompt= ::
18657           Prompt for footnote labels.
18659      - =fnauto= ::
18661           Create =[fn:1]=-like labels automatically (default).
18663      - =fnconfirm= ::
18665           Offer automatic label for editing or confirmation.
18667      - =fnadjust= ::
18669           Automatically renumber and sort footnotes.
18671      - =nofnadjust= ::
18673           Do not renumber and sort automatically.
18675      #+vindex: org-hide-block-startup
18676      To hide blocks on startup, use these keywords.  The corresponding
18677      variable is ~org-hide-block-startup~.
18679      - =hideblocks= ::
18681           Hide all begin/end blocks on startup.
18683      - =nohideblocks= ::
18685           Do not hide blocks on startup.
18687      #+vindex: org-pretty-entities
18688      The display of entities as UTF-8 characters is governed by the
18689      variable ~org-pretty-entities~ and the keywords
18691      - =entitiespretty= ::
18693           Show entities as UTF-8 characters where possible.
18695      - =entitiesplain= ::
18697           Leave entities plain.
18699 - =#+TAGS: TAG1(c1) TAG2(c2)= ::
18701      #+cindex: @samp{TAGS}, keyword
18702      #+vindex: org-tag-alist
18703      These lines (several such lines are allowed) specify the valid
18704      tags in this file, and (potentially) the corresponding /fast tag
18705      selection/ keys.  The corresponding variable is ~org-tag-alist~.
18707 - =#+TODO:=, =#+SEQ_TODO:=, =#+TYP_TODO:= ::
18709      #+cindex: @samp{SEQ_TODO}, keyword
18710      #+cindex: @samp{TODO}, keyword
18711      #+cindex: @samp{TYP_TODO}, keyword
18712      #+vindex: org-todo-keywords
18713      These lines set the TODO keywords and their interpretation in the
18714      current file.  The corresponding variable is ~org-todo-keywords~.
18716 ** The Very Busy {{{kbd(C-c C-c)}}} Key
18717 :PROPERTIES:
18718 :DESCRIPTION: When in doubt, press @kbd{C-c C-c}.
18719 :END:
18720 #+kindex: C-c C-c
18721 #+cindex: @kbd{C-c C-c}, overview
18723 The {{{kbd(C-c C-c)}}} key in Org serves many purposes depending on
18724 the context.  It is probably the most over-worked, multi-purpose key
18725 combination in Org.  Its uses are well documented throughout this
18726 manual, but here is a consolidated list for easy reference.
18728 - If any highlights shown in the buffer from the creation of a sparse
18729   tree, or from clock display, remove such highlights.
18731 - If the cursor is in one of the special =KEYWORD= lines, scan the
18732   buffer for these lines and update the information.  Also reset the
18733   Org file cache used to temporary store the contents of URLs used as
18734   values for keywords like =SETUPFILE=.
18736 - If the cursor is inside a table, realign the table.  The table
18737   realigns even if automatic table editor is turned off.
18739 - If the cursor is on a =TBLFM= keyword, re-apply the formulas to the
18740   entire table.
18742 - If the current buffer is a capture buffer, close the note and file
18743   it.  With a prefix argument, also jump to the target location after
18744   saving the note.
18746 - If the cursor is on a =<<<target>>>=, update radio targets and
18747   corresponding links in this buffer.
18749 - If the cursor is on a property line or at the start or end of
18750   a property drawer, offer property commands.
18752 - If the cursor is at a footnote reference, go to the corresponding
18753   definition, and /vice versa/.
18755 - If the cursor is on a statistics cookie, update it.
18757 - If the cursor is in a plain list item with a checkbox, toggle the
18758   status of the checkbox.
18760 - If the cursor is on a numbered item in a plain list, renumber the
18761   ordered list.
18763 - If the cursor is on the =#+BEGIN= line of a dynamic block, the block
18764   is updated.
18766 - If the cursor is at a timestamp, fix the day name in the timestamp.
18768 ** A Cleaner Outline View
18769 :PROPERTIES:
18770 :DESCRIPTION: Getting rid of leading stars in the outline.
18771 :ALT_TITLE: Clean View
18772 :END:
18773 #+cindex: hiding leading stars
18774 #+cindex: dynamic indentation
18775 #+cindex: odd-levels-only outlines
18776 #+cindex: clean outline view
18778 Org's default outline with stars and no indents can become too
18779 cluttered for short documents.  For /book-like/ long documents, the
18780 effect is not as noticeable.  Org provides an alternate stars and
18781 indentation scheme, as shown on the right in the following table.  It
18782 uses only one star and indents text to line with the heading:
18784 #+begin_example
18785 ,* Top level headline             |    * Top level headline
18786 ,** Second level                  |      * Second level
18787 ,*** Third level                  |        * Third level
18788     some text                    |          some text
18789 ,*** Third level                  |        * Third level
18790     more text                    |          more text
18791 ,* Another top level headline     |    * Another top level headline
18792 #+end_example
18794 #+texinfo: @noindent
18795 #+cindex: Indent mode
18796 #+findex: org-indent-mode
18797 To turn this mode on, use the minor mode, ~org-indent-mode~.  Text
18798 lines that are not headlines are prefixed with spaces to vertically
18799 align with the headline text[fn:135].
18801 #+vindex: org-indent-indentation-per-level
18802 To make more horizontal space, the headlines are shifted by two stars.
18803 This can be configured by the ~org-indent-indentation-per-level~
18804 variable.  Only one star on each headline is visible, the rest are
18805 masked with the same font color as the background.
18807 Note that turning on ~org-indent-mode~ sets ~org-hide-leading-stars~
18808 to ~t~ and ~org-adapt-indentation~ to ~nil~.
18810 #+vindex: org-startup-indented
18811 To globally turn on ~org-indent-mode~ for all files, customize the
18812 variable ~org-startup-indented~.
18814 To turn on indenting for individual files, use =STARTUP= keyword as
18815 follows:
18817 : #+STARTUP: indent
18819 Indent on startup makes Org use hard spaces to align text with
18820 headings as shown in examples below.
18822 - /Indentation of text below headlines/ ::
18824      Indent text to align with the headline.
18826      #+begin_example
18827      ,*** Third level
18828          more text, now indented
18829      #+end_example
18831      #+vindex: org-adapt-indentation
18832      Org supports this with paragraph filling, line wrapping, and
18833      structure editing, preserving or adapting the indentation as
18834      appropriate[fn:136].
18836 - /Hiding leading stars/ ::
18838      #+vindex: org-hide-leading-stars
18839      Org can make leading stars invisible.  For global preference,
18840      configure the variable ~org-hide-leading-stars~.  For per-file
18841      preference, use these file =STARTUP= options:
18843      #+begin_example
18844      ,#+STARTUP: hidestars
18845      ,#+STARTUP: showstars
18846      #+end_example
18848      With stars hidden, the tree is shown as:
18850      #+begin_example
18851      ,* Top level headline
18852       ,* Second level
18853        ,* Third level
18854        ...
18855      #+end_example
18857      #+texinfo: @noindent
18858      #+vindex: org-hide, face
18859      Because Org makes the font color the same as the background color
18860      to hide to stars, sometimes ~org-hide~ face may need tweaking to
18861      get the effect right.  For some black and white combinations,
18862      ~grey90~ on a white background might mask the stars better.
18864 - /Odd levels/ ::
18866      #+vindex: org-odd-levels-only
18867      Using stars for only odd levels, 1, 3, 5, ..., can also clean up
18868      the clutter.  This removes two stars from each level[fn:137].
18869      For Org to properly handle this cleaner structure during edits
18870      and exports, configure the variable ~org-odd-levels-only~.  To
18871      set this per-file, use either one of the following lines:
18873      #+begin_example
18874      ,#+STARTUP: odd
18875      ,#+STARTUP: oddeven
18876      #+end_example
18878      To switch between single and double stars layouts, use {{{kbd(M-x
18879      org-convert-to-odd-levels)}}} and {{{kbd(M-x
18880      org-convert-to-oddeven-levels)}}}.
18882 ** Using Org on a TTY
18883 :PROPERTIES:
18884 :DESCRIPTION: Using Org on a tty.
18885 :ALT_TITLE: TTY Keys
18886 :END:
18887 #+cindex: tty key bindings
18889 Org provides alternative key bindings for TTY and modern mobile
18890 devices that cannot handle cursor keys and complex modifier key
18891 chords.  Some of these workarounds may be more cumbersome than
18892 necessary.  Users should look into customizing these further based on
18893 their usage needs.  For example, the normal {{{kbd(S-<cursor>)}}} for
18894 editing timestamp might be better with {{{kbd(C-c .)}}} chord.
18896 #+attr_texinfo: :columns 0.2 0.28 0.15 0.21
18897 | Default              | Alternative 1            | Speed key    | Alternative 2        |
18898 |----------------------+--------------------------+--------------+----------------------|
18899 | {{{kbd(S-TAB)}}}     | {{{kbd(C-u TAB)}}}       | {{{kbd(C)}}} |                      |
18900 | {{{kbd(M-LEFT)}}}    | {{{kbd(C-c C-x l)}}}     | {{{kbd(l)}}} | {{{kbd(Esc LEFT)}}}  |
18901 | {{{kbd(M-S-LEFT)}}}  | {{{kbd(C-c C-x L)}}}     | {{{kbd(L)}}} |                      |
18902 | {{{kbd(M-RIGHT)}}}   | {{{kbd(C-c C-x r)}}}     | {{{kbd(r)}}} | {{{kbd(Esc RIGHT)}}} |
18903 | {{{kbd(M-S-RIGHT)}}} | {{{kbd(C-c C-x R)}}}     | {{{kbd(R)}}} |                      |
18904 | {{{kbd(M-UP)}}}      | {{{kbd(C-c C-x u)}}}     |              | {{{kbd(Esc UP)}}}    |
18905 | {{{kbd(M-S-UP)}}}    | {{{kbd(C-c C-x U)}}}     | {{{kbd(U)}}} |                      |
18906 | {{{kbd(M-DOWN)}}}    | {{{kbd(C-c C-x d)}}}     |              | {{{kbd(Esc DOWN)}}}  |
18907 | {{{kbd(M-S-DOWN)}}}  | {{{kbd(C-c C-x D)}}}     | {{{kbd(D)}}} |                      |
18908 | {{{kbd(S-RET)}}}     | {{{kbd(C-c C-x c)}}}     |              |                      |
18909 | {{{kbd(M-RET)}}}     | {{{kbd(C-c C-x m)}}}     |              | {{{kbd(Esc RET)}}}   |
18910 | {{{kbd(M-S-RET)}}}   | {{{kbd(C-c C-x M)}}}     |              |                      |
18911 | {{{kbd(S-LEFT)}}}    | {{{kbd(C-c LEFT)}}}      |              |                      |
18912 | {{{kbd(S-RIGHT)}}}   | {{{kbd(C-c RIGHT)}}}     |              |                      |
18913 | {{{kbd(S-UP)}}}      | {{{kbd(C-c UP)}}}        |              |                      |
18914 | {{{kbd(S-DOWN)}}}    | {{{kbd(C-c DOWN)}}}      |              |                      |
18915 | {{{kbd(C-S-LEFT)}}}  | {{{kbd(C-c C-x LEFT)}}}  |              |                      |
18916 | {{{kbd(C-S-RIGHT)}}} | {{{kbd(C-c C-x RIGHT)}}} |              |                      |
18918 ** Interaction with Other Packages
18919 :PROPERTIES:
18920 :DESCRIPTION: With other Emacs packages.
18921 :ALT_TITLE: Interaction
18922 :END:
18923 #+cindex: packages, interaction with other
18925 Org's compatibility and the level of interaction with other Emacs
18926 packages are documented here.
18928 *** Packages that Org cooperates with
18929 :PROPERTIES:
18930 :DESCRIPTION: Packages Org cooperates with.
18931 :ALT_TITLE: Cooperation
18932 :END:
18934 - =calc.el= by Dave Gillespie ::
18935      #+cindex: @file{calc.el}
18937      Org uses the Calc package for implementing spreadsheet
18938      functionality in its tables (see [[*The spreadsheet]]).  Org also
18939      uses Calc for embedded calculations.  See [[info:calc:Embedded%20Mode][GNU Emacs Calc Manual]].
18941 - =constants.el= by Carsten Dominik ::
18942      #+cindex: @file{constants.el}
18943      #+vindex: org-table-formula-constants
18945      Org can use names for constants in formulas in tables.  Org can
18946      also use calculation suffixes for units, such as =M= for =Mega=.
18947      For a standard collection of such constants, install the
18948      =constants= package.  Install version 2.0 of this package,
18949      available at [[http://www.astro.uva.nl/~dominik/Tools]].  Org checks
18950      if the function ~constants-get~ has been autoloaded.
18951      Installation instructions are in the file =constants.el=.
18953 - =cdlatex.el= by Carsten Dominik ::
18954      #+cindex: @file{cdlatex.el}
18956      Org mode can make use of the CDLaTeX package to efficiently enter
18957      LaTeX fragments into Org files.  See [[*Using CDLaTeX to enter
18958      math]].
18960 - =imenu.el= by Ake Stenhoff and Lars Lindberg ::
18961      #+cindex: @file{imenu.el}
18963      Imenu creates dynamic menus based on an index of items in a file.
18964      Org mode supports Imenu menus.  Enable it with a mode hook as
18965      follows:
18967      #+begin_src emacs-lisp
18968      (add-hook 'org-mode-hook
18969                (lambda () (imenu-add-to-menubar "Imenu")))
18970      #+end_src
18972      #+vindex: org-imenu-depth
18973      By default the index is two levels deep---you can modify the
18974      depth using the option ~org-imenu-depth~.
18976 - =speedbar.el= by Eric M. Ludlam ::
18977      #+cindex: @file{speedbar.el}
18979      Speedbar package creates a special Emacs frame for displaying
18980      files and index items in files.  Org mode supports Speedbar;
18981      users can drill into Org files directly from the Speedbar.  The
18982      {{{kbd(<)}}} in the Speedbar frame tweaks the agenda commands to
18983      that file or to a subtree.
18985 - =table.el= by Takaaki Ota ::
18986      #+cindex: table editor, @file{table.el}
18987      #+cindex: @file{table.el}
18989      Complex ASCII tables with automatic line wrapping, column- and
18990      row-spanning, and alignment can be created using the Emacs table
18991      package by Takaaki Ota.  Org mode recognizes such tables and
18992      exports them properly.  {{{kbd(C-c ')}}} to edit these tables in
18993      a special buffer, much like Org's code blocks.  Because of
18994      interference with other Org mode functionality, Takaaki Ota
18995      tables cannot be edited directly in the Org buffer.
18997      - {{{kbd(C-c ')}}} (~org-edit-special~) ::
18999           #+kindex: C-c '
19000           #+findex: org-edit-special
19001           Edit a =table.el= table.  Works when the cursor is in
19002           a =table.el= table.
19004      - {{{kbd(C-c ~​)}}} (~org-table-create-with-table.el~) ::
19006           #+kindex: C-c ~
19007           #+findex: org-table-create-with-table.el
19008           Insert a =table.el= table.  If there is already a table at
19009           point, this command converts it between the =table.el=
19010           format and the Org mode format.  See the documentation
19011           string of the command ~org-convert-table~ for the
19012           restrictions under which this is possible.
19014 *** Packages that conflict with Org mode
19015 :PROPERTIES:
19016 :DESCRIPTION: Packages that lead to conflicts.
19017 :ALT_TITLE: Conflicts
19018 :END:
19020 #+cindex: shift-selection-mode
19021 #+vindex: org-support-shift-select
19022 In Emacs, ~shift-selection-mode~ combines cursor motions with shift
19023 key to enlarge regions.  Emacs sets this mode by default.  This
19024 conflicts with Org's use of {{{kbd(S-<cursor>)}}} commands to change
19025 timestamps, TODO keywords, priorities, and item bullet types, etc.
19026 Since {{{kbd(S-<cursor>)}}} commands outside of specific contexts do
19027 not do anything, Org offers the variable ~org-support-shift-select~
19028 for customization.  Org mode accommodates shift selection by (i)
19029 making it available outside of the special contexts where special
19030 commands apply, and (ii) extending an existing active region even if
19031 the cursor moves across a special context.
19033 - =cua.el= by Kim. F. Storm ::
19035      #+cindex: @file{cua.el}
19036      #+vindex: org-replace-disputed-keys
19037      Org key bindings conflict with {{{kbd(S-<cursor>)}}} keys used by
19038      CUA mode.  For Org to relinquish these bindings to CUA mode,
19039      configure the variable ~org-replace-disputed-keys~.  When set,
19040      Org moves the following key bindings in Org files, and in the
19041      agenda buffer---but not during date selection.
19043      #+attr_texinfo: :columns 0.4 0.4
19044      | {{{kbd(S-UP)}}}      \rArr{}  {{{kbd(M-p)}}}   | {{{kbd(S-DOWN)}}}     \rArr{}  {{{kbd(M-n)}}}   |
19045      | {{{kbd(S-LEFT)}}}    \rArr{}  {{{kbd(M--)}}}   | {{{kbd(S-RIGHT)}}}    \rArr{}  {{{kbd(M-+)}}}   |
19046      | {{{kbd(C-S-LEFT)}}}  \rArr{}  {{{kbd(M-S--)}}} | {{{kbd(C-S-RIGHT)}}}  \rArr{}  {{{kbd(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:
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 following example shows the
19223 process of adding Org links to Unix man pages, which look like this
19225 : [[man:printf][The printf manual]]
19227 #+texinfo: @noindent
19228 The following =org-man.el= file implements it
19230 #+begin_src emacs-lisp
19231 ;;; org-man.el - Support for links to man pages in Org mode
19232 (require 'org)
19234 (org-link-set-parameters "man"
19235                          :follow org-man-command
19236                          :export #'org-man-export
19237                          :store #'org-man-store-link)
19239 (defcustom org-man-command 'man
19240   "The Emacs command to be used to display a man page."
19241   :group 'org-link
19242   :type '(choice (const man) (const woman)))
19244 (defun org-man-store-link ()
19245   "Store a link to a man page."
19246   (when (memq major-mode '(Man-mode woman-mode))
19247     ;; This is a man page, we do make this link.
19248     (let* ((page (org-man-get-page-name))
19249            (link (concat "man:" page))
19250            (description (format "Man page for %s" page)))
19251       (org-store-link-props
19252        :type "man"
19253        :link link
19254        :description description))))
19256 (defun org-man-get-page-name ()
19257   "Extract the page name from the buffer name."
19258   ;; This works for both `Man-mode' and `woman-mode'.
19259   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
19260       (match-string 1 (buffer-name))
19261     (error "Cannot create link to this man page")))
19263 (defun org-man-export (link description format)
19264   "Export a man page link from Org files."
19265   (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
19266         (desc (or description link)))
19267     (pcase format
19268       (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
19269       (`latex (format "\\href{%s}{%s}" path desc))
19270       (`texinfo (format "@uref{%s,%s}" path desc))
19271       (`ascii (format "%s (%s)" desc path))
19272       (t path))))
19274 (provide 'org-man)
19275 ;;; org-man.el ends here
19276 #+end_src
19278 #+texinfo: @noindent
19279 To activate links to man pages in Org, enter this in the Emacs init
19280 file:
19282 #+begin_src emacs-lisp
19283 (require 'org-man)
19284 #+end_src
19286 #+texinfo: @noindent
19287 A review of =org-man.el=:
19289 1. First, ~(require 'org)~ ensures =org.el= is loaded.
19293    #+findex: org-link-set-parameters
19294    #+vindex: org-link-parameters
19295    Then ~org-link-set-parameters~ defines a new link type with =man=
19296    prefix and associates functions for following, exporting and
19297    storing such links.  See the variable ~org-link-parameters~ for
19298    a complete list of possible associations.
19300 3. The rest of the file implements necessary variables and functions.
19302    For example, ~org-man-store-link~ is responsible for storing a link
19303    when ~org-store-link~ (see [[*Handling Links]]) is called from a buffer
19304    displaying a man page.  It first checks if the ~major-mode~ is
19305    appropriate.  If check fails, the function returns ~nil~, which
19306    means it isn't responsible for creating a link to the current
19307    buffer.  Otherwise the function makes a link string by combining
19308    the =man:= prefix with the man topic.  It also provides a default
19309    description.  The function ~org-insert-link~ can insert it back
19310    into an Org buffer later on.
19312 ** Adding Export Back-ends
19313 :PROPERTIES:
19314 :DESCRIPTION: How to write new export back-ends.
19315 :END:
19316 #+cindex: Export, writing back-ends
19318 Org's export engine makes it easy for writing new back-ends.  The
19319 framework on which the engine was built makes it easy to derive new
19320 back-ends from existing ones.
19322 #+findex: org-export-define-backend
19323 #+findex: org-export-define-derived-backend
19324 The two main entry points to the export engine are:
19325 ~org-export-define-backend~ and ~org-export-define-derived-backend~.
19326 To grok these functions, see =ox-latex.el= for an example of defining
19327 a new back-end from scratch, and =ox-beamer.el= for an example of
19328 deriving from an existing engine.
19330 For creating a new back-end from scratch, first set its name as
19331 a symbol in an alist consisting of elements and export functions.  To
19332 make the back-end visible to the export dispatcher, set ~:menu-entry~
19333 keyword.  For export options specific to this back-end, set the
19334 ~:options-alist~.
19336 For creating a new back-end from an existing one, set
19337 ~:translate-alist~ to an alist of export functions.  This alist
19338 replaces the parent back-end functions.
19340 For complete documentation, see [[https://orgmode.org/worg/dev/org-export-reference.html][the Org Export Reference on Worg]].
19342 ** Tables in Arbitrary Syntax
19343 :PROPERTIES:
19344 :DESCRIPTION: Orgtbl for LaTeX and other programs.
19345 :END:
19346 #+cindex: tables, in other modes
19347 #+cindex: lists, in other modes
19348 #+cindex: Orgtbl mode
19350 Due to Org's success in handling tables with Orgtbl, a frequently
19351 requested feature is the use of Org's table functions in other modes,
19352 e.g., LaTeX.  This would be hard to do in a general way without
19353 complicated customization nightmares.  Moreover, that would take Org
19354 away from its simplicity roots that Orgtbl has proven.  There is,
19355 however, an alternate approach to accomplishing the same.
19357 This approach involves implementing a custom /translate/ function that
19358 operates on a native Org /source table/ to produce a table in another
19359 format.  This strategy would keep the excellently working Orgtbl
19360 simple and isolate complications, if any, confined to the translate
19361 function.  To add more alien table formats, we just add more translate
19362 functions.  Also the burden of developing custom translate functions
19363 for new table formats is in the hands of those who know those formats
19364 best.
19366 *** Radio tables
19367 :PROPERTIES:
19368 :DESCRIPTION: Sending and receiving radio tables.
19369 :END:
19370 #+cindex: radio tables
19372 Radio tables are target locations for translated tables that are not near
19373 their source.  Org finds the target location and inserts the translated
19374 table.
19376 The key to finding the target location is the magic words =BEGIN/END
19377 RECEIVE ORGTBL=.  They have to appear as comments in the current mode.
19378 If the mode is C, then:
19380 #+begin_example
19381 /* BEGIN RECEIVE ORGTBL table_name */
19382 /* END RECEIVE ORGTBL table_name */
19383 #+end_example
19385 #+texinfo: @noindent
19386 At the location of source, Org needs a special line to direct Orgtbl
19387 to translate and to find the target for inserting the translated
19388 table.  For example:
19390 #+cindex: @samp{ORGTBL}, keyword
19391 : #+ORGTBL: SEND table_name translation_function arguments ...
19393 #+texinfo: @noindent
19394 =table_name= is the table's reference name, which is also used in the
19395 receiver lines, and the =translation_function= is the Lisp function
19396 that translates.  This line, in addition, may also contain alternating
19397 key and value arguments at the end.  The translation function gets
19398 these values as a property list.  A few standard parameters are
19399 already recognized and acted upon before the translation function is
19400 called:
19402 - =:skip N= ::
19404      Skip the first N lines of the table.  Hlines do count; include
19405      them if they are to be skipped.
19407 - =:skipcols (n1 n2 ...)= ::
19409      List of columns to be skipped.  First Org automatically discards
19410      columns with calculation marks and then sends the table to the
19411      translator function, which then skips columns as specified in
19412      =skipcols=.
19414 #+texinfo: @noindent
19415 To keep the source table intact in the buffer without being disturbed
19416 when the source file is compiled or otherwise being worked on, use one
19417 of these strategies:
19419 - Place the table in a block comment.  For example, in C mode you
19420   could wrap the table between =/*= and =*/= lines.
19422 - Put the table after an "end" statement.  For example ~\bye~ in TeX
19423   and ~\end{document}~ in LaTeX.
19425 - Comment and un-comment each line of the table during edits.  The
19426   {{{kbd(M-x orgtbl-toggle-comment)}}} command makes toggling easy.
19428 *** A LaTeX example of radio tables
19429 :PROPERTIES:
19430 :DESCRIPTION: Step by step, almost a tutorial.
19431 :ALT_TITLE: A LaTeX example
19432 :END:
19433 #+cindex: @LaTeX{}, and Orgtbl mode
19435 To wrap a source table in LaTeX, use the =comment= environment
19436 provided by =comment.sty=[fn:138].  To activate it, put
19437 ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
19438 a radio table skeleton[fn:137] with the command {{{kbd(M-x
19439 orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
19440 example, if =salesfigures= is the name, the template inserts:
19442 #+begin_example
19443 % BEGIN RECEIVE ORGTBL salesfigures
19444 % END RECEIVE ORGTBL salesfigures
19445 \begin{comment}
19446 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19447 | | |
19448 \end{comment}
19449 #+end_example
19451 #+vindex: LaTeX-verbatim-environments
19452 #+texinfo: @noindent
19453 The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
19454 ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
19455 the table at the target (receive) location named =salesfigures=.  Now
19456 the table is ready for data entry.  It can even use spreadsheet
19457 features[fn:139]:
19459 #+begin_example
19460 % BEGIN RECEIVE ORGTBL salesfigures
19461 % END RECEIVE ORGTBL salesfigures
19462 \begin{comment}
19463 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19464 | Month | Days | Nr sold | per day |
19465 |-------+------+---------+---------|
19466 | Jan   |   23 |      55 |     2.4 |
19467 | Feb   |   21 |      16 |     0.8 |
19468 | March |   22 |     278 |    12.6 |
19469 ,#+TBLFM: $4=$3/$2;%.1f
19470 % $ (optional extra dollar to keep Font Lock happy, see footnote)
19471 \end{comment}
19472 #+end_example
19474 #+texinfo: @noindent
19475 After editing, {{{kbd(C-c C-c)}}} inserts the translated table at the
19476 target location, between the two marker lines.
19478 For hand-made custom tables, note that the translator needs to skip
19479 the first two lines of the source table.  Also the command has to
19480 /splice/ out the target table without the header and footer.
19482 #+begin_example
19483 \begin{tabular}{lrrr}
19484 Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\
19485 % BEGIN RECEIVE ORGTBL salesfigures
19486 % END RECEIVE ORGTBL salesfigures
19487 \end{tabular}
19489 \begin{comment}
19490 ,#+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
19491 | Month | Days | Nr sold | per day |
19492 |-------+------+---------+---------|
19493 | Jan   |   23 |      55 |     2.4 |
19494 | Feb   |   21 |      16 |     0.8 |
19495 | March |   22 |     278 |    12.6 |
19496 ,#+TBLFM: $4=$3/$2;%.1f
19497 \end{comment}
19498 #+end_example
19500 The LaTeX translator function ~orgtbl-to-latex~ is already part of
19501 Orgtbl mode and uses a =tabular= environment to typeset the table and
19502 marks horizontal lines with ~\hline~.  For additional parameters to
19503 control output, see [[*Translator functions]]:
19505 - ~:splice nil/t~ ::
19507      When non-~nil~, return only table body lines; not wrapped in
19508      tabular environment.  Default is ~nil~.
19510 - ~:fmt FMT~ ::
19512      Format to warp each field.  It should contain =%s= for the
19513      original field value.  For example, to wrap each field value in
19514      dollar symbol, you could use =:fmt "$%s$"=.  Format can also wrap
19515      a property list with column numbers and formats, for example
19516      =:fmt (2 "$%s$" 4 "%s\\%%")=.  In place of a string, a function
19517      of one argument can be used; the function must return a formatted
19518      string.
19520 - ~:efmt EFMT~ ::
19522      Format numbers as exponentials.  The spec should have =%s= twice
19523      for inserting mantissa and exponent, for example
19524      ="%s\\times10^{%s}"=.  This may also be a property list with
19525      column numbers and formats, for example =:efmt (2
19526      "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$")=.  After
19527      {{{var(EFMT)}}} has been applied to a value, {{{var(FMT)}}}---see
19528      above---is also be applied.  Functions with two arguments can be
19529      supplied instead of strings.  By default, no special formatting
19530      is applied.
19532 *** Translator functions
19533 :PROPERTIES:
19534 :DESCRIPTION: Copy and modify.
19535 :END:
19536 #+cindex: HTML, and Orgtbl mode
19537 #+cindex: translator function
19539 #+findex: orgtbl-to-csv
19540 #+findex: orgtbl-to-tsv
19541 #+findex: orgtbl-to-latex
19542 #+findex: orgtbl-to-html
19543 #+findex: orgtbl-to-texinfo
19544 #+findex: orgtbl-to-unicode
19545 #+findex: orgtbl-to-orgtbl
19546 #+findex: orgtbl-to-generic
19547 Orgtbl mode has built-in translator functions: ~orgtbl-to-csv~
19548 (comma-separated values), ~orgtbl-to-tsv~ (TAB-separated values),
19549 ~orgtbl-to-latex~, ~orgtbl-to-html~, ~orgtbl-to-texinfo~,
19550 ~orgtbl-to-unicode~ and ~orgtbl-to-orgtbl~.  They use the generic
19551 translator, ~orgtbl-to-generic~, which delegates translations to
19552 various export back-ends.
19554 Properties passed to the function through the =ORGTBL SEND= line take
19555 precedence over properties defined inside the function.  For example,
19556 this overrides the default LaTeX line endings, ~\\~, with ~\\[2mm]~:
19558 : #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
19560 For a new language translator, define a converter function.  It can be
19561 a generic function, such as shown in this example.  It marks
19562 a beginning and ending of a table with =!BTBL!= and =!ETBL!=;
19563 a beginning and ending of lines with =!BL!= and =!EL!=; and uses a TAB
19564 for a field separator:
19566 #+begin_src emacs-lisp
19567 (defun orgtbl-to-language (table params)
19568   "Convert the orgtbl-mode TABLE to language."
19569   (orgtbl-to-generic
19570    table
19571    (org-combine-plists
19572     '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
19573     params)))
19574 #+end_src
19576 #+texinfo: @noindent
19577 The documentation for the ~orgtbl-to-generic~ function shows
19578 a complete list of parameters, each of which can be passed through to
19579 ~orgtbl-to-latex~, ~orgtbl-to-texinfo~, and any other function using
19580 that generic function.
19582 For complicated translations the generic translator function could be
19583 replaced by a custom translator function.  Such a custom function must
19584 take two arguments and return a single string containing the formatted
19585 table.  The first argument is the table whose lines are a list of
19586 fields or the symbol ~hline~.  The second argument is the property
19587 list consisting of parameters specified in the =#+ORGTBL: SEND= line.
19588 Please share your translator functions by posting them to the Org
19589 users mailing list, at mailto:emacs-orgmode@gnu.org.
19591 ** Dynamic Blocks
19592 :PROPERTIES:
19593 :DESCRIPTION: Automatically filled blocks.
19594 :END:
19595 #+cindex: dynamic blocks
19597 Org supports /dynamic blocks/ in Org documents.  They are inserted
19598 with begin and end markers like any other code block, but the contents
19599 are updated automatically by a user function.  For example, {{{kbd(C-c
19600 C-x C-r)}}} inserts a dynamic table that updates the work time (see
19601 [[*Clocking Work Time]]).
19603 Dynamic blocks can have names and function parameters.  The syntax is
19604 similar to source code block specifications:
19606 #+begin_example
19607 ,#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
19608   ...
19609 ,#+END:
19610 #+end_example
19612 These commands update dynamic blocks:
19614 - {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
19616      #+kindex: C-c C-x C-u
19617      #+findex: org-dblock-update
19618      Update dynamic block at point.
19620 - {{{kbd(C-u C-c C-x C-u)}}} ::
19622      #+kindex: C-u C-c C-x C-u
19623      Update all dynamic blocks in the current file.
19625 Before updating a dynamic block, Org removes content between the
19626 =BEGIN= and =END= markers.  Org then reads the parameters on the
19627 =BEGIN= line for passing to the writer function.  If the function
19628 expects to access the removed content, then Org expects an extra
19629 parameter, =:content=, on the =BEGIN= line.
19631 The syntax for naming a writer function with a dynamic block labelled
19632 =myblock= is: ~org-dblock-write:myblock~.  Parameters come from the
19633 =BEGIN= line.
19635 The following is an example of a dynamic block and a block writer function
19636 that updates the time when the function was last run:
19638 #+begin_example
19639 ,#+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
19640   ...
19641 ,#+END:
19642 #+end_example
19644 #+texinfo: @noindent
19645 The dynamic block's writer function:
19647 #+begin_src emacs-lisp
19648 (defun org-dblock-write:block-update-time (params)
19649   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
19650     (insert "Last block update at: "
19651             (format-time-string fmt))))
19652 #+end_src
19654 To keep dynamic blocks up-to-date in an Org file, use the function,
19655 ~org-update-all-dblocks~ in hook, such as ~before-save-hook~.  The
19656 ~org-update-all-dblocks~ function does not run if the file is not in
19657 Org mode.
19659 #+findex: org-narrow-to-block
19660 Dynamic blocks, like any other block, can be narrowed with
19661 ~org-narrow-to-block~.
19663 ** Special Agenda Views
19664 :PROPERTIES:
19665 :DESCRIPTION: Customized views.
19666 :END:
19667 #+cindex: agenda views, user-defined
19669 #+vindex: org-agenda-skip-function
19670 #+vindex: org-agenda-skip-function-global
19671 Org provides a special hook to further limit items in agenda views:
19672 ~agenda~, ~agenda*~[fn:140], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
19673 ~tags-tree~.  Specify a custom function that tests inclusion of every
19674 matched item in the view.  This function can also skip as much as is
19675 needed.
19677 For a global condition applicable to agenda views, use the
19678 ~org-agenda-skip-function-global~ variable.  Org uses a global
19679 condition with ~org-agenda-skip-function~ for custom searching.
19681 This example defines a function for a custom view showing TODO items
19682 with =waiting= status.  Manually this is a multi-step search process,
19683 but with a custom view, this can be automated as follows:
19685 The custom function searches the subtree for the =waiting= tag and
19686 returns ~nil~ on match.  Otherwise it gives the location from where
19687 the search continues.
19689 #+begin_src emacs-lisp
19690 (defun my-skip-unless-waiting ()
19691   "Skip trees that are not waiting"
19692   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
19693     (if (re-search-forward ":waiting:" subtree-end t)
19694         nil          ; tag found, do not skip
19695       subtree-end))) ; tag not found, continue after end of subtree
19696 #+end_src
19698 To use this custom function in a custom agenda command:
19700 #+begin_src emacs-lisp
19701 (org-add-agenda-custom-command
19702  '("b" todo "PROJECT"
19703    ((org-agenda-skip-function 'my-skip-unless-waiting)
19704     (org-agenda-overriding-header "Projects waiting for something: "))))
19705 #+end_src
19707 #+vindex: org-agenda-overriding-header
19708 Note that this also binds ~org-agenda-overriding-header~ to a more
19709 meaningful string suitable for the agenda view.
19711 #+vindex: org-odd-levels-only
19712 #+vindex: org-agenda-skip-function
19713 Search for entries with a limit set on levels for the custom search.
19714 This is a general approach to creating custom searches in Org.  To
19715 include all levels, use =LEVEL>0=[fn:141].  Then to selectively pick
19716 the matched entries, use ~org-agenda-skip-function~, which also
19717 accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
19718 ~org-agenda-skip-subtree-if~.  For example:
19720 - ~(org-agenda-skip-entry-if 'scheduled)~ ::
19722      Skip current entry if it has been scheduled.
19724 - ~(org-agenda-skip-entry-if 'notscheduled)~ ::
19726      Skip current entry if it has not been scheduled.
19728 - ~(org-agenda-skip-entry-if 'deadline)~ ::
19730      Skip current entry if it has a deadline.
19732 - ~(org-agenda-skip-entry-if 'scheduled 'deadline)~ ::
19734      Skip current entry if it has a deadline, or if it is scheduled.
19736 - ~(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))~ ::
19738      Skip current entry if the TODO keyword is TODO or WAITING.
19740 - ~(org-agenda-skip-entry-if 'todo 'done)~ ::
19742      Skip current entry if the TODO keyword marks a DONE state.
19744 - ~(org-agenda-skip-entry-if 'timestamp)~ ::
19746      Skip current entry if it has any timestamp, may also be deadline
19747      or scheduled.
19749 - ~(org-agenda-skip-entry-if 'regexp "regular expression")~ ::
19751      Skip current entry if the regular expression matches in the
19752      entry.
19754 - ~(org-agenda-skip-entry-if 'notregexp "regular expression")~ ::
19756      Skip current entry unless the regular expression matches.
19758 - ~(org-agenda-skip-subtree-if 'regexp "regular expression")~ ::
19760      Same as above, but check and skip the entire subtree.
19762 The following is an example of a search for =waiting= without the
19763 special function:
19765 #+begin_src emacs-lisp
19766 (org-add-agenda-custom-command
19767  '("b" todo "PROJECT"
19768    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
19769                                 'regexp ":waiting:"))
19770     (org-agenda-overriding-header "Projects waiting for something: "))))
19771 #+end_src
19773 ** Speeding Up Your Agendas
19774 :PROPERTIES:
19775 :DESCRIPTION: Tips on how to speed up your agendas.
19776 :END:
19777 #+cindex: agenda views, optimization
19779 Some agenda commands slow down when the Org files grow in size or
19780 number.  Here are tips to speed up:
19782 - Reduce the number of Org agenda files to avoid slowdowns due to hard drive
19783   accesses.
19785 - Reduce the number of DONE and archived headlines so agenda
19786   operations that skip over these can finish faster.
19788 - Do not dim blocked tasks:
19789   #+vindex: org-agenda-dim-blocked-tasks
19791   #+begin_src emacs-lisp
19792   (setq org-agenda-dim-blocked-tasks nil)
19793   #+end_src
19795 - Stop preparing agenda buffers on startup:
19796   #+vindex: org-startup-folded
19797   #+vindex: org-agenda-inhibit-startup
19799   #+begin_src emacs-lisp
19800   (setq org-agenda-inhibit-startup nil)
19801   #+end_src
19803 - Disable tag inheritance for agendas:
19804   #+vindex: org-agenda-show-inherited-tags
19805   #+vindex: org-agenda-use-tag-inheritance
19807   #+begin_src emacs-lisp
19808   (setq org-agenda-use-tag-inheritance nil)
19809   #+end_src
19811 These options can be applied to selected agenda views.  For more
19812 details about generation of agenda views, see the docstrings for the
19813 relevant variables, and this [[https://orgmode.org/worg/agenda-optimization.html][dedicated Worg page]] for agenda
19814 optimization.
19816 ** Extracting Agenda Information
19817 :PROPERTIES:
19818 :DESCRIPTION: Post-processing agenda information.
19819 :END:
19820 #+cindex: agenda, pipe
19821 #+cindex: scripts, for agenda processing
19823 Org provides commands to access agendas through Emacs batch mode.
19824 Through this command-line interface, agendas are automated for further
19825 processing or printing.
19827 #+vindex: org-agenda-custom-commands
19828 #+findex: org-batch-agenda
19829 ~org-batch-agenda~ creates an agenda view in ASCII and outputs to
19830 standard output.  This command takes one string parameter.  When
19831 string consists of a single character, Org uses it as a key to
19832 ~org-agenda-custom-commands~.  These are the same ones available
19833 through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
19835 This example command line directly prints the TODO list to the printer:
19837 : emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
19839 When the string parameter length is two or more characters, Org
19840 matches it with tags/TODO strings.  For example, this example command
19841 line prints items tagged with =shop=, but excludes items tagged with
19842 =NewYork=:
19844 #+begin_example
19845 emacs -batch -l ~/.emacs                                      \
19846       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
19847 #+end_example
19849 #+texinfo: @noindent
19850 An example showing on-the-fly parameter modifications:
19852 #+begin_example
19853 emacs -batch -l ~/.emacs                                      \
19854    -eval '(org-batch-agenda "a"                               \
19855            org-agenda-span (quote month)                      \
19856            org-agenda-include-diary nil                       \
19857            org-agenda-files (quote ("~/org/project.org")))'   \
19858    | lpr
19859 #+end_example
19861 #+texinfo: @noindent
19862 which produces an agenda for the next 30 days from just the
19863 =~/org/projects.org= file.
19865 #+findex: org-batch-agenda-csv
19866 For structured processing of agenda output, use ~org-batch-agenda-csv~
19867 with the following fields:
19869 - category :: The category of the item
19870 - head :: The headline, without TODO keyword, TAGS and PRIORITY
19871 - type :: The type of the agenda entry, can be
19873      | ~todo~              | selected in TODO match              |
19874      | ~tagsmatch~         | selected in tags match              |
19875      | ~diary~             | imported from diary                 |
19876      | ~deadline~          | a deadline                          |
19877      | ~scheduled~         | scheduled                           |
19878      | ~timestamp~         | appointment, selected by timestamp  |
19879      | ~closed~            | entry was closed on date            |
19880      | ~upcoming-deadline~ | warning about nearing deadline      |
19881      | ~past-scheduled~    | forwarded scheduled item            |
19882      | ~block~             | entry has date block including date |
19884 - todo :: The TODO keyword, if any
19885 - tags :: All tags including inherited ones, separated by colons
19886 - date :: The relevant date, like =2007-2-14=
19887 - time :: The time, like =15:00-16:50=
19888 - extra :: String with extra planning info
19889 - priority-l :: The priority letter if any was given
19890 - priority-n :: The computed numerical priority
19892 #+texinfo: @noindent
19893 If the selection of the agenda item was based on a timestamp,
19894 including those items with =DEADLINE= and =SCHEDULED= keywords, then
19895 Org includes date and time in the output.
19897 If the selection of the agenda item was based on a timestamp  (or
19898 deadline/scheduled), then Org includes date and time in the output.
19900 Here is an example of a post-processing script in Perl.  It takes the
19901 CSV output from Emacs and prints with a checkbox:
19903 #+begin_src perl
19904 #!/usr/bin/perl
19906 # define the Emacs command to run
19907 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
19909 # run it and capture the output
19910 $agenda = qx{$cmd 2>/dev/null};
19912 # loop over all lines
19913 foreach $line (split(/\n/,$agenda)) {
19914     # get the individual values
19915     ($category,$head,$type,$todo,$tags,$date,$time,$extra,
19916      $priority_l,$priority_n) = split(/,/,$line);
19917     # process and print
19918     print "[ ] $head\n";
19920 #+end_src
19922 ** Using the Property API
19923 :PROPERTIES:
19924 :DESCRIPTION: Writing programs that use entry properties.
19925 :END:
19926 #+cindex: API, for properties
19927 #+cindex: properties, API
19929 Here is a description of the functions that can be used to work with
19930 properties.
19932 #+attr_texinfo: :options org-entry-properties &optional pom which
19933 #+begin_defun
19934 Get all properties of the entry at point-or-marker {{{var(POM)}}}.
19935 This includes the TODO keyword, the tags, time strings for deadline,
19936 scheduled, and clocking, and any additional properties defined in the
19937 entry.  The return value is an alist.  Keys may occur multiple times
19938 if the property key was used several times.  {{{var(POM)}}} may also
19939 be ~nil~, in which case the current entry is used.  If
19940 {{{var(WHICH)}}} is ~nil~ or ~all~, get all properties.  If
19941 {{{var(WHICH)}}} is ~special~ or ~standard~, only get that subclass.
19942 #+end_defun
19944 #+vindex: org-use-property-inheritance
19945 #+findex: org-insert-property-drawer
19946 #+attr_texinfo: :options org-entry-get pom property &optional inherit
19947 #+begin_defun
19948 Get value of {{{var(PROPERTY)}}} for entry at point-or-marker
19949 {{{var(POM)}}}.  By default, this only looks at properties defined
19950 locally in the entry.  If {{{var(INHERIT)}}} is non-~nil~ and the
19951 entry does not have the property, then also check higher levels of the
19952 hierarchy.  If {{{var(INHERIT)}}} is the symbol ~selective~, use
19953 inheritance if and only if the setting of
19954 ~org-use-property-inheritance~ selects {{{var(PROPERTY)}}} for
19955 inheritance.
19956 #+end_defun
19958 #+attr_texinfo: :options org-entry-delete pom property
19959 #+begin_defun
19960 Delete the property {{{var(PROPERTY)}}} from entry at point-or-marker
19961 {{{var(POM)}}}.
19962 #+end_defun
19964 #+attr_texinfo: :options org-entry-put pom property value
19965 #+begin_defun
19966 Set {{{var(PROPERTY)}}} to {{{var(VALUES)}}} for entry at
19967 point-or-marker POM.
19968 #+end_defun
19970 #+attr_texinfo: :options org-buffer-property-keys &optional include-specials
19971 #+begin_defun
19972 Get all property keys in the current buffer.
19973 #+end_defun
19975 #+attr_texinfo: :options org-insert-property-drawer
19976 #+begin_defun
19977 Insert a property drawer for the current entry.  Also
19978 #+end_defun
19980 #+attr_texinfo: :options org-entry-put-multivalued-property pom property &rest values
19981 #+begin_defun
19982 Set {{{var(PROPERTY)}}} at point-or-marker {{{var(POM)}}} to
19983 {{{var(VALUES)}}}.  {{{var(VALUES)}}} should be a list of strings.
19984 They are concatenated, with spaces as separators.
19985 #+end_defun
19987 #+attr_texinfo: :options org-entry-get-multivalued-property pom property
19988 #+begin_defun
19989 Treat the value of the property {{{var(PROPERTY)}}} as
19990 a whitespace-separated list of values and return the values as a list
19991 of strings.
19992 #+end_defun
19994 #+attr_texinfo: :options org-entry-add-to-multivalued-property pom property value
19995 #+begin_defun
19996 Treat the value of the property {{{var(PROPERTY)}}} as
19997 a whitespace-separated list of values and make sure that
19998 {{{var(VALUE)}}} is in this list.
19999 #+end_defun
20001 #+attr_texinfo: :options org-entry-remove-from-multivalued-property pom property value
20002 #+begin_defun
20003 Treat the value of the property {{{var(PROPERTY)}}} as
20004 a whitespace-separated list of values and make sure that
20005 {{{var(VALUE)}}} is /not/ in this list.
20006 #+end_defun
20008 #+attr_texinfo: :options org-entry-member-in-multivalued-property pom property value
20009 #+begin_defun
20010 Treat the value of the property {{{var(PROPERTY)}}} as
20011 a whitespace-separated list of values and check if {{{var(VALUE)}}} is
20012 in this list.
20013 #+end_defun
20015 #+attr_texinfo: :options org-property-allowed-value-functions
20016 #+begin_defopt
20017 Hook for functions supplying allowed values for a specific property.
20018 The functions must take a single argument, the name of the property,
20019 and return a flat list of allowed values.  If =:ETC= is one of the
20020 values, use the values as completion help, but allow also other values
20021 to be entered.  The functions must return ~nil~ if they are not
20022 responsible for this property.
20023 #+end_defopt
20025 ** Using the Mapping API
20026 :PROPERTIES:
20027 :DESCRIPTION: Mapping over all or selected entries.
20028 :END:
20029 #+cindex: API, for mapping
20030 #+cindex: mapping entries, API
20032 Org has sophisticated mapping capabilities to find all entries
20033 satisfying certain criteria.  Internally, this functionality is used
20034 to produce agenda views, but there is also an API that can be used to
20035 execute arbitrary functions for each or selected entries.  The main
20036 entry point for this API is:
20038 #+attr_texinfo: :options org-map-entries func &optional match scope &rest skip
20039 #+begin_defun
20040 Call {{{(var(FUNC))}}} at each headline selected by {{{var(MATCH)}}}
20041 in {{{var(SCOPE)}}}.
20043 {{{var(FUNC)}}} is a function or a Lisp form.  With the cursor
20044 positioned at the beginning of the headline, call the function without
20045 arguments.  Org returns an alist of return values of calls to the
20046 function.
20048 To avoid preserving point, Org wraps the call to {{{var(FUNC)}}} in
20049 save-excursion form.  After evaluation, Org moves the cursor to the
20050 end of the line that was just processed.  Search continues from that
20051 point forward.  This may not always work as expected under some
20052 conditions, such as if the current sub-tree was removed by a previous
20053 archiving operation.  In such rare circumstances, Org skips the next
20054 entry entirely when it should not.  To stop Org from such skips, make
20055 {{{var(FUNC)}}} set the variable ~org-map-continue-from~ to a specific
20056 buffer position.
20058 {{{var(MATCH)}}} is a tags/property/TODO match.  Org iterates only
20059 matched headlines.  Org iterates over all headlines when
20060 {{{var(MATCH)}}} is ~nil~ or ~t~.
20062 {{{var(SCOPE)}}} determines the scope of this command.  It can be any
20065 - ~nil~ ::
20067      The current buffer, respecting the restriction, if any.
20069 - ~tree~ ::
20071      The subtree started with the entry at point.
20073 - ~region~ ::
20075      The entries within the active region, if any.
20077 - ~file~ ::
20079      The current buffer, without restriction.
20081 - ~file-with-archives~ ::
20083      The current buffer, and any archives associated with it.
20085 - ~agenda~ ::
20087      All agenda files.
20089 - ~agenda-with-archives~ ::
20091      All agenda files with any archive files associated with them.
20093 - ~(file1 file2 ...)~ ::
20095      If this is a list, all files in the list are scanned.
20097 #+texinfo: @noindent
20098 The remaining arguments are treated as settings for the scanner's
20099 skipping facilities.  Valid arguments are:
20101 - ~archive~ ::
20103      Skip trees with the archive tag.
20105 - ~comment~ ::
20107      Skip trees with the COMMENT keyword.
20109 - function or Lisp form ::
20111      #+vindex: org-agenda-skip-function
20112      Used as value for ~org-agenda-skip-function~, so whenever the
20113      function returns ~t~, {{{var(FUNC)}}} is called for that entry
20114      and search continues from the point where the function leaves it.
20115 #+end_defun
20117 The mapping routine can call any arbitrary function, even functions
20118 that change meta data or query the property API (see [[*Using the
20119 Property API]]).  Here are some handy functions:
20121 #+attr_texinfo: :options org-todo &optional arg
20122 #+begin_defun
20123 Change the TODO state of the entry.  See the docstring of the
20124 functions for the many possible values for the argument
20125 {{{var(ARG)}}}.
20126 #+end_defun
20128 #+attr_texinfo: :options org-priority &optional action
20129 #+begin_defun
20130 Change the priority of the entry.  See the docstring of this function
20131 for the possible values for {{{var(ACTION)}}}.
20132 #+end_defun
20134 #+attr_texinfo: :options org-toggle-tag tag &optional onoff
20135 #+begin_defun
20136 Toggle the tag {{{var(TAG)}}} in the current entry.  Setting
20137 {{{var(ONOFF)}}} to either ~on~ or ~off~ does not toggle tag, but
20138 ensure that it is either on or off.
20139 #+end_defun
20141 #+attr_texinfo: :options org-promote
20142 #+begin_defun
20143 Promote the current entry.
20144 #+end_defun
20146 #+attr_texinfo: :options org-demote
20147 #+begin_defun
20148 Demote the current entry.
20149 #+end_defun
20151 This example turns all entries tagged with =TOMORROW= into TODO
20152 entries with keyword =UPCOMING=.  Org ignores entries in comment trees
20153 and archive trees.
20155 #+begin_src emacs-lisp
20156 (org-map-entries '(org-todo "UPCOMING")
20157                  "+TOMORROW" 'file 'archive 'comment)
20158 #+end_src
20160 The following example counts the number of entries with TODO keyword
20161 =WAITING=, in all agenda files.
20163 #+begin_src emacs-lisp
20164 (length (org-map-entries t "/+WAITING" 'agenda))
20165 #+end_src
20167 * MobileOrg
20168 :PROPERTIES:
20169 :DESCRIPTION: Viewing and capture on a mobile device.
20170 :APPENDIX: Appendix
20171 :END:
20172 #+cindex: iPhone
20173 #+cindex: smartphone
20174 #+cindex: android
20175 #+cindex: MobileOrg
20177 MobileOrg is a companion mobile app that runs on iOS and Android
20178 devices.  MobileOrg enables offline-views and capture support for an
20179 Org mode system that is rooted on a "real" computer.  MobileOrg can
20180 record changes to existing entries.
20182 The [[https://github.com/MobileOrg/][iOS implementation]] for the /iPhone/iPod Touch/iPad/ series of
20183 devices, was started by Richard Moreland and is now in the hands of
20184 Sean Escriva.  Android users should check out [[http://wiki.github.com/matburt/mobileorg-android/][MobileOrg Android]] by
20185 Matt Jones.  Though the two implementations are not identical, they
20186 offer similar features.
20188 This appendix describes Org's support for agenda view formats
20189 compatible with MobileOrg.  It also describes synchronizing changes,
20190 such as to notes, between MobileOrg and the computer.
20192 To change tags and TODO states in MobileOrg, first customize the
20193 variables ~org-todo-keywords~ and ~org-tag-alist~.  These should cover
20194 all the important tags and TODO keywords, even if Org files use only
20195 some of them.  Though MobileOrg has in-buffer settings, it understands
20196 TODO states /sets/ (see [[*Setting up keywords for individual files]]) and
20197 /mutually exclusive/ tags (see [[*Setting Tags]]) only for those set in
20198 these variables.
20200 ** Setting Up the Staging Area
20201 :PROPERTIES:
20202 :DESCRIPTION: For the mobile device.
20203 :END:
20205 MobileOrg needs access to a file directory on a server to interact
20206 with Emacs.  With a public server, consider encrypting the files.
20207 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
20208 requires =openssl= installed on the local computer.  To turn on
20209 encryption, set the same password in MobileOrg and in Emacs.  Set the
20210 password in the variable ~org-mobile-use-encryption~[fn:142].  Note
20211 that even after MobileOrg encrypts the file contents, the file name
20212 remains visible on the file systems of the local computer, the server,
20213 and the mobile device.
20215 For a server to host files, consider options like [[http://dropbox.com][Dropbox.com]]
20216 account[fn:143].  On first connection, MobileOrg creates a directory
20217 =MobileOrg= on Dropbox.  Pass its location to Emacs through an
20218 initialisation file variable as follows:
20220 #+begin_src emacs-lisp
20221 (setq org-mobile-directory "~/Dropbox/MobileOrg")
20222 #+end_src
20224 Org copies files to the above directory for MobileOrg.  Org also uses
20225 the same directory for sharing notes between Org and MobileOrg.
20227 ** Pushing to MobileOrg
20228 :PROPERTIES:
20229 :DESCRIPTION: Uploading Org files and agendas.
20230 :END:
20232 #+vindex: org-mobile-files
20233 #+vindex: org-directory
20234 Org pushes files listed in ~org-mobile-files~ to
20235 ~org-mobile-directory~.  Files include agenda files (as listed in
20236 ~org-agenda-files~).  Customize ~org-mobile-files~ to add other files.
20237 File names are staged with paths relative to ~org-directory~, so all
20238 files should be inside this directory[fn:144].
20240 Push creates a special Org file =agendas.org= with custom agenda views
20241 defined by the user[fn:145].
20243 Finally, Org writes the file =index.org=, containing links to other
20244 files.  MobileOrg reads this file first from the server to determine
20245 what other files to download for agendas.  For faster downloads,
20246 MobileOrg only reads files whose checksums[fn:146] have changed.
20248 ** Pulling from MobileOrg
20249 :PROPERTIES:
20250 :DESCRIPTION: Integrating captured and flagged items.
20251 :END:
20253 When MobileOrg synchronizes with the server, it pulls the Org files
20254 for viewing.  It then appends to the file =mobileorg.org= on the
20255 server the captured entries, pointers to flagged and changed entries.
20256 Org integrates its data in an inbox file format.
20259    #+vindex: org-mobile-inbox-for-pull
20260    Org moves all entries found in =mobileorg.org=[fn:147] and appends
20261    them to the file pointed to by the variable
20262    ~org-mobile-inbox-for-pull~.  Each captured entry and each editing
20263    event is a top-level entry in the inbox file.
20265 2. After moving the entries, Org attempts changes to MobileOrg.  Some
20266    changes are applied directly and without user interaction.
20267    Examples include changes to tags, TODO state, headline and body
20268    text.  Entries for further action are tagged as =FLAGGED=.  Org
20269    marks entries with problems with an error message in the inbox.
20270    They have to be resolved manually.
20272 3. Org generates an agenda view for flagged entries for user
20273    intervention to clean up.  For notes stored in flagged entries,
20274    MobileOrg displays them in the echo area when the cursor is on the
20275    corresponding agenda item.
20277    - {{{kbd(?)}}} ::
20278         #+kindex: ?
20280         Pressing {{{kbd(?)}}} displays the entire flagged note in
20281         another window.  Org also pushes it to the kill ring.  To
20282         store flagged note as a normal note, use {{{kbd(? z C-y C-c
20283         C-c)}}}.  Pressing{{{kbd(?)}}} twice does these things: first
20284         it removes the =FLAGGED= tag; second, it removes the flagged
20285         note from the property drawer; third, it signals that manual
20286         editing of the flagged entry is now finished.
20288 #+kindex: ? @r{(Agenda dispatcher)}
20289 From the agenda dispatcher, {{{kbd(?)}}} returns to the view to finish
20290 processing flagged entries.  Note that these entries may not be the
20291 most recent since MobileOrg searches files that were last pulled.  To
20292 get an updated agenda view with changes since the last pull, pull
20293 again.
20295 * History and Acknowledgments
20296 :PROPERTIES:
20297 :DESCRIPTION: How Org came into being.
20298 :APPENDIX: t
20299 :END:
20301 ** From Carsten
20302 :PROPERTIES:
20303 :UNNUMBERED: notoc
20304 :END:
20306 Org was born in 2003, out of frustration over the user interface of
20307 the Emacs Outline mode.  I was trying to organize my notes and
20308 projects, and using Emacs seemed to be the natural way to go.
20309 However, having to remember eleven different commands with two or
20310 three keys per command, only to hide and show parts of the outline
20311 tree, that seemed entirely unacceptable to me.  Also, when using
20312 outlines to take notes, I constantly wanted to restructure the tree,
20313 organizing it parallel to my thoughts and plans.  /Visibility cycling/
20314 and /structure editing/ were originally implemented in the package
20315 =outline-magic.el=, but quickly moved to the more general =org.el=.
20316 As this environment became comfortable for project planning, the next
20317 step was adding /TODO entries/, basic /timestamps/, and /table
20318 support/.  These areas highlighted the two main goals that Org still
20319 has today: to be a new, outline-based, plain text mode with innovative
20320 and intuitive editing features, and to incorporate project planning
20321 functionality directly into a notes file.
20323 Since the first release, literally thousands of emails to me or to the
20324 [[mailto:emacs-orgmode@gnu.org][mailing list]] have provided a constant stream of bug reports, feedback,
20325 new ideas, and sometimes patches and add-on code.  Many thanks to
20326 everyone who has helped to improve this package.  I am trying to keep
20327 here a list of the people who had significant influence in shaping one
20328 or more aspects of Org.  The list may not be complete, if I have
20329 forgotten someone, please accept my apologies and let me know.
20331 Before I get to this list, a few special mentions are in order:
20333 - Bastien Guerry ::
20335      Bastien has written a large number of extensions to Org (most of
20336      them integrated into the core by now), including the LaTeX
20337      exporter and the plain list parser.  His support during the early
20338      days was central to the success of this project.  Bastien also
20339      invented Worg, helped establishing the Web presence of Org, and
20340      sponsored hosting costs for the orgmode.org website.  Bastien
20341      stepped in as maintainer of Org between 2011 and 2013, at a time
20342      when I desperately needed a break.
20344 - Eric Schulte and Dan Davison ::
20346      Eric and Dan are jointly responsible for the Org Babel system,
20347      which turns Org into a multi-language environment for evaluating
20348      code and doing literate programming and reproducible research.
20349      This has become one of Org's killer features that define what Org
20350      is today.
20352 - John Wiegley ::
20354      John has contributed a number of great ideas and patches directly
20355      to Org, including the attachment system (=org-attach.el=),
20356      integration with Apple Mail (=org-mac-message.el=), hierarchical
20357      dependencies of TODO items, habit tracking (=org-habits.el=), and
20358      encryption (=org-crypt.el=).  Also, the capture system is really
20359      an extended copy of his great =remember.el=.
20361 - Sebastian Rose ::
20363      Without Sebastian, the HTML/XHTML publishing of Org would be the
20364      pitiful work of an ignorant amateur.  Sebastian has pushed this
20365      part of Org onto a much higher level.  He also wrote
20366      =org-info.js=, a Java script for displaying webpages derived from
20367      Org using an Info-like or a folding interface with single-key
20368      navigation.
20370 #+texinfo: @noindent
20371 See below for the full list of contributions! Again, please let me
20372 know what I am missing here!
20374 ** From Bastien
20375 :PROPERTIES:
20376 :UNNUMBERED: notoc
20377 :END:
20379 I (Bastien) have been maintaining Org between 2011 and 2013.  This
20380 appendix would not be complete without adding a few more
20381 acknowledgments and thanks.
20383 I am first grateful to Carsten for his trust while handing me over the
20384 maintainership of Org.  His unremitting support is what really helped
20385 me getting more confident over time, with both the community and the
20386 code.
20388 When I took over maintainership, I knew I would have to make Org more
20389 collaborative than ever, as I would have to rely on people that are
20390 more knowledgeable than I am on many parts of the code.  Here is
20391 a list of the persons I could rely on, they should really be
20392 considered co-maintainers, either of the code or the community:
20394 - Eric Schulte ::
20396      Eric is maintaining the Babel parts of Org.  His reactivity here
20397      kept me away from worrying about possible bugs here and let me
20398      focus on other parts.
20400 - Nicolas Goaziou ::
20402      Nicolas is maintaining the consistency of the deepest parts of
20403      Org.  His work on =org-element.el= and =ox.el= has been
20404      outstanding, and it opened the doors for many new ideas and
20405      features.  He rewrote many of the old exporters to use the new
20406      export engine, and helped with documenting this major change.
20407      More importantly (if that's possible), he has been more than
20408      reliable during all the work done for Org 8.0, and always very
20409      reactive on the mailing list.
20411 - Achim Gratz ::
20413      Achim rewrote the building process of Org, turning some /ad hoc/
20414      tools into a flexible and conceptually clean process.  He
20415      patiently coped with the many hiccups that such a change can
20416      create for users.
20418 - Nick Dokos ::
20420      The Org mode mailing list would not be such a nice place without
20421      Nick, who patiently helped users so many times.  It is impossible
20422      to overestimate such a great help, and the list would not be so
20423      active without him.
20425 I received support from so many users that it is clearly impossible to
20426 be fair when shortlisting a few of them, but Org's history would not
20427 be complete if the ones above were not mentioned in this manual.
20429 ** List of Contributions
20430 :PROPERTIES:
20431 :UNNUMBERED: notoc
20432 :END:
20434 - Russel Adams came up with the idea for drawers.
20436 - Thomas Baumann wrote =org-bbdb.el= and =org-mhe.el=.
20438 - Christophe Bataillon created the great unicorn logo that we use on
20439   the Org mode website.
20441 - Alex Bochannek provided a patch for rounding timestamps.
20443 - Jan Böcker wrote =org-docview.el=.
20445 - Brad Bozarth showed how to pull RSS feed data into Org files.
20447 - Tom Breton wrote =org-choose.el=.
20449 - Charles Cave's suggestion sparked the implementation of templates
20450   for Remember, which are now templates for capture.
20452 - Pavel Chalmoviansky influenced the agenda treatment of items with
20453   specified time.
20455 - Gregory Chernov patched support for Lisp forms into table
20456   calculations and improved XEmacs compatibility, in particular by
20457   porting =nouline.el= to XEmacs.
20459 - Sacha Chua suggested copying some linking code from Planner.
20461 - Baoqiu Cui contributed the DocBook exporter.
20463 - Eddward DeVilla proposed and tested checkbox statistics.  He also
20464   came up with the idea of properties, and that there should be an API
20465   for them.
20467 - Nick Dokos tracked down several nasty bugs.
20469 - Kees Dullemond used to edit projects lists directly in HTML and so
20470   inspired some of the early development, including HTML export.  He
20471   also asked for a way to narrow wide table columns.
20473 - Thomas S. Dye contributed documentation on Worg and helped
20474   integrating the Org Babel documentation into the manual.
20476 - Christian Egli converted the documentation into Texinfo format,
20477   inspired the agenda, patched CSS formatting into the HTML exporter,
20478   and wrote =org-taskjuggler.el=.
20480 - David Emery provided a patch for custom CSS support in exported HTML
20481   agendas.
20483 - Nic Ferrier contributed mailcap and XOXO support.
20485 - Miguel A.  Figueroa-Villanueva implemented hierarchical checkboxes.
20487 - John Foerch figured out how to make incremental search show context
20488   around a match in a hidden outline tree.
20490 - Raimar Finken wrote =org-git-line.el=.
20492 - Mikael Fornius works as a mailing list moderator.
20494 - Austin Frank works as a mailing list moderator.
20496 - Eric Fraga drove the development of Beamer export with ideas and
20497   testing.
20499 - Barry Gidden did proofreading the manual in preparation for the book
20500   publication through Network Theory Ltd.
20502 - Niels Giesen had the idea to automatically archive DONE trees.
20504 - Nicolas Goaziou rewrote much of the plain list code.
20506 - Kai Grossjohann pointed out key-binding conflicts with other
20507   packages.
20509 - Brian Gough of Network Theory Ltd publishes the Org mode manual as
20510   a book.
20512 - Bernt Hansen has driven much of the support for auto-repeating
20513   tasks, task state change logging, and the clocktable.  His clear
20514   explanations have been critical when we started to adopt the Git
20515   version control system.
20517 - Manuel Hermenegildo has contributed various ideas, small fixes and
20518   patches.
20520 - Phil Jackson wrote =org-irc.el=.
20522 - Scott Jaderholm proposed footnotes, control over whitespace between
20523   folded entries, and column view for properties.
20525 - Matt Jones wrote MobileOrg Android.
20527 - Tokuya Kameshima wrote =org-wl.el= and =org-mew.el=.
20529 - Shidai Liu ("Leo") asked for embedded LaTeX and tested it.  He also
20530   provided frequent feedback and some patches.
20532 - Matt Lundin has proposed last-row references for table formulas and
20533   named invisible anchors.  He has also worked a lot on the FAQ.
20535 - David Maus wrote =org-atom.el=, maintains the issues file for Org,
20536   and is a prolific contributor on the mailing list with competent
20537   replies, small fixes and patches.
20539 - Jason F. McBrayer suggested agenda export to CSV format.
20541 - Max Mikhanosha came up with the idea of refiling.
20543 - Dmitri Minaev sent a patch to set priority limits on a per-file
20544   basis.
20546 - Stefan Monnier provided a patch to keep the Emacs Lisp compiler
20547   happy.
20549 - Richard Moreland wrote MobileOrg for the iPhone.
20551 - Rick Moynihan proposed allowing multiple TODO sequences in a file
20552   and being able to quickly restrict the agenda to a subtree.
20554 - Todd Neal provided patches for links to Info files and Elisp forms.
20556 - Greg Newman refreshed the unicorn logo into its current form.
20558 - Tim O'Callaghan suggested in-file links, search options for general
20559   file links, and tags.
20561 - Osamu Okano wrote =orgcard2ref.pl=, a Perl program to create a text
20562   version of the reference card.
20564 - Takeshi Okano translated the manual and David O'Toole's tutorial
20565   into Japanese.
20567 - Oliver Oppitz suggested multi-state TODO items.
20569 - Scott Otterson sparked the introduction of descriptive text for
20570   links, among other things.
20572 - Pete Phillips helped during the development of the TAGS feature,
20573   and provided frequent feedback.
20575 - Martin Pohlack provided the code snippet to bundle character
20576   insertion into bundles of 20 for undo.
20578 - T.V. Raman reported bugs and suggested improvements.
20580 - Matthias Rempe (Oelde) provided ideas, Windows support, and quality
20581   control.
20583 - Paul Rivier provided the basic implementation of named footnotes.
20584   He also acted as mailing list moderator for some time.
20586 - Kevin Rogers contributed code to access VM files on remote hosts.
20588 - Frank Ruell solved the mystery of the =keymapp nil= bug, a conflict
20589   with =allout.el=.
20591 - Jason Riedy generalized the send-receive mechanism for Orgtbl
20592   tables with extensive patches.
20594 - Philip Rooke created the Org reference card, provided lots of
20595   feedback, developed and applied standards to the Org documentation.
20597 - Christian Schlauer proposed angular brackets around links, among
20598   other things.
20600 - Paul Sexton wrote =org-ctags.el=.
20602 - Tom Shannon's =organizer-mode.el= inspired linking to VM/BBDB/Gnus.
20604 - Ilya Shlyakhter proposed the Archive Sibling, line numbering in
20605   literal examples, and remote highlighting for referenced code lines.
20607 - Stathis Sideris wrote the =ditaa.jar= ASCII to PNG converter that is
20608   now packaged into Org's =contrib/= directory.
20610 - Daniel Sinder came up with the idea of internal archiving by locking
20611   subtrees.
20613 - Dale Smith proposed link abbreviations.
20615 - James TD Smith has contributed a large number of patches for
20616   useful tweaks and features.
20618 - Adam Spiers asked for global linking commands, inspired the link
20619   extension system, added support for Mairix, and proposed the mapping
20620   API.
20622 - Ulf Stegemann created the table to translate special symbols to
20623   HTML, LaTeX, UTF-8, Latin-1 and ASCII.
20625 - Andy Stewart contributed code to =org-w3m.el=, to copy
20626   HTML content with links transformation to Org syntax.
20628 - David O'Toole wrote =org-publish.el= and drafted the
20629   manual chapter about publishing.
20631 - Jambunathan K. contributed the ODT exporter.
20633 - Sebastien Vauban reported many issues with LaTeX and Beamer export
20634   and enabled source code highlighting in Gnus.
20636 - Stefan Vollmar organized a video-recorded talk at the
20637   Max-Planck-Institute for Neurology.  He also inspired the creation
20638   of a concept index for HTML export.
20640 - Jürgen Vollmer contributed code generating the table of contents in
20641   HTML output.
20643 - Samuel Wales has provided important feedback and bug reports.
20645 - Chris Wallace provided a patch implementing the =QUOTE= block.
20647 - David Wainberg suggested archiving, and improvements to the
20648   linking system.
20650 - Carsten Wimmer suggested some changes and helped fix a bug in
20651   linking to Gnus.
20653 - Roland Winkler requested additional key bindings to make Org work on
20654   a TTY.
20656 - Piotr Zielinski wrote =org-mouse.el=, proposed agenda
20657   blocks and contributed various ideas and code snippets.
20659 - Marco Wahl wrote =org-eww.el=.
20661 * GNU Free Documentation License
20662 :PROPERTIES:
20663 :APPENDIX: t
20664 :DESCRIPTION: The license for this documentation.
20665 :END:
20667 #+texinfo: @include doclicense.texi
20669 * Main Index
20670 :PROPERTIES:
20671 :INDEX:    cp
20672 :DESCRIPTION: An index of Org's concepts and features.
20673 :END:
20675 * Key Index
20676 :PROPERTIES:
20677 :DESCRIPTION: Key bindings and where they are described.
20678 :INDEX:    ky
20679 :END:
20681 * Command and Function Index
20682 :PROPERTIES:
20683 :DESCRIPTION: Command names and some internal functions.
20684 :INDEX:    fn
20685 :END:
20687 * Variable Index
20688 :PROPERTIES:
20689 :DESCRIPTION: Variables mentioned in the manual.
20690 :INDEX:    vr
20691 :END:
20693 This is not a complete index of variables and faces, only the ones
20694 that are mentioned in the manual.  For a more complete list, use
20695 {{{kbd(M-x org-customize)}}} and then click yourself through the tree.
20697 * Copying
20698 :PROPERTIES:
20699 :copying:  t
20700 :END:
20702 This manual is for Org version {{{version}}}.
20704 Copyright \copy 2004--2018  Free Software Foundation, Inc.
20706 #+begin_quote
20707 Permission is granted to copy, distribute and/or modify this document
20708 under the terms of the GNU Free Documentation License, Version 1.3 or
20709 any later version published by the Free Software Foundation; with no
20710 Invariant Sections, with the Front-Cover Texts being "A GNU Manual,"
20711 and with the Back-Cover Texts as in (a) below.  A copy of the license
20712 is included in the section entitled "GNU Free Documentation License."
20714 (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
20715 modify this GNU manual."
20716 #+end_quote
20718 * Export Setup                                                          :noexport:
20720 #+subtitle:  Release {{{version}}}
20721 #+author:    by Carsten Dominik
20722 #+subauthor: with contributions by Bastien Guerry, Nicolas Goaziou, Eric Schulte, Jambunathan K, Dan Davison, Thomas Dye, David O'Toole, and Philip Rooke.
20723 #+date:      {{{modification-time}}}
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" "Alt" "Cmd" "Super" "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-mode-line-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 macOS, 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] Org used to offer four different targets for date/week tree
21067 capture.  Now, Org automatically translates these to use
21068 ~file+olp+datetree~, applying the ~:time-prompt~ and ~:tree-type~
21069 properties.  Please rewrite your date/week-tree targets using
21070 ~file+olp+datetree~ since the older targets are now deprecated.
21072 [fn:81] A date tree is an outline structure with years on the highest
21073 level, months or ISO weeks as sublevels and then dates on the lowest
21074 level.  Tags are allowed in the tree structure.
21076 [fn:82] If you need one of these sequences literally, escape the =%=
21077 with a backslash.
21079 [fn:83] If you define your own link types (see [[*Adding Hyperlink
21080 Types]]), any property you store with ~org-store-link-props~ can be
21081 accessed in capture templates in a similar way.
21083 [fn:84] This is always the other, not the user.  See the variable
21084 ~org-from-is-user-regexp~.
21086 [fn:85] If you move entries or Org files from one directory to
21087 another, you may want to configure ~org-attach-directory~ to contain
21088 an absolute path.
21090 [fn:86] Note the corresponding =STARTUP= options =logrefile=,
21091 =lognoterefile=, and =nologrefile=.
21093 [fn:87] If the value of that variable is not a list, but a single file
21094 name, then the list of agenda files in maintained in that external
21095 file.
21097 [fn:88] When using the dispatcher, pressing {{{kbd(<)}}} before
21098 selecting a command actually limits the command to the current file,
21099 and ignores ~org-agenda-files~ until the next dispatcher command.
21101 [fn:89] For backward compatibility, you can also press {{{kbd(1)}}} to
21102 restrict to the current buffer.
21104 [fn:90] For backward compatibility, you can also press {{{kbd(0)}}} to
21105 restrict to the current region/subtree.
21107 [fn:91] For backward compatibility, the universal prefix argument
21108 {{{kbd(C-u)}}} causes all TODO entries to be listed before the agenda.
21109 This feature is deprecated, use the dedicated TODO list, or a block
21110 agenda instead (see [[*Block agenda]]).
21112 [fn:92] The variable ~org-anniversary~ used in the example is just
21113 like ~diary-anniversary~, but the argument order is always according
21114 to ISO and therefore independent of the value of
21115 ~calendar-date-style~.
21117 [fn:93] Custom commands can preset a filter by binding the variable
21118 ~org-agenda-tag-filter-preset~ as an option.  This filter is then
21119 applied to the view and persists as a basic filter through refreshes
21120 and more secondary filtering.  The filter is a global property of the
21121 entire agenda view---in a block agenda, you should only set this in
21122 the global options section, not in the section of an individual block.
21124 [fn:94] Only tags filtering is respected here, effort filtering is
21125 ignored.
21127 [fn:95] You can also create persistent custom functions through
21128 ~org-agenda-bulk-custom-functions~.
21130 [fn:96] This file is parsed for the agenda when
21131 ~org-agenda-include-diary~ is set.
21133 [fn:97] You can provide a description for a prefix key by inserting
21134 a cons cell with the prefix and the description.
21136 [fn:98] /Planned/ means here that these entries have some planning
21137 information attached to them, like a time-stamp, a scheduled or
21138 a deadline string.  See ~org-agenda-entry-types~ on how to set what
21139 planning information is taken into account.
21141 [fn:99] For HTML you need to install Hrvoje Niksic's =htmlize.el=
21142 from [[https://github.com/hniksic/emacs-htmlize][Hrvoje Niksic's repository]].
21144 [fn:100] To create PDF output, the Ghostscript ps2pdf utility must be
21145 installed on the system.  Selecting a PDF file also creates the
21146 postscript file.
21148 [fn:101] If you want to store standard views like the weekly agenda or
21149 the global TODO list as well, you need to define custom commands for
21150 them in order to be able to specify file names.
21152 [fn:102] Quoting depends on the system you use, please check the FAQ
21153 for examples.
21155 [fn:103] This works automatically for the HTML backend (it requires
21156 version 1.34 of the =htmlize.el= package, which you need to install).
21157 Fontified code chunks in LaTeX can be achieved using either the
21158 listings package or the [[https://github.com/gpoore/minted][minted]] package.  Refer to
21159 ~org-export-latex-listings~ for details.
21161 [fn:104] Source code in code blocks may also be evaluated either
21162 interactively or on export.  See [[*Working with Source Code]] for more
21163 information on evaluating code blocks.
21165 [fn:105] Adding =-k= to =-n -r= /keeps/ the labels in the source code
21166 while using line numbers for the links, which might be useful to
21167 explain those in an Org mode example code.
21169 [fn:106] Upon exit, lines starting with =*=, =,*=, =#+= and =,#+= get
21170 a comma prepended, to keep them from being interpreted by Org as
21171 outline nodes or special syntax.  These commas are stripped when
21172 editing with {{{kbd(C-c ')}}}, and also before export.
21174 [fn:107] You may select a different-mode with the variable
21175 ~org-edit-fixed-width-region-mode~.
21177 [fn:108] You can turn this on by default by setting the variable
21178 ~org-pretty-entities~, or on a per-file base with the =STARTUP= option
21179 =entitiespretty=.
21181 [fn:109] This behavior can be disabled with =-= export setting (see
21182 [[*Export Settings]]).
21184 [fn:110] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
21185 system.  Many of the features described here as "LaTeX" are really
21186 from TeX, but for simplicity I am blurring this distinction.
21188 [fn:111] When MathJax is used, only the environments recognized by
21189 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
21190 used to create images, any LaTeX environment is handled.
21192 [fn:112] These are respectively available at
21193 [[http://sourceforge.net/projects/dvipng/]], [[http://dvisvgm.bplaced.net/]]
21194 and from the ImageMagick suite.  Choose the converter by setting the
21195 variable ~org-preview-latex-default-process~ accordingly.
21197 [fn:113] Org mode has a method to test if the cursor is inside such
21198 a fragment, see the documentation of the function
21199 ~org-inside-LaTeX-fragment-p~.
21201 [fn:114] The variable ~org-export-date-timestamp-format~ defines how
21202 this timestamp are exported.
21204 [fn:115] At the moment, some export back-ends do not obey this
21205 specification.  For example, LaTeX export excludes every unnumbered
21206 headline from the table of contents.
21208 [fn:116] Since commas separate the arguments, commas within arguments
21209 have to be escaped with the backslash character.  So only those
21210 backslash characters before a comma need escaping with another
21211 backslash character.
21213 [fn:117] For a less drastic behavior, consider using a select tag (see
21214 [[*Export Settings]]) instead.
21216 [fn:118] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
21217 to make it visible.  The tag serves as a visual aid and has no
21218 semantic relevance.
21220 [fn:119] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
21221 [[http://www.mathjax.org][MathJax]].
21223 [fn:120] 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
21224 about extensions.
21226 [fn:121] If the classes on TODO keywords and tags lead to conflicts,
21227 use the variables ~org-html-todo-kwd-class-prefix~ and
21228 ~org-html-tag-class-prefix~ to make them unique.
21230 [fn:122] This does not allow setting different bibliography compilers
21231 for different files.  However, "smart" LaTeX compilation systems, such
21232 as latexmk, can select the correct bibliography compiler.
21234 [fn:123] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
21235 (OpenDocument) Version 1.2]].
21237 [fn:124] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
21239 [fn:125] See [[http://dlmf.nist.gov/LaTeXML/]].
21241 [fn:126] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
21243 [fn:127] See the =<table:table-template>= element of the
21244 OpenDocument-v1.2 specification.
21246 [fn:128] See the attributes =table:template-name=,
21247 =table:use-first-row-styles=, =table:use-last-row-styles=,
21248 =table:use-first-column-styles=, =table:use-last-column-styles=,
21249 =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
21250 of the =<table:table>= element in the OpenDocument-v1.2 specification.
21252 [fn:129] If the publishing directory is the same as the source
21253 directory, =file.org= is exported as =file.org.org=, so you probably
21254 do not want to do this.
21256 [fn:130] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
21257 to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
21259 [fn:131] Actually, the constructs =call_<name>()= and =src_<lang>{}=
21260 are not evaluated when they appear in a keyword line---i.e. lines
21261 starting with =#+KEYWORD:=, see [[*Summary of In-Buffer Settings]].
21263 [fn:132] For Noweb literate programming details, see
21264 http://www.cs.tufts.edu/~nr/noweb/.
21266 [fn:133] For more information, please refer to the commentary section
21267 in =org-tempo.el=.
21269 [fn:134] Note that ~org-indent-mode~ also sets the ~wrap-prefix~
21270 property, such that ~visual-line-mode~ (or purely setting ~word-wrap~)
21271 wraps long lines (including headlines) correctly indented.
21273 [fn:135] The ~org-indent-mode~ also sets the ~wrap-prefix~ correctly
21274 for indenting and wrapping long lines of headlines or text.  This
21275 minor mode handles ~visual-line-mode~ and directly applied settings
21276 through ~word-wrap~.
21278 [fn:136] Also see the variable ~org-adapt-indentation~.
21280 [fn:137] Because =LEVEL=2= has 3 stars, =LEVEL=3= has 4 stars, and so
21283 [fn:138] https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en
21285 [fn:139] If the =TBLFM= keyword contains an odd number of dollar
21286 characters, this may cause problems with Font Lock in LaTeX mode.  As
21287 shown in the example you can fix this by adding an extra line inside
21288 the =comment= environment that is used to balance the dollar
21289 expressions.  If you are using AUCTeX with the font-latex library,
21290 a much better solution is to add the =comment= environment to the
21291 variable ~LaTeX-verbatim-environments~.
21293 [fn:140] The ~agenda*~ view is the same as ~agenda~ except that it
21294 only considers /appointments/, i.e., scheduled and deadline items that
21295 have a time specification =[h]h:mm= in their time-stamps.
21297 [fn:141] Note that, for ~org-odd-levels-only~, a level number
21298 corresponds to order in the hierarchy, not to the number of stars.
21300 [fn:142] If Emacs is configured for safe storing of passwords, then
21301 configure the variable, ~org-mobile-encryption-password~; please read
21302 the docstring of that variable.
21304 [fn:143] An alternative is to use a WebDAV server.  MobileOrg
21305 documentation has details of WebDAV server configuration.  Additional
21306 help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
21308 [fn:144] Symbolic links in ~org-directory~ need to have the same name
21309 as their targets.
21311 [fn:145] While creating the agendas, Org mode forces ID properties on
21312 all referenced entries, so that these entries can be uniquely
21313 identified if MobileOrg flags them for further action.  To avoid
21314 setting properties configure the variable
21315 ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
21316 on outline paths, assuming they are unique.
21318 [fn:146] Checksums are stored automatically in the file
21319 =checksums.dat=.
21321 [fn:147] The file will be empty after this operation.