Merge branch 'maint'
[org-mode/org-tableheadings.git] / contrib / manual.org
blob2fd735159aa5aafc71e5d78a8fb8f58d2061306e
1 #+title: The Org Manual
3 #+texinfo: @insertcopying
5 * Introduction
6 :PROPERTIES:
7 :DESCRIPTION: Getting started.
8 :END:
9 #+cindex: introduction
11 ** Summary
12 :PROPERTIES:
13 :DESCRIPTION: Brief summary of what Org does.
14 :END:
15 #+cindex: summary
17 Org is a mode for keeping notes, maintaining TODO lists, and project
18 planning with a fast and effective plain-text system.  It also is an
19 authoring system with unique support for literate programming and
20 reproducible research.
22 Org is implemented on top of Outline mode, which makes it possible to
23 keep the content of large files well structured.  Visibility cycling
24 and structure editing help to work with the tree.  Tables are easily
25 created with a built-in table editor.  Plain text URL-like links
26 connect to websites, emails, Usenet messages, BBDB entries, and any
27 files related to the projects.
29 Org develops organizational tasks around notes files that contain
30 lists or information about projects as plain text.  Project planning
31 and task management makes use of metadata which is part of an outline
32 node.  Based on this data, specific entries can be extracted in
33 queries and create dynamic /agenda views/ that also integrate the
34 Emacs calendar and diary.  Org can be used to implement many different
35 project planning schemes, such as David Allen's GTD system.
37 Org files can serve as a single source authoring system with export to
38 many different formats such as HTML, LaTeX, Open Document, and
39 Markdown.  New export backends can be derived from existing ones, or
40 defined from scratch.
42 Org files can include source code blocks, which makes Org uniquely
43 suited for authoring technical documents with code examples. Org
44 source code blocks are fully functional; they can be evaluated in
45 place and their results can be captured in the file.  This makes it
46 possible to create a single file reproducible research compendium.
48 Org keeps simple things simple.  When first fired up, it should feel
49 like a straightforward, easy to use outliner.  Complexity is not
50 imposed, but a large amount of functionality is available when needed.
51 Org is a toolbox.  Many users actually run only a---very
52 personal---fraction of Org's capabilities, and know that there is more
53 whenever they need it.
55 All of this is achieved with strictly plain text files, the most
56 portable and future-proof file format.  Org runs in Emacs.  Emacs is
57 one of the most widely ported programs, so that Org mode is available
58 on every major platform.
60 #+cindex: FAQ
61 There is a website for Org which provides links to the newest version
62 of Org, as well as additional information, frequently asked questions
63 (FAQ), links to tutorials, etc.  This page is located at
64 [[https://orgmode.org]].
66 #+cindex: print edition
67 An earlier version (7.3) of this manual is available as a [[http://www.network-theory.co.uk/org/manual/][paperback
68 book from Network Theory Ltd.]].
70 ** Installation
71 :PROPERTIES:
72 :DESCRIPTION: Installing Org.
73 :END:
74 #+cindex: installation
76 Org is part of recent distributions of GNU Emacs, so you normally do
77 not need to install it.  If, for one reason or another, you want to
78 install Org on top of this pre-packaged version, there are three ways
79 to do it:
81 - By using Emacs package system.
82 - By downloading Org as an archive.
83 - By using Org's git repository.
85 We *strongly recommend* to stick to a single installation method.
87 *** Using Emacs packaging system
88 :PROPERTIES:
89 :UNNUMBERED: notoc
90 :END:
92 Recent Emacs distributions include a packaging system which lets you
93 install Elisp libraries.  You can install Org with {{{kbd(M-x
94 package-install RET org)}}}.
96 #+texinfo: @noindent
97 *Important*: you need to do this in a session where no =.org= file has
98 been visited, i.e., where no Org built-in function have been loaded.
99 Otherwise autoload Org functions will mess up the installation.
101 Then, to make sure your Org configuration is taken into account,
102 initialize the package system with ~(package-initialize)~ in your
103 Emacs init file before setting any Org option.  If you want to use
104 Org's package repository, check out the [[https://orgmode.org/elpa.html][Org ELPA page]].
106 *** Downloading Org as an archive
107 :PROPERTIES:
108 :UNNUMBERED: notoc
109 :END:
111 You can download Org latest release from [[https://orgmode.org/][Org's website]].  In this case,
112 make sure you set the load-path correctly in your Emacs init file:
114 #+begin_src emacs-lisp
115   (add-to-list 'load-path "~/path/to/orgdir/lisp")
116 #+end_src
118 The downloaded archive contains contributed libraries that are not
119 included in Emacs.  If you want to use them, add the =contrib/=
120 directory to your load-path:
122 #+begin_src emacs-lisp
123   (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
124 #+end_src
126 Optionally, you can compile the files and/or install them in your
127 system.  Run =make help= to list compilation and installation options.
129 *** Using Org's git repository
130 :PROPERTIES:
131 :UNNUMBERED: notoc
132 :END:
134 You can clone Org's repository and install Org like this:
136 #+begin_example
137   $ cd ~/src/
138   $ git clone git@code.orgmode.org:bzg/org-mode.git
139   $ make autoloads
140 #+end_example
142 Note that in this case, ~make autoloads~ is mandatory: it defines
143 Org's version in =org-version.el= and Org's autoloads in
144 =org-loaddefs.el=.
146 Remember to add the correct load-path as described in the method
147 above.
149 You can also compile with =make=, generate the documentation with
150 =make doc=, create a local configuration with =make config= and
151 install Org with =make install=.  Please run =make help= to get the
152 list of compilation/installation options.
154 For more detailed explanations on Org's build system, please check the
155 Org Build System page on [[https://orgmode.org/worg/dev/org-build-system.html][Worg]].
157 ** Activation
158 :PROPERTIES:
159 :DESCRIPTION: How to activate Org for certain buffers.
160 :END:
161 #+cindex: activation
162 #+cindex: autoload
163 #+cindex: ELPA
164 #+cindex: global key bindings
165 #+cindex: key bindings, global
167 Org mode buffers need Font Lock to be turned on: this is the default
168 in Emacs[fn:1].
170 There are compatibility issues between Org mode and some other Elisp
171 packages (see [[*Packages that conflict with Org mode]]).  Please take the
172 time to check the list.
174 #+findex: org-agenda
175 #+findex: org-capture
176 #+findex: org-store-link
177 #+findex: org-iswitchb
178 For a better experience, the four Org commands ~org-store-link~,
179 ~org-capture~, ~org-agenda~, and ~org-iswitchb~ ought to be accessible
180 through global keys---i.e., anywhere in Emacs, not just in Org
181 buffers.  Here are suggested bindings for these keys, please modify
182 the keys to your own liking.
184 #+begin_src emacs-lisp
185   (global-set-key "\C-cl" 'org-store-link)
186   (global-set-key "\C-ca" 'org-agenda)
187   (global-set-key "\C-cc" 'org-capture)
188   (global-set-key "\C-cb" 'org-iswitchb)
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-errror <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 #+kindex: C-c a
359 #+kindex: C-c c
360 The manual suggests a few global key bindings, in particular
361 {{{kbd(C-c a)}}} for ~org-agenda~ and {{{kbd(C-c c)}}} for
362 ~org-capture~.  These are only suggestions, but the rest of the manual
363 assumes that these key bindings are in place in order to list commands
364 by key access.
366 Also, the manual lists both the keys and the corresponding commands
367 for accessing a functionality.  Org mode often uses the same key for
368 different functions, depending on context.  The command that is bound
369 to such keys has a generic name, like ~org-metaright~.  In the manual
370 we will, wherever possible, give the function that is internally
371 called by the generic command.  For example, in the chapter on
372 document structure, {{{kbd(M-right)}}} will be listed to call
373 ~org-do-demote~, while in the chapter on tables, it will be listed to
374 call ~org-table-move-column-right~.
376 * Document Structure
377 :PROPERTIES:
378 :DESCRIPTION: A tree works like your brain.
379 :END:
380 #+cindex: document structure
381 #+cindex: structure of document
383 Org is based on Outline mode and provides flexible commands to
384 edit the structure of the document.
386 ** Outlines
387 :PROPERTIES:
388 :DESCRIPTION: Org is based on Outline mode.
389 :END:
390 #+cindex: outlines
391 #+cindex: Outline mode
393 Org is implemented on top of Outline mode.  Outlines allow a document
394 to be organized in a hierarchical structure, which, least for me, is
395 the best representation of notes and thoughts.  An overview of this
396 structure is achieved by folding, i.e., hiding large parts of the
397 document to show only the general document structure and the parts
398 currently being worked on.  Org greatly simplifies the use of outlines
399 by compressing the entire show and hide functionalities into a single
400 command, ~org-cycle~, which is bound to the {{{kbd(TAB)}}} key.
402 ** Headlines
403 :PROPERTIES:
404 :DESCRIPTION: How to typeset Org tree headlines.
405 :END:
406 #+cindex: headlines
407 #+cindex: outline tree
408 #+vindex: org-special-ctrl-a/e
409 #+vindex: org-special-ctrl-k
410 #+vindex: org-ctrl-k-protect-subtree
412 Headlines define the structure of an outline tree.  The headlines in
413 Org start with one or more stars, on the left margin[fn:3].  For
414 example:
416 #+begin_example
417   ,* Top level headline
418   ,** Second level
419   ,*** Third level
420       some text
421   ,*** Third level
422       more text
423   ,* Another top level headline
424 #+end_example
426 #+vindex: org-footnote-section
427 #+texinfo: @noindent
428 Note that the name defined in ~org-footnote-section~ is reserved.  Do
429 not use it as a title for your own headings.
431 Some people find the many stars too noisy and would prefer an outline
432 that has whitespace followed by a single star as headline starters.
433 See [[*A Cleaner Outline View]].
435 #+vindex: org-cycle-separator-lines
436 An empty line after the end of a subtree is considered part of it and
437 is hidden when the subtree is folded.  However, if you leave at least
438 two empty lines, one empty line remains visible after folding the
439 subtree, in order to structure the collapsed view.  See the variable
440 ~org-cycle-separator-lines~ to modify this behavior.
442 ** Visibility Cycling
443 :PROPERTIES:
444 :DESCRIPTION: Show and hide, much simplified.
445 :END:
446 #+cindex: cycling, visibility
447 #+cindex: visibility cycling
448 #+cindex: trees, visibility
449 #+cindex: show hidden text
450 #+cindex: hide text
452 *** Global and local cycling
453 :PROPERTIES:
454 :DESCRIPTION: Cycling through various visibility states.
455 :END:
456 #+cindex: subtree visibility states
457 #+cindex: subtree cycling
458 #+cindex: folded, subtree visibility state
459 #+cindex: children, subtree visibility state
460 #+cindex: subtree, subtree visibility state
462 Outlines make it possible to hide parts of the text in the buffer.
463 Org uses just two commands, bound to {{{kbd(TAB)}}} and
464 {{{kbd(S-TAB)}}} to change the visibility in the buffer.
466 #+attr_texinfo: :sep ,
467 - {{{kbd(TAB)}}} (~org-cycle~) ::
469      #+kindex: TAB
470      #+findex: org-cycle
471      /Subtree cycling/: Rotate current subtree among the states
473      #+begin_example
474        ,-> FOLDED -> CHILDREN -> SUBTREE --.
475        '-----------------------------------'
476      #+end_example
478      #+vindex: org-cycle-emulate-tab
479      The cursor must be on a headline for this to work[fn:4].
481 - {{{kbd(S-TAB)}}} (~org-global-cycle~), {{{kbd(C-u TAB)}}} ::
483      #+cindex: global visibility states
484      #+cindex: global cycling
485      #+cindex: overview, global visibility state
486      #+cindex: contents, global visibility state
487      #+cindex: show all, global visibility state
488      #+kindex: C-u TAB
489      #+kindex: S-TAB
490      #+findex: org-global-cycle
491      /Global cycling/: Rotate the entire buffer among the states
493      #+begin_example
494        ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
495        '--------------------------------------'
496      #+end_example
498      When {{{kbd(S-TAB)}}} is called with a numeric prefix argument N,
499      the CONTENTS view up to headlines of level N are shown.  Note
500      that inside tables (see [[*Tables]]), {{{kbd(S-TAB)}}} jumps to the
501      previous field instead.
503      #+vindex: org-cycle-global-at-bob
504      You can run global cycling using {{{kbd(TAB)}}} only if point is
505      at the very beginning of the buffer, but not on a headline, and
506      ~org-cycle-global-at-bob~ is set to a non-~nil~ value.
508 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
510      #+cindex: startup visibility
511      #+kindex: C-u C-u TAB
512      #+findex: org-set-startup-visibility
513      Switch back to the startup visibility of the buffer (see [[*Initial
514      visibility]]).
516 - {{{kbd(C-u C-u C-u TAB)}}} (~outline-show-all~) ::
518      #+cindex: show all, command
519      #+kindex: C-u C-u C-u TAB
520      #+findex: outline-show-all
521      Show all, including drawers.
523 - {{{kbd(C-c C-r)}}} (~org-reveal~) ::
525      #+cindex: revealing context
526      #+kindex: C-c C-r
527      #+findex: org-reveal
528      Reveal context around point, showing the current entry, the
529      following heading and the hierarchy above.  Useful for working
530      near a location that has been exposed by a sparse tree command
531      (see [[*Sparse Trees]]) or an agenda command (see [[*Commands in the
532      Agenda Buffer]]).  With a prefix argument show, on each level, all
533      sibling headings.  With a double prefix argument, also show the
534      entire subtree of the parent.
536 - {{{kbd(C-c C-k)}}} (~outline-show-branches~) ::
538      #+cindex: show branches, command
539      #+kindex: C-c C-k
540      #+findex: outline-show-branches
541      Expose all the headings of the subtree, CONTENTS view for just
542      one subtree.
544 - {{{kbd(C-c TAB)}}} (~outline-show-children~) ::
546      #+cindex: show children, command
547      #+kindex: C-c TAB
548      #+findex: outline-show-children
549      Expose all direct children of the subtree.  With a numeric prefix
550      argument N, expose all children down to level N.
552 - {{{kbd(C-c C-x b)}}} (~org-tree-to-indirect-buffer~) ::
554      #+kindex: C-c C-x b
555      #+findex: org-tree-to-indirect-buffer
556      Show the current subtree in an indirect buffer[fn:5].  With
557      a numeric prefix argument, N, go up to level N and then take that
558      tree.  If N is negative then go up that many levels.  With
559      a {{{kbd(C-u)}}} prefix, do not remove the previously used
560      indirect buffer.
562 - {{{kbd(C-c C-x v)}}} (~org-copy-visible~) ::
564      #+kindex: C-c C-x v
565      #+findex: org-copy-visible
566      Copy the /visible/ text in the region into the kill ring.
568 *** Initial visibility
569 :PROPERTIES:
570 :DESCRIPTION: Setting the initial visibility state.
571 :END:
573 #+vindex: org-startup-folded
574 When Emacs first visits an Org file, the global state is set to
575 OVERVIEW, i.e., only the top level headlines are visible[fn:6].  This
576 can be configured through the variable ~org-startup-folded~, or on
577 a per-file basis by adding one of the following lines anywhere in the
578 buffer:
580 #+cindex: STARTUP, keyword
581 #+begin_example
582   ,#+STARTUP: overview
583   ,#+STARTUP: content
584   ,#+STARTUP: showall
585   ,#+STARTUP: showeverything
586 #+end_example
588 #+cindex: VISIBILITY, property
589 #+texinfo: @noindent
590 Furthermore, any entries with a =VISIBILITY= property (see [[*Properties
591 and Columns]]) get their visibility adapted accordingly.  Allowed values
592 for this property are =folded=, =children=, =content=, and ~all~.
594 - {{{kbd(C-u C-u TAB)}}} (~org-set-startup-visibility~) ::
596      #+kindex: C-u C-u TAB
597      #+findex: org-set-startup-visibility
598      Switch back to the startup visibility of the buffer, i.e.,
599      whatever is requested by startup options and =VISIBILITY=
600      properties in individual entries.
602 *** Catching invisible edits
603 :PROPERTIES:
604 :DESCRIPTION: Preventing mistakes when editing invisible parts.
605 :END:
606 #+cindex: edits, catching invisible
608 #+vindex: org-catch-invisible-edits
609 Sometimes you may inadvertently edit an invisible part of the buffer
610 and be confused on what has been edited and how to undo the mistake.
611 Setting ~org-catch-invisible-edits~ to non-~nil~ helps preventing
612 this.  See the docstring of this option on how Org should catch
613 invisible edits and process them.
615 ** Motion
616 :PROPERTIES:
617 :DESCRIPTION: Jumping to other headlines.
618 :END:
619 #+cindex: motion, between headlines
620 #+cindex: jumping, to headlines
621 #+cindex: headline navigation
623 The following commands jump to other headlines in the buffer.
625 - {{{kbd(C-c C-n)}}} (~outline-next-visible-heading~) ::
627      #+kindex: C-c C-n
628      #+findex: outline-next-visible-heading
629      Next heading.
631 - {{{kbd(C-c C-p)}}} (~outline-previous-visible-heading~) ::
633      #+kindex: C-c C-p
634      #+findex: outline-previous-visible-heading
635      Previous heading.
637 - {{{kbd(C-c C-f)}}} (~org-forward-same-level~) ::
639      #+kindex: C-c C-f
640      #+findex: org-forward-same-level
641      Next heading same level.
643 - {{{kbd(C-c C-b)}}} (~org-backward-same-level~) ::
645      #+kindex: C-c C-b
646      #+findex: org-backward-same-level
647      Previous heading same level.
649 - {{{kbd(C-c C-u)}}} (~outline-up-heading~) ::
651      #+kindex: C-c C-u
652      #+findex: outline-up-heading
653      Backward to higher level heading.
655 - {{{kbd(C-c C-j)}}} (~org-goto~) ::
657      #+kindex: C-c C-j
658      #+findex: org-goto
659      #+vindex: org-goto-auto-isearch
660      Jump to a different place without changing the current outline
661      visibility.  Shows the document structure in a temporary buffer,
662      where you can use the following keys to find your destination:
664      #+attr_texinfo: :columns 0.3 0.7
665      | {{{kbd(TAB)}}}                  | Cycle visibility.               |
666      | {{{kbd(down)}}} / {{{kbd(up)}}} | Next/previous visible headline. |
667      | {{{kbd(RET)}}}                  | Select this location.           |
668      | {{{kbd(/)}}}                    | Do a Sparse-tree search         |
670      #+texinfo: @noindent
671      The following keys work if you turn off ~org-goto-auto-isearch~
673      #+attr_texinfo: :columns 0.3 0.7
674      | {{{kbd(n)}}} / {{{kbd(p)}}}   | Next/previous visible headline.    |
675      | {{{kbd(f)}}} / {{{kbd(b)}}}   | Next/previous headline same level. |
676      | {{{kbd(u)}}}                  | One level up.                      |
677      | {{{kbd(0)}}} ... {{{kbd(9)}}} | Digit argument.                    |
678      | {{{kbd(q)}}}                  | Quit.                              |
680      #+vindex: org-goto-interface
681      #+texinfo: @noindent
682      See also the variable ~org-goto-interface~.
684 ** Structure Editing
685 :PROPERTIES:
686 :DESCRIPTION: Changing sequence and level of headlines.
687 :END:
688 #+cindex: structure editing
689 #+cindex: headline, promotion and demotion
690 #+cindex: promotion, of subtrees
691 #+cindex: demotion, of subtrees
692 #+cindex: subtree, cut and paste
693 #+cindex: pasting, of subtrees
694 #+cindex: cutting, of subtrees
695 #+cindex: copying, of subtrees
696 #+cindex: sorting, of subtrees
697 #+cindex: subtrees, cut and paste
699 - {{{kbd(M-RET)}}} (~org-meta-return~) ::
701      #+kindex: M-RET
702      #+findex: org-meta-return
703      #+vindex: org-M-RET-may-split-line
704      Insert a new heading, item or row.
706      If the command is used at the /beginning/ of a line, and if there
707      is a heading or a plain list item (see [[*Plain Lists]]) at point,
708      the new heading/item is created /before/ the current line.  When
709      used at the beginning of a regular line of text, turn that line
710      into a heading.
712      When this command is used in the middle of a line, the line is
713      split and the rest of the line becomes the new item or headline.
714      If you do not want the line to be split, customize
715      ~org-M-RET-may-split-line~.
717      Calling the command with a {{{kbd(C-u)}}} prefix unconditionally
718      inserts a new heading at the end of the current subtree, thus
719      preserving its contents.  With a double {{{kbd(C-u C-u)}}}
720      prefix, the new heading is created at the end of the parent
721      subtree instead.
723 - {{{kbd(C-RET)}}} (~org-insert-heading-respect-content~) ::
725      #+kindex: C-RET
726      #+findex: org-insert-heading-respect-content
727      Insert a new heading at the end of the current subtree.
729 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
731      #+kindex: M-S-RET
732      #+findex: org-insert-todo-heading
733      #+vindex: org-treat-insert-todo-heading-as-state-change
734      Insert new TODO entry with same level as current heading.  See
735      also the variable
736      ~org-treat-insert-todo-heading-as-state-change~.
738 - {{{kbd(C-S-RET)}}} (~org-insert-todo-heading-respect-content~) ::
740      #+kindex: C-S-RET
741      #+findex: org-insert-todo-heading-respect-content
742      Insert new TODO entry with same level as current heading.  Like
743      {{{kbd(C-RET)}}}, the new headline is inserted after the current
744      subtree.
746 - {{{kbd(TAB)}}} (~org-cycle~) ::
748      #+kindex: TAB
749      #+findex: org-cycle
750      In a new entry with no text yet, the first {{{kbd(TAB)}}} demotes
751      the entry to become a child of the previous one.  The next
752      {{{kbd(TAB)}}} makes it a parent, and so on, all the way to top
753      level.  Yet another {{{kbd(TAB)}}}, and you are back to the
754      initial level.
756 - {{{kbd(M-left)}}} (~org-do-promote~) ::
758      #+kindex: M-left
759      #+findex: org-do-promote
760      Promote current heading by one level.
762 - {{{kbd(M-right)}}} (~org-do-demote~) ::
764      #+kindex: M-right
765      #+findex: org-do-demote
766      Demote current heading by one level.
768 - {{{kbd(M-S-left)}}} (~org-promote-subtree~) ::
770      #+kindex: M-S-left
771      #+findex: org-promote-subtree
772      Promote the current subtree by one level.
774 - {{{kbd(M-S-right)}}} (~org-demote-subtree~) ::
776      #+kindex: M-S-right
777      #+findex: org-demote-subtree
778      Demote the current subtree by one level.
780 - {{{kbd(M-up)}}} (~org-move-subtree-up~) ::
782      #+kindex: M-up
783      #+findex: org-move-subtree-up
784      Move subtree up, i.e., swap with previous subtree of same level.
786 - {{{kbd(M-down)}}} (~org-move-subtree-down~) ::
788      #+kindex: M-down
789      #+findex: org-move-subtree-down
790      Move subtree down, i.e., swap with next subtree of same level.
792 - {{{kbd(C-c @)}}} (~org-mark-subtree~) ::
794      #+kindex: C-c @@
795      #+findex: org-mark-subtree
796      Mark the subtree at point.  Hitting repeatedly marks subsequent
797      subtrees of the same level as the marked subtree.
799 - {{{kbd(C-c C-x C-w)}}} (~org-cut-subtree~) ::
801      #+kindex: C-c C-x C-w
802      #+findex: org-cut-subtree
803      Kill subtree, i.e., remove it from buffer but save in kill ring.
804      With a numeric prefix argument N, kill N sequential subtrees.
806 - {{{kbd(C-c C-x M-w)}}} (~org-copy-subtree~) ::
808      #+kindex: C-c C-x M-w
809      #+findex: org-copy-subtree
810      Copy subtree to kill ring.  With a numeric prefix argument N,
811      copy the N sequential subtrees.
813 - {{{kbd(C-c C-x C-y)}}} (~org-paste-subtree~) ::
815      #+kindex: C-c C-x C-y
816      #+findex: org-paste-subtree
817      Yank subtree from kill ring.  This does modify the level of the
818      subtree to make sure the tree fits in nicely at the yank
819      position.  The yank level can also be specified with a numeric
820      prefix argument, or by yanking after a headline marker like
821      =****=.
823 - {{{kbd(C-y)}}} (~org-yank~) ::
825      #+kindex: C-y
826      #+findex: org-yank
827      #+vindex: org-yank-adjusted-subtrees
828      #+vindex: org-yank-folded-subtrees
829      Depending on the variables ~org-yank-adjusted-subtrees~ and
830      ~org-yank-folded-subtrees~, Org's internal ~yank~ command pastes
831      subtrees folded and in a clever way, using the same command as
832      {{{kbd(C-c C-x C-y)}}}.  With the default settings, no level
833      adjustment takes place, but the yanked tree is folded unless
834      doing so would swallow text previously visible.  Any prefix
835      argument to this command forces a normal ~yank~ to be executed,
836      with the prefix passed along.  A good way to force a normal yank
837      is {{{kbd(C-u C-y)}}}.  If you use ~yank-pop~ after a yank, it
838      yanks previous kill items plainly, without adjustment and
839      folding.
841 - {{{kbd(C-c C-x c)}}} (~org-clone-subtree-with-time-shift~) ::
843      #+kindex: C-c C-x c
844      #+findex: org-clone-subtree-with-time-shift
845      Clone a subtree by making a number of sibling copies of it.  You
846      are prompted for the number of copies to make, and you can also
847      specify if any timestamps in the entry should be shifted.  This
848      can be useful, for example, to create a number of tasks related
849      to a series of lectures to prepare.  For more details, see the
850      docstring of the command ~org-clone-subtree-with-time-shift~.
852 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
854      #+kindex: C-c C-w
855      #+findex: org-refile
856      Refile entry or region to a different location.  See [[Refile and
857      Copy]].
859 - {{{kbd(C-c ^)}}} (~org-sort~) ::
861      #+kindex: C-c ^
862      #+findex: org-sort
863      Sort same-level entries.  When there is an active region, all
864      entries in the region are sorted.  Otherwise the children of the
865      current headline are sorted.  The command prompts for the sorting
866      method, which can be alphabetically, numerically, by time---first
867      timestamp with active preferred, creation time, scheduled time,
868      deadline time---by priority, by TODO keyword---in the sequence
869      the keywords have been defined in the setup---or by the value of
870      a property.  Reverse sorting is possible as well.  You can also
871      supply your own function to extract the sorting key.  With
872      a {{{kbd(C-u)}}} prefix, sorting is case-sensitive.
874 - {{{kbd(C-x n s)}}} (~org-narrow-to-subtree~) ::
876      #+kindex: C-x n s
877      #+findex: org-narrow-to-subtree
878      Narrow buffer to current subtree.
880 - {{{kbd(C-x n b)}}} (~org-narrow-to-block~) ::
882      #+kindex: C-x n b
883      #+findex: org-narrow-to-block
884      Narrow buffer to current block.
886 - {{{kbd(C-x n w)}}} (~widen~) ::
888      #+kindex: C-x n w
889      #+findex: widen
890      Widen buffer to remove narrowing.
892 - {{{kbd(C-c *)}}} (~org-toggle-heading~) ::
894      #+kindex: C-c *
895      #+findex: org-toggle-heading
896      Turn a normal line or plain list item into a headline---so that
897      it becomes a subheading at its location.  Also turn a headline
898      into a normal line by removing the stars.  If there is an active
899      region, turn all lines in the region into headlines.  If the
900      first line in the region was an item, turn only the item lines
901      into headlines.  Finally, if the first line is a headline, remove
902      the stars from all headlines in the region.
904 #+cindex: region, active
905 #+cindex: active region
906 #+cindex: transient mark mode
907 When there is an active region---i.e., when Transient Mark mode is
908 active---promotion and demotion work on all headlines in the region.
909 To select a region of headlines, it is best to place both point and
910 mark at the beginning of a line, mark at the beginning of the first
911 headline, and point at the line just after the last headline to
912 change.  Note that when the cursor is inside a table (see [[*Tables]]),
913 the Meta-Cursor keys have different functionality.
915 ** Sparse Trees
916 :PROPERTIES:
917 :DESCRIPTION: Matches embedded in context.
918 :END:
919 #+cindex: sparse trees
920 #+cindex: trees, sparse
921 #+cindex: folding, sparse trees
922 #+cindex: occur, command
924 #+vindex: org-show-context-detail
925 An important feature of Org mode is the ability to construct /sparse
926 trees/ for selected information in an outline tree, so that the entire
927 document is folded as much as possible, but the selected information
928 is made visible along with the headline structure above it[fn:7].
929 Just try it out and you will see immediately how it works.
931 Org mode contains several commands creating such trees, all these
932 commands can be accessed through a dispatcher:
934 - {{{kbd(C-c /)}}} (~org-sparse-tree~) ::
936      #+kindex: C-c /
937      #+findex: org-sparse-tree
938      This prompts for an extra key to select a sparse-tree creating
939      command.
941 - {{{kbd(C-c / r)}}} or {{{kbd(C-c / /)}}} (~org-occur~) ::
943      #+kindex: C-c / r
944      #+kindex: C-c / /
945      #+findex: org-occur
946      #+vindex: org-remove-highlights-with-change
947      Prompts for a regexp and shows a sparse tree with all matches.
948      If the match is in a headline, the headline is made visible.  If
949      the match is in the body of an entry, headline and body are made
950      visible.  In order to provide minimal context, also the full
951      hierarchy of headlines above the match is shown, as well as the
952      headline following the match.  Each match is also highlighted;
953      the highlights disappear when the buffer is changed by an editing
954      command, or by pressing {{{kbd(C-c C-c)}}}[fn:8].  When called
955      with a {{{kbd(C-u)}}} prefix argument, previous highlights are
956      kept, so several calls to this command can be stacked.
958 - {{{kbd(M-g n)}}} or {{{kbd(M-g M-n)}}} (~next-error~) ::
960      #+kindex: M-g n
961      #+kindex: M-g M-n
962      #+findex: next-error
963      Jump to the next sparse tree match in this buffer.
965 - {{{kbd(M-g p)}}} or {{{kbd(M-g M-p)}}} (~previous-error~) ::
967      #+kindex: M-g p
968      #+kindex: M-g M-p
969      #+findex: previous-error
970      Jump to the previous sparse tree match in this buffer.
972 #+vindex: org-agenda-custom-commands
973 #+texinfo: @noindent
974 For frequently used sparse trees of specific search strings, you can
975 use the variable ~org-agenda-custom-commands~ to define fast keyboard
976 access to specific sparse trees.  These commands will then be
977 accessible through the agenda dispatcher (see [[*The Agenda Dispatcher]]).
978 For example:
980 #+begin_src emacs-lisp
981   (setq org-agenda-custom-commands
982         '(("f" occur-tree "FIXME")))
983 #+end_src
985 #+texinfo: @noindent
986 defines the key {{{kbd(C-c a f)}}} as a shortcut for creating a sparse
987 tree matching the string =FIXME=.
989 The other sparse tree commands select headings based on TODO keywords,
990 tags, or properties and are discussed later in this manual.
992 #+kindex: C-c C-e v
993 #+cindex: printing sparse trees
994 #+cindex: visible text, printing
995 To print a sparse tree, you can use the Emacs command
996 ~ps-print-buffer-with-faces~ which does not print invisible parts of
997 the document.  Or you can use the command {{{kbd(C-c C-e v)}}} to
998 export only the visible part of the document and print the resulting
999 file.
1001 ** Plain Lists
1002 :PROPERTIES:
1003 :DESCRIPTION: Additional structure within an entry.
1004 :END:
1005 #+cindex: plain lists
1006 #+cindex: lists, plain
1007 #+cindex: lists, ordered
1008 #+cindex: ordered lists
1010 Within an entry of the outline tree, hand-formatted lists can provide
1011 additional structure.  They also provide a way to create lists of
1012 checkboxes (see [[*Checkboxes]]).  Org supports editing such lists, and
1013 every exporter (see [[*Exporting]]) can parse and format them.
1015 Org knows ordered lists, unordered lists, and description lists.
1017 #+attr_texinfo: :indic @bullet
1018 - /Unordered/ list items start with =-=, =+=, or =*=[fn:9] as bullets.
1021   #+vindex: org-plain-list-ordered-item-terminator
1022   #+vindex: org-alphabetical-lists
1023   /Ordered/ list items start with a numeral followed by either
1024   a period or a right parenthesis[fn:10], such as =1.= or =1)=[fn:11]
1025   If you want a list to start with a different value---e.g.,
1026   20---start the text of the item with =[@20]=[fn:12].  Those
1027   constructs can be used in any item of the list in order to enforce
1028   a particular numbering.
1030 - /Description/ list items are unordered list items, and contain the
1031   separator =::= to distinguish the description /term/ from the
1032   description.
1034 Items belonging to the same list must have the same indentation on the
1035 first line.  In particular, if an ordered list reaches number =10.=,
1036 then the 2-digit numbers must be written left-aligned with the other
1037 numbers in the list.  An item ends before the next line that is less
1038 or equally indented than its bullet/number.
1040 A list ends whenever every item has ended, which means before any line
1041 less or equally indented than items at top level.  It also ends before
1042 two blank lines.  In that case, all items are closed.  Here is an
1043 example:
1045 #+begin_example
1046   ,* Lord of the Rings
1047   My favorite scenes are (in this order)
1048   1. The attack of the Rohirrim
1049   2. Eowyn's fight with the witch king
1050      + this was already my favorite scene in the book
1051      + I really like Miranda Otto.
1052   3. Peter Jackson being shot by Legolas
1053      - on DVD only
1054      He makes a really funny face when it happens.
1055   But in the end, no individual scenes matter but the film as a whole.
1056   Important actors in this film are:
1057   - Elijah Wood :: He plays Frodo
1058   - Sean Astin :: He plays Sam, Frodo's friend. I still remember him
1059        very well from his role as Mikey Walsh in /The Goonies/.
1060 #+end_example
1062 Org supports these lists by tuning filling and wrapping commands to
1063 deal with them correctly, and by exporting them properly (see
1064 [[Exporting]]).  Since indentation is what governs the structure of these
1065 lists, many structural constructs like =#+BEGIN_= blocks can be
1066 indented to signal that they belong to a particular item.
1068 #+vindex: org-list-demote-modify-bullet
1069 #+vindex: org-list-indent-offset
1070 If you find that using a different bullet for a sub-list---than that
1071 used for the current list-level---improves readability, customize the
1072 variable ~org-list-demote-modify-bullet~.  To get a greater difference
1073 of indentation between items and theirs sub-items, customize
1074 ~org-list-indent-offset~.
1076 #+vindex: org-list-automatic-rules
1077 The following commands act on items when the cursor is in the first
1078 line of an item---the line with the bullet or number.  Some of them
1079 imply the application of automatic rules to keep list structure
1080 intact.  If some of these actions get in your way, configure
1081 ~org-list-automatic-rules~ to disable them individually.
1083 #+attr_texinfo: :sep ,
1084 - {{{kbd(TAB)}}} (~org-cycle~) ::
1086      #+cindex: cycling, in plain lists
1087      #+kindex: TAB
1088      #+findex: org-cycle
1089      #+vindex: org-cycle-include-plain-lists
1090      Items can be folded just like headline levels.  Normally this
1091      works only if the cursor is on a plain list item.  For more
1092      details, see the variable ~org-cycle-include-plain-lists~.  If
1093      this variable is set to ~integrate~, plain list items are treated
1094      like low-level headlines.  The level of an item is then given by
1095      the indentation of the bullet/number.  Items are always
1096      subordinate to real headlines, however; the hierarchies remain
1097      completely separated.  In a new item with no text yet, the first
1098      {{{kbd(TAB)}}} demotes the item to become a child of the previous
1099      one.  Subsequent {{{kbd(TAB)}}}s move the item to meaningful
1100      levels in the list and eventually get it back to its initial
1101      position.
1103 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
1105      #+kindex: M-RET
1106      #+findex: org-insert-heading
1107      #+vindex: org-M-RET-may-split-line
1108      Insert new item at current level.  With a prefix argument, force
1109      a new heading (see [[*Structure Editing]]).  If this command is used
1110      in the middle of an item, that item is /split/ in two, and the
1111      second part becomes the new item[fn:13].  If this command is
1112      executed /before item's body/, the new item is created /before/
1113      the current one.
1115 - {{{kbd(M-S-RET)}}} ::
1117      #+kindex: M-S-RET
1118      Insert a new item with a checkbox (see [[Checkboxes]]).
1120 - {{{kbd(S-up)}}}, {{{kbd(S-down)}}} ::
1122      #+kindex: S-up
1123      #+kindex: S-down
1124      #+cindex: shift-selection-mode
1125      #+vindex: org-support-shift-select
1126      #+vindex: org-list-use-circular-motion
1127      Jump to the previous/next item in the current list, but only if
1128      ~org-support-shift-select~ is off[fn:14].  If not, you can
1129      still use paragraph jumping commands like {{{kbd(C-up)}}}
1130      and {{{kbd(C-down)}}} to quite similar effect.
1132 - {{{kbd(M-up)}}}, {{{kbd(M-down)}}} ::
1134      #+kindex: M-up
1135      #+kindex: M-down
1136      Move the item including subitems up/down[fn:15], i.e., swap with
1137      previous/next item of same indentation.  If the list is ordered,
1138      renumbering is automatic.
1140 - {{{kbd(M-left)}}}, {{{kbd(M-right)}}} ::
1142      #+kindex: M-left
1143      #+kindex: M-right
1144      Decrease/increase the indentation of an item, leaving children
1145      alone.
1147 - {{{kbd(M-S-left)}}}, {{{kbd(M-S-right)}}} ::
1149      #+kindex: M-S-left
1150      #+kindex: M-S-right
1151      Decrease/increase the indentation of the item, including
1152      subitems.  Initially, the item tree is selected based on current
1153      indentation.  When these commands are executed several times in
1154      direct succession, the initially selected region is used, even if
1155      the new indentation would imply a different hierarchy.  To use
1156      the new hierarchy, break the command chain with a cursor motion
1157      or so.
1159      As a special case, using this command on the very first item of
1160      a list moves the whole list.  This behavior can be disabled by
1161      configuring ~org-list-automatic-rules~.  The global indentation
1162      of a list has no influence on the text /after/ the list.
1164 - {{{kbd(C-c C-c)}}} ::
1166      #+kindex: C-c C-c
1167      If there is a checkbox (see [[Checkboxes]]) in the item line, toggle
1168      the state of the checkbox.  In any case, verify bullets and
1169      indentation consistency in the whole list.
1171 - {{{kbd(C-c -)}}} ::
1173      #+kindex: C-c -
1174      #+vindex: org-plain-list-ordered-item-terminator
1175      Cycle the entire list level through the different
1176      itemize/enumerate bullets (=-=, =+=, =*=, =1.=, =1)=) or a subset
1177      of them, depending on ~org-plain-list-ordered-item-terminator~,
1178      the type of list, and its indentation.  With a numeric prefix
1179      argument N, select the Nth bullet from this list.  If there is an
1180      active region when calling this, selected text is changed into an
1181      item.  With a prefix argument, all lines are converted to list
1182      items.  If the first line already was a list item, any item
1183      marker is removed from the list.  Finally, even without an active
1184      region, a normal line is converted into a list item.
1186 - {{{kbd(C-c *)}}} ::
1188      #+kindex: C-c *
1189      Turn a plain list item into a headline---so that it becomes
1190      a subheading at its location.  See [[*Structure Editing]], for
1191      a detailed explanation.
1193 - {{{kbd(C-c C-*)}}} ::
1195      #+kindex: C-c C-*
1196      Turn the whole plain list into a subtree of the current heading.
1197      Checkboxes (see [[*Checkboxes]]) become TODO, respectively DONE,
1198      keywords when unchecked, respectively checked.
1200 - {{{kbd(S-left)}}}, {{{kbd(S-right)}}} ::
1202      #+vindex: org-support-shift-select
1203      #+kindex: S-left
1204      #+kindex: S-right
1205      This command also cycles bullet styles when the cursor in on the
1206      bullet or anywhere in an item line, details depending on
1207      ~org-support-shift-select~.
1209 - {{{kbd(C-c ^)}}} ::
1211      #+kindex: C-c ^
1212      #+cindex: sorting, of plain list
1213      Sort the plain list.  Prompt for the sorting method: numerically,
1214      alphabetically, by time, or by custom function.
1216 ** Drawers
1217 :PROPERTIES:
1218 :DESCRIPTION: Tucking stuff away.
1219 :END:
1220 #+cindex: drawers
1221 #+cindex: visibility cycling, drawers
1223 Sometimes you want to keep information associated with an entry, but
1224 you normally do not want to see it.  For this, Org mode has /drawers/.
1225 They can contain anything but a headline and another drawer.  Drawers
1226 look like this:
1228 #+begin_example
1229   ,** This is a headline
1230   Still outside the drawer
1231   :DRAWERNAME:
1232   This is inside the drawer.
1233   :END:
1234   After the drawer.
1235 #+end_example
1237 #+kindex: C-c C-x d
1238 #+findex: org-insert-drawer
1239 You can interactively insert a drawer at point by calling
1240 ~org-insert-drawer~, which is bound to {{{kbd(C-c C-x d)}}}.  With an
1241 active region, this command puts the region inside the drawer.  With
1242 a prefix argument, this command calls ~org-insert-property-drawer~,
1243 which creates a =PROPERTIES= drawer right below the current headline.
1244 Org mode uses this special drawer for storing properties (see
1245 [[*Properties and Columns]]).  You cannot use it for anything else.
1247 Completion over drawer keywords is also possible using
1248 {{{kbd(M-TAB)}}}[fn:16].
1250 Visibility cycling (see [[*Visibility Cycling]]) on the headline hides and
1251 shows the entry, but keep the drawer collapsed to a single line.  In
1252 order to look inside the drawer, you need to move the cursor to the
1253 drawer line and press {{{kbd(TAB)}}} there.
1255 You can also arrange for state change notes (see [[Tracking TODO state
1256 changes]]) and clock times (see [[*Clocking Work Time]]) to be stored in
1257 a =LOGBOOK= drawer.  If you want to store a quick note there, in
1258 a similar way to state changes, use
1260 - {{{kbd(C-c C-z)}}} ::
1262      #+kindex: C-c C-z
1263      Add a time-stamped note to the =LOGBOOK= drawer.
1265 ** Blocks
1266 :PROPERTIES:
1267 :DESCRIPTION: Folding blocks.
1268 :END:
1269 #+vindex: org-hide-block-startup
1270 #+cindex: blocks, folding
1272 Org mode uses =#+BEGIN= ... =#+END= blocks for various purposes from
1273 including source code examples (see [[*Literal Examples]]) to capturing
1274 time logging information (see [[*Clocking Work Time]]).  These blocks can
1275 be folded and unfolded by pressing {{{kbd(TAB)}}} in the =#+BEGIN=
1276 line.  You can also get all blocks folded at startup by configuring
1277 the variable ~org-hide-block-startup~ or on a per-file basis by using
1279 #+cindex: STARTUP, keyword
1280 #+begin_example
1281   ,#+STARTUP: hideblocks
1282   ,#+STARTUP: nohideblocks
1283 #+end_example
1285 ** Creating Footnotes
1286 :PROPERTIES:
1287 :DESCRIPTION: How footnotes are defined in Org's syntax.
1288 :END:
1289 #+cindex: footnotes
1291 Org mode supports the creation of footnotes.
1293 A footnote is started by a footnote marker in square brackets in
1294 column 0, no indentation allowed.  It ends at the next footnote
1295 definition, headline, or after two consecutive empty lines.  The
1296 footnote reference is simply the marker in square brackets, inside
1297 text.  Markers always start with =fn:=.  For example:
1299 #+begin_example
1300   The Org homepage[fn:1] now looks a lot better than it used to.
1301   ...
1302   [fn:1] The link is: https://orgmode.org
1303 #+end_example
1305 Org mode extends the number-based syntax to /named/ footnotes and
1306 optional inline definition.  Here are the valid references:
1308 - =[fn:NAME]= ::
1310      A named footnote reference, where {{{var(NAME)}}} is a unique
1311      label word, or, for simplicity of automatic creation, a number.
1313 - =[fn:: This is the inline definition of this footnote]= ::
1315      A LaTeX-like anonymous footnote where the definition is given
1316      directly at the reference point.
1318 - =[fn:NAME: a definition]= ::
1320      An inline definition of a footnote, which also specifies a name
1321      for the note.  Since Org allows multiple references to the same
1322      note, you can then use =[fn:NAME]= to create additional
1323      references.
1325 #+vindex: org-footnote-auto-label
1326 Footnote labels can be created automatically, or you can create names
1327 yourself.  This is handled by the variable ~org-footnote-auto-label~
1328 and its corresponding =STARTUP= keywords.  See the docstring of that
1329 variable for details.
1331 #+texinfo: @noindent
1332 The following command handles footnotes:
1334 - {{{kbd(C-c C-x f)}}} ::
1336      The footnote action command.
1338      #+kindex: C-c C-x f
1339      When the cursor is on a footnote reference, jump to the
1340      definition.  When it is at a definition, jump to
1341      the---first---reference.
1343      #+vindex: org-footnote-define-inline
1344      #+vindex: org-footnote-section
1345      Otherwise, create a new footnote.  Depending on the variable
1346      ~org-footnote-define-inline~[fn:17], the definition is placed
1347      right into the text as part of the reference, or separately into
1348      the location determined by the variable ~org-footnote-section~.
1350      When this command is called with a prefix argument, a menu of
1351      additional options is offered:
1353      #+attr_texinfo: :columns 0.1 0.9
1354      | {{{kbd(s)}}} | Sort the footnote definitions by reference sequence.               |
1355      | {{{kbd(r)}}} | Renumber the simple =fn:N= footnotes.                              |
1356      | {{{kbd(S)}}} | Short for first {{{kbd(r)}}}, then {{{kbd(s)}}} action.            |
1357      | {{{kbd(n)}}} | Rename all footnotes into a =fn:1= ... =fn:n= sequence.            |
1358      | {{{kbd(d)}}} | Delete the footnote at point, including definition and references. |
1360      #+vindex: org-footnote-auto-adjust
1361      Depending on the variable ~org-footnote-auto-adjust~[fn:18],
1362      renumbering and sorting footnotes can be automatic after each
1363      insertion or deletion.
1365 - {{{kbd(C-c C-c)}}} ::
1367      #+kindex: C-c C-c
1368      If the cursor is on a footnote reference, jump to the definition.
1369      If it is at the definition, jump back to the reference.  When
1370      called at a footnote location with a prefix argument, offer the
1371      same menu as {{{kbd(C-c C-x f)}}}.
1373 - {{{kbd(C-c C-o)}}} or {{{kbd(mouse-1/2)}}} ::
1375      #+kindex: C-c C-o
1376      #+kindex: mouse-1
1377      #+kindex: mouse-2
1378      Footnote labels are also links to the corresponding definition or
1379      reference, and you can use the usual commands to follow these
1380      links.
1382 ** Org Syntax
1383 :PROPERTIES:
1384 :DESCRIPTION: Formal description of Org's syntax.
1385 :END:
1387 A reference document providing a formal description of Org's syntax is
1388 available as [[https://orgmode.org/worg/dev/org-syntax.html][a draft on Worg]], written and maintained by Nicolas
1389 Goaziou.  It defines Org's core internal concepts such as =headlines=,
1390 =sections=, =affiliated keywords=, =(greater) elements= and =objects=.
1391 Each part of an Org file falls into one of the categories above.
1393 To explore the abstract structure of an Org buffer, run this in
1394 a buffer:
1396 : M-: (org-element-parse-buffer) <RET>
1398 #+texinfo: @noindent
1399 It outputs a list containing the buffer's content represented as an
1400 abstract structure.  The export engine relies on the information
1401 stored in this list.  Most interactive commands---e.g., for structure
1402 editing---also rely on the syntactic meaning of the surrounding
1403 context.
1405 #+cindex: syntax checker
1406 #+cindex: linter
1407 #+findex: org-lint
1408 You can check syntax in your documents using ~org-lint~ command.
1410 * Tables
1411 :PROPERTIES:
1412 :DESCRIPTION: Pure magic for quick formatting.
1413 :END:
1414 #+cindex: tables
1415 #+cindex: editing tables
1417 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1418 calculations are supported using the Emacs Calc package (see
1419 [[info:calc]]).
1421 ** Built-in Table Editor
1422 :PROPERTIES:
1423 :DESCRIPTION: Simple tables.
1424 :END:
1425 #+cindex: table editor, built-in
1427 Org makes it easy to format tables in plain ASCII.  Any line with =|=
1428 as the first non-whitespace character is considered part of a table.
1429 =|= is also the column separator[fn:19].  A table might look like
1430 this:
1432 #+begin_example
1433   | Name  | Phone | Age |
1434   |-------+-------+-----|
1435   | Peter |  1234 |  17 |
1436   | Anna  |  4321 |  25 |
1437 #+end_example
1439 A table is re-aligned automatically each time you press
1440 {{{kbd(TAB)}}}, {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} inside the table.
1441 {{{kbd(TAB)}}} also moves to the next field---{{{kbd(RET)}}} to the
1442 next row---and creates new table rows at the end of the table or
1443 before horizontal lines.  The indentation of the table is set by the
1444 first line.  Any line starting with =|-= is considered as a horizontal
1445 separator line and will be expanded on the next re-align to span the
1446 whole table width.  So, to create the above table, you would only type
1448 #+begin_example
1449   |Name|Phone|Age|
1450   |-
1451 #+end_example
1453 #+texinfo: @noindent
1454 and then press {{{kbd(TAB)}}} to align the table and start filling in
1455 fields.  Even faster would be to type =|Name|Phone|Age= followed by
1456 {{{kbd(C-c RET)}}}.
1458 When typing text into a field, Org treats {{{kbd(DEL)}}},
1459 {{{kbd(Backspace)}}}, and all character keys in a special way, so that
1460 inserting and deleting avoids shifting other fields.  Also, when
1461 typing /immediately/ after the cursor was moved into a new field with
1462 {{{kbd(TAB)}}}, {{{kbd(S-TAB)}}} or {{{kbd(RET)}}}, the field is
1463 automatically made blank.  If this behavior is too unpredictable for
1464 you, configure the option ~org-table-auto-blank-field~.
1466 *** Creation and conversion
1467 :PROPERTIES:
1468 :UNNUMBERED: notoc
1469 :END:
1471 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1473      #+kindex: C-c |
1474      #+findex: org-table-create-or-convert-from-region
1475      Convert the active region to table.  If every line contains at
1476      least one {{{kbd(TAB)}}} character, the function assumes that the
1477      material is tab separated.  If every line contains a comma,
1478      comma-separated values (CSV) are assumed.  If not, lines are
1479      split at whitespace into fields.  You can use a prefix argument
1480      to force a specific separator: {{{kbd(C-u)}}} forces CSV,
1481      {{{kbd(C-u C-u)}}} forces {{{kbd(TAB)}}}, {{{kbd(C-u C-u C-u)}}}
1482      prompts for a regular expression to match the separator, and
1483      a numeric argument N indicates that at least N consecutive
1484      spaces, or alternatively a {{{kbd(TAB)}}} will be the separator.
1486      If there is no active region, this command creates an empty Org
1487      table.  But it is easier just to start typing, like {{{kbd(|
1488      N a m e | P h o n e | A g e RET | - TAB)}}}.
1490 *** Re-aligning and field motion
1491 :PROPERTIES:
1492 :UNNUMBERED: notoc
1493 :END:
1495 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1497      #+kindex: C-c C-c
1498      #+findex: org-table-align
1499      Re-align the table without moving the cursor.
1501 - {{{kbd(TAB)}}} (~org-table-next-field~) ::
1503      #+kindex: TAB
1504      #+findex: org-table-next-field
1505      Re-align the table, move to the next field.  Creates a new row if
1506      necessary.
1508 - {{{kbd(C-c SPC)}}} (~org-table-blank-field~) ::
1510      #+kindex: C-c SPC
1511      #+findex: org-table-blank-field
1512      Blank the field at point.
1514 - {{{kbd(S-TAB)}}} (~org-table-previous-field~) ::
1516      #+kindex: S-TAB
1517      #+findex: org-table-previous-field
1518      Re-align, move to previous field.
1520 - {{{kbd(RET)}}} (~org-table-next-row~) ::
1522      #+kindex: RET
1523      #+findex: org-table-next-row
1524      Re-align the table and move down to next row.  Creates a new row
1525      if necessary.  At the beginning or end of a line, {{{kbd(RET)}}}
1526      still inserts a new line, so it can be used to split a table.
1528 - {{{kbd(M-a)}}} (~org-table-beginning-of-field~) ::
1530      #+kindex: M-a
1531      #+findex: org-table-beginning-of-field
1532      Move to beginning of the current table field, or on to the
1533      previous field.
1535 - {{{kbd(M-e)}}} (~org-table-end-of-field~) ::
1537      #+kindex: M-e
1538      #+findex: org-table-end-of-field
1539      Move to end of the current table field, or on to the next field.
1541 *** Column and row editing
1542 :PROPERTIES:
1543 :UNNUMBERED: notoc
1544 :END:
1546 - {{{kbd(M-left)}}} (~org-table-move-column-left~) ::
1548      #+kindex: M-left
1549      #+findex: org-table-move-column-left
1550      Move the current column left.
1552 - {{{kbd(M-right)}}} (~org-table-move-column-right~) ::
1554      #+kindex: M-right
1555      #+findex: org-table-move-column-right
1556      Move the current column right.
1558 - {{{kbd(M-S-left)}}} (~org-table-delete-column~) ::
1560      #+kindex: M-S-left
1561      #+findex: org-table-delete-column
1562      Kill the current column.
1564 - {{{kbd(M-S-right)}}} (~org-table-insert-column~) ::
1566      #+kindex: M-S-right
1567      #+findex: org-table-insert-column
1568      Insert a new column to the left of the cursor position.
1570 - {{{kbd(M-up)}}} (~org-table-move-row-up~) ::
1572      #+kindex: M-up
1573      #+findex: org-table-move-row-up
1574      Move the current row up.
1576 - {{{kbd(M-down)}}} (~org-table-move-row-down~) ::
1578      #+kindex: M-down
1579      #+findex: org-table-move-row-down
1580      Move the current row down.
1582 - {{{kbd(M-S-up)}}} (~org-table-kill-row~) ::
1584      #+kindex: M-S-up
1585      #+findex: org-table-kill-row
1586      Kill the current row or horizontal line.
1588 - {{{kbd(M-S-down)}}} (~org-table-insert-row~) ::
1590      #+kindex: M-S-down
1591      #+findex: org-table-insert-row
1592      Insert a new row above the current row.  With a prefix argument,
1593      the line is created below the current one.
1595 - {{{kbd(C-c -)}}} (~org-table-insert-hline~) ::
1597      #+kindex: C-c -
1598      #+findex: org-table-insert-hline
1599      Insert a horizontal line below current row.  With a prefix
1600      argument, the line is created above the current line.
1602 - {{{kbd(C-c RET)}}} (~org-table-hline-and-move~) ::
1604      #+kindex: C-c RET
1605      #+findex: org-table-hline-and-move
1606      Insert a horizontal line below current row, and move the cursor
1607      into the row below that line.
1609 - {{{kbd(C-c ^)}}} (~org-table-sort-lines~) ::
1611      #+kindex: C-c ^
1612      #+findex: org-table-sort-lines
1613      Sort the table lines in the region.  The position of point
1614      indicates the column to be used for sorting, and the range of
1615      lines is the range between the nearest horizontal separator
1616      lines, or the entire table.  If point is before the first column,
1617      you are prompted for the sorting column.  If there is an active
1618      region, the mark specifies the first line and the sorting column,
1619      while point should be in the last line to be included into the
1620      sorting.  The command prompts for the sorting type,
1621      alphabetically, numerically, or by time.  You can sort in normal
1622      or reverse order.  You can also supply your own key extraction
1623      and comparison functions.  When called with a prefix argument,
1624      alphabetic sorting is case-sensitive.
1626 *** Regions
1627 :PROPERTIES:
1628 :UNNUMBERED: notoc
1629 :END:
1631 - {{{kbd(C-c C-x M-w)}}} (~org-table-copy-region~) ::
1633      #+kindex: C-c C-x M-w
1634      #+findex: org-table-copy-region
1635      Copy a rectangular region from a table to a special clipboard.
1636      Point and mark determine edge fields of the rectangle.  If there
1637      is no active region, copy just the current field.  The process
1638      ignores horizontal separator lines.
1640 - {{{kbd(C-c C-x C-w)}}} (~org-table-cut-region~) ::
1642      #+kindex: C-c C-x C-w
1643      #+findex: org-table-cut-region
1644      Copy a rectangular region from a table to a special clipboard,
1645      and blank all fields in the rectangle.  So this is the "cut"
1646      operation.
1648 - {{{kbd(C-c C-x C-y)}}} (~org-table-paste-rectangle~) ::
1650      #+kindex: C-c C-x C-y
1651      #+findex: org-table-paste-rectangle
1652      Paste a rectangular region into a table.  The upper left corner
1653      ends up in the current field.  All involved fields are
1654      overwritten.  If the rectangle does not fit into the present
1655      table, the table is enlarged as needed.  The process ignores
1656      horizontal separator lines.
1658 - {{{kbd(M-RET)}}} (~org-table-wrap-region~) ::
1660      #+kindex: M-RET
1661      #+findex: org-table-wrap-region
1662      Split the current field at the cursor position and move the rest
1663      to the line below.  If there is an active region, and both point
1664      and mark are in the same column, the text in the column is
1665      wrapped to minimum width for the given number of lines.
1666      A numeric prefix argument may be used to change the number of
1667      desired lines.  If there is no region, but you specify a prefix
1668      argument, the current field is made blank, and the content is
1669      appended to the field above.
1671 *** Calculations
1672 :PROPERTIES:
1673 :UNNUMBERED: notoc
1674 :END:
1676 #+cindex: formula, in tables
1677 #+cindex: calculations, in tables
1679 - {{{kbd(C-c +)}}} (~org-table-sum~) ::
1681      #+kindex: C-c +
1682      #+findex: org-table-sum
1683      Sum the numbers in the current column, or in the rectangle
1684      defined by the active region.  The result is shown in the echo
1685      area and can be inserted with {{{kbd(C-y)}}}.
1687 - {{{kbd(S-RET)}}} (~org-table-copy-down~) ::
1689      #+kindex: S-RET
1690      #+findex: org-table-copy-down
1691      #+vindex: org-table-copy-increment
1692      When current field is empty, copy from first non-empty field
1693      above.  When not empty, copy current field down to next row and
1694      move cursor along with it.  Depending on the variable
1695      ~org-table-copy-increment~, integer field values can be
1696      incremented during copy.  Integers that are too large are not
1697      incremented, however.  Also, a ~0~ prefix argument temporarily
1698      disables the increment.  This key is also used by shift-selection
1699      and related modes (see [[*Packages that conflict with Org mode]]).
1701 *** Miscellaneous
1702 :PROPERTIES:
1703 :UNNUMBERED: notoc
1704 :END:
1706 - {{{kbd(C-c `)}}} (~org-table-edit-field~) ::
1708      #+kindex: C-c `
1709      #+findex: org-table-edit-field
1710      Edit the current field in a separate window.  This is useful for
1711      fields that are not fully visible (see [[*Column Width and
1712      Alignment]]).  When called with a {{{kbd(C-u)}}} prefix, just make
1713      the full field visible, so that it can be edited in place.  When
1714      called with two {{{kbd(C-u)}}} prefixes, make the editor window
1715      follow the cursor through the table and always show the current
1716      field.  The follow mode exits automatically when the cursor
1717      leaves the table, or when you repeat this command with {{{kbd(C-u
1718      C-u C-c `)}}}.
1720 - {{{kbd(M-x org-table-import)}}} ::
1722      #+findex: org-table-import
1723      Import a file as a table.  The table should be TAB or whitespace
1724      separated.  Use, for example, to import a spreadsheet table or
1725      data from a database, because these programs generally can write
1726      TAB-separated text files.  This command works by inserting the
1727      file into the buffer and then converting the region to a table.
1728      Any prefix argument is passed on to the converter, which uses it
1729      to determine the separator.
1731 - {{{kbd(C-c |)}}} (~org-table-create-or-convert-from-region~) ::
1733      #+kindex: C-c |
1734      #+findex: org-table-create-or-convert-from-region
1735      Tables can also be imported by pasting tabular text into the Org
1736      buffer, selecting the pasted text with {{{kbd(C-x C-x)}}} and
1737      then using the {{{kbd(C-c |)}}} command (see [[*Creation and
1738      conversion]]).
1740 - {{{kbd(M-x org-table-export)}}} ::
1742      #+findex: org-table-export
1743      #+vindex: org-table-export-default-format
1744      Export the table, by default as a TAB-separated file.  Use for
1745      data exchange with, for example, spreadsheet or database
1746      programs.  The format used to export the file can be configured
1747      in the variable ~org-table-export-default-format~.  You may also
1748      use properties =TABLE_EXPORT_FILE= and =TABLE_EXPORT_FORMAT= to
1749      specify the file name and the format for table export in
1750      a subtree.  Org supports quite general formats for exported
1751      tables.  The exporter format is the same as the format used by
1752      Orgtbl radio tables, see [[*Translator functions]], for a detailed
1753      description.
1755 ** Column Width and Alignment
1756 :PROPERTIES:
1757 :DESCRIPTION: Overrule the automatic settings.
1758 :END:
1759 #+cindex: narrow columns in tables
1760 #+cindex: alignment in tables
1762 The width of columns is automatically determined by the table editor.
1763 The alignment of a column is determined automatically from the
1764 fraction of number-like versus non-number fields in the column.
1766 #+vindex: org-table-automatic-realign
1767 Editing a field may modify alignment of the table.  Moving
1768 a contiguous row or column---i.e., using {{{kbd(TAB)}}} or
1769 {{{kbd(RET)}}}---automatically re-aligns it.  If you want to disable
1770 this behavior, set ~org-table-automatic-realign~ to ~nil~.  In any
1771 case, you can always align manually a table:
1773 - {{{kbd(C-c C-c)}}} (~org-table-align~) ::
1775      #+kindex: C-c C-c
1776      #+findex: org-table-align
1777      Align the current table.
1779 #+texinfo: @noindent
1780 #+vindex: org-startup-align-all-tables
1781 Setting the option ~org-startup-align-all-tables~ re-aligns all tables
1782 in a file upon visiting it.  You can also set this option on
1783 a per-file basis with:
1785 #+begin_example
1786   ,#+STARTUP: align
1787   ,#+STARTUP: noalign
1788 #+end_example
1790 Sometimes a single field or a few fields need to carry more text,
1791 leading to inconveniently wide columns.  Maybe you want to hide away
1792 several columns or display them with a fixed width, regardless of
1793 content, as shown in the following example.
1795 #+begin_example
1796   |---+---------------------+--------|           |---+-------…|…|
1797   |   | <6>                 |        |           |   | <6>   â€¦|…|
1798   | 1 | one                 | some   |   ----\   | 1 | one   â€¦|…|
1799   | 2 | two                 | boring |   ----/   | 2 | two   â€¦|…|
1800   | 3 | This is a long text | column |           | 3 | This i…|…|
1801   |---+---------------------+--------|           |---+-------…|…|
1802 #+end_example
1804 To set the width of a column, one field anywhere in the column may
1805 contain just the string =<N>= where {{{var(N)}}} specifies the width
1806 as a number of characters.  You control displayed width of columns
1807 with the following tools:
1809 - {{{kbd(C-c TAB)}}} (~org-table-toggle-column-width~) ::
1811      #+kindex: C-c TAB
1812      #+findex: org-table-toggle-column-width
1813      Shrink or expand current column.
1815      If a width cookie specifies a width W for the column, shrinking
1816      it displays the first W visible characters only.  Otherwise, the
1817      column is shrunk to a single character.
1819      When called before the first column or after the last one, ask
1820      for a list of column ranges to operate on.
1822 - {{{kbd(C-u C-c TAB)}}} (~org-table-shrink~) ::
1824      #+kindex: C-u C-c TAB
1825      #+findex: org-table-shrink
1826      Shrink all columns with a column width.  Expand the others.
1828 - {{{kbd(C-u C-u C-c TAB)}}} (~org-table-expand~) ::
1830      #+kindex: C-u C-u C-c TAB
1831      #+findex: org-table-expand
1832      Expand all columns.
1834 To see the full text of a shrunk field, hold the mouse over it---a
1835 tool-tip window then shows the full content.  Alternatively {{{kbd(C-h
1836 .)}}}  (~display-local-help~) reveals the full content.  For
1837 convenience, any change to a shrunk column expands it.
1839 #+vindex: org-startup-shrink-all-tables
1840 Setting the option ~org-startup-shrink-all-tables~ shrinks all columns
1841 containing a width cookie in a file the moment it is visited.  You can
1842 also set this option on a per-file basis with:
1844 : #+STARTUP: shrink
1846 If you would like to overrule the automatic alignment of number-rich
1847 columns to the right and of string-rich columns to the left, you can
1848 use =<r>=, =<c>= or =<l>= in a similar fashion.  You may also combine
1849 alignment and field width like this: =<r10>=.
1851 Lines which only contain these formatting cookies are removed
1852 automatically upon exporting the document.
1854 ** Column Groups
1855 :PROPERTIES:
1856 :DESCRIPTION: Grouping to trigger vertical lines.
1857 :END:
1858 #+cindex: grouping columns in tables
1860 When Org exports tables, it does so by default without vertical lines
1861 because that is visually more satisfying in general.  Occasionally
1862 however, vertical lines can be useful to structure a table into groups
1863 of columns, much like horizontal lines can do for groups of rows.  In
1864 order to specify column groups, you can use a special row where the
1865 first field contains only =/=.  The further fields can either contain
1866 =<= to indicate that this column should start a group, =>= to indicate
1867 the end of a column, or =<>= (no space between =<= and =>=) to make
1868 a column a group of its own.  Upon export, boundaries between column
1869 groups are marked with vertical lines.  Here is an example:
1871 #+begin_example
1872   | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1873   |---+-----+-----+-----+---------+------------|
1874   | / |  <  |     |  >  |       < |          > |
1875   | 1 |  1  |  1  |  1  |       1 |          1 |
1876   | 2 |  4  |  8  | 16  |  1.4142 |     1.1892 |
1877   | 3 |  9  | 27  | 81  |  1.7321 |     1.3161 |
1878   |---+-----+-----+-----+---------+------------|
1879   ,#+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
1880 #+end_example
1882 It is also sufficient to just insert the column group starters after
1883 every vertical line you would like to have:
1885 #+begin_example
1886   | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1887   |---+-----+-----+-----+---------+------------|
1888   | / | <   |     |     | <       |            |
1889 #+end_example
1891 ** The Orgtbl Minor Mode
1892 :PROPERTIES:
1893 :DESCRIPTION: The table editor as minor mode.
1894 :ALT_TITLE: Orgtbl Mode
1895 :END:
1896 #+cindex: Orgtbl mode
1897 #+cindex: minor mode for tables
1899 #+findex: orgtbl-mode
1900 If you like the intuitive way the Org table editor works, you might
1901 also want to use it in other modes like Text mode or Mail mode.  The
1902 minor mode Orgtbl mode makes this possible.  You can always toggle the
1903 mode with {{{kbd(M-x orgtbl-mode)}}}.  To turn it on by default, for
1904 example in Message mode, use
1906 #+begin_src emacs-lisp
1907   (add-hook 'message-mode-hook 'turn-on-orgtbl)
1908 #+end_src
1910 Furthermore, with some special setup, it is possible to maintain
1911 tables in arbitrary syntax with Orgtbl mode.  For example, it is
1912 possible to construct LaTeX tables with the underlying ease and power
1913 of Orgtbl mode, including spreadsheet capabilities.  For details, see
1914 [[*Tables in Arbitrary Syntax]].
1916 ** The spreadsheet
1917 :PROPERTIES:
1918 :DESCRIPTION: The table editor has spreadsheet capabilities.
1919 :END:
1920 #+cindex: calculations, in tables
1921 #+cindex: spreadsheet capabilities
1922 #+cindex: Calc package
1924 The table editor makes use of the Emacs Calc package to implement
1925 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms
1926 to derive fields from other fields.  While fully featured, Org's
1927 implementation is not identical to other spreadsheets.  For example,
1928 Org knows the concept of a /column formula/ that will be applied to
1929 all non-header fields in a column without having to copy the formula
1930 to each relevant field.  There is also a formula debugger, and
1931 a formula editor with features for highlighting fields in the table
1932 corresponding to the references at the point in the formula, moving
1933 these references by arrow keys.
1935 *** References
1936 :PROPERTIES:
1937 :DESCRIPTION: How to refer to another field or range.
1938 :END:
1939 #+cindex: references
1941 To compute fields in the table from other fields, formulas must
1942 reference other fields or ranges.  In Org, fields can be referenced by
1943 name, by absolute coordinates, and by relative coordinates.  To find
1944 out what the coordinates of a field are, press {{{kbd(C-c ?)}}} in
1945 that field, or press {{{kbd(C-c })}}} to toggle the display of a grid.
1947 **** Field references
1948 :PROPERTIES:
1949 :UNNUMBERED: notoc
1950 :END:
1952 #+cindex: field references
1953 #+cindex: references, to fields
1954 Formulas can reference the value of another field in two ways.  Like
1955 in any other spreadsheet, you may reference fields with
1956 a letter/number combination like =B3=, meaning the second field in the
1957 third row.  However, Org prefers to use another, more general
1958 representation that looks like this:[fn:20]
1960 : @ROW$COLUMN
1962 Column specifications can be absolute like =$1=, =$2=, ..., =$N=, or
1963 relative to the current column, i.e., the column of the field which is
1964 being computed, like =$+1= or =$-2=.  =$<= and =$>= are immutable
1965 references to the first and last column, respectively, and you can use
1966 =$>>>= to indicate the third column from the right.
1968 The row specification only counts data lines and ignores horizontal
1969 separator lines, or "hlines".  Like with columns, you can use absolute
1970 row numbers =@1=, =@2=, ..., =@N=, and row numbers relative to the
1971 current row like =@+3= or =@-1=.  =@<= and =@>= are immutable
1972 references the first and last row in the table, respectively.  You may
1973 also specify the row relative to one of the hlines: =@I= refers to the
1974 first hline, =@II= to the second, etc.  =@-I= refers to the first such
1975 line above the current line, =@+I= to the first such line below the
1976 current line.  You can also write =@III+2= which is the second data
1977 line after the third hline in the table.
1979 =@0= and =$0= refer to the current row and column, respectively, i.e.,
1980 to the row/column for the field being computed.  Also, if you omit
1981 either the column or the row part of the reference, the current
1982 row/column is implied.
1984 Org's references with /unsigned/ numbers are fixed references in the
1985 sense that if you use the same reference in the formula for two
1986 different fields, the same field is referenced each time.  Org's
1987 references with /signed/ numbers are floating references because the
1988 same reference operator can reference different fields depending on
1989 the field being calculated by the formula.
1991 Here are a few examples:
1993 #+attr_texinfo: :columns 0.2 0.8
1994 | =@2$3=   | 2nd row, 3rd column (same as =C2=)                 |
1995 | =$5=     | column 5 in the current row (same as =E&=)         |
1996 | =@2=     | current column, row 2                              |
1997 | =@-1$-3= | field one row up, three columns to the left        |
1998 | =@-I$2=  | field just under hline above current row, column 2 |
1999 | =@>$5=   | field in the last row, in column 5                 |
2001 **** Range references
2002 :PROPERTIES:
2003 :UNNUMBERED: notoc
2004 :END:
2006 #+cindex: range references
2007 #+cindex: references, to ranges
2008 You may reference a rectangular range of fields by specifying two
2009 field references connected by two dots =..=.  If both fields are in
2010 the current row, you may simply use =$2..$7=, but if at least one
2011 field is in a different row, you need to use the general =@ROW$COLUMN=
2012 format at least for the first field, i.e., the reference must start
2013 with =@= in order to be interpreted correctly.  Examples:
2015 #+attr_texinfo: :columns 0.2 0.8
2016 | =$1..$3=      | first three fields in the current row                          |
2017 | =$P..$Q=      | range, using column names (see [[*Advanced features]])             |
2018 | =$<<<..$>>=   | start in third column, continue to the last but one            |
2019 | =@2$1..@4$3=  | six fields between these two fields (same as =A2..C4=)         |
2020 | =@-1$-2..@-1= | 3 fields in the row above, starting from 2 columns on the left |
2021 | =@I..II=      | between first and second hline, short for =@I..@II=            |
2023 #+texinfo: @noindent
2024 Range references return a vector of values that can be fed into Calc
2025 vector functions.  Empty fields in ranges are normally suppressed, so
2026 that the vector contains only the non-empty fields.  For other options
2027 with the mode switches =E=, =N= and examples, see [[*Formula syntax for
2028 Calc]].
2030 **** Field coordinates in formulas
2031 :PROPERTIES:
2032 :UNNUMBERED: notoc
2033 :END:
2035 #+cindex: field coordinates
2036 #+cindex: coordinates, of field
2037 #+cindex: row, of field coordinates
2038 #+cindex: column, of field coordinates
2039 #+vindex: org-table-current-column
2040 #+vindex: org-table-current-dline
2041 One of the very first actions during evaluation of Calc formulas and
2042 Lisp formulas is to substitute =@#= and =$#= in the formula with the
2043 row or column number of the field where the current result will go to.
2044 The traditional Lisp formula equivalents are ~org-table-current-dline~
2045 and ~org-table-current-column~.  Examples:
2047 - =if(@# % 2, $#, string(""))= ::
2049      Insert column number on odd rows, set field to empty on even
2050      rows.
2052 - =$2 = '(identity remote(FOO, @@#$1))= ::
2054      Copy text or values of each row of column 1 of the table named
2055      {{{var(FOO)}}} into column 2 of the current table.
2057 - =@3 = 2 * remote(FOO, @@1$$#)= ::
2059      Insert the doubled value of each column of row 1 of the table
2060      named {{{var(FOO)}}} into row 3 of the current table.
2062 #+texinfo: @noindent
2063 For the second and third examples, table {{{var(FOO)}}} must have at
2064 least as many rows or columns as the current table.  Note that this is
2065 inefficient[fn:21] for large number of rows.
2067 **** Named references
2068 :PROPERTIES:
2069 :UNNUMBERED: notoc
2070 :END:
2071 #+cindex: named references
2072 #+cindex: references, named
2073 #+cindex: name, of column or field
2074 #+cindex: constants, in calculations
2075 #+cindex: CONSTANTS, keyword
2076 #+vindex: org-table-formula-constants
2078 =$name= is interpreted as the name of a column, parameter or constant.
2079 Constants are defined globally through the variable
2080 ~org-table-formula-constants~, and locally---for the file---through
2081 a line like this example:
2083 : #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2085 #+texinfo: @noindent
2086 #+vindex: constants-unit-system
2087 #+pindex: constants.el
2088 Also, properties (see [[*Properties and Columns]]) can be used as
2089 constants in table formulas: for a property =Xyz= use the name
2090 =$PROP_Xyz=, and the property will be searched in the current outline
2091 entry and in the hierarchy above it.  If you have the =constants.el=
2092 package, it will also be used to resolve constants, including natural
2093 constants like =$h= for Planck's constant, and units like =$km= for
2094 kilometers[fn:22].  Column names and parameters can be specified in
2095 special table lines.  These are described below, see [[*Advanced
2096 features]].  All names must start with a letter, and further consist of
2097 letters and numbers.
2099 **** Remote references
2100 :PROPERTIES:
2101 :UNNUMBERED: notoc
2102 :END:
2104 #+cindex: remote references
2105 #+cindex: references, remote
2106 #+cindex: references, to a different table
2107 #+cindex: name, of column or field
2108 #+cindex: constants, in calculations
2109 #+cindex: NAME, keyword
2110 You may also reference constants, fields and ranges from a different
2111 table, either in the current file or even in a different file.  The
2112 syntax is
2114 : remote(NAME,REF)
2116 #+texinfo: @noindent
2117 where {{{var(NAME)}}} can be the name of a table in the current file
2118 as set by a =#+NAME:= line before the table.  It can also be the ID of
2119 an entry, even in a different file, and the reference then refers to
2120 the first table in that entry.  {{{var(REF)}}} is an absolute field or
2121 range reference as described above for example =@3$3= or =$somename=,
2122 valid in the referenced table.
2124 #+cindex: table indirection
2125 When {{{var(NAME)}}} has the format =@ROW$COLUMN=, it is substituted
2126 with the name or ID found in this field of the current table.  For
2127 example =remote($1, @@>$2)= \Rightarrow =remote(year_2013, @@>$1)=.  The format
2128 =B3= is not supported because it can not be distinguished from a plain
2129 table name or ID.
2131 *** Formula syntax for Calc
2132 :PROPERTIES:
2133 :DESCRIPTION: Using Calc to compute stuff.
2134 :END:
2135 #+cindex: formula syntax, Calc
2136 #+cindex: syntax, of formulas
2138 A formula can be any algebraic expression understood by the Emacs
2139 =Calc= package. Note that =calc= has the non-standard convention that
2140 =/= has lower precedence than =*=, so that =a/b*c= is interpreted as
2141 =(a/(b*c))=.  Before evaluation by ~calc-eval~ (see [[info:calc#Calling Calc from Your Programs][Calling Calc from
2142 Your Lisp Programs]]), variable substitution takes place according to
2143 the rules described above.
2145 #+cindex: vectors, in table calculations
2146 The range vectors can be directly fed into the Calc vector functions
2147 like ~vmean~ and ~vsum~.
2149 #+cindex: format specifier, in spreadsheet
2150 #+cindex: mode, for Calc
2151 #+vindex: org-calc-default-modes
2152 A formula can contain an optional mode string after a semicolon.  This
2153 string consists of flags to influence Calc and other modes during
2154 execution.  By default, Org uses the standard Calc modes (precision
2155 12, angular units degrees, fraction and symbolic modes off).  The
2156 display format, however, has been changed to ~(float 8)~ to keep
2157 tables compact.  The default settings can be configured using the
2158 variable ~org-calc-default-modes~.
2160 - =p20= ::
2162      Set the internal Calc calculation precision to 20 digits.
2164 - =n3=, =s3=, =e2=, =f4= ::
2166      Normal, scientific, engineering or fixed format of the result of
2167      Calc passed back to Org.  Calc formatting is unlimited in
2168      precision as long as the Calc calculation precision is greater.
2170 - =D=, =R= ::
2172      Degree and radian angle modes of Calc.
2174 - =F=, =S= ::
2176      Fraction and symbolic modes of Calc.
2178 - =T=, =t=, =U= ::
2180      Duration computations in Calc or Lisp, [[*Durations and time
2181      values]].
2183 - =E= ::
2185      If and how to consider empty fields.  Without =E= empty fields in
2186      range references are suppressed so that the Calc vector or Lisp
2187      list contains only the non-empty fields.  With =E= the empty
2188      fields are kept.  For empty fields in ranges or empty field
2189      references the value =nan= (not a number) is used in Calc
2190      formulas and the empty string is used for Lisp formulas.  Add =N=
2191      to use 0 instead for both formula types.  For the value of
2192      a field the mode =N= has higher precedence than =E=.
2194 - =N= ::
2196      Interpret all fields as numbers, use 0 for non-numbers.  See the
2197      next section to see how this is essential for computations with
2198      Lisp formulas.  In Calc formulas it is used only occasionally
2199      because there number strings are already interpreted as numbers
2200      without =N=.
2202 - =L= ::
2204      Literal, for Lisp formulas only.  See the next section.
2206 #+texinfo: @noindent
2207 Unless you use large integer numbers or high-precision calculation and
2208 display for floating point numbers you may alternatively provide
2209 a ~printf~ format specifier to reformat the Calc result after it has
2210 been passed back to Org instead of letting Calc already do the
2211 formatting[fn:23].  A few examples:
2213 | =$1+$2=            | Sum of first and second field                    |
2214 | =$1+$2;%.2f=       | Same, format result to two decimals              |
2215 | =exp($2)+exp($1)=  | Math functions can be used                       |
2216 | =$0;%.1f=          | Reformat current cell to 1 decimal               |
2217 | =($3-32)*5/9=      | Degrees F \to C conversion                         |
2218 | =$c/$1/$cm=        | Hz \to cm conversion, using =constants.el=         |
2219 | =tan($1);Dp3s1=    | Compute in degrees, precision 3, display SCI 1   |
2220 | =sin($1);Dp3%.1e=  | Same, but use ~printf~ specifier for display     |
2221 | =vmean($2..$7)=    | Compute column range mean, using vector function |
2222 | =vmean($2..$7);EN= | Same, but treat empty fields as 0                |
2223 | =taylor($3,x=7,2)= | Taylor series of $3, at x=7, second degree       |
2225 Calc also contains a complete set of logical operations (see [[info:calc#Logical%20Operations][Logical
2226 Operations]]).  For example
2228 - =if($1 < 20, teen, string(""))= ::
2230      ="teen"= if age =$1= is less than 20, else the Org table result
2231      field is set to empty with the empty string.
2233 - =if("$1" == "nan" || "$2" == "nan", string(""), $1 + $2); E f-1= ::
2235      Sum of the first two columns.  When at least one of the input
2236      fields is empty the Org table result field is set to empty.  =E=
2237      is required to not convert empty fields to 0.  =f-1= is an
2238      optional Calc format string similar to =%.1f= but leaves empty
2239      results empty.
2241 - =if(typeof(vmean($1..$7)) == 12, string(""), vmean($1..$7); E= ::
2243      Mean value of a range unless there is any empty field.  Every
2244      field in the range that is empty is replaced by =nan= which lets
2245      =vmean= result in =nan=.  Then =typeof == 12= detects the =nan=
2246      from ~vmean~ and the Org table result field is set to empty.  Use
2247      this when the sample set is expected to never have missing
2248      values.
2250 - =if("$1..$7" == "[]", string(""), vmean($1..$7))= ::
2252      Mean value of a range with empty fields skipped.  Every field in
2253      the range that is empty is skipped.  When all fields in the range
2254      are empty the mean value is not defined and the Org table result
2255      field is set to empty.  Use this when the sample set can have
2256      a variable size.
2258 - =vmean($1..$7); EN= ::
2260      To complete the example before: Mean value of a range with empty
2261      fields counting as samples with value 0.  Use this only when
2262      incomplete sample sets should be padded with 0 to the full size.
2264 You can add your own Calc functions defined in Emacs Lisp with
2265 ~defmath~ and use them in formula syntax for Calc.
2267 *** Emacs Lisp forms as formulas
2268 :PROPERTIES:
2269 :DESCRIPTION: Writing formulas in Emacs Lisp.
2270 :ALT_TITLE: Formula syntax for Lisp
2271 :END:
2272 #+cindex: Lisp forms, as table formulas
2274 It is also possible to write a formula in Emacs Lisp.  This can be
2275 useful for string manipulation and control structures, if Calc's
2276 functionality is not enough.
2278 If a formula starts with a single-quote followed by an opening
2279 parenthesis, then it is evaluated as a Lisp form.  The evaluation
2280 should return either a string or a number.  Just as with Calc
2281 formulas, you can specify modes and a ~printf~ format after
2282 a semicolon.
2284 With Emacs Lisp forms, you need to be conscious about the way field
2285 references are interpolated into the form.  By default, a reference is
2286 interpolated as a Lisp string (in double-quotes) containing the field.
2287 If you provide the =N= mode switch, all referenced elements are
2288 numbers---non-number fields will be zero---and interpolated as Lisp
2289 numbers, without quotes.  If you provide the =L= flag, all fields are
2290 interpolated literally, without quotes.  I.e., if you want a reference
2291 to be interpreted as a string by the Lisp form, enclose the reference
2292 operator itself in double-quotes, like ="$3"=.  Ranges are inserted as
2293 space-separated fields, so you can embed them in list or vector
2294 syntax.
2296 Here are a few examples---note how the =N= mode is used when we do
2297 computations in Lisp:
2299 - ='(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))= ::
2301      Swap the first two characters of the content of column 1.
2303 - ='(+ $1 $2);N= ::
2305      Add columns 1 and 2, equivalent to Calc's =$1+$2=.
2307 - ='(apply '+ '($1..$4));N= ::
2309      Compute the sum of columns 1 to 4, like Calc's =vsum($1..$4)=.
2311 *** Durations and time values
2312 :PROPERTIES:
2313 :DESCRIPTION: How to compute durations and time values.
2314 :END:
2315 #+cindex: Duration, computing
2316 #+cindex: Time, computing
2317 #+vindex: org-table-duration-custom-format
2319 If you want to compute time values use the =T=, =t=, or =U= flag,
2320 either in Calc formulas or Elisp formulas:
2322 #+begin_example
2323   |  Task 1 |   Task 2 |    Total |
2324   |---------+----------+----------|
2325   |    2:12 |     1:47 | 03:59:00 |
2326   |    2:12 |     1:47 |    03:59 |
2327   | 3:02:20 | -2:07:00 |     0.92 |
2328   ,#+TBLFM: @2$3=$1+$2;T::@3$3=$1+$2;U::@4$3=$1+$2;t
2329 #+end_example
2331 Input duration values must be of the form =HH:MM[:SS]=, where seconds
2332 are optional.  With the =T= flag, computed durations are displayed as
2333 =HH:MM:SS= (see the first formula above).  With the =U= flag, seconds
2334 are omitted so that the result is only =HH:MM= (see second formula
2335 above).  Zero-padding of the hours field depends upon the value of the
2336 variable ~org-table-duration-hour-zero-padding~.
2338 With the =t= flag, computed durations are displayed according to the
2339 value of the option ~org-table-duration-custom-format~, which defaults
2340 to ~hours~ and displays the result as a fraction of hours (see the
2341 third formula in the example above).
2343 Negative duration values can be manipulated as well, and integers are
2344 considered as seconds in addition and subtraction.
2346 *** Field and range formulas
2347 :PROPERTIES:
2348 :DESCRIPTION: Formula for specific (ranges of) fields.
2349 :END:
2350 #+cindex: field formula
2351 #+cindex: range formula
2352 #+cindex: formula, for individual table field
2353 #+cindex: formula, for range of fields
2355 To assign a formula to a particular field, type it directly into the
2356 field, preceded by =:==, for example =vsum(@II..III)=.  When you press
2357 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with the cursor
2358 still in the field, the formula is stored as the formula for this
2359 field, evaluated, and the current field is replaced with the result.
2361 #+cindex: TBLFM, keyword
2362 Formulas are stored in a special =TBLFM= keyword located directly
2363 below the table.  If you type the equation in the fourth field of the
2364 third data line in the table, the formula looks like =@3$4=$1+$2=.
2365 When inserting/deleting/swapping column and rows with the appropriate
2366 commands, /absolute references/ (but not relative ones) in stored
2367 formulas are modified in order to still reference the same field.  To
2368 avoid this from happening, in particular in range references, anchor
2369 ranges at the table borders (using =@<=, =@>=, =$<=, =$>=), or at
2370 hlines using the =@I= notation.  Automatic adaptation of field
2371 references does of course not happen if you edit the table structure
2372 with normal editing commands---then you must fix the equations
2373 yourself.
2375 Instead of typing an equation into the field, you may also use the
2376 following command
2378 - {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2380      #+kindex: C-u C-c =
2381      #+findex: org-table-eval-formula
2382      Install a new formula for the current field.  The command prompts
2383      for a formula with default taken from the =TBLFM= keyword,
2384      applies it to the current field, and stores it.
2386 The left-hand side of a formula can also be a special expression in
2387 order to assign the formula to a number of different fields.  There is
2388 no keyboard shortcut to enter such range formulas.  To add them, use
2389 the formula editor (see [[*Editing and debugging formulas]]) or edit the
2390 =TBLFM= keyword directly.
2392 - =$2== ::
2394      Column formula, valid for the entire column.  This is so common
2395      that Org treats these formulas in a special way, see [[*Column
2396      formulas]].
2398 - ~@3=~ ::
2400      Row formula, applies to all fields in the specified row.  =@>==
2401      means the last row.
2403 - =@1$2..@4$3== ::
2405      Range formula, applies to all fields in the given rectangular
2406      range.  This can also be used to assign a formula to some but not
2407      all fields in a row.
2409 - =$NAME== ::
2411      Named field, see [[*Advanced features]].
2413 *** Column formulas
2414 :PROPERTIES:
2415 :DESCRIPTION: Formulas valid for an entire column.
2416 :END:
2417 #+cindex: column formula
2418 #+cindex: formula, for table column
2420 When you assign a formula to a simple column reference like =$3==, the
2421 same formula is used in all fields of that column, with the following
2422 very convenient exceptions: (i) If the table contains horizontal
2423 separator hlines with rows above and below, everything before the
2424 first such hline is considered part of the table /header/ and is not
2425 modified by column formulas.  Therefore a header is mandatory when you
2426 use column formulas and want to add hlines to group rows, like for
2427 example to separate a total row at the bottom from the summand rows
2428 above.  (ii) Fields that already get a value from a field/range
2429 formula are left alone by column formulas.  These conditions make
2430 column formulas very easy to use.
2432 To assign a formula to a column, type it directly into any field in
2433 the column, preceded by an equal sign, like ==$1+$2=.  When you press
2434 {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(C-c C-c)}}} with the cursor
2435 still in the field, the formula is stored as the formula for the
2436 current column, evaluated and the current field replaced with the
2437 result.  If the field contains only ===, the previously stored formula
2438 for this column is used.  For each column, Org only remembers the most
2439 recently used formula.  In the =TBLFM= keyword, column formulas look
2440 like =$4=$1+$2=.  The left-hand side of a column formula can not be
2441 the name of column, it must be the numeric column reference or =$>=.
2443 Instead of typing an equation into the field, you may also use the
2444 following command:
2446 - {{{kbd(C-c =)}}} (~org-table-eval-formula~) ::
2448      #+kindex: C-c =
2449      #+findex: org-table-eval-formula
2450      Install a new formula for the current column and replace current
2451      field with the result of the formula.  The command prompts for
2452      a formula, with default taken from the =TBLFM= keyword, applies
2453      it to the current field and stores it.  With a numeric prefix
2454      argument, e.g., {{{kbd(C-5 C-c =)}}}, the command applies it to
2455      that many consecutive fields in the current column.
2457 *** Lookup functions
2458 :PROPERTIES:
2459 :DESCRIPTION: Lookup functions for searching tables.
2460 :END:
2461 #+cindex: lookup functions in tables
2462 #+cindex: table lookup functions
2464 Org has three predefined Emacs Lisp functions for lookups in tables.
2466 - ~(org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)~ ::
2468      #+findex: org-lookup-first
2469      Searches for the first element {{{var(S)}}} in list
2470      {{{var(S-LIST)}}} for which
2471      #+begin_src emacs-lisp
2472        (PREDICATE VAL S)
2473      #+end_src
2474      is non-~nil~; returns the value from the corresponding position
2475      in list {{{var(R-LIST)}}}.  The default {{{var(PREDICATE)}}} is
2476      ~equal~.  Note that the parameters {{{var(VAL)}}} and
2477      {{{var(S)}}} are passed to {{{var(PREDICATE)}}} in the same order
2478      as the corresponding parameters are in the call to
2479      ~org-lookup-first~, where {{{var(VAL)}}} precedes
2480      {{{var(S-LIST)}}}.  If {{{var(R-LIST)}}} is ~nil~, the matching
2481      element {{{var(S)}}} of {{{var(S-LIST)}}} is returned.
2483 - ~(org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)~ ::
2485      #+findex: org-lookup-last
2486      Similar to ~org-lookup-first~ above, but searches for the /last/
2487      element for which {{{var(PREDICATE)}}} is non-~nil~.
2489 - ~(org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)~ ::
2491      #+findex: org-lookup-all
2492      Similar to ~org-lookup-first~, but searches for /all/ elements
2493      for which {{{var(PREDICATE)}}} is non-~nil~, and returns /all/
2494      corresponding values.  This function can not be used by itself in
2495      a formula, because it returns a list of values.  However,
2496      powerful lookups can be built when this function is combined with
2497      other Emacs Lisp functions.
2499 If the ranges used in these functions contain empty fields, the =E=
2500 mode for the formula should usually be specified: otherwise empty
2501 fields are not included in {{{var(S-LIST)}}} and/or {{{var(R-LIST)}}}
2502 which can, for example, result in an incorrect mapping from an element
2503 of {{{var(S-LIST)}}} to the corresponding element of
2504 {{{var(R-LIST)}}}.
2506 These three functions can be used to implement associative arrays,
2507 count matching cells, rank results, group data, etc.  For practical
2508 examples see [[https://orgmode.org/worg/org-tutorials/org-lookups.html][this tutorial on Worg]].
2510 *** Editing and debugging formulas
2511 :PROPERTIES:
2512 :DESCRIPTION: Fixing formulas.
2513 :END:
2514 #+cindex: formula editing
2515 #+cindex: editing, of table formulas
2517 #+vindex: org-table-use-standard-references
2518 You can edit individual formulas in the minibuffer or directly in the
2519 field.  Org can also prepare a special buffer with all active formulas
2520 of a table.  When offering a formula for editing, Org converts
2521 references to the standard format (like =B3= or =D&=) if possible.  If
2522 you prefer to only work with the internal format (like =@3$2= or
2523 =$4=), configure the variable ~org-table-use-standard-references~.
2525 - {{{kbd(C-c =)}}} or {{{kbd(C-u C-c =)}}} (~org-table-eval-formula~) ::
2527      #+kindex: C-c =
2528      #+kindex: C-u C-c =
2529      #+findex: org-table-eval-formula
2530      Edit the formula associated with the current column/field in the
2531      minibuffer.  See [[*Column formulas]], and [[*Field and range formulas]].
2533 - {{{kbd(C-u C-u C-c =)}}} (~org-table-eval-formula~) ::
2535      #+kindex: C-u C-u C-c =
2536      #+findex: org-table-eval-formula
2537      Re-insert the active formula (either a field formula, or a column
2538      formula) into the current field, so that you can edit it directly
2539      in the field.  The advantage over editing in the minibuffer is
2540      that you can use the command {{{kbd(C-c ?)}}}.
2542 - {{{kbd(C-c ?)}}} (~org-table-field-info~) ::
2544      #+kindex: C-c ?
2545      #+findex: org-table-field-info
2546      While editing a formula in a table field, highlight the field(s)
2547      referenced by the reference at the cursor position in the
2548      formula.
2550 - {{{kbd(C-c })}}} (~org-table-toggle-coordinate-overlays~) ::
2552      #+kindex: C-c @}
2553      #+findex: org-table-toggle-coordinate-overlays
2554      Toggle the display of row and column numbers for a table, using
2555      overlays.  These are updated each time the table is aligned; you
2556      can force it with {{{kbd(C-c C-c)}}}.
2558 - {{{kbd(C-c {)}}} (~org-table-toggle-formula-debugger~) ::
2560      #+kindex: C-c @{
2561      #+findex: org-table-toggle-formula-debugger
2562      Toggle the formula debugger on and off.  See below.
2564 - {{{kbd(C-c ')}}} (~org-table-edit-formulas~) ::
2566      #+kindex: C-c '
2567      #+findex: org-table-edit-formulas
2568      Edit all formulas for the current table in a special buffer,
2569      where the formulas are displayed one per line.  If the current
2570      field has an active formula, the cursor in the formula editor
2571      marks it.  While inside the special buffer, Org automatically
2572      highlights any field or range reference at the cursor position.
2573      You may edit, remove and add formulas, and use the following
2574      commands:
2576      - {{{kbd(C-c C-c)}}} or {{{kbd(C-x C-s)}}} (~org-table-fedit-finish~) ::
2578           #+kindex: C-x C-s
2579           #+kindex: C-c C-c
2580           #+findex: org-table-fedit-finish
2581           Exit the formula editor and store the modified formulas.  With
2582           {{{kbd(C-u)}}} prefix, also apply the new formulas to the
2583           entire table.
2585      - {{{kbd(C-c C-q)}}} (~org-table-fedit-abort~) ::
2587           #+kindex: C-c C-q
2588           #+findex: org-table-fedit-abort
2589           Exit the formula editor without installing changes.
2591      - {{{kbd(C-c C-r)}}} (~org-table-fedit-toggle-ref-type~) ::
2593           #+kindex: C-c C-r
2594           #+findex: org-table-fedit-toggle-ref-type
2595           Toggle all references in the formula editor between standard
2596           (like =B3=) and internal (like =@3$2=).
2598      - {{{kbd(TAB)}}} (~org-table-fedit-lisp-indent~) ::
2600           #+kindex: TAB
2601           #+findex: org-table-fedit-lisp-indent
2602           Pretty-print or indent Lisp formula at point.  When in a line
2603           containing a Lisp formula, format the formula according to
2604           Emacs Lisp rules.  Another {{{kbd(TAB)}}} collapses the formula
2605           back again.  In the open formula, {{{kbd(TAB)}}} re-indents
2606           just like in Emacs Lisp mode.
2608      - {{{kbd(M-TAB)}}} (~lisp-complete-symbol~) ::
2610           #+kindex: M-TAB
2611           #+findex: lisp-complete-symbol
2612           Complete Lisp symbols, just like in Emacs Lisp mode.
2614      - {{{kbd(S-up)}}}, {{{kbd(S-down)}}}, {{{kbd(S-left)}}}, {{{kbd(S-right)}}} ::
2616           #+kindex: S-up
2617           #+kindex: S-down
2618           #+kindex: S-left
2619           #+kindex: S-right
2620           #+findex: org-table-fedit-ref-up
2621           #+findex: org-table-fedit-ref-down
2622           #+findex: org-table-fedit-ref-left
2623           #+findex: org-table-fedit-ref-right
2624           Shift the reference at point.  For example, if the reference
2625           is =B3= and you press {{{kbd(S-right)}}}, it becomes =C3=.
2626           This also works for relative references and for hline
2627           references.
2629      - {{{kbd(M-S-up)}}} (~org-table-fedit-line-up~) ::
2631           #+kindex: M-S-up
2632           #+findex: org-table-fedit-line-up
2633           Move the test line for column formulas up in the Org buffer.
2635      - {{{kbd(M-S-down)}}} (~org-table-fedit-line-down~) ::
2637           #+kindex: M-S-down
2638           #+findex: org-table-fedit-line-down
2639           Move the test line for column formulas down in the Org buffer.
2641      - {{{kbd(M-up)}}} (~org-table-fedit-scroll-up~) ::
2643           #+kindex: M-up
2644           #+findex: org-table-fedit-scroll-up
2645           Scroll up the window displaying the table.
2647      - {{{kbd(M-down)}}} (~org-table-fedit-scroll-down~) ::
2649           #+kindex: M-down
2650           #+findex: org-table-fedit-scroll-down
2651           Scroll down the window displaying the table.
2653      - {{{kbd(C-c })}}} ::
2655           #+kindex: C-c @}
2656           #+findex: org-table-toggle-coordinate-overlays
2657           Turn the coordinate grid in the table on and off.
2659 Making a table field blank does not remove the formula associated with
2660 the field, because that is stored in a different line---the =TBLFM=
2661 keyword line.  During the next recalculation, the field will be filled
2662 again.  To remove a formula from a field, you have to give an empty
2663 reply when prompted for the formula, or to edit the =TBLFM= keyword.
2665 #+kindex: C-c C-c
2666 You may edit the =TBLFM= keyword directly and re-apply the changed
2667 equations with {{{kbd(C-c C-c)}}} in that line or with the normal
2668 recalculation commands in the table.
2670 **** Using multiple =TBLFM= lines
2671 :PROPERTIES:
2672 :UNNUMBERED: notoc
2673 :END:
2674 #+cindex: multiple formula lines
2675 #+cindex: TBLFM keywords, multiple
2676 #+cindex: TBLFM, switching
2678 #+kindex: C-c C-c
2679 You may apply the formula temporarily.  This is useful when you switch
2680 the formula.  Place multiple =TBLFM= keywords right after the table,
2681 and then press {{{kbd(C-c C-c)}}} on the formula to apply.  Here is an
2682 example:
2684 #+begin_example
2685   | x | y |
2686   |---+---|
2687   | 1 |   |
2688   | 2 |   |
2689   ,#+TBLFM: $2=$1*1
2690   ,#+TBLFM: $2=$1*2
2691 #+end_example
2693 #+texinfo: @noindent
2694 Pressing {{{kbd(C-c C-c)}}} in the line of =#+TBLFM: $2=$1*2= yields:
2696 #+begin_example
2697   | x | y |
2698   |---+---|
2699   | 1 | 2 |
2700   | 2 | 4 |
2701   ,#+TBLFM: $2=$1*1
2702   ,#+TBLFM: $2=$1*2
2703 #+end_example
2705 #+texinfo: @noindent
2706 Note: If you recalculate this table, with {{{kbd(C-u C-c *)}}}, for
2707 example, you get the following result of applying only the first
2708 =TBLFM= keyword.
2710 #+begin_example
2711   | x | y |
2712   |---+---|
2713   | 1 | 1 |
2714   | 2 | 2 |
2715   ,#+TBLFM: $2=$1*1
2716   ,#+TBLFM: $2=$1*2
2717 #+end_example
2719 **** Debugging formulas
2720 :PROPERTIES:
2721 :UNNUMBERED: notoc
2722 :END:
2723 #+cindex: formula debugging
2724 #+cindex: debugging, of table formulas
2726 When the evaluation of a formula leads to an error, the field content
2727 becomes the string =#ERROR=.  If you would like to see what is going
2728 on during variable substitution and calculation in order to find
2729 a bug, turn on formula debugging in the Tbl menu and repeat the
2730 calculation, for example by pressing {{{kbd(C-u C-u C-c = RET)}}} in
2731 a field.  Detailed information are displayed.
2733 *** Updating the table
2734 :PROPERTIES:
2735 :DESCRIPTION: Recomputing all dependent fields.
2736 :END:
2737 #+cindex: recomputing table fields
2738 #+cindex: updating, table
2740 Recalculation of a table is normally not automatic, but needs to be
2741 triggered by a command.  To make recalculation at least
2742 semi-automatic, see [[*Advanced features]].
2744 In order to recalculate a line of a table or the entire table, use the
2745 following commands:
2747 - {{{kbd(C-c *)}}} (~org-table-recalculate~) ::
2749      #+kindex: C-c *
2750      #+findex: org-table-recalculate
2751      Recalculate the current row by first applying the stored column
2752      formulas from left to right, and all field/range formulas in the
2753      current row.
2755 - {{{kbd(C-u C-c *)}}} or {{{kbd(C-u C-c C-c)}}} ::
2757      #+kindex: C-u C-c *
2758      #+kindex: C-u C-c C-c
2759      Recompute the entire table, line by line.  Any lines before the
2760      first hline are left alone, assuming that these are part of the
2761      table header.
2763 - {{{kbd(C-u C-u C-c *)}}} or {{{kbd(C-u C-u C-c C-c)}}} (~org-table-iterate~) ::
2765      #+kindex: C-u C-u C-c *
2766      #+kindex: C-u C-u C-c C-c
2767      #+findex: org-table-iterate
2768      Iterate the table by recomputing it until no further changes
2769      occur.  This may be necessary if some computed fields use the
2770      value of other fields that are computed /later/ in the
2771      calculation sequence.
2773 - {{{kbd(M-x org-table-recalculate-buffer-tables)}}} ::
2775      #+findex: org-table-recalculate-buffer-tables
2776      Recompute all tables in the current buffer.
2778 - {{{kbd(M-x org-table-iterate-buffer-tables)}}} ::
2780      #+findex: org-table-iterate-buffer-tables
2781      Iterate all tables in the current buffer, in order to converge
2782      table-to-table dependencies.
2784 *** Advanced features
2785 :PROPERTIES:
2786 :DESCRIPTION: Field and column names, automatic recalculation...
2787 :END:
2789 If you want the recalculation of fields to happen automatically, or if
2790 you want to be able to assign /names/[fn:24] to fields and columns,
2791 you need to reserve the first column of the table for special marking
2792 characters.
2794 - {{{kbd(C-#)}}} (~org-table-rotate-recalc-marks~) ::
2796      #+kindex: C-#
2797      #+findex: org-table-rotate-recalc-marks
2798      Rotate the calculation mark in first column through the states
2799      =#=, =*=, =!=, =$=.  When there is an active region, change all
2800      marks in the region.
2802 Here is an example of a table that collects exam results of students
2803 and makes use of these features:
2805 #+begin_example
2806   |---+---------+--------+--------+--------+-------+------|
2807   |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2808   |---+---------+--------+--------+--------+-------+------|
2809   | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2810   | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2811   | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2812   |---+---------+--------+--------+--------+-------+------|
2813   | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2814   | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2815   |---+---------+--------+--------+--------+-------+------|
2816   |   | Average |        |        |        |  25.0 |      |
2817   | ^ |         |        |        |        |    at |      |
2818   | $ | max=50  |        |        |        |       |      |
2819   |---+---------+--------+--------+--------+-------+------|
2820   ,#+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@-II..@-I);%.1f
2821 #+end_example
2823 #+texinfo: @noindent
2824 *Important*: please note that for these special tables, recalculating
2825 the table with {{{kbd(C-u C-c *)}}} only affects rows that are marked
2826 =#= or =*=, and fields that have a formula assigned to the field
2827 itself.  The column formulas are not applied in rows with empty first
2828 field.
2830 #+cindex: marking characters, tables
2831 The marking characters have the following meaning:
2833 - =!= ::
2835      The fields in this line define names for the columns, so that you
2836      may refer to a column as =$Tot= instead of =$6=.
2838 - =^= ::
2840      This row defines names for the fields /above/ the row.  With such
2841      a definition, any formula in the table may use =$m1= to refer to
2842      the value =10=.  Also, if you assign a formula to a names field,
2843      it is stored as =$name = ...=.
2845 - =_= ::
2847      Similar to =^=, but defines names for the fields in the row
2848      /below/.
2850 - =$= ::
2852      Fields in this row can define /parameters/ for formulas.  For
2853      example, if a field in a =$= row contains =max=50=, then formulas
2854      in this table can refer to the value 50 using =$max=.  Parameters
2855      work exactly like constants, only that they can be defined on
2856      a per-table basis.
2858 - =#= ::
2860      Fields in this row are automatically recalculated when pressing
2861      {{{kbd(TAB)}}} or {{{kbd(RET)}}} or {{{kbd(S-TAB)}}} in this row.
2862      Also, this row is selected for a global recalculation with
2863      {{{kbd(C-u C-c *)}}}.  Unmarked lines are left alone by this
2864      command.
2866 - =*= ::
2868      Selects this line for global recalculation with {{{kbd(C-u C-c
2869      *)}}}, but not for automatic recalculation.  Use this when
2870      automatic recalculation slows down editing too much.
2872 - =/= ::
2874      Do not export this line.  Useful for lines that contain the
2875      narrowing =<N>= markers or column group markers.
2877 Finally, just to whet your appetite for what can be done with the
2878 fantastic Calc package, here is a table that computes the Taylor
2879 series of degree n at location x for a couple of functions.
2881 #+begin_example
2882   |---+-------------+---+-----+--------------------------------------|
2883   |   | Func        | n | x   | Result                               |
2884   |---+-------------+---+-----+--------------------------------------|
2885   | # | exp(x)      | 1 | x   | 1 + x                                |
2886   | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2887   | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2888   | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2889   | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2890   | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2891   |---+-------------+---+-----+--------------------------------------|
2892   ,#+TBLFM: $5=taylor($2,$4,$3);n3
2893 #+end_example
2895 ** Org Plot
2896 :PROPERTIES:
2897 :DESCRIPTION: Plotting from Org tables.
2898 :END:
2899 #+cindex: graph, in tables
2900 #+cindex: plot tables using Gnuplot
2902 Org Plot can produce graphs of information stored in Org tables,
2903 either graphically or in ASCII art.
2905 *** Graphical plots using Gnuplot
2906 :PROPERTIES:
2907 :UNNUMBERED: notoc
2908 :END:
2910 #+cindex: PLOT, keyword
2911 Org Plot can produce 2D and 3D graphs of information stored in Org
2912 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
2913 that you have both Gnuplot and Gnuplot mode installed on your system,
2914 then call {{{kbd(C-c \quot g)}}} or {{{kbd(M-x org-plot/gnuplot)}}} on the
2915 following table.
2917 #+begin_example
2918   ,#+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2919   | Sede      | Max cites | H-index |
2920   |-----------+-----------+---------|
2921   | Chile     |    257.72 |   21.39 |
2922   | Leeds     |    165.77 |   19.68 |
2923   | Sao Paolo |     71.00 |   11.50 |
2924   | Stockholm |    134.19 |   14.33 |
2925   | Morels    |    257.56 |   17.67 |
2926 #+end_example
2928 Notice that Org Plot is smart enough to apply the table's headers as
2929 labels.  Further control over the labels, type, content, and
2930 appearance of plots can be exercised through the =PLOT= keyword
2931 preceding a table.  See below for a complete list of Org Plot options.
2932 For more information and examples see the [[https://orgmode.org/worg/org-tutorials/org-plot.html][Org Plot tutorial]].
2934 **** Plot options
2935 :PROPERTIES:
2936 :UNNUMBERED: notoc
2937 :END:
2939 - =set= ::
2941      Specify any Gnuplot option to be set when graphing.
2943 - =title= ::
2945      Specify the title of the plot.
2947 - =ind= ::
2949      Specify which column of the table to use as the =x= axis.
2951 - =deps= ::
2953      Specify the columns to graph as a Lisp style list, surrounded by
2954      parentheses and separated by spaces for example =dep:(3 4)= to
2955      graph the third and fourth columns.  Defaults to graphing all
2956      other columns aside from the =ind= column.
2958 - =type= ::
2960      Specify whether the plot is =2d=, =3d=, or =grid=.
2962 - =with= ::
2964      Specify a =with= option to be inserted for every column being
2965      plotted, e.g., =lines=, =points=, =boxes=, =impulses=.  Defaults
2966      to =lines=.
2968 - =file= ::
2970      If you want to plot to a file, specify
2971      ="path/to/desired/output-file"=.
2973 - =labels= ::
2975      List of labels to be used for the =deps=.  Defaults to the column
2976      headers if they exist.
2978 - =line= ::
2980      Specify an entire line to be inserted in the Gnuplot script.
2982 - =map= ::
2984      When plotting =3d= or =grid= types, set this to =t= to graph
2985      a flat mapping rather than a =3d= slope.
2987 - =timefmt= ::
2989      Specify format of Org mode timestamps as they will be parsed by
2990      Gnuplot.  Defaults to =%Y-%m-%d-%H:%M:%S=.
2992 - =script= ::
2994      If you want total control, you can specify a script file---place
2995      the file name between double-quotes---which will be used to plot.
2996      Before plotting, every instance of =$datafile= in the specified
2997      script will be replaced with the path to the generated data file.
2998      Note: even if you set this option, you may still want to specify
2999      the plot type, as that can impact the content of the data file.
3001 *** ASCII bar plots
3002 :PROPERTIES:
3003 :UNNUMBERED: notoc
3004 :END:
3006 While the cursor is on a column, typing {{{kbd(C-c " a)}}} or
3007 {{{kbd(M-x orgtbl-ascii-plot)}}} create a new column containing an
3008 ASCII-art bars plot.  The plot is implemented through a regular column
3009 formula.  When the source column changes, the bar plot may be updated
3010 by refreshing the table, for example typing {{{kbd(C-u C-c *)}}}.
3012 #+begin_example
3013   | Sede          | Max cites |              |
3014   |---------------+-----------+--------------|
3015   | Chile         |    257.72 | WWWWWWWWWWWW |
3016   | Leeds         |    165.77 | WWWWWWWh     |
3017   | Sao Paolo     |     71.00 | WWW;         |
3018   | Stockholm     |    134.19 | WWWWWW:      |
3019   | Morelia       |    257.56 | WWWWWWWWWWWH |
3020   | Rochefourchat |      0.00 |              |
3021   ,#+TBLFM: $3='(orgtbl-ascii-draw $2 0.0 257.72 12)
3022 #+end_example
3024 The formula is an Elisp call.
3026 #+attr_texinfo: :options orgtbl-ascii-draw value min max &optional width
3027 #+begin_defun
3028 Draw an ASCII bar in a table.
3030 {{{var(VALUE)}}} is the value to plot.
3032 {{{var(MIN)}}} is the value displayed as an empty bar.  {{{var(MAX)}}}
3033 is the value filling all the {{{var(WIDTH)}}}.  Sources values outside
3034 this range are displayed as =too small= or =too large=.
3036 {{{var(WIDTH)}}} is the number of characters of the bar plot.  It
3037 defaults to =12=.
3038 #+end_defun
3040 * Hyperlinks
3041 :PROPERTIES:
3042 :DESCRIPTION: Notes in context.
3043 :END:
3044 #+cindex: hyperlinks
3046 Like HTML, Org provides links inside a file, external links to
3047 other files, Usenet articles, emails, and much more.
3049 ** Link Format
3050 :PROPERTIES:
3051 :DESCRIPTION: How links in Org are formatted.
3052 :END:
3053 #+cindex: link format
3054 #+cindex: format, of links
3056 Org recognizes plain URL-like links and activate them as clickable
3057 links.  The general link format, however, looks like this:
3059 : [[LINK][DESCRIPTION]]
3061 #+texinfo: @noindent
3062 or alternatively
3064 : [[LINK]]
3066 #+texinfo: @noindent
3067 Once a link in the buffer is complete (all brackets present), Org
3068 changes the display so that =DESCRIPTION= is displayed instead of
3069 =[[LINK][DESCRIPTION]]= and =LINK= is displayed instead of =[[LINK]]=.  Links are be
3070 highlighted in the face ~org-link~, which by default is an underlined
3071 face.  You can directly edit the visible part of a link.  Note that
3072 this can be either the LINK part, if there is no description, or the
3073 {{{var(DESCRIPTION)}}} part.  To edit also the invisible
3074 {{{var(LINK)}}} part, use {{{kbd(C-c C-l)}}} with the cursor on the
3075 link.
3077 If you place the cursor at the beginning or just behind the end of the
3078 displayed text and press {{{kbd(BS)}}}, you remove
3079 the---invisible---bracket at that location.  This makes the link
3080 incomplete and the internals are again displayed as plain text.
3081 Inserting the missing bracket hides the link internals again.  To show
3082 the internal structure of all links, use the menu: Org \rarr Hyperlinks \rarr
3083 Literal links.
3085 ** Internal Links
3086 :PROPERTIES:
3087 :DESCRIPTION: Links to other places in the current file.
3088 :END:
3089 #+cindex: internal links
3090 #+cindex: links, internal
3091 #+cindex: targets, for links
3093 #+cindex: CUSTOM_ID, property
3094 If the link does not look like a URL, it is considered to be internal
3095 in the current file.  The most important case is a link like
3096 =[[#my-custom-id]]= which links to the entry with the =CUSTOM_ID= property
3097 =my-custom-id=.  You are responsible yourself to make sure these
3098 custom IDs are unique in a file.
3100 Links such as =[[My Target]]= or =[[My Target][Find my target]]= lead to a text search in
3101 the current file.
3103 The link can be followed with {{{kbd(C-c C-o)}}} when the cursor is on
3104 the link, or with a mouse click (see [[*Handling Links]]).  Links to
3105 custom IDs point to the corresponding headline.  The preferred match
3106 for a text link is a /dedicated target/: the same string in double
3107 angular brackets, like =<<My Target>>=.
3109 #+cindex: NAME, keyword
3110 If no dedicated target exists, the link tries to match the exact name
3111 of an element within the buffer.  Naming is done with the =NAME=
3112 keyword, which has to be put in the line before the element it refers
3113 to, as in the following example
3115 #+begin_example
3116   ,#+NAME: My Target
3117   | a  | table      |
3118   |----+------------|
3119   | of | four cells |
3120 #+end_example
3122 If none of the above succeeds, Org searches for a headline that is
3123 exactly the link text but may also include a TODO keyword and
3124 tags[fn:25].
3126 During export, internal links are used to mark objects and assign them
3127 a number.  Marked objects are then referenced by links pointing to
3128 them.  In particular, links without a description appear as the number
3129 assigned to the marked object[fn:26].  In the following excerpt from
3130 an Org buffer
3132 #+begin_example
3133   1. one item
3134   2. <<target>>another item
3135   Here we refer to item [[target]].
3136 #+end_example
3138 #+texinfo: @noindent
3139 The last sentence will appear as =Here we refer to item 2= when
3140 exported.
3142 In non-Org files, the search looks for the words in the link text.  In
3143 the above example the search would be for =target=.
3145 Following a link pushes a mark onto Org's own mark ring.  You can
3146 return to the previous position with {{{kbd(C-c &)}}}.  Using this
3147 command several times in direct succession goes back to positions
3148 recorded earlier.
3150 ** Radio Targets
3151 :PROPERTIES:
3152 :DESCRIPTION: Make targets trigger links in plain text.
3153 :END:
3154 #+cindex: radio targets
3155 #+cindex: targets, radio
3156 #+cindex: links, radio targets
3158 Org can automatically turn any occurrences of certain target names in
3159 normal text into a link.  So without explicitly creating a link, the
3160 text connects to the target radioing its position.  Radio targets are
3161 enclosed by triple angular brackets.  For example, a target =<<<My
3162 Target>>>= causes each occurrence of =my target= in normal text to
3163 become activated as a link.  The Org file is scanned automatically for
3164 radio targets only when the file is first loaded into Emacs.  To
3165 update the target list during editing, press {{{kbd(C-c C-c)}}} with
3166 the cursor on or at a target.
3168 ** External Links
3169 :PROPERTIES:
3170 :DESCRIPTION: URL-like links to the world.
3171 :END:
3172 #+cindex: links, external
3173 #+cindex: external links
3174 #+cindex: Gnus links
3175 #+cindex: BBDB links
3176 #+cindex: irc links
3177 #+cindex: URL links
3178 #+cindex: file links
3179 #+cindex: Rmail links
3180 #+cindex: MH-E links
3181 #+cindex: Usenet links
3182 #+cindex: shell links
3183 #+cindex: Info links
3184 #+cindex: Elisp links
3186 Org supports links to files, websites, Usenet and email messages, BBDB
3187 database entries and links to both IRC conversations and their logs.
3188 External links are URL-like locators.  They start with a short
3189 identifying string followed by a colon.  There can be no space after
3190 the colon.  The following list shows examples for each link type.
3192 | =http://www.astro.uva.nl/=dominik=          | on the web                     |
3193 | =doi:10.1000/182=                           | DOI for an electronic resource |
3194 | =file:/home/dominik/images/jupiter.jpg=     | file, absolute path            |
3195 | =/home/dominik/images/jupiter.jpg=          | same as above                  |
3196 | =file:papers/last.pdf=                      | file, relative path            |
3197 | =./papers/last.pdf=                         | same as above                  |
3198 | =file:/ssh:me@some.where:papers/last.pdf=   | file, path on remote machine   |
3199 | =/ssh:me@some.where:papers/last.pdf=        | same as above                  |
3200 | =file:sometextfile::NNN=                    | file, jump to line number      |
3201 | =file:projects.org=                         | another Org file               |
3202 | =file:projects.org::some words=             | text search in Org file[fn:27] |
3203 | =file:projects.org::*task title=            | heading search in Org file     |
3204 | =file+sys:/path/to/file=                    | open via OS, like double-click |
3205 | =file+emacs:/path/to/file=                  | force opening by Emacs         |
3206 | =docview:papers/last.pdf::NNN=              | open in doc-view mode at page  |
3207 | =id:B7423F4D-2E8A-471B-8810-C40F074717E9=   | Link to heading by ID          |
3208 | =news:comp.emacs=                           | Usenet link                    |
3209 | =mailto:adent@galaxy.net=                   | Mail link                      |
3210 | =mhe:folder=                                | MH-E folder link               |
3211 | =mhe:folder#id=                             | MH-E message link              |
3212 | =rmail:folder=                              | Rmail folder link              |
3213 | =rmail:folder#id=                           | Rmail message link             |
3214 | =gnus:group=                                | Gnus group link                |
3215 | =gnus:group#id=                             | Gnus article link              |
3216 | =bbdb:R.*Stallman=                          | BBDB link (with regexp)        |
3217 | =irc:/irc.com/#emacs/bob=                   | IRC link                       |
3218 | =info:org#External links=                   | Info node link                 |
3219 | =shell:ls *.org=                            | A shell command                |
3220 | =elisp:org-agenda=                          | Interactive Elisp command      |
3221 | =elisp:(find-file-other-frame "Elisp.org")= | Elisp form to evaluate         |
3223 #+cindex: VM links
3224 #+cindex: Wanderlust links
3225 On top of these built-in link types, some are available through the
3226 =contrib/= directory (see [[*Installation]]).  For example, these links to
3227 VM or Wanderlust messages are available when you load the
3228 corresponding libraries from the =contrib/= directory:
3230 | =vm:folder=                            | VM folder link          |
3231 | =vm:folder#id=                         | VM message link         |
3232 | =vm://myself@some.where.org/folder#id= | VM on remote machine    |
3233 | =vm-imap:account:folder=               | VM IMAP folder link     |
3234 | =vm-imap:account:folder#id=            | VM IMAP message link    |
3235 | =wl:folder=                            | Wanderlust folder link  |
3236 | =wl:folder#id=                         | Wanderlust message link |
3238 For customizing Org to add new link types, see [[*Adding Hyperlink
3239 Types]].
3241 A link should be enclosed in double brackets and may contain
3242 a descriptive text to be displayed instead of the URL (see [[*Link
3243 Format]]), for example:
3245 : [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3247 #+texinfo: @noindent
3248 If the description is a file name or URL that points to an image, HTML
3249 export (see [[*HTML Export]]) inlines the image as a clickable button.  If
3250 there is no description at all and the link points to an image, that
3251 image is inlined into the exported HTML file.
3253 #+cindex: square brackets, around links
3254 #+cindex: angular brackets, around links
3255 #+cindex: plain text external links
3256 Org also finds external links in the normal text and activates them as
3257 links.  If spaces must be part of the link (for example in
3258 =bbdb:Richard Stallman=), or if you need to remove ambiguities about
3259 the end of the link, enclose them in square or angular brackets.
3261 ** Handling Links
3262 :PROPERTIES:
3263 :DESCRIPTION: Creating, inserting and following.
3264 :END:
3265 #+cindex: links, handling
3267 Org provides methods to create a link in the correct syntax, to insert
3268 it into an Org file, and to follow the link.
3270 #+attr_texinfo: :sep ,
3271 - {{{kbd(C-c l)}}} (~org-store-link~) ::
3273      #+kindex: C-c l
3274      #+findex: org-store-link
3275      #+cindex: storing links
3276      Store a link to the current location.  This is a /global/
3277      command---you must create the key binding yourself---which can
3278      be used in any buffer to create a link.  The link is stored for
3279      later insertion into an Org buffer---see below.  What kind of
3280      link is created depends on the current buffer:
3282      - /Org mode buffers/ ::
3284           For Org files, if there is a =<<target>>= at the cursor, the
3285           link points to the target.  Otherwise it points to the
3286           current headline, which is also the description[fn:28].
3288           #+vindex: org-link-to-org-use-id
3289           #+cindex: CUSTOM_ID, property
3290           #+cindex: ID, property
3291           If the headline has a =CUSTOM_ID= property, store a link to
3292           this custom ID.  In addition or alternatively, depending on
3293           the value of ~org-link-to-org-use-id~, create and/or use
3294           a globally unique ID property for the link[fn:29].  So using
3295           this command in Org buffers potentially creates two links:
3296           a human-readable link from the custom ID, and one that is
3297           globally unique and works even if the entry is moved from
3298           file to file.  Later, when inserting the link, you need to
3299           decide which one to use.
3301      - /Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus/ ::
3303           Pretty much all Emacs mail clients are supported.  The link
3304           points to the current article, or, in some Gnus buffers, to
3305           the group.  The description is constructed from the author
3306           and the subject.
3308      - /Web browsers: W3 and W3M/ ::
3310           Here the link is the current URL, with the page title as
3311           description.
3313      - /Contacts: BBDB/ ::
3315           Links created in a BBDB buffer point to the current entry.
3317      - /Chat: IRC/ ::
3319           #+vindex: org-irc-links-to-logs
3320           For IRC links, if the variable ~org-irc-link-to-logs~ is
3321           non-~nil~, create a =file= style link to the relevant point
3322           in the logs for the current conversation.  Otherwise store
3323           an =irc= style link to the user/channel/server under the
3324           point.
3326      - /Other files/ ::
3328           For any other files, the link points to the file, with
3329           a search string (see [[*Search Options in File Links]]) pointing
3330           to the contents of the current line.  If there is an active
3331           region, the selected words form the basis of the search
3332           string.  If the automatically created link is not working
3333           correctly or accurately enough, you can write custom
3334           functions to select the search string and to do the search
3335           for particular file types (see [[*Custom Searches]]).  The key
3336           binding {{{kbd(C-c l)}}} is only a suggestion (see
3337           [[*Installation]]).
3339      - /Agenda view/ ::
3341           When the cursor is in an agenda view, the created link
3342           points to the entry referenced by the current line.
3344 - {{{kbd(C-c C-l)}}} (~org-insert-link~) ::
3346      #+kindex: C-c C-l
3347      #+findex: org-insert-link
3348      #+cindex: link completion
3349      #+cindex: completion, of links
3350      #+cindex: inserting links
3351      #+vindex: org-keep-stored-link-after-insertion
3352      Insert a link[fn:30].  This prompts for a link to be inserted
3353      into the buffer.  You can just type a link, using text for an
3354      internal link, or one of the link type prefixes mentioned in the
3355      examples above.  The link is inserted into the buffer, along with
3356      a descriptive text[fn:31].  If some text was selected at this
3357      time, it becomes the default description.
3359      - /Inserting stored links/ ::
3361           All links stored during the current session are part of the
3362           history for this prompt, so you can access them with
3363           {{{kbd(up)}}} and {{{kbd(down)}}} (or {{{kbd(M-p)}}},
3364           {{{kbd(M-n)}}}).
3366      - /Completion support/ ::
3368           Completion with {{{kbd(TAB)}}} helps you to insert valid
3369           link prefixes like =http= or =ftp=, including the prefixes
3370           defined through link abbreviations (see [[*Link
3371           Abbreviations]]).  If you press {{{kbd(RET)}}} after inserting
3372           only the prefix, Org offers specific completion support for
3373           some link types[fn:32].  For example, if you type {{{kbd(f
3374           i l e RET)}}}---alternative access: {{{kbd(C-u C-c C-l)}}},
3375           see below---Org offers file name completion, and after
3376           {{{kbd(b b d b RET)}}} you can complete contact names.
3378 - {{{kbd(C-u C-c C-l)}}} ::
3380      #+cindex: file name completion
3381      #+cindex: completion, of file names
3382      #+kindex: C-u C-c C-l
3383      When {{{kbd(C-c C-l)}}} is called with a {{{kbd(C-u)}}} prefix
3384      argument, insert a link to a file.  You may use file name
3385      completion to select the name of the file.  The path to the file
3386      is inserted relative to the directory of the current Org file, if
3387      the linked file is in the current directory or in a sub-directory
3388      of it, or if the path is written relative to the current
3389      directory using =../=.  Otherwise an absolute path is used, if
3390      possible with =~/= for your home directory.  You can force an
3391      absolute path with two {{{kbd(C-u)}}} prefixes.
3393 - {{{kbd(C-c C-l)}}} (with cursor on existing link) ::
3395      #+cindex: following links
3396      When the cursor is on an existing link, {{{kbd(C-c C-l)}}} allows
3397      you to edit the link and description parts of the link.
3399      - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
3401           #+kindex: C-c C-o
3402           #+findex: org-open-at-point
3403           #+vindex: org-file-apps
3404           #+vindex: org-link-frame-setup
3405           Open link at point.  This launches a web browser for URL
3406           (using ~browse-url-at-point~), run
3407           VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for the corresponding
3408           links, and execute the command in a shell link.  When the
3409           cursor is on an internal link, this command runs the
3410           corresponding search.  When the cursor is on a TAG list in
3411           a headline, it creates the corresponding TAGS view.  If the
3412           cursor is on a timestamp, it compiles the agenda for that
3413           date.  Furthermore, it visits text and remote files in
3414           =file= links with Emacs and select a suitable application
3415           for local non-text files.  Classification of files is based
3416           on file extension only.  See option ~org-file-apps~.  If you
3417           want to override the default application and visit the file
3418           with Emacs, use a {{{kbd(C-u)}}} prefix.  If you want to
3419           avoid opening in Emacs, use a {{{kbd(C-u C-u)}}} prefix. \\
3420           If the cursor is on a headline, but not on a link, offer all
3421           links in the headline and entry text.  If you want to setup
3422           the frame configuration for following links, customize
3423           ~org-link-frame-setup~.
3425      - {{{kbd(RET)}}} ::
3427           #+vindex: org-return-follows-link
3428           #+kindex: RET
3429           When ~org-return-follows-link~ is set, {{{kbd(RET)}}} also
3430           follows the link at point.
3432      - {{{kbd(mouse-2)}}} or {{{kbd(mouse-1)}}} ::
3434           #+kindex: mouse-2
3435           #+kindex: mouse-1
3436           On links, {{{kbd(mouse-1)}}} and {{{kbd(mouse-2)}}} opens
3437           the link just as {{{kbd(C-c C-o)}}} does.
3439      - {{{kbd(mouse-3)}}} ::
3441           #+vindex: org-display-internal-link-with-indirect-buffer
3442           #+kindex: mouse-3
3443           Like {{{kbd(mouse-2)}}}, but force file links to be opened
3444           with Emacs, and internal links to be displayed in another
3445           window[fn:33].
3447      - {{{kbd(C-c C-x C-v)}}} (~org-toggle-inline-images~) ::
3449           #+cindex: inlining images
3450           #+cindex: images, inlining
3451           #+vindex: org-startup-with-inline-images
3452           #+kindex: C-c C-x C-v
3453           #+findex: org-toggle-inline-images
3454           Toggle the inline display of linked images.  Normally this
3455           only inlines images that have no description part in the
3456           link, i.e., images that are inlined during export.  When
3457           called with a prefix argument, also display images that do
3458           have a link description.  You can ask for inline images to
3459           be displayed at startup by configuring the variable
3460           ~org-startup-with-inline-images~[fn:34].
3462      - {{{kbd(C-c %)}}} (~org-mark-ring-push~) ::
3464           #+kindex: C-c %
3465           #+findex: org-mark-ring-push
3466           #+cindex: mark ring
3467           Push the current position onto the mark ring, to be able to
3468           return easily.  Commands following an internal link do this
3469           automatically.
3471      - {{{kbd(C-c &)}}} (~org-mark-ring-goto~) ::
3473           #+kindex: C-c &
3474           #+findex: org-mark-ring-goto
3475           #+cindex: links, returning to
3476           Jump back to a recorded position.  A position is recorded by
3477           the commands following internal links, and by {{{kbd(C-c
3478           %)}}}.  Using this command several times in direct
3479           succession moves through a ring of previously recorded
3480           positions.
3482 - {{{kbd(C-c C-x C-n)}}} (~org-next-link~), {{{kbd(C-c C-x C-p)}}} (~org-previous-link~) ::
3484      #+kindex: C-c C-x C-p
3485      #+findex: org-previous-link
3486      #+kindex: C-c C-x C-n
3487      #+findex: org-next-link
3488      #+cindex: links, finding next/previous
3489      Move forward/backward to the next link in the buffer.  At the
3490      limit of the buffer, the search fails once, and then wraps
3491      around.  The key bindings for this are really too long; you might
3492      want to bind this also to {{{kbd(C-n)}}} and {{{kbd(C-p)}}}.
3494      #+begin_src emacs-lisp
3495        (add-hook 'org-load-hook
3496                  (lambda ()
3497                    (define-key org-mode-map "\C-n" 'org-next-link)
3498                    (define-key org-mode-map "\C-p" 'org-previous-link)))
3499      #+end_src
3501 ** Using Links Outside Org
3502 :PROPERTIES:
3503 :DESCRIPTION: Linking from my C source code?
3504 :END:
3506 You can insert and follow links that have Org syntax not only in Org,
3507 but in any Emacs buffer.  For this, you should create two global
3508 commands, like this (please select suitable global keys yourself):
3510 #+begin_src emacs-lisp
3511   (global-set-key "\C-c L" 'org-insert-link-global)
3512   (global-set-key "\C-c o" 'org-open-at-point-global)
3513 #+end_src
3515 ** Link Abbreviations
3516 :PROPERTIES:
3517 :DESCRIPTION: Shortcuts for writing complex links.
3518 :END:
3519 #+cindex: link abbreviations
3520 #+cindex: abbreviation, links
3522 Long URL can be cumbersome to type, and often many similar links are
3523 needed in a document.  For this you can use link abbreviations.  An
3524 abbreviated link looks like this
3526 : [[linkword:tag][description]]
3528 #+texinfo: @noindent
3529 #+vindex: org-link-abbrev-alist
3530 where the tag is optional.  The /linkword/ must be a word, starting
3531 with a letter, followed by letters, numbers, =-=, and =_=.
3532 Abbreviations are resolved according to the information in the
3533 variable ~org-link-abbrev-alist~ that relates the linkwords to
3534 replacement text.  Here is an example:
3536 #+begin_src emacs-lisp
3537   (setq org-link-abbrev-alist
3538         '(("bugzilla"  . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3539           ("url-to-ja" . "http://translate.google.fr/translate?sl=en&tl=ja&u=%h")
3540           ("google"    . "http://www.google.com/search?q=")
3541           ("gmap"      . "http://maps.google.com/maps?q=%s")
3542           ("omap"      . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3543           ("ads"       . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3544 #+end_src
3546 If the replacement text contains the string =%s=, it is replaced with
3547 the tag.  Using =%h= instead of =%s= percent-encodes the tag (see the
3548 example above, where we need to encode the URL parameter).  Using
3549 =%(my-function)= passes the tag to a custom function, and replace it
3550 by the resulting string.
3552 If the replacement text do not contain any specifier, it is simply
3553 appended to the string in order to create the link.
3555 Instead of a string, you may also specify a function that will be
3556 called with the tag as the only argument to create the link.
3558 With the above setting, you could link to a specific bug with
3559 =[[bugzilla:129]]=, search the web for =OrgMode= with =[[google:OrgMode]]=,
3560 show the map location of the Free Software Foundation =[[gmap:51
3561 Franklin Street, Boston]]= or of Carsten office =[[omap:Science Park 904,
3562 Amsterdam, The Netherlands]]= and find out what the Org author is doing
3563 besides Emacs hacking with =[[ads:Dominik,C]]=.
3565 If you need special abbreviations just for a single Org buffer, you
3566 can define them in the file with
3568 #+cindex: LINK, keyword
3569 #+begin_example
3570   ,#+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3571   ,#+LINK: google    http://www.google.com/search?q=%s
3572 #+end_example
3574 #+texinfo: @noindent
3575 In-buffer completion (see [[*Completion]]) can be used after =[= to
3576 complete link abbreviations.  You may also define a function that
3577 implements special (e.g., completion) support for inserting such
3578 a link with {{{kbd(C-c C-l)}}}.  Such a function should not accept any
3579 arguments, and return the full link with prefix.  You can set the link
3580 completion function like this:
3582 #+begin_src emacs-lisp
3583   (org-link-set-parameter "type" :complete #'some-completion-function)
3584 #+end_src
3586 ** Search Options in File Links
3587 :PROPERTIES:
3588 :DESCRIPTION: Linking to a specific location.
3589 :ALT_TITLE: Search Options
3590 :END:
3591 #+cindex: search option in file links
3592 #+cindex: file links, searching
3594 File links can contain additional information to make Emacs jump to
3595 a particular location in the file when following a link.  This can be
3596 a line number or a search option after a double colon[fn:35].  For
3597 example, when the command {{{kbd(C-c l)}}} creates a link (see
3598 [[*Handling Links]]) to a file, it encodes the words in the current line
3599 as a search string that can be used to find this line back later when
3600 following the link with {{{kbd(C-c C-o)}}}.
3602 Here is the syntax of the different ways to attach a search to a file
3603 link, together with an explanation:
3605 #+begin_example
3606   [[file:~/code/main.c::255]]
3607   [[file:~/xx.org::My Target]]
3608   [[file:~/xx.org::*My Target]]
3609   [[file:~/xx.org::#my-custom-id]]
3610   [[file:~/xx.org::/regexp/]]
3611 #+end_example
3613 - =255= ::
3615      Jump to line 255.
3617 - =My Target= ::
3619      Search for a link target =<<My Target>>=, or do a text search for
3620      =my target=, similar to the search in internal links, see
3621      [[*Internal Links]].  In HTML export (see [[*HTML Export]]), such a file
3622      link becomes a HTML reference to the corresponding named anchor
3623      in the linked file.
3625 - =*My Target= ::
3627      In an Org file, restrict search to headlines.
3629 - =#my-custom-id= ::
3631      Link to a heading with a =CUSTOM_ID= property
3633 - =/REGEXP/= ::
3635      Do a regular expression search for {{{var(REGEXP)}}}.  This uses
3636      the Emacs command ~occur~ to list all matches in a separate
3637      window.  If the target file is in Org mode, ~org-occur~ is used
3638      to create a sparse tree with the matches.
3640 As a degenerate case, a file link with an empty file name can be used
3641 to search the current file.  For example, =[[file:::find me]]= does
3642 a search for =find me= in the current file, just as =[[find me]]= would.
3644 ** Custom Searches
3645 :PROPERTIES:
3646 :DESCRIPTION: When the default search is not enough.
3647 :END:
3648 #+cindex: custom search strings
3649 #+cindex: search strings, custom
3651 The default mechanism for creating search strings and for doing the
3652 actual search related to a file link may not work correctly in all
3653 cases.  For example, BibTeX database files have many entries like
3654 ~year="1993"~ which would not result in good search strings, because
3655 the only unique identification for a BibTeX entry is the citation key.
3657 #+vindex: org-create-file-search-functions
3658 #+vindex: org-execute-file-search-functions
3659 If you come across such a problem, you can write custom functions to
3660 set the right search string for a particular file type, and to do the
3661 search for the string in the file.  Using ~add-hook~, these functions
3662 need to be added to the hook variables
3663 ~org-create-file-search-functions~ and
3664 ~org-execute-file-search-functions~.  See the docstring for these
3665 variables for more information.  Org actually uses this mechanism for
3666 BibTeX database files, and you can use the corresponding code as an
3667 implementation example.  See the file =org-bibtex.el=.
3669 * TODO Items
3670 :PROPERTIES:
3671 :DESCRIPTION: Every tree branch can be a TODO item.
3672 :END:
3673 #+cindex: TODO items
3675 Org mode does not maintain TODO lists as separate documents[fn:36].
3676 Instead, TODO items are an integral part of the notes file, because
3677 TODO items usually come up while taking notes!  With Org mode, simply
3678 mark any entry in a tree as being a TODO item.  In this way,
3679 information is not duplicated, and the entire context from which the
3680 TODO item emerged is always present.
3682 Of course, this technique for managing TODO items scatters them
3683 throughout your notes file.  Org mode compensates for this by
3684 providing methods to give you an overview of all the things that you
3685 have to do.
3687 ** Basic TODO Functionality
3688 :PROPERTIES:
3689 :DESCRIPTION: Marking and displaying TODO entries.
3690 :ALT_TITLE: TODO Basics
3691 :END:
3693 Any headline becomes a TODO item when it starts with the word =TODO=,
3694 for example:
3696 : *** TODO Write letter to Sam Fortune
3698 #+texinfo: @noindent
3699 The most important commands to work with TODO entries are:
3701 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
3703      #+kindex: C-c C-t
3704      #+cindex: cycling, of TODO states
3705      Rotate the TODO state of the current item among
3707      #+begin_example
3708      ,-> (unmarked) -> TODO -> DONE --.
3709      '--------------------------------'
3710      #+end_example
3712      If TODO keywords have fast access keys (see [[*Fast access to
3713      TODO states]]), prompt for a TODO keyword through the fast
3714      selection interface; this is the default behavior when
3715      ~org-use-fast-todo-selection~ is non-~nil~.
3717      The same rotation can also be done "remotely" from the timeline
3718      and agenda buffers with the {{{kbd(t)}}} command key (see
3719      [[*Commands in the Agenda Buffer]]).
3721 - {{{kbd(C-u C-c C-t)}}} ::
3723      #+kindex: C-u C-c C-t
3724      When TODO keywords have no selection keys, select a specific
3725      keyword using completion; otherwise force cycling through TODO
3726      states with no prompt.  When ~org-use-fast-todo-selection~ is set
3727      to ~prefix~, use the fast selection interface.
3729 - {{{kbd(S-right)}}} {{{kbd(S-left)}}} ::
3731      #+kindex: S-right
3732      #+kindex: S-left
3733      #+vindex: org-treat-S-cursor-todo-selection-as-state-change
3734      Select the following/preceding TODO state, similar to cycling.
3735      Useful mostly if more than two TODO states are possible (see
3736      [[*Extended Use of TODO Keywords]]).  See also [[*Packages that
3737      conflict with Org mode]], for a discussion of the interaction with
3738      ~shift-selection-mode~.  See also the variable
3739      ~org-treat-S-cursor-todo-selection-as-state-change~.
3741 - {{{kbd(C-c / t)}}} (~org-show-todo-tree~) ::
3743      #+kindex: C-c / t
3744      #+cindex: sparse tree, for TODO
3745      #+vindex: org-todo-keywords
3746      #+findex: org-show-todo-tree
3747      View TODO items in a /sparse tree/ (see [[*Sparse Trees]]).  Folds
3748      the entire buffer, but shows all TODO items---with not-DONE
3749      state---and the headings hierarchy above them.  With a prefix
3750      argument, or by using {{{kbd(C-c / T)}}}, search for a specific
3751      TODO.  You are prompted for the keyword, and you can also give
3752      a list of keywords like =KWD1|KWD2|...= to list entries that
3753      match any one of these keywords.  With a numeric prefix argument
3754      N, show the tree for the Nth keyword in the variable
3755      ~org-todo-keywords~.  With two prefix arguments, find all TODO
3756      states, both un-done and done.
3758 - {{{kbd(C-c a t)}}} (~org-todo-list~) ::
3760      #+kindex: C-c a t
3761      Show the global TODO list.  Collects the TODO items (with
3762      not-DONE states) from all agenda files (see [[*Agenda Views]]) into
3763      a single buffer.  The new buffer is in Org Agenda mode, which
3764      provides commands to examine and manipulate the TODO entries from
3765      the new buffer (see [[*Commands in the Agenda Buffer]]).  See [[*The
3766      global TODO list]], for more information.
3768 - {{{kbd(S-M-RET)}}} (~org-insert-todo-heading~) ::
3770      #+kindex: S-M-RET
3771      #+findex: org-insert-todo-heading
3772      Insert a new TODO entry below the current one.
3774 #+vindex: org-todo-state-tags-triggers
3775 #+texinfo: @noindent
3776 Changing a TODO state can also trigger tag changes.  See the docstring
3777 of the option ~org-todo-state-tags-triggers~ for details.
3779 ** Extended Use of TODO Keywords
3780 :PROPERTIES:
3781 :DESCRIPTION: Workflow and assignments.
3782 :ALT_TITLE: TODO Extensions
3783 :END:
3784 #+cindex: extended TODO keywords
3786 #+vindex: org-todo-keywords
3787 By default, marked TODO entries have one of only two states: TODO and
3788 DONE.  Org mode allows you to classify TODO items in more complex ways
3789 with /TODO keywords/ (stored in ~org-todo-keywords~).  With special
3790 setup, the TODO keyword system can work differently in different
3791 files.
3793 Note that /tags/ are another way to classify headlines in general and
3794 TODO items in particular (see [[*Tags]]).
3796 *** TODO keywords as workflow states
3797 :PROPERTIES:
3798 :DESCRIPTION: From TODO to DONE in steps.
3799 :ALT_TITLE: Workflow states
3800 :END:
3801 #+cindex: TODO workflow
3802 #+cindex: workflow states as TODO keywords
3804 You can use TODO keywords to indicate different /sequential/ states in
3805 the process of working on an item, for example[fn:37]:
3807 #+begin_src emacs-lisp
3808   (setq org-todo-keywords
3809         '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3810 #+end_src
3812 The vertical bar separates the TODO keywords (states that /need
3813 action/) from the DONE states (which need /no further action/).  If
3814 you do not provide the separator bar, the last state is used as the
3815 DONE state.
3817 #+cindex: completion, of TODO keywords
3818 With this setup, the command {{{kbd(C-c C-t)}}} cycles an entry from
3819 =TODO= to =FEEDBACK=, then to =VERIFY=, and finally to =DONE= and
3820 =DELEGATED=.  You may also use a numeric prefix argument to quickly
3821 select a specific state.  For example {{{kbd(C-3 C-c C-t)}}} changes
3822 the state immediately to =VERIFY=.  Or you can use {{{kbd(S-left)}}}
3823 to go backward through the sequence.  If you define many keywords, you
3824 can use in-buffer completion (see [[*Completion]]) or even a special
3825 one-key selection scheme (see [[*Fast access to TODO states]]) to insert
3826 these words into the buffer.  Changing a TODO state can be logged with
3827 a timestamp, see [[*Tracking TODO state changes]], for more information.
3829 *** TODO keywords as types
3830 :PROPERTIES:
3831 :DESCRIPTION: I do this, Fred does the rest.
3832 :ALT_TITLE: TODO types
3833 :END:
3834 #+cindex: TODO types
3835 #+cindex: names as TODO keywords
3836 #+cindex: types as TODO keywords
3838 The second possibility is to use TODO keywords to indicate different
3839 /types/ of action items.  For example, you might want to indicate that
3840 items are for "work" or "home".  Or, when you work with several people
3841 on a single project, you might want to assign action items directly to
3842 persons, by using their names as TODO keywords.  This would be set up
3843 like this:
3845 #+begin_src emacs-lisp
3846   (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3847 #+end_src
3849 In this case, different keywords do not indicate a sequence, but
3850 rather different types.  So the normal work flow would be to assign
3851 a task to a person, and later to mark it DONE.  Org mode supports this
3852 style by adapting the workings of the command {{{kbd(C-c
3853 C-t)}}}[fn:38].  When used several times in succession, it still
3854 cycles through all names, in order to first select the right type for
3855 a task.  But when you return to the item after some time and execute
3856 {{{kbd(C-c C-t)}}} again, it will switch from any name directly to
3857 =DONE=.  Use prefix arguments or completion to quickly select
3858 a specific name.  You can also review the items of a specific TODO
3859 type in a sparse tree by using a numeric prefix to {{{kbd(C-c / t)}}}.
3860 For example, to see all things Lucy has to do, you would use
3861 {{{kbd(C-3 C-c / t)}}}.  To collect Lucy's items from all agenda files
3862 into a single buffer, you would use the numeric prefix argument as
3863 well when creating the global TODO list: {{{kbd(C-3 C-c a t)}}}.
3865 *** Multiple keyword sets in one file
3866 :PROPERTIES:
3867 :DESCRIPTION: Mixing it all, still finding your way.
3868 :ALT_TITLE: Multiple sets in one file
3869 :END:
3870 #+cindex: TODO keyword sets
3872 Sometimes you may want to use different sets of TODO keywords in
3873 parallel.  For example, you may want to have the basic TODO/DONE, but
3874 also a workflow for bug fixing, and a separate state indicating that
3875 an item has been canceled---so it is not DONE, but also does not
3876 require action.  Your setup would then look like this:
3878 #+begin_src emacs-lisp
3879   (setq org-todo-keywords
3880         '((sequence "TODO" "|" "DONE")
3881           (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3882           (sequence "|" "CANCELED")))
3883 #+end_src
3885 The keywords should all be different, this helps Org mode to keep
3886 track of which subsequence should be used for a given entry.  In this
3887 setup, {{{kbd(C-c C-t)}}} only operates within a subsequence, so it
3888 switches from =DONE= to (nothing) to =TODO=, and from =FIXED= to
3889 (nothing) to =REPORT=.  Therefore you need a mechanism to initially
3890 select the correct sequence.  Besides the obvious ways like typing
3891 a keyword or using completion, you may also apply the following
3892 commands:
3894 #+attr_texinfo: :sep ,
3895 - {{{kbd(C-u C-u C-c C-t)}}}, {{{kbd(C-S-right)}}}, {{{kbd(C-S-left)}}} ::
3897      #+kindex: C-S-right
3898      #+kindex: C-S-left
3899      #+kindex: C-u C-u C-c C-t
3900      These keys jump from one TODO subset to the next.  In the above
3901      example, {{{kbd(C-u C-u C-c C-t)}}} or {{{kbd(C-S-right)}}} would
3902      jump from =TODO= or =DONE= to =REPORT=, and any of the words in
3903      the second row to =CANCELED=.  Note that the {{{kbd(C-S-)}}} key
3904      binding conflict with ~shift-selection-mode~ (see [[*Packages
3905      that conflict with Org mode]]).
3907 - {{{kbd(S-right)}}}, {{{kbd(S-left)}}} ::
3909      #+kindex: S-right
3910      #+kindex: S-left
3911      {{{kbd(S-left)}}} and {{{kbd(S-right)}}} walk through /all/
3912      keywords from all sets, so for example {{{kbd(S-right)}}} would
3913      switch from =DONE= to =REPORT= in the example above.  For
3914      a discussion of the interaction with ~shift-selection-mode~, see
3915      [[*Packages that conflict with Org mode]].
3917 *** Fast access to TODO states
3918 :PROPERTIES:
3919 :DESCRIPTION: Single letter selection of state.
3920 :END:
3922 If you would like to quickly change an entry to an arbitrary TODO
3923 state instead of cycling through the states, you can set up keys for
3924 single-letter access to the states.  This is done by adding the
3925 selection character after each keyword, in parentheses[fn:39].  For
3926 example:
3928 #+begin_src emacs-lisp
3929   (setq org-todo-keywords
3930         '((sequence "TODO(t)" "|" "DONE(d)")
3931           (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3932           (sequence "|" "CANCELED(c)")))
3933 #+end_src
3935 #+vindex: org-fast-tag-selection-include-todo
3936 If you then press {{{kbd(C-c C-t)}}} followed by the selection key,
3937 the entry is switched to this state.  {{{kbd(SPC)}}} can be used to
3938 remove any TODO keyword from an entry[fn:40].
3940 *** Setting up keywords for individual files
3941 :PROPERTIES:
3942 :DESCRIPTION: Different files, different requirements.
3943 :ALT_TITLE: Per-file keywords
3944 :END:
3945 #+cindex: keyword options
3946 #+cindex: per-file keywords
3947 #+cindex: TODO, keyword
3948 #+cindex: TYP_TODO, keyword
3949 #+cindex: SEQ_TODO, keyword
3951 It can be very useful to use different aspects of the TODO mechanism
3952 in different files.  For file-local settings, you need to add special
3953 lines to the file which set the keywords and interpretation for that
3954 file only.  For example, to set one of the two examples discussed
3955 above, you need one of the following lines, starting in column zero
3956 anywhere in the file:
3958 : #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3960 #+texinfo: @noindent
3961 you may also write =#+SEQ_TODO= to be explicit about the
3962 interpretation, but it means the same as =#+TODO=, or
3964 : #+TYP_TODO: Fred Sara Lucy Mike | DONE
3966 A setup for using several sets in parallel would be:
3968 #+begin_example
3969   ,#+TODO: TODO | DONE
3970   ,#+TODO: REPORT BUG KNOWNCAUSE | FIXED
3971   ,#+TODO: | CANCELED
3972 #+end_example
3974 #+cindex: completion, of option keywords
3975 #+kindex: M-TAB
3976 #+texinfo: @noindent
3977 To make sure you are using the correct keyword, type =#+= into the
3978 buffer and then use {{{kbd(M-TAB)}}} completion.
3980 #+cindex: DONE, final TODO keyword
3981 Remember that the keywords after the vertical bar---or the last
3982 keyword if no bar is there---must always mean that the item is DONE,
3983 although you may use a different word.  After changing one of these
3984 lines, use {{{kbd(C-c C-c)}}} with the cursor still in the line to
3985 make the changes known to Org mode[fn:41].
3987 *** Faces for TODO keywords
3988 :PROPERTIES:
3989 :DESCRIPTION: Highlighting states.
3990 :END:
3991 #+cindex: faces, for TODO keywords
3993 #+vindex: org-todo, face
3994 #+vindex: org-done, face
3995 #+vindex: org-todo-keyword-faces
3996 Org mode highlights TODO keywords with special faces: ~org-todo~ for
3997 keywords indicating that an item still has to be acted upon, and
3998 ~org-done~ for keywords indicating that an item is finished.  If you
3999 are using more than two different states, you might want to use
4000 special faces for some of them.  This can be done using the variable
4001 ~org-todo-keyword-faces~.  For example:
4003 #+begin_src emacs-lisp
4004   (setq org-todo-keyword-faces
4005         '(("TODO" . org-warning) ("STARTED" . "yellow")
4006           ("CANCELED" . (:foreground "blue" :weight bold))))
4007 #+end_src
4009 #+vindex: org-faces-easy-properties
4010 While using a list with face properties as shown for =CANCELED=
4011 /should/ work, this does not always seem to be the case.  If
4012 necessary, define a special face and use that.  A string is
4013 interpreted as a color.  The variable ~org-faces-easy-properties~
4014 determines if that color is interpreted as a foreground or
4015 a background color.
4017 *** TODO dependencies
4018 :PROPERTIES:
4019 :DESCRIPTION: When one task needs to wait for others.
4020 :END:
4021 #+cindex: TODO dependencies
4022 #+cindex: dependencies, of TODO states
4024 #+vindex: org-enforce-todo-dependencies
4025 #+cindex: ORDERED, property
4026 The structure of Org files---hierarchy and lists---makes it easy to
4027 define TODO dependencies.  Usually, a parent TODO task should not be
4028 marked DONE until all subtasks, defined as children tasks, are marked
4029 as DONE.  And sometimes there is a logical sequence to a number of
4030 (sub)tasks, so that one task cannot be acted upon before all siblings
4031 above it are done.  If you customize the variable
4032 ~org-enforce-todo-dependencies~, Org blocks entries from changing
4033 state to DONE while they have children that are not DONE.
4034 Furthermore, if an entry has a property =ORDERED=, each of its
4035 children is blocked until all earlier siblings are marked DONE.  Here
4036 is an example:
4038 #+begin_example
4039   ,* TODO Blocked until (two) is done
4040   ,** DONE one
4041   ,** TODO two
4043   ,* Parent
4044   :PROPERTIES:
4045   :ORDERED:  t
4046   :END:
4047   ,** TODO a
4048   ,** TODO b, needs to wait for (a)
4049   ,** TODO c, needs to wait for (a) and (b)
4050 #+end_example
4052 #+cindex: TODO dependencies, NOBLOCKING
4053 #+cindex: NOBLOCKING, property
4054 You can ensure an entry is never blocked by using the =NOBLOCKING=
4055 property:
4057 #+begin_example
4058   ,* This entry is never blocked
4059   :PROPERTIES:
4060   :NOBLOCKING: t
4061   :END:
4062 #+end_example
4064 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4066      #+kindex: C-c C-x o
4067      #+findex: org-toggle-ordered-property
4068      #+vindex: org-track-ordered-property-with-tag
4069      #+cindex: ORDERED, property
4070      Toggle the =ORDERED= property of the current entry.  A property
4071      is used for this behavior because this should be local to the
4072      current entry, not inherited like a tag.  However, if you would
4073      like to /track/ the value of this property with a tag for better
4074      visibility, customize the variable
4075      ~org-track-ordered-property-with-tag~.
4077 - {{{kbd(C-u C-u C-u C-c C-t)}}} ::
4079      #+kindex: C-u C-u C-u C-c C-t
4080      Change TODO state, circumventing any state blocking.
4082 #+vindex: org-agenda-dim-blocked-tasks
4083 If you set the variable ~org-agenda-dim-blocked-tasks~, TODO entries
4084 that cannot be closed because of such dependencies are shown in
4085 a dimmed font or even made invisible in agenda views (see [[*Agenda
4086 Views]]).
4088 #+cindex: checkboxes and TODO dependencies
4089 #+vindex: org-enforce-todo-dependencies
4090 You can also block changes of TODO states by looking at checkboxes
4091 (see [[*Checkboxes]]).  If you set the variable
4092 ~org-enforce-todo-checkbox-dependencies~, an entry that has unchecked
4093 checkboxes is blocked from switching to DONE.
4095 If you need more complex dependency structures, for example
4096 dependencies between entries in different trees or files, check out
4097 the contributed module =org-depend.el=.
4099 ** Progress Logging
4100 :PROPERTIES:
4101 :DESCRIPTION: Dates and notes for progress.
4102 :END:
4103 #+cindex: progress logging
4104 #+cindex: logging, of progress
4106 Org mode can automatically record a timestamp and possibly a note when
4107 you mark a TODO item as DONE, or even each time you change the state
4108 of a TODO item.  This system is highly configurable, settings can be
4109 on a per-keyword basis and can be localized to a file or even
4110 a subtree.  For information on how to clock working time for a task,
4111 see [[*Clocking Work Time]].
4113 *** Closing items
4114 :PROPERTIES:
4115 :DESCRIPTION: When was this entry marked DONE?
4116 :END:
4118 The most basic logging is to keep track of /when/ a certain TODO item
4119 was finished.  This is achieved with[fn:42]
4121 #+begin_src emacs-lisp
4122   (setq org-log-done 'time)
4123 #+end_src
4125 #+vindex: org-closed-keep-when-no-todo
4126 #+texinfo: @noindent
4127 Then each time you turn an entry from a TODO (not-done) state into any
4128 of the DONE states, a line =CLOSED: [timestamp]= is inserted just
4129 after the headline.  If you turn the entry back into a TODO item
4130 through further state cycling, that line is removed again.  If you
4131 turn the entry back to a non-TODO state (by pressing {{{kbd(C-c C-t
4132 SPC)}}} for example), that line is also removed, unless you set
4133 ~org-closed-keep-when-no-todo~ to non-~nil~.  If you want to record
4134 a note along with the timestamp, use[fn:43]
4136 #+begin_src emacs-lisp
4137   (setq org-log-done 'note)
4138 #+end_src
4140 #+texinfo: @noindent
4141 You are then be prompted for a note, and that note is stored below the
4142 entry with a =Closing Note= heading.
4144 *** Tracking TODO state changes
4145 :PROPERTIES:
4146 :DESCRIPTION: When did the status change?
4147 :END:
4148 #+cindex: drawer, for state change recording
4150 #+vindex: org-log-states-order-reversed
4151 #+vindex: org-log-into-drawer
4152 #+cindex: LOG_INTO_DRAWER, property
4153 When TODO keywords are used as workflow states (see [[*TODO keywords as workflow states][*Workflow states]]),
4154 you might want to keep track of when a state change occurred and maybe
4155 take a note about this change.  You can either record just
4156 a timestamp, or a time-stamped note for a change.  These records are
4157 inserted after the headline as an itemized list, newest first[fn:44].
4158 When taking a lot of notes, you might want to get the notes out of the
4159 way into a drawer (see [[*Drawers]]).  Customize the variable
4160 ~org-log-into-drawer~ to get this behavior---the recommended drawer
4161 for this is called =LOGBOOK=[fn:45].  You can also overrule the
4162 setting of this variable for a subtree by setting a =LOG_INTO_DRAWER=
4163 property.
4165 Since it is normally too much to record a note for every state, Org
4166 mode expects configuration on a per-keyword basis for this.  This is
4167 achieved by adding special markers =!= (for a timestamp) or =@= (for
4168 a note with timestamp) in parentheses after each keyword.  For
4169 example, with the setting
4171 #+begin_src emacs-lisp
4172   (setq org-todo-keywords
4173         '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))
4174 #+end_src
4176 To record a timestamp without a note for TODO keywords configured with
4177 =@=, just type {{{kbd(C-c C-c)}}} to enter a blank note when prompted.
4179 #+vindex: org-log-done
4180 #+texinfo: noindent
4181 you not only define global TODO keywords and fast access keys, but
4182 also request that a time is recorded when the entry is set to =DONE=,
4183 and that a note is recorded when switching to =WAIT= or
4184 =CANCELED=[fn:46].  The setting for =WAIT= is even more special: the
4185 =!= after the slash means that in addition to the note taken when
4186 entering the state, a timestamp should be recorded when /leaving/ the
4187 =WAIT= state, if and only if the /target/ state does not configure
4188 logging for entering it.  So it has no effect when switching from
4189 =WAIT= to =DONE=, because =DONE= is configured to record a timestamp
4190 only.  But when switching from =WAIT= back to =TODO=, the =/!= in the
4191 =WAIT= setting now triggers a timestamp even though =TODO= has no
4192 logging configured.
4194 You can use the exact same syntax for setting logging preferences local
4195 to a buffer:
4197 : #+TODO: TODO(t) WAIT(w@/!) | DONE(d!) CANCELED(c@)
4199 #+cindex: LOGGING, property
4200 In order to define logging settings that are local to a subtree or
4201 a single item, define a =LOGGING= property in this entry.  Any
4202 non-empty =LOGGING= property resets all logging settings to ~nil~.
4203 You may then turn on logging for this specific tree using =STARTUP=
4204 keywords like =lognotedone= or =logrepeat=, as well as adding state
4205 specific settings like =TODO(!)=.  For example:
4207 #+begin_example
4208   ,* TODO Log each state with only a time
4209     :PROPERTIES:
4210     :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4211     :END:
4212   ,* TODO Only log when switching to WAIT, and when repeating
4213     :PROPERTIES:
4214     :LOGGING: WAIT(@) logrepeat
4215     :END:
4216   ,* TODO No logging at all
4217     :PROPERTIES:
4218     :LOGGING: nil
4219     :END:
4220 #+end_example
4222 *** Tracking your habits
4223 :PROPERTIES:
4224 :DESCRIPTION: How consistent have you been?
4225 :END:
4226 #+cindex: habits
4227 #+cindex: STYLE, property
4229 Org has the ability to track the consistency of a special category of
4230 TODO, called "habits."  A habit has the following properties:
4232 1. You have enabled the ~habits~ module by customizing the variable
4233    ~org-modules~.
4235 2. The habit is a TODO item, with a TODO keyword representing an open
4236    state.
4238 3. The property =STYLE= is set to the value =habit=.
4240 4. The TODO has a scheduled date, usually with a =.+= style repeat
4241    interval.  A =++= style may be appropriate for habits with time
4242    constraints, e.g., must be done on weekends, or a =+= style for an
4243    unusual habit that can have a backlog, e.g., weekly reports.
4245 5. The TODO may also have minimum and maximum ranges specified by
4246    using the syntax =.+2d/3d=, which says that you want to do the task
4247    at least every three days, but at most every two days.
4249 6. You must also have state logging for the DONE state enabled (see
4250    [[*Tracking TODO state changes]]), in order for historical data to be
4251    represented in the consistency graph.  If it is not enabled it is
4252    not an error, but the consistency graphs are largely meaningless.
4254 To give you an idea of what the above rules look like in action, here's an
4255 actual habit with some history:
4257 #+begin_example
4258   ,** TODO Shave
4259      SCHEDULED: <2009-10-17 Sat .+2d/4d>
4260      :PROPERTIES:
4261      :STYLE:    habit
4262      :LAST_REPEAT: [2009-10-19 Mon 00:36]
4263      :END:
4264      - State "DONE"       from "TODO"       [2009-10-15 Thu]
4265      - State "DONE"       from "TODO"       [2009-10-12 Mon]
4266      - State "DONE"       from "TODO"       [2009-10-10 Sat]
4267      - State "DONE"       from "TODO"       [2009-10-04 Sun]
4268      - State "DONE"       from "TODO"       [2009-10-02 Fri]
4269      - State "DONE"       from "TODO"       [2009-09-29 Tue]
4270      - State "DONE"       from "TODO"       [2009-09-25 Fri]
4271      - State "DONE"       from "TODO"       [2009-09-19 Sat]
4272      - State "DONE"       from "TODO"       [2009-09-16 Wed]
4273      - State "DONE"       from "TODO"       [2009-09-12 Sat]
4274 #+end_example
4276 What this habit says is: I want to shave at most every 2 days---given
4277 by the =SCHEDULED= date and repeat interval---and at least every
4278 4 days.  If today is the 15th, then the habit first appears in the
4279 agenda on Oct 17, after the minimum of 2 days has elapsed, and will
4280 appear overdue on Oct 19, after four days have elapsed.
4282 What's really useful about habits is that they are displayed along
4283 with a consistency graph, to show how consistent you've been at
4284 getting that task done in the past.  This graph shows every day that
4285 the task was done over the past three weeks, with colors for each day.
4286 The colors used are:
4288 - Blue :: If the task was not to be done yet on that day.
4289 - Green :: If the task could have been done on that day.
4290 - Yellow :: If the task was going to be overdue the next day.
4291 - Red :: If the task was overdue on that day.
4293 In addition to coloring each day, the day is also marked with an
4294 asterisk if the task was actually done that day, and an exclamation
4295 mark to show where the current day falls in the graph.
4297 There are several configuration variables that can be used to change
4298 the way habits are displayed in the agenda.
4300 - ~org-habit-graph-column~ ::
4302      #+vindex: org-habit-graph-column
4303      The buffer column at which the consistency graph should be drawn.
4304      This overwrites any text in that column, so it is a good idea to
4305      keep your habits' titles brief and to the point.
4307 - ~org-habit-preceding-days~ ::
4309      #+vindex: org-habit-preceding-days
4310      The amount of history, in days before today, to appear in
4311      consistency graphs.
4313 - ~org-habit-following-days~ ::
4315      #+vindex: org-habit-following-days
4316      The number of days after today that appear in consistency graphs.
4318 - ~org-habit-show-habits-only-for-today~ ::
4320      #+vindex: org-habit-show-habits-only-for-today
4321      If non-~nil~, only show habits in today's agenda view.  This is
4322      set to true by default.
4324 Lastly, pressing {{{kbd(K)}}} in the agenda buffer causes habits to
4325 temporarily be disabled and do not appear at all.  Press {{{kbd(K)}}}
4326 again to bring them back.  They are also subject to tag filtering, if
4327 you have habits which should only be done in certain contexts, for
4328 example.
4330 ** Priorities
4331 :PROPERTIES:
4332 :DESCRIPTION: Some things are more important than others.
4333 :END:
4334 #+cindex: priorities
4335 #+cindex: priority cookie
4337 If you use Org mode extensively, you may end up with enough TODO items
4338 that it starts to make sense to prioritize them.  Prioritizing can be
4339 done by placing a /priority cookie/ into the headline of a TODO item,
4340 like this
4342 : *** TODO [#A] Write letter to Sam Fortune
4344 #+vindex: org-priority-faces
4345 #+texinfo: @noindent
4346 By default, Org mode supports three priorities: =A=, =B=, and =C=.
4347 =A= is the highest priority.  An entry without a cookie is treated
4348 just like priority =B=.  Priorities make a difference only for sorting
4349 in the agenda (see [[*Weekly/daily agenda]]); outside the agenda, they
4350 have no inherent meaning to Org mode.  The cookies can be highlighted
4351 with special faces by customizing the variable ~org-priority-faces~.
4353 Priorities can be attached to any outline node; they do not need to be
4354 TODO items.
4356 #+attr_texinfo: :sep ;
4357 - {{{kbd(C-c \,)}}} (~org-priority~) ::
4359      #+kindex: C-c ,
4360      #+findex: org-priority
4361      Set the priority of the current headline.  The command prompts
4362      for a priority character =A=, =B= or =C=.  When you press
4363      {{{kbd(SPC)}}} instead, the priority cookie is removed from the
4364      headline.  The priorities can also be changed "remotely" from the
4365      timeline and agenda buffer with the {{{kbd(\,)}}} command (see
4366      [[*Commands in the Agenda Buffer]]).
4368 - {{{kbd(S-up)}}} (~org-priority-up~); {{{kbd(S-down)}}} (~org-priority-down~) ::
4370      #+kindex: S-up
4371      #+kindex: S-down
4372      #+findex: org-priority-up
4373      #+findex: org-priority-down
4374      #+vindex: org-priority-start-cycle-with-default
4375      Increase/decrease priority of current headline[fn:47].  Note that
4376      these keys are also used to modify timestamps (see [[*Creating
4377      Timestamps]]).  See also [[*Packages that conflict with Org mode]], for
4378      a discussion of the interaction with ~shift-selection-mode~.
4380 #+vindex: org-highest-priority
4381 #+vindex: org-lowest-priority
4382 #+vindex: org-default-priority
4383 You can change the range of allowed priorities by setting the
4384 variables ~org-highest-priority~, ~org-lowest-priority~, and
4385 ~org-default-priority~.  For an individual buffer, you may set these
4386 values (highest, lowest, default) like this (please make sure that the
4387 highest priority is earlier in the alphabet than the lowest priority):
4389 #+cindex: PRIORITIES, keyword
4390 : #+PRIORITIES: A C B
4392 ** Breaking Down Tasks into Subtasks
4393 :PROPERTIES:
4394 :DESCRIPTION: Splitting a task into manageable pieces.
4395 :ALT_TITLE: Breaking Down Tasks
4396 :END:
4397 #+cindex: tasks, breaking down
4398 #+cindex: statistics, for TODO items
4400 #+vindex: org-agenda-todo-list-sublevels
4401 It is often advisable to break down large tasks into smaller,
4402 manageable subtasks.  You can do this by creating an outline tree
4403 below a TODO item, with detailed subtasks on the tree[fn:48].  To keep
4404 the overview over the fraction of subtasks that are already completed,
4405 insert either =[/]= or =[%]= anywhere in the headline.  These cookies
4406 are updated each time the TODO status of a child changes, or when
4407 pressing {{{kbd(C-c C-c)}}} on the cookie.  For example:
4409 #+begin_example
4410   ,* Organize Party [33%]
4411   ,** TODO Call people [1/2]
4412   ,*** TODO Peter
4413   ,*** DONE Sarah
4414   ,** TODO Buy food
4415   ,** DONE Talk to neighbor
4416 #+end_example
4418 #+cindex: COOKIE_DATA, property
4419 If a heading has both checkboxes and TODO children below it, the
4420 meaning of the statistics cookie become ambiguous.  Set the property
4421 =COOKIE_DATA= to either =checkbox= or =todo= to resolve this issue.
4423 #+vindex: org-hierarchical-todo-statistics
4424 If you would like to have the statistics cookie count any TODO entries
4425 in the subtree (not just direct children), configure the variable
4426 ~org-hierarchical-todo-statistics~.  To do this for a single subtree,
4427 include the word =recursive= into the value of the =COOKIE_DATA=
4428 property.
4430 #+begin_example org
4431   ,* Parent capturing statistics [2/20]
4432     :PROPERTIES:
4433     :COOKIE_DATA: todo recursive
4434     :END:
4435 #+end_example
4437 If you would like a TODO entry to automatically change to DONE when
4438 all children are done, you can use the following setup:
4440 #+begin_src emacs-lisp
4441   (defun org-summary-todo (n-done n-not-done)
4442     "Switch entry to DONE when all subentries are done, to TODO otherwise."
4443     (let (org-log-done org-log-states)   ; turn off logging
4444       (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4446   (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4447 #+end_src
4449 Another possibility is the use of checkboxes to identify (a hierarchy
4450 of) a large number of subtasks (see [[*Checkboxes]]).
4452 ** Checkboxes
4453 :PROPERTIES:
4454 :DESCRIPTION: Tick-off lists.
4455 :END:
4456 #+cindex: checkboxes
4458 #+vindex: org-list-automatic-rules
4459 Every item in a plain list[fn:49] (see [[*Plain Lists]]) can be made into
4460 a checkbox by starting it with the string =[ ]=.  This feature is
4461 similar to TODO items (see [[*TODO Items]]), but is more lightweight.
4462 Checkboxes are not included into the global TODO list, so they are
4463 often great to split a task into a number of simple steps.  Or you can
4464 use them in a shopping list.  To toggle a checkbox, use {{{kbd(C-c
4465 C-c)}}}, or use the mouse (thanks to Piotr Zielinski's
4466 =org-mouse.el=).
4468 Here is an example of a checkbox list.
4470 #+begin_example
4471   ,* TODO Organize party [2/4]
4472     - [-] call people [1/3]
4473       - [ ] Peter
4474       - [X] Sarah
4475       - [ ] Sam
4476     - [X] order food
4477     - [ ] think about what music to play
4478     - [X] talk to the neighbors
4479 #+end_example
4481 Checkboxes work hierarchically, so if a checkbox item has children
4482 that are checkboxes, toggling one of the children checkboxes makes the
4483 parent checkbox reflect if none, some, or all of the children are
4484 checked.
4486 #+cindex: statistics, for checkboxes
4487 #+cindex: checkbox statistics
4488 #+cindex: COOKIE_DATA, property
4489 #+vindex: org-hierarchical-checkbox-statistics
4490 The =[2/4]= and =[1/3]= in the first and second line are cookies
4491 indicating how many checkboxes present in this entry have been checked
4492 off, and the total number of checkboxes present.  This can give you an
4493 idea on how many checkboxes remain, even without opening a folded
4494 entry.  The cookies can be placed into a headline or into (the first
4495 line of) a plain list item.  Each cookie covers checkboxes of direct
4496 children structurally below the headline/item on which the cookie
4497 appears[fn:50].  You have to insert the cookie yourself by typing
4498 either =[/]= or =[%]=.  With =[/]= you get an =n out of m= result, as
4499 in the examples above.  With =[%]= you get information about the
4500 percentage of checkboxes checked (in the above example, this would be
4501 =[50%]= and =[33%]=, respectively).  In a headline, a cookie can count
4502 either checkboxes below the heading or TODO states of children, and it
4503 displays whatever was changed last.  Set the property =COOKIE_DATA= to
4504 either =checkbox= or =todo= to resolve this issue.
4506 #+cindex: blocking, of checkboxes
4507 #+cindex: checkbox blocking
4508 #+cindex: ORDERED, property
4509 If the current outline node has an =ORDERED= property, checkboxes must
4510 be checked off in sequence, and an error is thrown if you try to check
4511 off a box while there are unchecked boxes above it.
4513 #+texinfo: @noindent
4514 The following commands work with checkboxes:
4516 - {{{kbd(C-c C-c)}}} (~org-toggle-checkbox~) ::
4518      #+kindex: C-c C-c
4519      #+findex: org-toggle-checkbox
4520      Toggle checkbox status or---with prefix argument---checkbox
4521      presence at point.  With a single prefix argument, add an empty
4522      checkbox or remove the current one[fn:51].  With a double prefix
4523      argument, set it to =[-]=, which is considered to be an
4524      intermediate state.
4526 - {{{kbd(C-c C-x C-b)}}} (~org-toggle-checkbox~) ::
4528      #+kindex: C-c C-x C-b
4529      Toggle checkbox status or---with prefix argument---checkbox
4530      presence at point.  With double prefix argument, set it to =[-]=,
4531      which is considered to be an intermediate state.
4533      - If there is an active region, toggle the first checkbox in the
4534        region and set all remaining boxes to the same status as the
4535        first.  With a prefix argument, add or remove the checkbox for
4536        all items in the region.
4538      - If the cursor is in a headline, toggle checkboxes in the region
4539        between this headline and the next---so /not/ the entire
4540        subtree.
4542      - If there is no active region, just toggle the checkbox at
4543        point.
4545 - {{{kbd(M-S-RET)}}} (~org-insert-todo-heading~) ::
4547      #+kindex: M-S-RET
4548      #+findex: org-insert-todo-heading
4549      Insert a new item with a checkbox.  This works only if the cursor
4550      is already in a plain list item (see [[*Plain Lists]]).
4552 - {{{kbd(C-c C-x o)}}} (~org-toggle-ordered-property~) ::
4554      #+kindex: C-c C-x o
4555      #+findex: org-toggle-ordered-property
4556      #+vindex: org-track-ordered-property-with-tag
4557      Toggle the =ORDERED= property of the entry, to toggle if
4558      checkboxes must be checked off in sequence.  A property is used
4559      for this behavior because this should be local to the current
4560      entry, not inherited like a tag.  However, if you would like to
4561      /track/ the value of this property with a tag for better
4562      visibility, customize ~org-track-ordered-property-with-tag~.
4564 - {{{kbd(C-c #)}}} (~org-update-statistics-cookies~) ::
4566      #+kindex: C-c #
4567      #+findex: org-update-statistics-cookies
4568      Update the statistics cookie in the current outline entry.  When
4569      called with a {{{kbd(C-u)}}} prefix, update the entire file.
4570      Checkbox statistic cookies are updated automatically if you
4571      toggle checkboxes with {{{kbd(C-c C-c)}}} and make new ones with
4572      {{{kbd(M-S-RET)}}}.  TODO statistics cookies update when changing
4573      TODO states.  If you delete boxes/entries or add/change them by
4574      hand, use this command to get things back into sync.
4576 * Tags
4577 :PROPERTIES:
4578 :DESCRIPTION: Tagging headlines and matching sets of tags.
4579 :END:
4580 #+cindex: tags
4581 #+cindex: headline tagging
4582 #+cindex: matching, tags
4583 #+cindex: sparse tree, tag based
4585 An excellent way to implement labels and contexts for
4586 cross-correlating information is to assign /tags/ to headlines.  Org
4587 mode has extensive support for tags.
4589 #+vindex: org-tag-faces
4590 Every headline can contain a list of tags; they occur at the end of
4591 the headline.  Tags are normal words containing letters, numbers, =_=,
4592 and =@=.  Tags must be preceded and followed by a single colon, e.g.,
4593 =:work:=.  Several tags can be specified, as in =:work:urgent:=.  Tags
4594 by default are in bold face with the same color as the headline.  You
4595 may specify special faces for specific tags using the variable
4596 ~org-tag-faces~, in much the same way as you can for TODO keywords
4597 (see [[*Faces for TODO keywords]]).
4599 ** Tag Inheritance
4600 :PROPERTIES:
4601 :DESCRIPTION: Tags use the tree structure of an outline.
4602 :END:
4603 #+cindex: tag inheritance
4604 #+cindex: inheritance, of tags
4605 #+cindex: sublevels, inclusion into tags match
4607 /Tags/ make use of the hierarchical structure of outline trees.  If
4608 a heading has a certain tag, all subheadings inherit the tag as well.
4609 For example, in the list
4611 #+begin_example
4612   ,* Meeting with the French group      :work:
4613   ,** Summary by Frank                  :boss:notes:
4614   ,*** TODO Prepare slides for him      :action:
4615 #+end_example
4617 #+texinfo: @noindent
4618 the final heading has the tags =work=, =boss=, =notes=, and =action=
4619 even though the final heading is not explicitly marked with those
4620 tags.  You can also set tags that all entries in a file should inherit
4621 just as if these tags were defined in a hypothetical level zero that
4622 surrounds the entire file.  Use a line like this[fn:52]
4624 #+cindex: FILETAGS, keyword
4625 : #+FILETAGS: :Peter:Boss:Secret:
4627 #+vindex: org-use-tag-inheritance
4628 #+vindex: org-tags-exclude-from-inheritance
4629 #+texinfo: @noindent
4630 To limit tag inheritance to specific tags, or to turn it off entirely,
4631 use the variables ~org-use-tag-inheritance~ and
4632 ~org-tags-exclude-from-inheritance~.
4634 #+vindex: org-tags-match-list-sublevels
4635 When a headline matches during a tags search while tag inheritance is
4636 turned on, all the sublevels in the same tree---for a simple match
4637 form---match as well[fn:53].  The list of matches may then become
4638 very long.  If you only want to see the first tags match in a subtree,
4639 configure the variable ~org-tags-match-list-sublevels~ (not
4640 recommended).
4642 #+vindex: org-agenda-use-tag-inheritance
4643 Tag inheritance is relevant when the agenda search tries to match
4644 a tag, either in the ~tags~ or ~tags-todo~ agenda types.  In other
4645 agenda types, ~org-use-tag-inheritance~ has no effect.  Still, you may
4646 want to have your tags correctly set in the agenda, so that tag
4647 filtering works fine, with inherited tags.  Set
4648 ~org-agenda-use-tag-inheritance~ to control this: the default value
4649 includes all agenda types, but setting this to ~nil~ can really speed
4650 up agenda generation.
4652 ** Setting Tags
4653 :PROPERTIES:
4654 :DESCRIPTION: How to assign tags to a headline.
4655 :END:
4656 #+cindex: setting tags
4657 #+cindex: tags, setting
4659 #+kindex: M-TAB
4660 Tags can simply be typed into the buffer at the end of a headline.
4661 After a colon, {{{kbd(M-TAB)}}} offers completion on tags.  There is
4662 also a special command for inserting tags:
4664 - {{{kbd(C-c C-q)}}} (~org-set-tags-command~) ::
4666      #+kindex: C-c C-q
4667      #+findex: org-set-tags-command
4668      #+cindex: completion, of tags
4669      #+vindex: org-tags-column
4670      Enter new tags for the current headline.  Org mode either offers
4671      completion or a special single-key interface for setting tags,
4672      see below.  After pressing {{{kbd(RET)}}}, the tags are inserted
4673      and aligned to ~org-tags-column~.  When called with
4674      a {{{kbd(C-u)}}} prefix, all tags in the current buffer are
4675      aligned to that column, just to make things look nice.  Tags are
4676      automatically realigned after promotion, demotion, and TODO state
4677      changes (see [[*Basic TODO Functionality]]).
4679 - {{{kbd(C-c C-c)}}} (~org-set-tags-command~) ::
4681      #+kindex: C-c C-c
4682      When the cursor is in a headline, this does the same as
4683      {{{kbd(C-c C-q)}}}.
4685 #+vindex: org-tag-alist
4686 Org supports tag insertion based on a /list of tags/.  By default this
4687 list is constructed dynamically, containing all tags currently used in
4688 the buffer.  You may also globally specify a hard list of tags with
4689 the variable ~org-tag-alist~.  Finally you can set the default tags
4690 for a given file with lines like
4692 #+cindex: TAGS, keyword
4693 #+begin_example
4694   ,#+TAGS: @work @home @tennisclub
4695   ,#+TAGS: laptop car pc sailboat
4696 #+end_example
4698 If you have globally defined your preferred set of tags using the
4699 variable ~org-tag-alist~, but would like to use a dynamic tag list in
4700 a specific file, add an empty =TAGS= keyword to that file:
4702 : #+TAGS:
4704 #+vindex: org-tag-persistent-alist
4705 If you have a preferred set of tags that you would like to use in
4706 every file, in addition to those defined on a per-file basis by =TAGS=
4707 keyword, then you may specify a list of tags with the variable
4708 ~org-tag-persistent-alist~.  You may turn this off on a per-file basis
4709 by adding a =STARTUP= keyword to that file:
4711 : #+STARTUP: noptag
4713 By default Org mode uses the standard minibuffer completion facilities
4714 for entering tags.  However, it also implements another, quicker, tag
4715 selection method called /fast tag selection/.  This allows you to
4716 select and deselect tags with just a single key press.  For this to
4717 work well you should assign unique letters to most of your commonly
4718 used tags.  You can do this globally by configuring the variable
4719 ~org-tag-alist~ in your Emacs init file.  For example, you may find
4720 the need to tag many items in different files with =@home=.  In this
4721 case you can set something like:
4723 #+begin_src emacs-lisp
4724   (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("laptop" . ?l)))
4725 #+end_src
4727 #+texinfo: @noindent
4728 If the tag is only relevant to the file you are working on, then you
4729 can instead set the =TAGS= keyword as:
4731 : #+TAGS: @work(w)  @home(h)  @tennisclub(t)  laptop(l)  pc(p)
4733 #+texinfo: @noindent
4734 The tags interface shows the available tags in a splash window.  If
4735 you want to start a new line after a specific tag, insert =\n= into
4736 the tag list
4738 : #+TAGS: @work(w) @home(h) @tennisclub(t) \n laptop(l) pc(p)
4740 #+texinfo: @noindent
4741 or write them in two lines:
4743 #+begin_example
4744   ,#+TAGS: @work(w)  @home(h)  @tennisclub(t)
4745   ,#+TAGS: laptop(l)  pc(p)
4746 #+end_example
4748 #+texinfo: @noindent
4749 You can also group together tags that are mutually exclusive by using
4750 braces, as in:
4752 : #+TAGS: { @work(w)  @home(h)  @tennisclub(t) }  laptop(l)  pc(p)
4754 #+texinfo: @noindent
4755 you indicate that at most one of =@work=, =@home=, and =@tennisclub=
4756 should be selected.  Multiple such groups are allowed.
4758 #+texinfo: @noindent
4759 Do not forget to press {{{kbd(C-c C-c)}}} with the cursor in one of
4760 these lines to activate any changes.
4762 #+texinfo: @noindent
4763 To set these mutually exclusive groups in the variable
4764 ~org-tags-alist~, you must use the dummy tags ~:startgroup~ and
4765 ~:endgroup~ instead of the braces.  Similarly, you can use ~:newline~
4766 to indicate a line break.  The previous example would be set globally
4767 by the following configuration:
4769 #+begin_src emacs-lisp
4770   (setq org-tag-alist '((:startgroup . nil)
4771                         ("@work" . ?w) ("@home" . ?h)
4772                         ("@tennisclub" . ?t)
4773                         (:endgroup . nil)
4774                         ("laptop" . ?l) ("pc" . ?p)))
4775 #+end_src
4777 If at least one tag has a selection key then pressing {{{kbd(C-c
4778 C-c)}}} automatically presents you with a special interface, listing
4779 inherited tags, the tags of the current headline, and a list of all
4780 valid tags with corresponding keys[fn:54].
4782 Pressing keys assigned to tags adds or removes them from the list of
4783 tags in the current line.  Selecting a tag in a group of mutually
4784 exclusive tags turns off any other tag from that group.
4786 In this interface, you can also use the following special keys:
4788 - {{{kbd(TAB)}}} ::
4790      #+kindex: TAB
4791      Enter a tag in the minibuffer, even if the tag is not in the
4792      predefined list.  You can complete on all tags present in the
4793      buffer.  You can also add several tags: just separate them with
4794      a comma.
4796 - {{{kbd(SPC)}}} ::
4798      #+kindex: SPC
4799      Clear all tags for this line.
4801 - {{{kbd(RET)}}} ::
4803      #+kindex: RET
4804      Accept the modified set.
4806 - {{{kbd(C-g)}}} ::
4808      #+kindex: C-g
4809      Abort without installing changes.
4811 - {{{kbd(q)}}} ::
4813      #+kindex: q
4814      If {{{kbd(q)}}} is not assigned to a tag, it aborts like
4815      {{{kbd(C-g)}}}.
4817 - {{{kbd(!)}}} ::
4819      #+kindex: !
4820      Turn off groups of mutually exclusive tags.  Use this to (as an
4821      exception) assign several tags from such a group.
4823 - {{{kbd(C-c)}}} ::
4825      #+kindex: C-c C-c
4826      Toggle auto-exit after the next change (see below).  If you are
4827      using expert mode, the first {{{kbd(C-c)}}} displays the
4828      selection window.
4830 #+texinfo: @noindent
4831 This method lets you assign tags to a headline with very few keys.
4832 With the above setup, you could clear the current tags and set
4833 =@home=, =laptop= and =pc= tags with just the following keys:
4834 {{{kbd(C-c C-c SPC h l p RET)}}}.  Switching from =@home= to =@work=
4835 would be done with {{{kbd(C-c C-c w RET)}}} or alternatively with
4836 {{{kbd(C-c C-c C-c w)}}}.  Adding the non-predefined tag =Sarah= could
4837 be done with {{{kbd(C-c C-c TAB S a r a h RET)}}}.
4839 #+vindex: org-fast-tag-selection-single-key
4840 If you find that most of the time you need only a single key press to
4841 modify your list of tags, set the variable
4842 ~org-fast-tag-selection-single-key~.  Then you no longer have to press
4843 {{{kbd(RET)}}} to exit fast tag selection---it exits after the first
4844 change.  If you then occasionally need more keys, press {{{kbd(C-c)}}}
4845 to turn off auto-exit for the current tag selection process (in
4846 effect: start selection with {{{kbd(C-c C-c C-c)}}} instead of
4847 {{{kbd(C-c C-c)}}}).  If you set the variable to the value ~expert~,
4848 the special window is not even shown for single-key tag selection, it
4849 comes up only when you press an extra {{{kbd(C-c)}}}.
4851 ** Tag Hierarchy
4852 :PROPERTIES:
4853 :DESCRIPTION: Create a hierarchy of tags.
4854 :END:
4855 #+cindex: group tags
4856 #+cindex: tags, groups
4857 #+cindex: tags hierarchy
4859 Tags can be defined in hierarchies.  A tag can be defined as a /group
4860 tag/ for a set of other tags.  The group tag can be seen as the
4861 "broader term" for its set of tags.  Defining multiple group tags and
4862 nesting them creates a tag hierarchy.
4864 One use-case is to create a taxonomy of terms (tags) that can be used
4865 to classify nodes in a document or set of documents.
4867 When you search for a group tag, it return matches for all members in
4868 the group and its subgroups.  In an agenda view, filtering by a group
4869 tag displays or hide headlines tagged with at least one of the members
4870 of the group or any of its subgroups.  This makes tag searches and
4871 filters even more flexible.
4873 You can set group tags by using brackets and inserting a colon between
4874 the group tag and its related tags---beware that all whitespaces are
4875 mandatory so that Org can parse this line correctly:
4877 : #+TAGS: [ GTD : Control Persp ]
4879 In this example, =GTD= is the group tag and it is related to two other
4880 tags: =Control=, =Persp=.  Defining =Control= and =Persp= as group
4881 tags creates an hierarchy of tags:
4883 #+begin_example
4884   ,#+TAGS: [ Control : Context Task ]
4885   ,#+TAGS: [ Persp : Vision Goal AOF Project ]
4886 #+end_example
4888 That can conceptually be seen as a hierarchy of tags:
4890 - =GTD=
4891   - =Persp=
4892     - =Vision=
4893     - =Goal=
4894     - =AOF=
4895     - =Project=
4896   - =Control=
4897     - =Context=
4898     - =Task=
4900 You can use the ~:startgrouptag~, ~:grouptags~ and ~:endgrouptag~
4901 keyword directly when setting ~org-tag-alist~ directly:
4903 #+begin_src emacs-lisp
4904   (setq org-tag-alist '((:startgrouptag)
4905                         ("GTD")
4906                         (:grouptags)
4907                         ("Control")
4908                         ("Persp")
4909                         (:endgrouptag)
4910                         (:startgrouptag)
4911                         ("Control")
4912                         (:grouptags)
4913                         ("Context")
4914                         ("Task")
4915                         (:endgrouptag)))
4916 #+end_src
4918 The tags in a group can be mutually exclusive if using the same group
4919 syntax as is used for grouping mutually exclusive tags together; using
4920 curly brackets.
4922 : #+TAGS: { Context : @Home @Work @Call }
4924 When setting ~org-tag-alist~ you can use ~:startgroup~ and ~:endgroup~
4925 instead of ~:startgrouptag~ and ~:endgrouptag~ to make the tags
4926 mutually exclusive.
4928 Furthermore, the members of a group tag can also be regular
4929 expressions, creating the possibility of a more dynamic and rule-based
4930 tag structure.  The regular expressions in the group must be specified
4931 within curly brackets.  Here is an expanded example:
4933 #+begin_example
4934   ,#+TAGS: [ Vision : {V@.+} ]
4935   ,#+TAGS: [ Goal : {G@.+} ]
4936   ,#+TAGS: [ AOF : {AOF@.+} ]
4937   ,#+TAGS: [ Project : {P@.+} ]
4938 #+end_example
4940 Searching for the tag =Project= now lists all tags also including
4941 regular expression matches for =P@.+=, and similarly for tag searches
4942 on =Vision=, =Goal= and =AOF=.  For example, this would work well for
4943 a project tagged with a common project-identifier,
4944 e.g. =P@2014_OrgTags=.
4946 #+kindex: C-c C-x q
4947 #+findex: org-toggle-tags-groups
4948 #+vindex: org-group-tags
4949 If you want to ignore group tags temporarily, toggle group tags
4950 support with ~org-toggle-tags-groups~, bound to {{{kbd(C-c C-x q)}}}.
4951 If you want to disable tag groups completely, set ~org-group-tags~ to
4952 ~nil~.
4954 ** Tag Searches
4955 :PROPERTIES:
4956 :DESCRIPTION: Searching for combinations of tags.
4957 :END:
4958 #+cindex: tag searches
4959 #+cindex: searching for tags
4961 Once a system of tags has been set up, it can be used to collect
4962 related information into special lists.
4964 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
4966      #+kindex: C-c / m
4967      #+kindex: C-c \
4968      #+findex: org-match-sparse-tree
4969      Create a sparse tree with all headlines matching a tags search.
4970      With a {{{kbd(C-u)}}} prefix argument, ignore headlines that are
4971      not a TODO line.
4973 - {{{kbd(C-c a m)}}} (~org-tags-view~) ::
4975      #+kindex: C-c a m
4976      #+findex: org-tags-view
4977      Create a global list of tag matches from all agenda files.  See
4978      [[*Matching tags and properties]].
4980 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
4982      #+kindex: C-c a M
4983      #+vindex: org-tags-match-list-sublevels
4984      Create a global list of tag matches from all agenda files, but
4985      check only TODO items and force checking subitems (see the option
4986      ~org-tags-match-list-sublevels~).
4988 These commands all prompt for a match string which allows basic
4989 Boolean logic like =+boss+urgent-project1=, to find entries with tags
4990 =boss= and =urgent=, but not =project1=, or =Kathy|Sally= to find
4991 entries which are tagged, like =Kathy= or =Sally=.  The full syntax of
4992 the search string is rich and allows also matching against TODO
4993 keywords, entry levels and properties.  For a complete description
4994 with many examples, see [[*Matching tags and properties]].
4996 * Properties and Columns
4997 :PROPERTIES:
4998 :DESCRIPTION: Storing information about an entry.
4999 :END:
5000 #+cindex: properties
5002 A property is a key-value pair associated with an entry.  Properties
5003 can be set so they are associated with a single entry, with every
5004 entry in a tree, or with every entry in an Org file.
5006 There are two main applications for properties in Org mode.  First,
5007 properties are like tags, but with a value.  Imagine maintaining
5008 a file where you document bugs and plan releases for a piece of
5009 software.  Instead of using tags like =release_1=, =release_2=, you
5010 can use a property, say =Release=, that in different subtrees has
5011 different values, such as =1.0= or =2.0=.  Second, you can use
5012 properties to implement (very basic) database capabilities in an Org
5013 buffer.  Imagine keeping track of your music CDs, where properties
5014 could be things such as the album, artist, date of release, number of
5015 tracks, and so on.
5017 Properties can be conveniently edited and viewed in column view (see
5018 [[*Column View]]).
5020 ** Property Syntax
5021 :PROPERTIES:
5022 :DESCRIPTION: How properties are spelled out.
5023 :END:
5024 #+cindex: property syntax
5025 #+cindex: drawer, for properties
5027 Properties are key--value pairs.  When they are associated with
5028 a single entry or with a tree they need to be inserted into a special
5029 drawer (see [[*Drawers]]) with the name =PROPERTIES=, which has to be
5030 located right below a headline, and its planning line (see [[*Deadlines
5031 and Scheduling]]) when applicable.  Each property is specified on
5032 a single line, with the key---surrounded by colons---first, and the
5033 value after it.  Keys are case-insensitive.  Here is an example:
5035 #+begin_example
5036   ,* CD collection
5037   ,** Classic
5038   ,*** Goldberg Variations
5039       :PROPERTIES:
5040       :Title:     Goldberg Variations
5041       :Composer:  J.S. Bach
5042       :Artist:    Glen Gould
5043       :Publisher: Deutsche Grammophon
5044       :NDisks:    1
5045       :END:
5046 #+end_example
5048 Depending on the value of ~org-use-property-inheritance~, a property
5049 set this way is associated either with a single entry, or with the
5050 sub-tree defined by the entry, see [[*Property Inheritance]].
5052 You may define the allowed values for a particular property =Xyz= by
5053 setting a property =Xyz_ALL=.  This special property is /inherited/,
5054 so if you set it in a level 1 entry, it applies to the entire tree.
5055 When allowed values are defined, setting the corresponding property
5056 becomes easier and is less prone to typing errors.  For the example
5057 with the CD collection, we can pre-define publishers and the number of
5058 disks in a box like this:
5060 #+begin_example
5061   ,* CD collection
5062     :PROPERTIES:
5063     :NDisks_ALL:  1 2 3 4
5064     :Publisher_ALL: "Deutsche Grammophon" Philips EMI
5065     :END:
5066 #+end_example
5068 If you want to set properties that can be inherited by any entry in
5069 a file, use a line like:
5071 #+cindex: @samp{_ALL} suffix, in properties
5072 #+cindex: PROPERTY, keyword
5073 : #+PROPERTY: NDisks_ALL 1 2 3 4
5075 #+cindex: @samp{+} suffix, in properties
5076 If you want to add to the value of an existing property, append a =+=
5077 to the property name.  The following results in the property =var=
5078 having the value =foo=1 bar=2=.
5080 #+begin_example
5081   ,#+PROPERTY: var  foo=1
5082   ,#+PROPERTY: var+ bar=2
5083 #+end_example
5085 It is also possible to add to the values of inherited properties.  The
5086 following results in the =Genres= property having the value =Classic
5087 Baroque= under the =Goldberg Variations= subtree.
5089 #+begin_example
5090   ,* CD collection
5091   ,** Classic
5092       :PROPERTIES:
5093       :Genres: Classic
5094       :END:
5095   ,*** Goldberg Variations
5096       :PROPERTIES:
5097       :Title:     Goldberg Variations
5098       :Composer:  J.S. Bach
5099       :Artist:    Glen Gould
5100       :Publisher: Deutsche Grammophon
5101       :NDisks:    1
5102       :Genres+:   Baroque
5103       :END:
5104 #+end_example
5106 Note that a property can only have one entry per drawer.
5108 #+vindex: org-global-properties
5109 Property values set with the global variable ~org-global-properties~
5110 can be inherited by all entries in all Org files.
5112 #+texinfo: @noindent
5113 The following commands help to work with properties:
5115 #+attr_texinfo: :sep ,
5116 - {{{kbd(M-TAB)}}} (~pcomplete~) ::
5118      #+kindex: M-TAB
5119      #+findex: pcomplete
5120      After an initial colon in a line, complete property keys.  All
5121      keys used in the current file are offered as possible
5122      completions.
5124 - {{{kbd(C-c C-x p)}}} (~org-set-property~) ::
5126      #+kindex: C-c C-x p
5127      #+findex: org-set-property
5128      Set a property.  This prompts for a property name and a value.
5129      If necessary, the property drawer is created as well.
5131 - {{{kbd(C-u M-x org-insert-drawer)}}} ::
5133      #+findex: org-insert-drawer
5134      Insert a property drawer into the current entry.  The drawer is
5135      inserted early in the entry, but after the lines with planning
5136      information like deadlines.
5138 - {{{kbd(C-c C-c)}}} (~org-property-action~) ::
5140      #+kindex: C-c C-c
5141      #+findex: org-property-action
5142      With the cursor in a property drawer, this executes property
5143      commands.
5145 - {{{kbd(C-c C-c s)}}} (~org-set-property~) ::
5147      #+kindex: C-c C-c s
5148      #+findex: org-set-property
5149      Set a property in the current entry.  Both the property and the value
5150      can be inserted using completion.
5152 - {{{kbd(S-right)}}} (~org-property-next-allowed-values~),  {{{kbd(S-left)}}} (~org-property-previous-allowed-value~) ::
5154      #+kindex: S-right
5155      #+kindex: S-left
5156      Switch property at point to the next/previous allowed value.
5158 - {{{kbd(C-c C-c d)}}} (~org-delete-property~) ::
5160      #+kindex: C-c C-c d
5161      #+findex: org-delete-property
5162      Remove a property from the current entry.
5164 - {{{kbd(C-c C-c D)}}} (~org-delete-property-globally~) ::
5166      #+kindex: C-c C-c D
5167      #+findex: org-delete-property-globally
5168      Globally remove a property, from all entries in the current file.
5170 - {{{kbd(C-c C-c c)}}} (~org-compute-property-at-point~) ::
5172      #+kindex: C-c C-c c
5173      #+findex: org-compute-property-at-point
5174      Compute the property at point, using the operator and scope from
5175      the nearest column format definition.
5177 ** Special Properties
5178 :PROPERTIES:
5179 :DESCRIPTION: Access to other Org mode features.
5180 :END:
5181 #+cindex: properties, special
5183 Special properties provide an alternative access method to Org mode
5184 features, like the TODO state or the priority of an entry, discussed
5185 in the previous chapters.  This interface exists so that you can
5186 include these states in a column view (see [[*Column View]]), or to use
5187 them in queries.  The following property names are special and should
5188 not be used as keys in the properties drawer:
5190 #+cindex: ALLTAGS, special property
5191 #+cindex: BLOCKED, special property
5192 #+cindex: CLOCKSUM, special property
5193 #+cindex: CLOCKSUM_T, special property
5194 #+cindex: CLOSED, special property
5195 #+cindex: DEADLINE, special property
5196 #+cindex: FILE, special property
5197 #+cindex: ITEM, special property
5198 #+cindex: PRIORITY, special property
5199 #+cindex: SCHEDULED, special property
5200 #+cindex: TAGS, special property
5201 #+cindex: TIMESTAMP, special property
5202 #+cindex: TIMESTAMP_IA, special property
5203 #+cindex: TODO, special property
5204 | =ALLTAGS=      | All tags, including inherited ones.                            |
5205 | =BLOCKED=      | ~t~ if task is currently blocked by children or siblings.      |
5206 | =CATEGORY=     | The category of an entry.                                      |
5207 | =CLOCKSUM=     | The sum of CLOCK intervals in the subtree.  ~org-clock-sum~    |
5208 |                | must be run first to compute the values in the current buffer. |
5209 | =CLOCKSUM_T=   | The sum of CLOCK intervals in the subtree for today.           |
5210 |                | ~org-clock-sum-today~ must be run first to compute the         |
5211 |                | values in the current buffer.                                  |
5212 | =CLOSED=       | When was this entry closed?                                    |
5213 | =DEADLINE=     | The deadline time string, without the angular brackets.        |
5214 | =FILE=         | The filename the entry is located in.                          |
5215 | =ITEM=         | The headline of the entry.                                     |
5216 | =PRIORITY=     | The priority of the entry, a string with a single letter.      |
5217 | =SCHEDULED=    | The scheduling timestamp, without the angular brackets.        |
5218 | =TAGS=         | The tags defined directly in the headline.                     |
5219 | =TIMESTAMP=    | The first keyword-less timestamp in the entry.                 |
5220 | =TIMESTAMP_IA= | The first inactive timestamp in the entry.                     |
5221 | =TODO=         | The TODO keyword of the entry.                                 |
5223 ** Property Searches
5224 :PROPERTIES:
5225 :DESCRIPTION: Matching property values.
5226 :END:
5227 #+cindex: properties, searching
5228 #+cindex: searching, of properties
5230 To create sparse trees and special lists with selection based on
5231 properties, the same commands are used as for tag searches (see [[*Tag
5232 Searches]]).
5234 - {{{kbd(C-c / m)}}} or {{{kbd(C-c \)}}} (~org-match-sparse-tree~) ::
5236      #+kindex: C-c / m
5237      #+kindex: C-c \
5238      #+findex: org-match-sparse-tree
5239      Create a sparse tree with all matching entries.  With
5240      a {{{kbd(C-u)}}} prefix argument, ignore headlines that are not
5241      a TODO line.
5243 - {{{kbd(C-c a m)}}}, ~org-tags-view~ ::
5245      #+kindex: C-c a m
5246      Create a global list of tag/property matches from all agenda
5247      files.
5249 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
5251      #+kindex: C-c a M
5252      #+findex: org-tags-view
5253      #+vindex: org-tags-match-list-sublevels
5254      Create a global list of tag matches from all agenda files, but
5255      check only TODO items and force checking of subitems (see the
5256      option ~org-tags-match-list-sublevels~).
5258 The syntax for the search string is described in [[*Matching tags and
5259 properties]].
5261 There is also a special command for creating sparse trees based on a
5262 single property:
5264 - {{{kbd(C-c / p)}}} ::
5266      #+kindex: C-c / p
5267      Create a sparse tree based on the value of a property.  This
5268      first prompts for the name of a property, and then for a value.
5269      A sparse tree is created with all entries that define this
5270      property with the given value.  If you enclose the value in curly
5271      braces, it is interpreted as a regular expression and matched
5272      against the property values.
5274 ** Property Inheritance
5275 :PROPERTIES:
5276 :DESCRIPTION: Passing values down a tree.
5277 :END:
5278 #+cindex: properties, inheritance
5279 #+cindex: inheritance, of properties
5281 #+vindex: org-use-property-inheritance
5282 The outline structure of Org documents lends itself to an inheritance
5283 model of properties: if the parent in a tree has a certain property,
5284 the children can inherit this property.  Org mode does not turn this
5285 on by default, because it can slow down property searches
5286 significantly and is often not needed.  However, if you find
5287 inheritance useful, you can turn it on by setting the variable
5288 ~org-use-property-inheritance~.  It may be set to ~t~ to make all
5289 properties inherited from the parent, to a list of properties that
5290 should be inherited, or to a regular expression that matches inherited
5291 properties.  If a property has the value ~nil~, this is interpreted as
5292 an explicit un-define of the property, so that inheritance search
5293 stops at this value and returns ~nil~.
5295 Org mode has a few properties for which inheritance is hard-coded, at
5296 least for the special applications for which they are used:
5298 - ~COLUMNS~ ::
5300      #+cindex: COLUMNS, property
5301      The =COLUMNS= property defines the format of column view (see
5302      [[*Column View]]).  It is inherited in the sense that the level where
5303      a =COLUMNS= property is defined is used as the starting point for
5304      a column view table, independently of the location in the subtree
5305      from where columns view is turned on.
5307 - ~CATEGORY~ ::
5309      #+cindex: CATEGORY, property
5310      For agenda view, a category set through a =CATEGORY= property
5311      applies to the entire subtree.
5313 - ~ARCHIVE~ ::
5315      #+cindex: ARCHIVE, property
5316      For archiving, the =ARCHIVE= property may define the archive
5317      location for the entire subtree (see [[*Moving a tree to an archive
5318      file]]).
5320 - ~LOGGING~ ::
5322      #+cindex: LOGGING, property
5323      The =LOGGING= property may define logging settings for an entry
5324      or a subtree (see [[*Tracking TODO state changes]]).
5326 ** Column View
5327 :PROPERTIES:
5328 :DESCRIPTION: Tabular viewing and editing.
5329 :END:
5331 A great way to view and edit properties in an outline tree is /column
5332 view/.  In column view, each outline node is turned into a table row.
5333 Columns in this table provide access to properties of the entries.
5334 Org mode implements columns by overlaying a tabular structure over the
5335 headline of each item.  While the headlines have been turned into
5336 a table row, you can still change the visibility of the outline tree.
5337 For example, you get a compact table by switching to "contents"
5338 view---{{{kbd(S-TAB)}}} {{{kbd(S-TAB)}}}, or simply {{{kbd(c)}}}
5339 while column view is active---but you can still open, read, and edit
5340 the entry below each headline.  Or, you can switch to column view
5341 after executing a sparse tree command and in this way get a table only
5342 for the selected items.  Column view also works in agenda buffers (see
5343 [[*Agenda Views]]) where queries have collected selected items, possibly
5344 from a number of files.
5346 *** Defining columns
5347 :PROPERTIES:
5348 :DESCRIPTION: The COLUMNS format property.
5349 :END:
5350 #+cindex: column view, for properties
5351 #+cindex: properties, column view
5353 Setting up a column view first requires defining the columns.  This is
5354 done by defining a column format line.
5356 **** Scope of column definitions
5357 :PROPERTIES:
5358 :DESCRIPTION: Where defined, where valid?
5359 :END:
5361 To define a column format for an entire file, use a line like:
5363 #+cindex: COLUMNS, keyword
5364 : #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5366 To specify a format that only applies to a specific tree, add
5367 a =COLUMNS= property to the top node of that tree, for example:
5369 #+begin_example
5370   ,** Top node for columns view
5371      :PROPERTIES:
5372      :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5373      :END:
5374 #+end_example
5376 If a =COLUMNS= property is present in an entry, it defines columns for
5377 the entry itself, and for the entire subtree below it.  Since the
5378 column definition is part of the hierarchical structure of the
5379 document, you can define columns on level 1 that are general enough
5380 for all sublevels, and more specific columns further down, when you
5381 edit a deeper part of the tree.
5383 **** Column attributes
5384 :PROPERTIES:
5385 :DESCRIPTION: Appearance and content of a column.
5386 :END:
5388 A column definition sets the attributes of a column.  The general
5389 definition looks like this:
5391 : %[WIDTH]PROPERTY[(TITLE)][{SUMMARY-TYPE}]
5393 #+texinfo: @noindent
5394 Except for the percent sign and the property name, all items are
5395 optional.  The individual parts have the following meaning:
5397 - {{{var(WIDTH)}}} ::
5399      An integer specifying the width of the column in characters.  If
5400      omitted, the width is determined automatically.
5402 - {{{var(PROPERTY)}}} ::
5404      The property that should be edited in this column.  Special
5405      properties representing meta data are allowed here as well (see
5406      [[*Special Properties]]).
5408 - {{{var(TITLE)}}} ::
5410      The header text for the column.  If omitted, the property name is
5411      used.
5413 - {{{var(SUMMARY-TYPE)}}} ::
5415      The summary type.  If specified, the column values for parent
5416      nodes are computed from the children[fn:55].
5418      Supported summary types are:
5420      | =+=      | Sum numbers in this column.                           |
5421      | =+;%.1f= | Like =+=, but format result with =%.1f=.              |
5422      | =$=      | Currency, short for =+;%.2f=.                         |
5423      | =min=    | Smallest number in column.                            |
5424      | =max=    | Largest number.                                       |
5425      | =mean=   | Arithmetic mean of numbers.                           |
5426      | =X=      | Checkbox status, =[X]= if all children are =[X]=.     |
5427      | =X/=     | Checkbox status, =[n/m]=.                             |
5428      | =X%=     | Checkbox status, =[n%]=.                              |
5429      | =:=      | Sum times, HH:MM, plain numbers are hours.            |
5430      | =:min=   | Smallest time value in column.                        |
5431      | =:max=   | Largest time value.                                   |
5432      | =:mean=  | Arithmetic mean of time values.                       |
5433      | =@min=   | Minimum age[fn:56] (in days/hours/mins/seconds).      |
5434      | =@max=   | Maximum age (in days/hours/mins/seconds).             |
5435      | =@mean=  | Arithmetic mean of ages (in days/hours/mins/seconds). |
5436      | =est+=   | Add low-high estimates.                               |
5438      #+texinfo: @noindent
5439      #+vindex: org-columns-summary-types
5440      You can also define custom summary types by setting
5441      ~org-columns-summary-types~.
5443 The =est+= summary type requires further explanation.  It is used for
5444 combining estimates, expressed as low-high ranges.  For example,
5445 instead of estimating a particular task will take 5 days, you might
5446 estimate it as 5-6 days if you're fairly confident you know how much
5447 work is required, or 1-10 days if you do not really know what needs to
5448 be done.  Both ranges average at 5.5 days, but the first represents
5449 a more predictable delivery.
5451 When combining a set of such estimates, simply adding the lows and
5452 highs produces an unrealistically wide result.  Instead, =est+= adds
5453 the statistical mean and variance of the sub-tasks, generating a final
5454 estimate from the sum.  For example, suppose you had ten tasks, each
5455 of which was estimated at 0.5 to 2 days of work.  Straight addition
5456 produces an estimate of 5 to 20 days, representing what to expect if
5457 everything goes either extremely well or extremely poorly.  In
5458 contrast, =est+= estimates the full job more realistically, at 10-15
5459 days.
5461 Here is an example for a complete columns definition, along with
5462 allowed values[fn:57].
5464 #+begin_example
5465   :COLUMNS:  %25ITEM %9Approved(Approved?){X} %Owner %11Status \
5466                      %10Time_Estimate{:} %CLOCKSUM %CLOCKSUM_T
5467   :Owner_ALL:    Tammy Mark Karl Lisa Don
5468   :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5469   :Approved_ALL: "[ ]" "[X]"
5470 #+end_example
5472 #+texinfo: @noindent
5473 The first column, =%25ITEM=, means the first 25 characters of the item
5474 itself, i.e., of the headline.  You probably always should start the
5475 column definition with the =ITEM= specifier.  The other specifiers
5476 create columns =Owner= with a list of names as allowed values, for
5477 =Status= with four different possible values, and for a checkbox field
5478 =Approved=.  When no width is given after the =%= character, the
5479 column is exactly as wide as it needs to be in order to fully display
5480 all values.  The =Approved= column does have a modified title
5481 (=Approved?=, with a question mark).  Summaries are created for the
5482 =Time_Estimate= column by adding time duration expressions like HH:MM,
5483 and for the =Approved= column, by providing an =[X]= status if all
5484 children have been checked.  The =CLOCKSUM= and =CLOCKSUM_T= columns
5485 are special, they lists the sums of CLOCK intervals in the subtree,
5486 either for all clocks or just for today.
5488 *** Using column view
5489 :PROPERTIES:
5490 :DESCRIPTION: How to create and use column view.
5491 :END:
5493 **** Turning column view on or off
5494 :PROPERTIES:
5495 :UNNUMBERED: notoc
5496 :END:
5498 - {{{kbd(C-c C-x C-c)}}} (~org-columns~) ::
5500      #+kindex: C-c C-x C-c
5501      #+vindex: org-columns
5502      #+vindex: org-columns-default-format
5503      Turn on column view.  If the cursor is before the first headline
5504      in the file, column view is turned on for the entire file, using
5505      the =#+COLUMNS= definition.  If the cursor is somewhere inside
5506      the outline, this command searches the hierarchy, up from point,
5507      for a =COLUMNS= property that defines a format.  When one is
5508      found, the column view table is established for the tree starting
5509      at the entry that contains the =COLUMNS= property.  If no such
5510      property is found, the format is taken from the =#+COLUMNS= line
5511      or from the variable ~org-columns-default-format~, and column
5512      view is established for the current entry and its subtree.
5514 - {{{kbd(r)}}} or {{{kbd(g)}}} (~org-columns-redo~) ::
5516      #+kindex: r
5517      #+kindex: g
5518      #+findex: org-columns-redo
5519      Recreate the column view, to include recent changes made in the
5520      buffer.
5522 - {{{kbd(q)}}} (~org-columns-quit~) ::
5524      #+kindex: q
5525      #+findex: org-columns-quit
5526      Exit column view.
5528 **** Editing values
5529 :PROPERTIES:
5530 :UNNUMBERED: notoc
5531 :END:
5533 #+attr_texinfo: :sep and
5534 - {{{kbd(left)}}}, {{{kbd(right)}}}, {{{kbd(up)}}}, {{{kbd(down)}}} ::
5536      Move through the column view from field to field.
5538 - {{{kbd(1..9\,0)}}} ::
5540      #+kindex: 1..9,0
5541      Directly select the Nth allowed value, {{{kbd(0)}}} selects the
5542      10th value.
5544 - {{{kbd(n)}}} or {{{kbd(S-right)}}} (~org-columns-next-allowed-value~) and {{{kbd(p)}}} or {{{kbd(S-left)}}} (~org-columns-previous-allowed-value~) ::
5546      #+kindex: n
5547      #+kindex: S-right
5548      #+kindex: p
5549      #+kindex: S-left
5550      #+findex: org-columns-next-allowed-value
5551      #+findex: org-columns-previous-allowed-value
5552      Switch to the next/previous allowed value of the field.  For
5553      this, you have to have specified allowed values for a property.
5555 - {{{kbd(e)}}} (~org-columns-edit-value~) ::
5557      #+kindex: e
5558      #+findex: org-columns-edit-value
5559      Edit the property at point.  For the special properties, this
5560      invokes the same interface that you normally use to change that
5561      property.  For example, the tag completion or fast selection
5562      interface pops up when editing a =TAGS= property.
5564 - {{{kbd(C-c C-c)}}} (~org-columns-set-tags-or-toggle~) ::
5566      #+kindex: C-c C-c
5567      #+findex: org-columns-set-tags-or-toggle
5568      When there is a checkbox at point, toggle it.
5570 - {{{kbd(v)}}} (~org-columns-show-value~) ::
5572      #+kindex: v
5573      #+findex: org-columns-show-value
5574      View the full value of this property.  This is useful if the
5575      width of the column is smaller than that of the value.
5577 - {{{kbd(a)}}} (~org-columns-edit-allowed~) ::
5579      #+kindex: a
5580      #+findex: org-columns-edit-allowed
5581      Edit the list of allowed values for this property.  If the list
5582      is found in the hierarchy, the modified values is stored there.
5583      If no list is found, the new value is stored in the first entry
5584      that is part of the current column view.
5586 **** Modifying column view on-the-fly:
5587 :PROPERTIES:
5588 :UNNUMBERED: notoc
5589 :END:
5591 #+attr_texinfo: :sep and
5592 - {{{kbd(<)}}} (~org-columns-narrow~) and {{{kbd(>)}}} (~org-columns-widen~) ::
5594      #+kindex: <
5595      #+kindex: >
5596      #+findex: org-columns-narrow
5597      #+findex: org-columns-widen
5598      Make the column narrower/wider by one character.
5600 - {{{kbd(S-M-right)}}} (~org-columns-new~) ::
5602      #+kindex: S-M-right
5603      #+findex: org-columns-new
5604      Insert a new column, to the left of the current column.
5606 - {{{kbd(S-M-left)}}} (~org-columns-delete~) ::
5608      #+kindex: S-M-left
5609      #+findex: org-columns-delete
5610      Delete the current column.
5612 *** Capturing column view
5613 :PROPERTIES:
5614 :DESCRIPTION: A dynamic block for column view.
5615 :END:
5617 Since column view is just an overlay over a buffer, it cannot be
5618 exported or printed directly.  If you want to capture a column view,
5619 use a =columnview= dynamic block (see [[*Dynamic Blocks]]).  The frame of
5620 this block looks like this:
5622 #+cindex: BEGIN columnview
5623 #+begin_example
5624   ,* The column view
5625   ,#+BEGIN: columnview :hlines 1 :id "label"
5627   ,#+END:
5628 #+end_example
5630 #+texinfo: @noindent
5631 This dynamic block has the following parameters:
5633 - =:id= ::
5635      This is the most important parameter.  Column view is a feature
5636      that is often localized to a certain (sub)tree, and the capture
5637      block might be at a different location in the file.  To identify
5638      the tree whose view to capture, you can use four values:
5640      - =local= ::
5642           Use the tree in which the capture block is located.
5644      - =global= ::
5646           Make a global view, including all headings in the file.
5648      - =file:FILENAME= ::
5650           Run column view at the top of the {{{var(FILENAME)}}} file
5652      - =LABEL= ::
5654           #+cindex: ID, property
5655           Call column view in the tree that has an =ID= property with
5656           the value {{{var(LABEL)}}}.  You can use {{{kbd(M-x
5657           org-id-copy)}}} to create a globally unique ID for the
5658           current entry and copy it to the kill-ring.
5660 - =:hlines= ::
5662      When ~t~, insert an hline after every line.  When a number N,
5663      insert an hline before each headline with level ~<= N~.
5665 - =:vlines= ::
5667      When non-~nil~, force column groups to get vertical lines.
5669 - =:maxlevel= ::
5671      When set to a number, do not capture entries below this level.
5673 - =:skip-empty-rows= ::
5675      When non-~nil~, skip rows where the only non-empty specifier of
5676      the column view is =ITEM=.
5678 - =:indent= ::
5680      When non-~nil~, indent each =ITEM= field according to its level.
5682 #+texinfo: @noindent
5683 The following commands insert or update the dynamic block:
5685 - {{{kbd(C-c C-x i)}}} (~org-insert-columns-dblock~) ::
5687      #+kindex: C-c C-x i
5688      #+findex: org-insert-columns-dblock
5689      Insert a dynamic block capturing a column view.  Prompt for the
5690      scope or ID of the view.
5692 - {{{kbd(C-c C-c)}}} {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
5694      #+kindex: C-c C-c
5695      #+kindex: C-c C-x C-u
5696      #+findex: org-dblock-update
5697      Update dynamic block at point.  The cursor needs to be in the
5698      =#+BEGIN= line of the dynamic block.
5700 - {{{kbd(C-u C-c C-x C-u)}}} (~org-update-all-dblocks~) ::
5702      #+kindex: C-u C-c C-x C-u
5703      Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful
5704      if you have several clock table blocks, column-capturing blocks
5705      or other dynamic blocks in a buffer.
5707 You can add formulas to the column view table and you may add plotting
5708 instructions in front of the table---these survive an update of the
5709 block.  If there is a =TBLFM= keyword after the table, the table is
5710 recalculated automatically after an update.
5712 An alternative way to capture and process property values into a table
5713 is provided by Eric Schulte's =org-collector.el= which is
5714 a contributed package[fn:58].  It provides a general API to collect
5715 properties from entries in a certain scope, and arbitrary Lisp
5716 expressions to process these values before inserting them into a table
5717 or a dynamic block.
5719 * Dates and Times
5720 :PROPERTIES:
5721 :DESCRIPTION: Making items useful for planning.
5722 :END:
5723 #+cindex: dates
5724 #+cindex: times
5725 #+cindex: timestamp
5726 #+cindex: date stamp
5728 To assist project planning, TODO items can be labeled with a date
5729 and/or a time.  The specially formatted string carrying the date and
5730 time information is called a /timestamp/ in Org mode.  This may be
5731 a little confusing because timestamp is often used as indicating when
5732 something was created or last changed.  However, in Org mode this term
5733 is used in a much wider sense.
5735 ** Timestamps, Deadlines and Scheduling
5736 :PROPERTIES:
5737 :DESCRIPTION: Assigning a time to a tree entry.
5738 :ALT_TITLE: Timestamps
5739 :END:
5740 #+cindex: timestamps
5741 #+cindex: ranges, time
5742 #+cindex: date stamps
5743 #+cindex: deadlines
5744 #+cindex: scheduling
5746 A timestamp is a specification of a date (possibly with a time or
5747 a range of times) in a special format, either =<2003-09-16 Tue>= or
5748 =<2003-09-16 Tue 09:39>= or =<2003-09-16 Tue 12:00-12:30>=[fn:59].
5749 A timestamp can appear anywhere in the headline or body of an Org tree
5750 entry.  Its presence causes entries to be shown on specific dates in
5751 the agenda (see [[*Weekly/daily agenda]]).  We distinguish:
5753 - Plain timestamp; Event; Appointment ::
5755      #+cindex: timestamp
5756      #+cindex: appointment
5757      A simple timestamp just assigns a date/time to an item.  This is
5758      just like writing down an appointment or event in a paper agenda.
5759      In the timeline and agenda displays, the headline of an entry
5760      associated with a plain timestamp is shown exactly on that date.
5762      #+begin_example
5763        ,* Meet Peter at the movies
5764          <2006-11-01 Wed 19:15>
5765        ,* Discussion on climate change
5766          <2006-11-02 Thu 20:00-22:00>
5767      #+end_example
5769 - Timestamp with repeater interval ::
5771      #+cindex: timestamp, with repeater interval
5772      A timestamp may contain a /repeater interval/, indicating that it
5773      applies not only on the given date, but again and again after
5774      a certain interval of N days (d), weeks (w), months (m), or years
5775      (y).  The following shows up in the agenda every Wednesday:
5777      #+begin_example
5778        ,* Pick up Sam at school
5779          <2007-05-16 Wed 12:30 +1w>
5780      #+end_example
5782 - Diary-style sexp entries ::
5784      #+cindex: diary style timestamps
5785      #+cindex: sexp timestamps
5786      For more complex date specifications, Org mode supports using the
5787      special sexp diary entries implemented in the Emacs
5788      calendar/diary package[fn:60].  For example, with optional time:
5790      #+begin_example
5791        ,* 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
5792          <%%(org-float t 4 2)>
5793      #+end_example
5795 - Time/Date range ::
5797      #+cindex: timerange
5798      #+cindex: date range
5799      Two timestamps connected by =--= denote a range.  The headline is
5800      shown on the first and last day of the range, and on any dates
5801      that are displayed and fall in the range.  Here is an example:
5803      #+begin_example
5804        ,** Meeting in Amsterdam
5805           <2004-08-23 Mon>--<2004-08-26 Thu>
5806      #+end_example
5808 - Inactive timestamp ::
5810      #+cindex: timestamp, inactive
5811      #+cindex: inactive timestamp
5812      Just like a plain timestamp, but with square brackets instead of
5813      angular ones.  These timestamps are inactive in the sense that
5814      they do /not/ trigger an entry to show up in the agenda.
5816      #+begin_example
5817        ,* Gillian comes late for the fifth time
5818          [2006-11-01 Wed]
5819      #+end_example
5821 ** Creating Timestamps
5822 :PROPERTIES:
5823 :DESCRIPTION: Commands to insert timestamps.
5824 :END:
5826 For Org mode to recognize timestamps, they need to be in the specific
5827 format.  All commands listed below produce timestamps in the correct
5828 format.
5830 #+attr_texinfo: :sep ,
5831 - {{{kbd(C-c .)}}} (~org-time-stamp~) ::
5833      #+kindex: C-c .
5834      #+findex: org-time-stamp
5835      Prompt for a date and insert a corresponding timestamp.  When the
5836      cursor is at an existing timestamp in the buffer, the command is
5837      used to modify this timestamp instead of inserting a new one.
5838      When this command is used twice in succession, a time range is
5839      inserted.
5841 - {{{kbd(C-c !)}}} (~org-time-stamp-inactive~) ::
5843      #+kindex: C-c !
5844      #+findex: org-time-stamp-inactive
5845      Like {{{kbd(C-c .)}}}, but insert an inactive timestamp that does
5846      not cause an agenda entry.
5848 - {{{kbd(C-u C-c .)}}}, {{{kbd(C-u C-c !)}}} ::
5850      #+kindex: C-u C-c .
5851      #+kindex: C-u C-c .
5852      #+kindex: C-u C-c !
5853      #+vindex: org-time-stamp-rounding-minutes
5854      Like {{{kbd(C-c .)}}} and {{{kbd(C-c !)}}}, but use the
5855      alternative format which contains date and time.  The default
5856      time can be rounded to multiples of 5 minutes, see the option
5857      ~org-time-stamp-rounding-minutes~.
5859 - {{{kbd(C-c C-c)}}} ::
5861      #+kindex: C-c C-c
5862      Normalize timestamp, insert/fix day name if missing or wrong.
5864 - {{{kbd(C-c <)}}} (~org-date-from-calendar~) ::
5866      #+kindex: C-c <
5867      #+findex: org-date-from-calendar
5868      Insert a timestamp corresponding to the cursor date in the Calendar.
5870 - {{{kbd(C-c >)}}} (~org-goto-calendar~) ::
5872      #+kindex: C-c >
5873      #+findex: org-goto-calendar
5874      Access the Emacs calendar for the current date.  If there is a
5875      timestamp in the current line, go to the corresponding date instead.
5877 - {{{kbd(C-c C-o)}}} (~org-open-at-point~) ::
5879      #+kindex: C-c C-o
5880      #+findex: org-open-at-point
5881      Access the agenda for the date given by the timestamp or -range
5882      at point (see [[*Weekly/daily agenda]]).
5884 - {{{kbd(S-left)}}} (~org-timestamp-down-day~), {{{kbd(S-right)}}} (~org-timestamp-up-day~) ::
5886      #+kindex: S-left
5887      #+kindex: S-right
5888      #+findex: org-timestamp-down-day
5889      #+findex: org-timestamp-up-day
5890      Change date at cursor by one day.  These key bindings conflict
5891      with shift-selection and related modes (see [[*Packages that
5892      conflict with Org mode]]).
5894 - {{{kbd(S-up)}}} (~org-timestamp-up~), {{{kbd(S-down)}}} (~org-timestamp-down~) ::
5896      #+kindex: S-up
5897      Change the item under the cursor in a timestamp.  The cursor can
5898      be on a year, month, day, hour or minute.  When the timestamp
5899      contains a time range like =15:30-16:30=, modifying the first
5900      time also shifts the second, shifting the time block with
5901      constant length.  To change the length, modify the second time.
5902      Note that if the cursor is in a headline and not at a timestamp,
5903      these same keys modify the priority of an item.  (see
5904      [[*Priorities]]).  The key bindings also conflict with
5905      shift-selection and related modes (see [[*Packages that conflict
5906      with Org mode]]).
5908 - {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
5910      #+kindex: C-c C-y
5911      #+findex: org-evaluate-time-range
5912      #+cindex: evaluate time range
5913      Evaluate a time range by computing the difference between start
5914      and end.  With a prefix argument, insert result after the time
5915      range (in a table: into the following column).
5917 *** The date/time prompt
5918 :PROPERTIES:
5919 :DESCRIPTION: How Org mode helps you enter dates and times.
5920 :END:
5921 #+cindex: date, reading in minibuffer
5922 #+cindex: time, reading in minibuffer
5924 #+vindex: org-read-date-prefer-future
5925 When Org mode prompts for a date/time, the default is shown in default
5926 date/time format, and the prompt therefore seems to ask for a specific
5927 format.  But it in fact accepts date/time information in a variety of
5928 formats.  Generally, the information should start at the beginning of
5929 the string.  Org mode finds whatever information is in there and
5930 derives anything you have not specified from the /default date and
5931 time/.  The default is usually the current date and time, but when
5932 modifying an existing timestamp, or when entering the second stamp of
5933 a range, it is taken from the stamp in the buffer.  When filling in
5934 information, Org mode assumes that most of the time you want to enter
5935 a date in the future: if you omit the month/year and the given
5936 day/month is /before/ today, it assumes that you mean a future
5937 date[fn:61].  If the date has been automatically shifted into the
5938 future, the time prompt shows this with =(=>F)=.
5940 For example, let's assume that today is *June 13, 2006*.  Here is how
5941 various inputs are interpreted, the items filled in by Org mode are in
5942 *bold*.
5944 | =3-2-5=        | \rArr{} 2003-02-05                              |
5945 | =2/5/3=        | \rArr{} 2003-02-05                              |
5946 | =14=           | \rArr{} *2006*-*06*-14                          |
5947 | =12=           | \rArr{} *2006*-*07*-12                          |
5948 | =2/5=          | \rArr{} *2007*-02-05                            |
5949 | =Fri=          | \rArr{} nearest Friday (default date or later)  |
5950 | =sep 15=       | \rArr{} *2006*-09-15                            |
5951 | =feb 15=       | \rArr{} *2007*-02-15                            |
5952 | =sep 12 9=     | \rArr{} 2009-09-12                              |
5953 | =12:45=        | \rArr{} *2006*-*06*-*13* 12:45                  |
5954 | =22 sept 0:34= | \rArr{} *2006*-09-22 0:34                       |
5955 | =w4=           | \rArr{} ISO week for of the current year *2006* |
5956 | =2012 w4 fri=  | \rArr{} Friday of ISO week 4 in 2012            |
5957 | =2012-w04-5=   | \rArr{} Same as above                           |
5959 Furthermore you can specify a relative date by giving, as the /first/
5960 thing in the input: a plus/minus sign, a number and a letter---=d=,
5961 =w=, =m= or =y=---to indicate change in days, weeks, months, or
5962 years.  With a single plus or minus, the date is always relative to
5963 today.  With a double plus or minus, it is relative to the default
5964 date.  If instead of a single letter, you use the abbreviation of day
5965 name, the date is the Nth such day, e.g.:
5967 | =+0=    | \rArr{} today                       |
5968 | =.=     | \rArr{} today                       |
5969 | =+4d=   | \rArr{} four days from today        |
5970 | =+4=    | \rArr{} same as +4d                 |
5971 | =+2w=   | \rArr{} two weeks from today        |
5972 | =++5=   | \rArr{} five days from default date |
5973 | =+2tue= | \rArr{} second Tuesday from now     |
5975 #+vindex: parse-time-months
5976 #+vindex: parse-time-weekdays
5977 The function understands English month and weekday abbreviations.  If
5978 you want to use un-abbreviated names and/or other languages, configure
5979 the variables ~parse-time-months~ and ~parse-time-weekdays~.
5981 #+vindex: org-read-date-force-compatible-dates
5982 Not all dates can be represented in a given Emacs implementation.  By
5983 default Org mode forces dates into the compatibility range 1970--2037
5984 which works on all Emacs implementations.  If you want to use dates
5985 outside of this range, read the docstring of the variable
5986 ~org-read-date-force-compatible-dates~.
5988 You can specify a time range by giving start and end times or by
5989 giving a start time and a duration (in HH:MM format).  Use one or two
5990 dash(es) as the separator in the former case and use =+= as the
5991 separator in the latter case, e.g.:
5993 | =11am-1:15pm=  | \rArr{} 11:00-13:15   |
5994 | =11am--1:15pm= | \rArr{} same as above |
5995 | =11am+2:15=    | \rArr{} same as above |
5997 #+cindex: calendar, for selecting date
5998 #+vindex: org-popup-calendar-for-date-prompt
5999 Parallel to the minibuffer prompt, a calendar is popped up[fn:62].
6000 When you exit the date prompt, either by clicking on a date in the
6001 calendar, or by pressing {{{kbd(RET)}}}, the date selected in the
6002 calendar is combined with the information entered at the prompt.  You
6003 can control the calendar fully from the minibuffer:
6005 #+kindex: <
6006 #+kindex: >
6007 #+kindex: M-v
6008 #+kindex: C-v
6009 #+kindex: mouse-1
6010 #+kindex: S-right
6011 #+kindex: S-left
6012 #+kindex: S-down
6013 #+kindex: S-up
6014 #+kindex: M-S-right
6015 #+kindex: M-S-left
6016 #+kindex: RET
6017 #+attr_texinfo: :columns 0.25 0.55
6018 | {{{kbd(RET)}}}           | Choose date at cursor in calendar.     |
6019 | {{{kbd(mouse-1)}}}       | Select date by clicking on it.         |
6020 | {{{kbd(S-right)}}}    | One day forward.                       |
6021 | {{{kbd(S-left)}}}     | One day backward.                      |
6022 | {{{kbd(S-down)}}}     | One week forward.                      |
6023 | {{{kbd(S-up)}}}       | One week backward.                     |
6024 | {{{kbd(M-S-right)}}}  | One month forward.                     |
6025 | {{{kbd(M-S-left)}}}   | One month backward.                    |
6026 | {{{kbd(>)}}}             | Scroll calendar forward by one month.  |
6027 | {{{kbd(<)}}}             | Scroll calendar backward by one month. |
6028 | {{{kbd(M-v)}}}           | Scroll calendar forward by 3 months.   |
6029 | {{{kbd(C-v)}}}           | Scroll calendar backward by 3 months.  |
6031 #+vindex: org-read-date-display-live
6032 The actions of the date/time prompt may seem complex, but I assure you
6033 they will grow on you, and you will start getting annoyed by pretty
6034 much any other way of entering a date/time out there.  To help you
6035 understand what is going on, the current interpretation of your input
6036 is displayed live in the minibuffer[fn:63].
6038 *** Custom time format
6039 :PROPERTIES:
6040 :DESCRIPTION: Making dates look different.
6041 :END:
6042 #+cindex: custom date/time format
6043 #+cindex: time format, custom
6044 #+cindex: date format, custom
6046 #+vindex: org-display-custom-times
6047 #+vindex: org-time-stamp-custom-formats
6048 Org mode uses the standard ISO notation for dates and times as it is
6049 defined in ISO 8601.  If you cannot get used to this and require
6050 another representation of date and time to keep you happy, you can get
6051 it by customizing the variables ~org-display-custom-times~ and
6052 ~org-time-stamp-custom-formats~.
6054 - {{{kbd(C-c C-x C-t)}}} (~org-toggle-time-stamp-overlays~) ::
6056      #+kindex: C-c C-x C-t
6057      #+findex: org-toggle-time-stamp-overlays
6058      Toggle the display of custom formats for dates and times.
6060 #+texinfo: @noindent
6061 Org mode needs the default format for scanning, so the custom
6062 date/time format does not /replace/ the default format.  Instead, it
6063 is put /over/ the default format using text properties.  This has the
6064 following consequences:
6066 - You cannot place the cursor onto a timestamp anymore, only before or
6067   after.
6069 - The {{{kbd(S-up)}}} and {{{kbd(S-down)}}} keys can no longer be used
6070   to adjust each component of a timestamp.  If the cursor is at the
6071   beginning of the stamp, {{{kbd(S-up)}}} and {{{kbd(S-down)}}} change
6072   the stamp by one day, just like {{{kbd(S-left)}}}
6073   {{{kbd(S-right)}}}.  At the end of the stamp, change the time by one
6074   minute.
6076 - If the timestamp contains a range of clock times or a repeater,
6077   these are not overlaid, but remain in the buffer as they were.
6079 - When you delete a timestamp character-by-character, it only
6080   disappears from the buffer after /all/ (invisible) characters
6081   belonging to the ISO timestamp have been removed.
6083 - If the custom timestamp format is longer than the default and you
6084   are using dates in tables, table alignment will be messed up.  If
6085   the custom format is shorter, things do work as expected.
6087 ** Deadlines and Scheduling
6088 :PROPERTIES:
6089 :DESCRIPTION: Planning your work.
6090 :END:
6092 A timestamp may be preceded by special keywords to facilitate
6093 planning.  Both the timestamp and the keyword have to be positioned
6094 immediately after the task they refer to.
6096 - =DEADLINE= ::
6098      #+cindex: DEADLINE
6099      Meaning: the task (most likely a TODO item, though not
6100      necessarily) is supposed to be finished on that date.
6102      #+vindex: org-deadline-warning-days
6103      On the deadline date, the task is listed in the agenda.  In
6104      addition, the agenda for /today/ carries a warning about the
6105      approaching or missed deadline, starting
6106      ~org-deadline-warning-days~ before the due date, and continuing
6107      until the entry is marked DONE.  An example:
6109      #+begin_example
6110        ,*** TODO write article about the Earth for the Guide
6111            DEADLINE: <2004-02-29 Sun>
6112            The editor in charge is [[bbdb:Ford Prefect]]
6113      #+end_example
6115      #+vindex: org-agenda-skip-deadline-prewarning-if-scheduled
6116      You can specify a different lead time for warnings for a specific
6117      deadlines using the following syntax.  Here is an example with
6118      a warning period of 5 days =DEADLINE: <2004-02-29 Sun -5d>=.
6119      This warning is deactivated if the task gets scheduled and you
6120      set ~org-agenda-skip-deadline-prewarning-if-scheduled~ to ~t~.
6122 - =SCHEDULED= ::
6124      #+cindex: SCHEDULED
6125      Meaning: you are planning to start working on that task on the
6126      given date.
6128      #+vindex: org-agenda-skip-scheduled-if-done
6129      The headline is listed under the given date[fn:64].  In addition,
6130      a reminder that the scheduled date has passed is present in the
6131      compilation for /today/, until the entry is marked DONE, i.e.,
6132      the task is automatically forwarded until completed.
6134      #+begin_example
6135        ,*** TODO Call Trillian for a date on New Years Eve.
6136            SCHEDULED: <2004-12-25 Sat>
6137      #+end_example
6139      #+vindex: org-scheduled-delay-days
6140      #+vindex: org-agenda-skip-scheduled-delay-if-deadline
6141      If you want to /delay/ the display of this task in the agenda,
6142      use =SCHEDULED: <2004-12-25 Sat -2d>=: the task is still
6143      scheduled on the 25th but will appear two days later.  In case
6144      the task contains a repeater, the delay is considered to affect
6145      all occurrences; if you want the delay to only affect the first
6146      scheduled occurrence of the task, use =--2d= instead.  See
6147      ~org-scheduled-delay-days~ and
6148      ~org-agenda-skip-scheduled-delay-if-deadline~ for details on how
6149      to control this globally or per agenda.
6151      #+texinfo: @noindent
6152      *Important:* Scheduling an item in Org mode should /not/ be
6153      understood in the same way that we understand /scheduling
6154      a meeting/.  Setting a date for a meeting is just a simple
6155      appointment, you should mark this entry with a simple plain
6156      timestamp, to get this item shown on the date where it applies.
6157      This is a frequent misunderstanding by Org users.  In Org mode,
6158      /scheduling/ means setting a date when you want to start working
6159      on an action item.
6161 You may use timestamps with repeaters in scheduling and deadline
6162 entries.  Org mode issues early and late warnings based on the
6163 assumption that the timestamp represents the /nearest instance/ of the
6164 repeater.  However, the use of diary S-exp entries like
6166 : <%%(org-float t 42)>
6168 #+texinfo: @noindent
6169 in scheduling and deadline timestamps is limited.  Org mode does not
6170 know enough about the internals of each S-exp function to issue early
6171 and late warnings.  However, it shows the item on each day where the
6172 S-exp entry matches.
6174 *** Inserting deadlines or schedules
6175 :PROPERTIES:
6176 :DESCRIPTION: Planning items.
6177 :ALT_TITLE: Inserting deadline/schedule
6178 :END:
6180 The following commands allow you to quickly insert a deadline or to
6181 schedule an item:[fn:65]
6183 - {{{kbd(C-c C-d)}}} (~org-deadline~) ::
6185      #+kindex: C-c C-d
6186      #+findex: org-deadline
6187      #+vindex: org-log-redeadline
6188      Insert =DEADLINE= keyword along with a stamp.  The insertion
6189      happens in the line directly following the headline.  Remove any
6190      =CLOSED= timestamp .  When called with a prefix argument, also
6191      remove any existing deadline from the entry.  Depending on the
6192      variable ~org-log-redeadline~, take a note when changing an
6193      existing deadline[fn:66].
6195 - {{{kbd(C-c C-s)}}} (~org-schedule~) ::
6197      #+kindex: C-c C-s
6198      #+findex: org-schedule
6199      #+vindex: org-log-reschedule
6200      Insert =SCHEDULED= keyword along with a stamp.  The insertion
6201      happens in the line directly following the headline.  Remove any
6202      =CLOSED= timestamp.  When called with a prefix argument, also
6203      remove the scheduling date from the entry.  Depending on the
6204      variable ~org-log-reschedule~, take a note when changing an
6205      existing scheduling time[fn:67].
6207 - {{{kbd(C-c C-x C-k)}}} (~org-mark-entry-for-agenda-action~) ::
6209      #+kindex: C-c C-x C-k
6210      #+kindex: k a
6211      #+kindex: k s
6212      #+findex: org-mark-entry-for-agenda-action
6213      Mark the current entry for agenda action.  After you have marked
6214      the entry like this, you can open the agenda or the calendar to
6215      find an appropriate date.  With the cursor on the selected date,
6216      press {{{kbd(k s)}}} or {{{kbd(k d)}}} to schedule the marked
6217      item.
6219 - {{{kbd(C-c / d)}}} (~org-check-deadlines~) ::
6221      #+kindex: C-c / d
6222      #+findex: org-check-deadlines
6223      #+cindex: sparse tree, for deadlines
6224      #+vindex: org-deadline-warning-days
6225      Create a sparse tree with all deadlines that are either past-due,
6226      or which will become due within ~org-deadline-warning-days~.
6227      With {{{kbd(C-u)}}} prefix, show all deadlines in the file.  With
6228      a numeric prefix, check that many days.  For example, {{{kbd(C-1
6229      C-c / d)}}} shows all deadlines due tomorrow.
6231 - {{{kbd(C-c / b)}}}, ~org-check-before-date~ ::
6233      #+kindex: C-c / b
6234      #+findex: org-check-before-date
6235      Sparse tree for deadlines and scheduled items before a given
6236      date.
6238 - {{{kbd(C-c / a)}}}, ~org-check-after-date~ ::
6240      #+kindex: C-c / a
6241      #+findex: org-check-after-date
6242      Sparse tree for deadlines and scheduled items after a given date.
6244 Note that ~org-schedule~ and ~org-deadline~ supports setting the date
6245 by indicating a relative time e.g., =+1d= sets the date to the next
6246 day after today, and =--1w= sets the date to the previous week before
6247 any current timestamp.
6249 *** Repeated tasks
6250 :PROPERTIES:
6251 :DESCRIPTION: Items that show up again and again.
6252 :END:
6253 #+cindex: tasks, repeated
6254 #+cindex: repeated tasks
6256 Some tasks need to be repeated again and again.  Org mode helps to
6257 organize such tasks using a so-called repeater in a =DEADLINE=,
6258 =SCHEDULED=, or plain timestamp.  In the following example:
6260 #+begin_example
6261   ,** TODO Pay the rent
6262      DEADLINE: <2005-10-01 Sat +1m>
6263 #+end_example
6265 #+texinfo: noindent
6266 the =+1m= is a repeater; the intended interpretation is that the task
6267 has a deadline on =<2005-10-01>= and repeats itself every (one) month
6268 starting from that time.  You can use yearly, monthly, weekly, daily
6269 and hourly repeat cookies by using the ~y/w/m/d/h~ letters.  If you
6270 need both a repeater and a special warning period in a deadline entry,
6271 the repeater should come first and the warning period last: =DEADLINE:
6272 <2005-10-01 Sat +1m -3d>=.
6274 #+vindex: org-todo-repeat-to-state
6275 Deadlines and scheduled items produce entries in the agenda when they
6276 are over-due, so it is important to be able to mark such an entry as
6277 completed once you have done so.  When you mark a =DEADLINE= or
6278 a =SCHEDULED= with the TODO keyword =DONE=, it no longer produces
6279 entries in the agenda.  The problem with this is, however, is that
6280 then also the /next/ instance of the repeated entry will not be
6281 active.  Org mode deals with this in the following way: when you try
6282 to mark such an entry DONE, using {{{kbd(C-c C-t)}}}, it shifts the
6283 base date of the repeating timestamp by the repeater interval, and
6284 immediately sets the entry state back to TODO[fn:68].  In the example
6285 above, setting the state to DONE would actually switch the date like
6286 this:
6288 #+begin_example
6289   ,** TODO Pay the rent
6290      DEADLINE: <2005-11-01 Tue +1m>
6291 #+end_example
6293 To mark a task with a repeater as DONE, use {{{kbd(C-- 1 C-c C-t)}}},
6294 i.e., ~org-todo~ with a numeric prefix argument of =-1=.
6296 #+vindex: org-log-repeat
6297 A timestamp[fn:69] is added under the deadline, to keep a record that
6298 you actually acted on the previous instance of this deadline.
6300 As a consequence of shifting the base date, this entry is no longer
6301 visible in the agenda when checking past dates, but all future
6302 instances will be visible.
6304 With the =+1m= cookie, the date shift is always exactly one month.  So
6305 if you have not paid the rent for three months, marking this entry
6306 DONE still keeps it as an overdue deadline.  Depending on the task,
6307 this may not be the best way to handle it.  For example, if you forgot
6308 to call your father for 3 weeks, it does not make sense to call him
6309 3 times in a single day to make up for it.  Finally, there are tasks
6310 like changing batteries which should always repeat a certain time
6311 /after/ the last time you did it.  For these tasks, Org mode has
6312 special repeaters =++= and =.+=.  For example:
6314 #+begin_example
6315   ,** TODO Call Father
6316      DEADLINE: <2008-02-10 Sun ++1w>
6317      Marking this DONE shifts the date by at least one week, but also
6318      by as many weeks as it takes to get this date into the future.
6319      However, it stays on a Sunday, even if you called and marked it
6320      done on Saturday.
6322   ,** TODO Empty kitchen trash
6323      DEADLINE: <2008-02-08 Fri 20:00 ++1d>
6324      Marking this DONE shifts the date by at least one day, and also
6325      by as many days as it takes to get the timestamp into the future.
6326      Since there is a time in the timestamp, the next deadline in the
6327      future will be on today's date if you complete the task before
6328      20:00.
6330   ,** TODO Check the batteries in the smoke detectors
6331      DEADLINE: <2005-11-01 Tue .+1m>
6332      Marking this DONE will shift the date to one month after today.
6333 #+end_example
6335 #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
6336 You may have both scheduling and deadline information for a specific
6337 task.  If the repeater is set for the scheduling information only, you
6338 probably want the repeater to be ignored after the deadline.  If so,
6339 set the variable ~org-agenda-skip-scheduled-if-deadline-is-shown~ to
6340 ~repeated-after-deadline~.  However, any scheduling information
6341 without a repeater is no longer relevant once the task is done, and
6342 thus, removed upon repeating the task.  If you want both scheduling
6343 and deadline information to repeat after the same interval, set the
6344 same repeater for both timestamps.
6346 An alternative to using a repeater is to create a number of copies of
6347 a task subtree, with dates shifted in each copy.  The command
6348 {{{kbd(C-c C-x c)}}} was created for this purpose; it is described in
6349 [[*Structure Editing]].
6351 ** Clocking Work Time
6352 :PROPERTIES:
6353 :DESCRIPTION: Tracking how long you spend on a task.
6354 :END:
6355 #+cindex: clocking time
6356 #+cindex: time clocking
6358 Org mode allows you to clock the time you spend on specific tasks in
6359 a project.  When you start working on an item, you can start the
6360 clock.  When you stop working on that task, or when you mark the task
6361 done, the clock is stopped and the corresponding time interval is
6362 recorded.  It also computes the total time spent on each
6363 subtree[fn:70] of a project.  And it remembers a history or tasks
6364 recently clocked, to that you can jump quickly between a number of
6365 tasks absorbing your time.
6367 To save the clock history across Emacs sessions, use:
6369 #+begin_src emacs-lisp
6370   (setq org-clock-persist 'history)
6371   (org-clock-persistence-insinuate)
6372 #+end_src
6374 #+vindex: org-clock-persist
6375 When you clock into a new task after resuming Emacs, the incomplete
6376 clock[fn:71] is retrieved (see [[*Resolving idle time]]) and you are
6377 prompted about what to do with it.
6379 *** Clocking commands
6380 :PROPERTIES:
6381 :DESCRIPTION: Starting and stopping a clock.
6382 :END:
6384 #+attr_texinfo: :sep ,
6385 - {{{kbd(C-c C-x C-i)}}} (~org-clock-in~) ::
6387      #+kindex: C-c C-x C-i
6388      #+findex: org-clock-in
6389      #+vindex: org-clock-into-drawer
6390      #+vindex: org-clock-continuously
6391      #+cindex: LOG_INTO_DRAWER, property
6392      Start the clock on the current item (clock-in).  This inserts the
6393      CLOCK keyword together with a timestamp.  If this is not the
6394      first clocking of this item, the multiple CLOCK lines are wrapped
6395      into a =LOGBOOK= drawer (see also the variable
6396      ~org-clock-into-drawer~).  You can also overrule the setting of
6397      this variable for a subtree by setting a =CLOCK_INTO_DRAWER= or
6398      =LOG_INTO_DRAWER= property.  When called with a {{{kbd(C-u)}}}
6399      prefix argument, select the task from a list of recently clocked
6400      tasks.  With two {{{kbd(C-u C-u)}}} prefixes, clock into the task
6401      at point and mark it as the default task; the default task is
6402      always be available with letter {{{kbd(d)}}} when selecting
6403      a clocking task.  With three {{{kbd(C-u C-u C-u)}}} prefixes,
6404      force continuous clocking by starting the clock when the last
6405      clock stopped.
6407      #+cindex: CLOCK_MODELINE_TOTAL, property
6408      #+cindex: LAST_REPEAT, property
6409      #+vindex: org-clock-modeline-total
6410      #+vindex: org-clock-in-prepare-hook
6411      While the clock is running, Org shows the current clocking time
6412      in the mode line, along with the title of the task.  The clock
6413      time shown is all time ever clocked for this task and its
6414      children.  If the task has an effort estimate (see [[*Effort
6415      Estimates]]), the mode line displays the current clocking time
6416      against it[fn:72].  If the task is a repeating one (see [[*Repeated
6417      tasks]]), show only the time since the last reset of the
6418      task[fn:73].  You can exercise more control over show time with
6419      the =CLOCK_MODELINE_TOTAL= property.  It may have the values
6420      =current= to show only the current clocking instance, =today= to
6421      show all time clocked on this tasks today---see also the
6422      variable ~org-extend-today-until~, ~all~ to include all time, or
6423      ~auto~ which is the default[fn:74].  Clicking with
6424      {{{kbd(mouse-1)}}} onto the mode line entry pops up a menu with
6425      clocking options.
6427 - {{{kbd(C-c C-x C-o)}}} (~org-clock-out~) ::
6429      #+kindex: C-c C-x C-o
6430      #+findex: org-clock-out
6431      #+vindex: org-log-note-clock-out
6432      Stop the clock (clock-out).  This inserts another timestamp at
6433      the same location where the clock was last started.  It also
6434      directly computes the resulting time in inserts it after the time
6435      range as ==>HH:MM=.  See the variable ~org-log-note-clock-out~
6436      for the possibility to record an additional note together with
6437      the clock-out timestamp[fn:75].
6439 - {{{kbd(C-c C-x C-x)}}} (~org-clock-in-last~) ::
6441      #+kindex: C-c C-x C-x
6442      #+findex: org-clock-in-last
6443      #+vindex: org-clock-continuously
6444      Re-clock the last clocked task.  With one {{{kbd(C-u)}}} prefix
6445      argument, select the task from the clock history.  With two
6446      {{{kbd(C-u)}}} prefixes, force continuous clocking by starting
6447      the clock when the last clock stopped.
6449 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6451      #+kindex: C-c C-x C-e
6452      #+findex: org-clock-modify-effort-estimate
6453      Update the effort estimate for the current clock task.
6455 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-y)}}} (~org-evaluate-time-range~) ::
6457      #+kindex: C-c C-c
6458      #+kindex: C-c C-y
6459      #+findex: org-evaluate-time-range
6460      Recompute the time interval after changing one of the timestamps.
6461      This is only necessary if you edit the timestamps directly.  If
6462      you change them with {{{kbd(S-<cursor>)}}} keys, the update is
6463      automatic.
6465 - {{{kbd(C-S-up)}}} (~org-clock-timestamps-up~), {{{kbd(C-S-down)}}} (~org-clock-timestamps-down~) ::
6467      #+kindex: C-S-up
6468      #+findex: org-clock-timestamps-up
6469      #+kindex: C-S-down
6470      #+findex: org-clock-timestamps-down
6471      On CLOCK log lines, increase/decrease both timestamps so that the
6472      clock duration keeps the same value.
6474 - {{{kbd(S-M-up)}}} (~org-timestamp-up~), {{{kbd(S-M-down)}}} (~org-timestamp-down~) ::
6476      #+kindex: S-M-up
6477      #+findex: org-clock-timestamp-up
6478      #+kindex: S-M-down
6479      #+findex: org-clock-timestamp-down
6480      On =CLOCK= log lines, increase/decrease the timestamp at point
6481      and the one of the previous, or the next, clock timestamp by the
6482      same duration.  For example, if you hit {{{kbd(S-M-up)}}} to
6483      increase a clocked-out timestamp by five minutes, then the
6484      clocked-in timestamp of the next clock is increased by five
6485      minutes.
6487 - {{{kbd(C-c C-t)}}} (~org-todo~) ::
6489      #+kindex: C-c C-t
6490      #+findex: org-todo
6491      Changing the TODO state of an item to DONE automatically stops
6492      the clock if it is running in this same item.
6494 - {{{kbd(C-c C-x C-q)}}} (~org-clock-cancel~) ::
6496      #+kindex: C-c C-x C-q
6497      #+findex: org-clock-cancel
6498      Cancel the current clock.  This is useful if a clock was started
6499      by mistake, or if you ended up working on something else.
6501 - {{{kbd(C-c C-x C-j)}}} (~org-clock-goto~) ::
6503      #+kindex: C-c C-x C-j
6504      #+findex: or-clock-goto
6505      Jump to the headline of the currently clocked in task.  With
6506      a {{{kbd(C-u)}}} prefix argument, select the target task from
6507      a list of recently clocked tasks.
6509 - {{{kbd(C-c C-x C-d)}}} (~org-clock-display~) ::
6511      #+kindex: C-c C-x C-d
6512      #+findex: org-clock-display
6513      #+vindex: org-remove-highlights-with-change
6514      Display time summaries for each subtree in the current buffer.
6515      This puts overlays at the end of each headline, showing the total
6516      time recorded under that heading, including the time of any
6517      subheadings.  You can use visibility cycling to study the tree,
6518      but the overlays disappear when you change the buffer (see
6519      variable ~org-remove-highlights-with-change~) or press {{{kbd(C-c
6520      C-c)}}}.
6522 The {{{kbd(l)}}} key may be used in the agenda (see [[*Weekly/daily
6523 agenda]]) to show which tasks have been worked on or closed during
6524 a day.
6526 *Important:* note that both ~org-clock-out~ and ~org-clock-in-last~
6527 can have a global keybinding and do not modify the window disposition.
6529 *** The clock table
6530 :PROPERTIES:
6531 :DESCRIPTION: Detailed reports.
6532 :END:
6533 #+cindex: clocktable, dynamic block
6534 #+cindex: report, of clocked time
6536 Org mode can produce quite complex reports based on the time clocking
6537 information.  Such a report is called a /clock table/, because it is
6538 formatted as one or several Org tables.
6540 #+attr_texinfo: :sep ,
6541 - {{{kbd(C-c C-x C-r)}}} (~org-clock-report~) ::
6543      #+kindex: C-c C-x C-r
6544      #+findex: org-clock-report
6545      Insert a dynamic block (see [[*Dynamic Blocks]]) containing a clock
6546      report as an Org mode table into the current file.  When the
6547      cursor is at an existing clock table, just update it.  When
6548      called with a prefix argument, jump to the first clock report in
6549      the current document and update it.  The clock table always
6550      includes also trees with =ARCHIVE= tag.
6552 - {{{kbd(C-c C-c)}}} or {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
6554      #+kindex: C-c C-c
6555      #+kindex: C-c C-x C-u
6556      #+findex: org-dblock-update
6557      Update dynamic block at point.  The cursor needs to be in the
6558      =BEGIN= line of the dynamic block.
6560 - {{{kbd(C-u C-c C-x C-u)}}} ::
6562      #+kindex: C-u C-c C-x C-u
6563      Update all dynamic blocks (see [[*Dynamic Blocks]]).  This is useful
6564      if you have several clock table blocks in a buffer.
6566 - {{{kbd(S-left)}}}, {{{kbd(S-right)}}} (~org-clocktable-try-shift~) ::
6568      #+kindex: S-left
6569      #+kindex: S-right
6570      #+findex: org-clocktable-try-shift
6571      Shift the current =:block= interval and update the table.  The
6572      cursor needs to be in the =#+BEGIN: clocktable= line for this
6573      command.  If =:block= is =today=, it is shifted to =today-1=,
6574      etc.
6576 Here is an example of the frame for a clock table as it is inserted
6577 into the buffer with the {{{kbd(C-c C-x C-r)}}} command:
6579 #+cindex: BEGIN clocktable
6580 #+begin_example
6581   ,#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6582   ,#+END: clocktable
6583 #+end_example
6585 #+texinfo: @noindent
6586 #+vindex: org-clocktable-defaults
6587 The =#+BEGIN= line and specify a number of options to define the
6588 scope, structure, and formatting of the report.  Defaults for all
6589 these options can be configured in the variable
6590 ~org-clocktable-defaults~.
6592 #+texinfo: @noindent
6593 First there are options that determine which clock entries are to
6594 be selected:
6596 - :maxlevel ::
6598      Maximum level depth to which times are listed in the table.
6599      Clocks at deeper levels are summed into the upper level.
6601 - :scope ::
6603      The scope to consider.  This can be any of the following:
6605      | ~nil~                  | the current buffer or narrowed region                    |
6606      | ~file~                 | the full current buffer                                  |
6607      | ~subtree~              | the subtree where the clocktable is located              |
6608      | ~treeN~                | the surrounding level N tree, for example =tree3=        |
6609      | ~tree~                 | the surrounding level 1 tree                             |
6610      | ~agenda~               | all agenda files                                         |
6611      | =("file" ...)=         | scan these files                                         |
6612      | =FUNCTION=             | scan files returned by calling FUNCTION with no argument |
6613      | ~file-with-archives~   | current file and its archives                            |
6614      | ~agenda-with-archives~ | all agenda files, including archives                     |
6616 - :block ::
6618      The time block to consider.  This block is specified either
6619      absolutely, or relative to the current time and may be any of
6620      these formats:
6622      | =2007-12-31=                            | New year eve 2007     |
6623      | =2007-12=                               | December 2007         |
6624      | =2007-W50=                              | ISO-week 50 in 2007   |
6625      | =2007-Q2=                               | 2nd quarter in 2007   |
6626      | =2007=                                  | the year 2007         |
6627      | ~today~, ~yesterday~, ~today-N~         | a relative day        |
6628      | ~thisweek~, ~lastweek~, ~thisweek-N~    | a relative week       |
6629      | ~thismonth~, ~lastmonth~, ~thismonth-N~ | a relative month      |
6630      | ~thisyear~, ~lastyear~, ~thisyear-N~    | a relative year       |
6631      | ~untilnow~                              | all clocked time ever |
6633      #+vindex: org-clock-display-default-range
6634      When this option is not set, Org falls back to the value in
6635      ~org-clock-display-default-range~, which defaults to the current
6636      year.
6638      Use {{{kbd(S-left)}}} or {{{kbd(S-right)}}} to shift the time
6639      interval.
6641 - :tstart ::
6643      A time string specifying when to start considering times.
6644      Relative times like ="<-2w>"= can also be used.  See [[*Matching
6645      tags and properties]] for relative time syntax.
6647 - :tend  ::
6649      A time string specifying when to stop considering times.
6650      Relative times like ="<now>"= can also be used.  See [[*Matching
6651      tags and properties]] for relative time syntax.
6653 - wstart ::
6655      The starting day of the week.  The default is 1 for Monday.
6657 - mstart ::
6659      The starting day of the month.  The default is 1 for the first.
6661 - :step ::
6663      Set to ~week~ or ~day~ to split the table into chunks.  To use
6664      this, ~:block~ or ~:tstart~, ~:tend~ are needed.
6666 - :stepskip0 ::
6668      Do not show steps that have zero time.
6670 - :fileskip0 ::
6672      Do not show table sections from files which did not contribute.
6674 - :tags ::
6676      A tags match to select entries that should contribute.  See
6677      [[*Matching tags and properties]] for the match syntax.
6679 #+findex: org-clocktable-write-default
6680 Then there are options that determine the formatting of the table.
6681 There options are interpreted by the function
6682 ~org-clocktable-write-default~, but you can specify your own function
6683 using the =:formatter= parameter.
6685 - :emphasize ::
6687      When ~t~, emphasize level one and level two items.
6689 - :lang ::
6691      Language[fn:76] to use for descriptive cells like "Task".
6693 - :link ::
6695      Link the item headlines in the table to their origins.
6697 - :narrow ::
6699      An integer to limit the width of the headline column in the Org
6700      table.  If you write it like =50!=, then the headline is also
6701      shortened in export.
6703 - :indent  ::
6705      Indent each headline field according to its level.
6707 - :tcolumns ::
6709      Number of columns to be used for times.  If this is smaller than
6710      =:maxlevel=, lower levels are lumped into one column.
6712 - :level ::
6714      Should a level number column be included?
6716 - :sort ::
6718      A cons cell containing the column to sort and a sorting type.
6719      E.g., =:sort (1 . ?a)= sorts the first column alphabetically.
6721 - :compact ::
6723      Abbreviation for =:level nil :indent t :narrow 40! :tcolumns 1=.
6724      All are overwritten except if there is an explicit =:narrow=.
6726 - :timestamp ::
6728      A timestamp for the entry, when available.  Look for SCHEDULED,
6729      DEADLINE, TIMESTAMP and TIMESTAMP_IA special properties (see
6730      [[*Special Properties]]), in this order.
6732 - :properties ::
6734      List of properties shown in the table.  Each property gets its
6735      own column.
6737 - :inherit-props ::
6739      When this flag is non-~nil~, the values for =:properties= are
6740      inherited.
6742 - :formula  ::
6744      Content of a =TBLFM= keyword to be added and evaluated.  As
6745      a special case, =:formula %= adds a column with % time.  If you
6746      do not specify a formula here, any existing formula below the
6747      clock table survives updates and is evaluated.
6749 - :formatter ::
6751      A function to format clock data and insert it into the buffer.
6753 To get a clock summary of the current level 1 tree, for the current
6754 day, you could write:
6756 #+begin_example
6757   ,#+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6758   ,#+END: clocktable
6759 #+end_example
6761 #+texinfo: @noindent
6762 To use a specific time range you could write[fn:77]
6764 #+begin_example
6765   ,#+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6766                       :tend "<2006-08-10 Thu 12:00>"
6767   ,#+END: clocktable
6768 #+end_example
6770 A range starting a week ago and ending right now could be written as
6772 #+begin_example
6773   ,#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
6774   ,#+END: clocktable
6775 #+end_example
6777 A summary of the current subtree with % times would be:
6779 #+begin_example
6780   ,#+BEGIN: clocktable :scope subtree :link t :formula %
6781   ,#+END: clocktable
6782 #+end_example
6784 A horizontally compact representation of everything clocked during
6785 last week would be:
6787 #+begin_example
6788   ,#+BEGIN: clocktable :scope agenda :block lastweek :compact t
6789   ,#+END: clocktable
6790 #+end_example
6792 *** Resolving idle time and continuous clocking
6793 :PROPERTIES:
6794 :DESCRIPTION: Resolving time when you've been idle.
6795 :ALT_TITLE: Resolving idle time
6796 :END:
6798 **** Resolving idle time
6799 :PROPERTIES:
6800 :UNNUMBERED: notoc
6801 :END:
6803 #+cindex: resolve idle time
6804 #+cindex: idle, resolve, dangling
6806 If you clock in on a work item, and then walk away from your
6807 computer---perhaps to take a phone call---you often need to
6808 "resolve" the time you were away by either subtracting it from the
6809 current clock, or applying it to another one.
6811 #+vindex: org-clock-idle-time
6812 #+vindex: org-clock-x11idle-program-name
6813 By customizing the variable ~org-clock-idle-time~ to some integer,
6814 such as 10 or 15, Emacs can alert you when you get back to your
6815 computer after being idle for that many minutes[fn:78], and ask what
6816 you want to do with the idle time.  There will be a question waiting
6817 for you when you get back, indicating how much idle time has passed
6818 constantly updated with the current amount, as well as a set of
6819 choices to correct the discrepancy:
6821 - {{{kbd(k)}}} ::
6823      #+kindex: k
6824      To keep some or all of the minutes and stay clocked in, press
6825      {{{kbd(k)}}}.  Org asks how many of the minutes to keep.  Press
6826      {{{kbd(RET)}}} to keep them all, effectively changing nothing, or
6827      enter a number to keep that many minutes.
6829 - {{{kbd(K)}}} ::
6831      #+kindex: K
6832      If you use the shift key and press {{{kbd(K)}}}, it keeps however
6833      many minutes you request and then immediately clock out of that
6834      task.  If you keep all of the minutes, this is the same as just
6835      clocking out of the current task.
6837 - {{{kbd(s)}}} ::
6839      #+kindex: s
6840      To keep none of the minutes, use {{{kbd(s)}}} to subtract all the
6841      away time from the clock, and then check back in from the moment
6842      you returned.
6844 - {{{kbd(S)}}} ::
6846      #+kindex: S
6847      To keep none of the minutes and just clock out at the start of
6848      the away time, use the shift key and press {{{kbd(S)}}}.
6849      Remember that using shift always leave you clocked out, no matter
6850      which option you choose.
6852 - {{{kbd(C)}}} ::
6854      #+kindex: C
6855      To cancel the clock altogether, use {{{kbd(C)}}}.  Note that if
6856      instead of canceling you subtract the away time, and the
6857      resulting clock amount is less than a minute, the clock is still
6858      canceled rather than cluttering up the log with an empty entry.
6860 What if you subtracted those away minutes from the current clock, and
6861 now want to apply them to a new clock?  Simply clock in to any task
6862 immediately after the subtraction.  Org will notice that you have
6863 subtracted time "on the books", so to speak, and will ask if you want
6864 to apply those minutes to the next task you clock in on.
6866 There is one other instance when this clock resolution magic occurs.
6867 Say you were clocked in and hacking away, and suddenly your cat chased
6868 a mouse who scared a hamster that crashed into your UPS's power
6869 button!  You suddenly lose all your buffers, but thanks to auto-save
6870 you still have your recent Org mode changes, including your last clock
6873 If you restart Emacs and clock into any task, Org will notice that you
6874 have a dangling clock which was never clocked out from your last
6875 session.  Using that clock's starting time as the beginning of the
6876 unaccounted-for period, Org will ask how you want to resolve that
6877 time.  The logic and behavior is identical to dealing with away time
6878 due to idleness; it is just happening due to a recovery event rather
6879 than a set amount of idle time.
6881 You can also check all the files visited by your Org agenda for
6882 dangling clocks at any time using {{{kbd(M-x org-resolve-clocks
6883 RET)}}} (or {{{kbd(C-c C-x C-z)}}}).
6885 **** Continuous clocking
6886 :PROPERTIES:
6887 :UNNUMBERED: notoc
6888 :END:
6889 #+cindex: continuous clocking
6891 #+vindex: org-clock-continuously
6892 You may want to start clocking from the time when you clocked out the
6893 previous task.  To enable this systematically, set
6894 ~org-clock-continuously~ to non-~nil~.  Each time you clock in, Org
6895 retrieves the clock-out time of the last clocked entry for this
6896 session, and start the new clock from there.
6898 If you only want this from time to time, use three universal prefix
6899 arguments with ~org-clock-in~ and two {{{kbd(C-u C-u)}}} with
6900 ~org-clock-in-last~.
6902 ** Effort Estimates
6903 :PROPERTIES:
6904 :DESCRIPTION: Planning work effort in advance.
6905 :END:
6906 #+cindex: effort estimates
6907 #+cindex: EFFORT, property
6908 #+vindex: org-effort-property
6910 If you want to plan your work in a very detailed way, or if you need
6911 to produce offers with quotations of the estimated work effort, you
6912 may want to assign effort estimates to entries.  If you are also
6913 clocking your work, you may later want to compare the planned effort
6914 with the actual working time, a great way to improve planning
6915 estimates.  Effort estimates are stored in a special property
6916 =EFFORT=.  You can set the effort for an entry with the following
6917 commands:
6919 - {{{kbd(C-c C-x e)}}}  (~org-set-effort~) ::
6921      #+kindex: C-c C-x e
6922      #+findex: org-set-effort
6923      Set the effort estimate for the current entry.  With a prefix
6924      argument, set it to the next allowed value---see below.  This
6925      command is also accessible from the agenda with the {{{kbd(e)}}}
6926      key.
6928 - {{{kbd(C-c C-x C-e)}}} (~org-clock-modify-effort-estimate~) ::
6930      #+kindex: C-c C-x C-e
6931      #+findex: org-clock-modify-effort-estimate
6932      Modify the effort estimate of the item currently being clocked.
6934 Clearly the best way to work with effort estimates is through column
6935 view (see [[*Column View]]).  You should start by setting up discrete
6936 values for effort estimates, and a =COLUMNS= format that displays
6937 these values together with clock sums---if you want to clock your
6938 time.  For a specific buffer you can use:
6940 #+begin_example
6941   ,#+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6942   ,#+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM
6943 #+end_example
6945 #+texinfo: noindent
6946 #+vindex: org-global-properties
6947 #+vindex: org-columns-default-format
6948 or, even better, you can set up these values globally by customizing
6949 the variables ~org-global-properties~ and
6950 ~org-columns-default-format~.  In particular if you want to use this
6951 setup also in the agenda, a global setup may be advised.
6953 The way to assign estimates to individual items is then to switch to
6954 column mode, and to use {{{kbd(S-right)}}} and {{{kbd(S-left)}}} to
6955 change the value.  The values you enter are immediately summed up in
6956 the hierarchy.  In the column next to it, any clocked time is
6957 displayed.
6959 #+vindex: org-agenda-columns-add-appointments-to-effort-sum
6960 If you switch to column view in the daily/weekly agenda, the effort
6961 column summarizes the estimated work effort for each day[fn:79], and
6962 you can use this to find space in your schedule.  To get an overview
6963 of the entire part of the day that is committed, you can set the
6964 option ~org-agenda-columns-add-appointments-to-effort-sum~.  The
6965 appointments on a day that take place over a specified time interval
6966 are then also added to the load estimate of the day.
6968 Effort estimates can be used in secondary agenda filtering that is
6969 triggered with the {{{kbd(/)}}} key in the agenda (see [[*Commands in
6970 the Agenda Buffer]]).  If you have these estimates defined consistently,
6971 two or three key presses narrow down the list to stuff that fits into
6972 an available time slot.
6974 ** Taking Notes with a Relative Timer
6975 :PROPERTIES:
6976 :DESCRIPTION: Notes with a running timer.
6977 :ALT_TITLE: Timers
6978 :END:
6979 #+cindex: relative timer
6980 #+cindex: countdown timer
6982 Org provides two types of timers.  There is a relative timer that
6983 counts up, which can be useful when taking notes during, for example,
6984 a meeting or a video viewing.  There is also a countdown timer.
6986 The relative and countdown are started with separate commands.
6988 - {{{kbd(C-c C-x 0)}}} (~org-timer-start~) ::
6990      #+kindex: C-c C-x 0
6991      #+findex: org-timer-start
6992      Start or reset the relative timer.  By default, the timer is set
6993      to 0.  When called with a {{{kbd(C-u)}}} prefix, prompt the user
6994      for a starting offset.  If there is a timer string at point, this
6995      is taken as the default, providing a convenient way to restart
6996      taking notes after a break in the process.  When called with
6997      a double prefix argument {{{kbd(C-u C-u)}}}, change all timer
6998      strings in the active region by a certain amount.  This can be
6999      used to fix timer strings if the timer was not started at exactly
7000      the right moment.
7002 - {{{kbd(C-c C-x ;)}}} (~org-timer-set-timer~) ::
7004      #+kindex: C-c C-x ;
7005      #+findex: org-timer-set-timer
7006      #+vindex: org-timer-default-timer
7007      Start a countdown timer.  The user is prompted for a duration.
7008      ~org-timer-default-timer~ sets the default countdown value.
7009      Giving a numeric prefix argument overrides this default value.
7010      This command is available as {{{kbd(;)}}} in agenda buffers.
7012 Once started, relative and countdown timers are controlled with the
7013 same commands.
7015 - {{{kbd(C-c C-x .)}}} (~org-timer~) ::
7017      #+kindex: C-c C-x .
7018      #+findex: org-timer
7019      Insert a relative time into the buffer.  The first time you use
7020      this, the timer starts.  Using a prefix argument restarts it.
7022 - {{{kbd(C-c C-x -)}}} (~org-timer-item~) ::
7024      #+kindex: C-c C-x -
7025      #+findex: org-timer-item
7026      Insert a description list item with the current relative time.
7027      With a prefix argument, first reset the timer to 0.
7029 - {{{kbd(M-RET)}}} (~org-insert-heading~) ::
7031      #+kindex: M-RET
7032      #+findex: org-insert-heading
7033      Once the timer list is started, you can also use
7034      {{{kbd(M-RET)}}} to insert new timer items.
7036 - {{{kbd(C-c C-x \,)}}} (~org-timer-pause-or-continue~) ::
7038      #+kindex: C-c C-x ,
7039      #+findex: org-timer-pause-or-continue
7040      Pause the timer, or continue it if it is already paused.
7042 - {{{kbd(C-c C-x _)}}} (~org-timer-stop~) ::
7044      #+kindex: C-c C-x _
7045      #+findex: org-timer-stop
7046      Stop the timer.  After this, you can only start a new timer, not
7047      continue the old one.  This command also removes the timer from
7048      the mode line.
7050 * Capture, Refile, Archive
7051 :PROPERTIES:
7052 :DESCRIPTION: The ins and outs for projects.
7053 :END:
7054 #+cindex: capture
7056 An important part of any organization system is the ability to quickly
7057 capture new ideas and tasks, and to associate reference material with
7058 them.  Org does this using a process called /capture/.  It also can
7059 store files related to a task (/attachments/) in a special directory.
7060 Once in the system, tasks and projects need to be moved around.
7061 Moving completed project trees to an archive file keeps the system
7062 compact and fast.
7064 ** Capture
7065 :PROPERTIES:
7066 :DESCRIPTION: Capturing new stuff.
7067 :END:
7068 #+cindex: capture
7070 Capture lets you quickly store notes with little interruption of your
7071 work flow.  Org's method for capturing new items is heavily inspired
7072 by John Wiegley's excellent =remember.el= package.
7074 *** Setting up capture
7075 :PROPERTIES:
7076 :DESCRIPTION: Where notes will be stored.
7077 :END:
7079 The following customization sets a default target file for notes, and
7080 defines a global key[fn:80] for capturing new material.
7082 #+vindex: org-default-notes-file
7083 #+begin_src emacs-lisp
7084   (setq org-default-notes-file (concat org-directory "/notes.org"))
7085   (define-key global-map "\C-cc" 'org-capture)
7086 #+end_src
7088 *** Using capture
7089 :PROPERTIES:
7090 :DESCRIPTION: Commands to invoke and terminate capture.
7091 :END:
7093 - {{{kbd(C-c c)}}} (~org-capture~) ::
7095      #+kindex: C-c c
7096      #+findex: org-capture
7097      #+cindex: date tree
7098      Call the command ~org-capture~.  Note that this keybinding is
7099      global and not active by default: you need to install it.  If you
7100      have templates defined (see [[*Capture templates]]), it offers these
7101      templates for selection or use a new Org outline node as the
7102      default template.  It inserts the template into the target file
7103      and switch to an indirect buffer narrowed to this new node.  You
7104      may then insert the information you want.
7106 - {{{kbd(C-c C-c)}}} (~org-capture-finalize~) ::
7108      #+kindex: C-c C-c
7109      #+findex: org-capture-finalize
7110      Once you have finished entering information into the capture
7111      buffer, {{{kbd(C-c C-c)}}} returns you to the window
7112      configuration before the capture process, so that you can resume
7113      your work without further distraction.  When called with a prefix
7114      argument, finalize and then jump to the captured item.
7116 - {{{kbd(C-c C-w)}}} (~org-capture-refile~) ::
7118      #+kindex: C-c C-w
7119      #+findex: org-capture-refile
7120      Finalize the capture process by refiling the note to a different
7121      place (see [[*Refile and Copy]]).  Please realize that this is
7122      a normal refiling command that will be executed---so the cursor
7123      position at the moment you run this command is important.  If you
7124      have inserted a tree with a parent and children, first move the
7125      cursor back to the parent.  Any prefix argument given to this
7126      command is passed on to the ~org-refile~ command.
7128 - {{{kbd(C-c C-k)}}} (~org-capture-kill~) ::
7130      #+kindex: C-c C-k
7131      #+findex: org-capture-kill
7132      Abort the capture process and return to the previous state.
7134 You can also call ~org-capture~ in a special way from the agenda,
7135 using the {{{kbd(k c)}}} key combination.  With this access, any
7136 timestamps inserted by the selected capture template defaults to the
7137 cursor date in the agenda, rather than to the current date.
7139 To find the locations of the last stored capture, use ~org-capture~
7140 with prefix commands:
7142 - {{{kbd(C-u C-c c)}}} ::
7144      #+kindex: C-u C-c c
7145      Visit the target location of a capture template.  You get to
7146      select the template in the usual way.
7148 - {{{kbd(C-u C-u C-c c)}}} ::
7150      #+kindex: C-u C-u C-c c
7151      Visit the last stored capture item in its buffer.
7153 #+vindex: org-capture-bookmark
7154 #+cindex: org-capture-last-stored
7155 You can also jump to the bookmark ~org-capture-last-stored~, which is
7156 automatically created unless you set ~org-capture-bookmark~ to ~nil~.
7158 To insert the capture at point in an Org buffer, call ~org-capture~
7159 with a ~C-0~ prefix argument.
7161 *** Capture templates
7162 :PROPERTIES:
7163 :DESCRIPTION: Define the outline of different note types.
7164 :END:
7165 #+cindex: templates, for Capture
7167 You can use templates for different types of capture items, and for
7168 different target locations.  The easiest way to create such templates
7169 is through the customize interface.
7171 - {{{kbd(C-c c C)}}} ::
7173      #+kindex: C-c c C
7174      #+vindex: org-capture-templates
7175      Customize the variable ~org-capture-templates~.
7177 Before we give the formal description of template definitions, let's
7178 look at an example.  Say you would like to use one template to create
7179 general TODO entries, and you want to put these entries under the
7180 heading =Tasks= in your file =~/org/gtd.org=.  Also, a date tree in
7181 the file =journal.org= should capture journal entries.  A possible
7182 configuration would look like:
7184 #+begin_src emacs-lisp
7185   (setq org-capture-templates
7186         '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
7187            "* TODO %?\n  %i\n  %a")
7188           ("j" "Journal" entry (file+datetree "~/org/journal.org")
7189            "* %?\nEntered on %U\n  %i\n  %a")))
7190 #+end_src
7192 #+texinfo: @noindent
7193 If you then press {{{kbd(C-c c t)}}}, Org will prepare the template
7194 for you like this:
7196 #+begin_example
7197   ,* TODO
7198     [[file:LINK TO WHERE YOU INITIATED CAPTURE]]
7199 #+end_example
7201 #+texinfo: @noindent
7202 During expansion of the template, ~%a~ has been replaced by a link to
7203 the location from where you called the capture command.  This can be
7204 extremely useful for deriving tasks from emails, for example.  You
7205 fill in the task definition, press {{{kbd(C-c C-c)}}} and Org returns
7206 you to the same place where you started the capture process.
7208 To define special keys to capture to a particular template without
7209 going through the interactive template selection, you can create your
7210 key binding like this:
7212 #+begin_src emacs-lisp
7213   (define-key global-map "\C-cx"
7214     (lambda () (interactive) (org-capture nil "x")))
7215 #+end_src
7217 **** Template elements
7218 :PROPERTIES:
7219 :DESCRIPTION: What is needed for a complete template entry.
7220 :END:
7222 Now lets look at the elements of a template definition.  Each entry in
7223 ~org-capture-templates~ is a list with the following items:
7225 - keys ::
7227      The keys that selects the template, as a string, characters only,
7228      for example ="a"=, for a template to be selected with a single
7229      key, or ="bt"= for selection with two keys.  When using several
7230      keys, keys using the same prefix key must be sequential in the
7231      list and preceded by a 2-element entry explaining the prefix key,
7232      for example:
7234      #+begin_src emacs-lisp
7235        ("b" "Templates for marking stuff to buy")
7236      #+end_src
7238      #+texinfo: @noindent
7239      If you do not define a template for the {{{kbd(C)}}} key, this
7240      key opens the Customize buffer for this complex variable.
7242 - description ::
7244      A short string describing the template, shown during selection.
7246 - type ::
7248      The type of entry, a symbol.  Valid values are:
7250      - ~entry~ ::
7252           An Org mode node, with a headline.  Will be filed as the child
7253           of the target entry or as a top-level entry.  The target file
7254           should be an Org file.
7256      - ~item~ ::
7258           A plain list item, placed in the first plain list at the
7259           target location.  Again the target file should be an Org
7260           file.
7262      - ~checkitem~ ::
7264           A checkbox item.  This only differs from the plain list item
7265           by the default template.
7267      - ~table-line~ ::
7269           A new line in the first table at the target location.  Where
7270           exactly the line will be inserted depends on the properties
7271           ~:prepend~ and ~:table-line-pos~ (see below).
7273      - ~plain~ ::
7275           Text to be inserted as it is.
7277 - target ::
7279      #+vindex: org-default-notes-file
7280      #+vindex: org-directory
7281      Specification of where the captured item should be placed.  In
7282      Org files, targets usually define a node.  Entries will become
7283      children of this node.  Other types will be added to the table or
7284      list in the body of this node.  Most target specifications
7285      contain a file name.  If that file name is the empty string, it
7286      defaults to ~org-default-notes-file~.  A file can also be given
7287      as a variable or as a function called with no argument.  When an
7288      absolute path is not specified for a target, it is taken as
7289      relative to ~org-directory~.
7291      Valid values are:
7293      - =(file "path/to/file")= ::
7295           Text will be placed at the beginning or end of that file.
7297      - =(id "id of existing org entry")= ::
7299           Filing as child of this entry, or in the body of the entry.
7301      - =(file+headline "filename" "node headline")= ::
7303           Fast configuration if the target heading is unique in the file.
7305      - =(file+olp "filename" "Level 1 heading" "Level 2" ...)= ::
7307           For non-unique headings, the full path is safer.
7309      - =(file+regexp "filename" "regexp to find location")= ::
7311           Use a regular expression to position the cursor.
7313      - =(file+olp+datetree "filename" [ "Level 1 heading" ...])= ::
7315           This target[fn:81] creates a heading in a date tree[fn:82] for
7316           today's date.  If the optional outline path is given, the tree
7317           will be built under the node it is pointing to, instead of at
7318           top level.  Check out the ~:time-prompt~ and ~:tree-type~
7319           properties below for additional options.
7321      - ~(file+function "filename" function-finding-location)~ ::
7323           A function to find the right location in the file.
7325      - ~(clock)~ ::
7327           File to the entry that is currently being clocked.
7329      - ~(function function-finding-location)~ ::
7331           Most general way: write your own function which both visits the
7332           file and moves point to the right location.
7334 - template ::
7336      The template for creating the capture item.  If you leave this
7337      empty, an appropriate default template will be used.  Otherwise
7338      this is a string with escape codes, which will be replaced
7339      depending on time and context of the capture call.  The string
7340      with escapes may be loaded from a template file, using the
7341      special syntax =(file "template filename")=.  See below for more
7342      details.
7344 - properties ::
7346      The rest of the entry is a property list of additional options.
7347      Recognized properties are:
7349      - ~:prepend~ ::
7351           Normally new captured information will be appended at the
7352           target location (last child, last table line, last list item,
7353           ...).  Setting this property changes that.
7355      - ~:immediate-finish~ ::
7357           When set, do not offer to edit the information, just file it
7358           away immediately.  This makes sense if the template only needs
7359           information that can be added automatically.
7361      - ~:empty-lines~ ::
7363           Set this to the number of lines to insert before and after the
7364           new item.  Default 0, and the only other common value is 1.
7366      - ~:clock-in~ ::
7368           Start the clock in this item.
7370      - ~:clock-keep~ ::
7372           Keep the clock running when filing the captured entry.
7374      - ~:clock-resume~ ::
7376           If starting the capture interrupted a clock, restart that clock
7377           when finished with the capture.  Note that ~:clock-keep~ has
7378           precedence over ~:clock-resume~.  When setting both to
7379           non-~nil~, the current clock will run and the previous one will
7380           not be resumed.
7382      - ~:time-prompt~ ::
7384           Prompt for a date/time to be used for date/week trees and when
7385           filling the template.  Without this property, capture uses the
7386           current date and time.  Even if this property has not been set,
7387           you can force the same behavior by calling ~org-capture~ with
7388           a {{{kbd(C-1)}}} prefix argument.
7390      - ~:tree-type~ ::
7392           When ~week~, make a week tree instead of the month tree, i.e.,
7393           place the headings for each day under a heading with the
7394           current ISO week.
7396      - ~:unnarrowed~ ::
7398           Do not narrow the target buffer, simply show the full buffer.  Default
7399           is to narrow it so that you only see the new material.
7401      - ~:table-line-pos~ ::
7403           Specification of the location in the table where the new line
7404           should be inserted.  It should be a string like =II-3= meaning
7405           that the new line should become the third line before the
7406           second horizontal separator line.
7408      - ~:kill-buffer~ ::
7410           If the target file was not yet visited when capture was invoked, kill
7411           the buffer again after capture is completed.
7413 **** Template expansion
7414 :PROPERTIES:
7415 :DESCRIPTION: Filling in information about time and context.
7416 :END:
7418 In the template itself, special "%-escapes"[fn:83] allow dynamic
7419 insertion of content.  The templates are expanded in the order given
7420 here:
7422 - ~%[FILE]~ ::
7424      Insert the contents of the file given by {{{var(FILE)}}}.
7426 - ~%(SEXP)~ ::
7428      Evaluate Elisp SEXP and replace with the result.  The
7429      {{{var(SEXP)}}} must return a string.
7431 - ~%<FORMAT>~ ::
7433      The result of format-time-string on the {{{var(FORMAT)}}}
7434      specification.
7436 - ~%t~ ::
7438      Timestamp, date only.
7440 - ~%T~ ::
7442      Timestamp, with date and time.
7444 - ~%u~, ~%U~ ::
7446      Like ~%t~, ~%T~ above, but inactive timestamps.
7448 - ~%i~ ::
7450      Initial content, the region when capture is called while the
7451      region is active.  The entire text will be indented like ~%i~
7452      itself.
7454 - ~%a~ ::
7456      Annotation, normally the link created with ~org-store-link~.
7458 - ~%A~ ::
7460      Like ~%a~, but prompt for the description part.
7462 - ~%l~ ::
7464      Like ~%a~, but only insert the literal link.
7466 - ~%c~ ::
7468      Current kill ring head.
7470 - ~%x~ ::
7472      Content of the X clipboard.
7474 - ~%k~ ::
7476      Title of the currently clocked task.
7478 - ~%K~ ::
7480      Link to the currently clocked task.
7482 - ~%n~ ::
7484      User name (taken from ~user-full-name~).
7486 - ~%f~ ::
7488      File visited by current buffer when org-capture was called.
7490 - ~%F~ ::
7492      Full path of the file or directory visited by current buffer.
7494 - ~%:keyword~ ::
7496      Specific information for certain link types, see below.
7498 - ~%^g~  ::
7500      Prompt for tags, with completion on tags in target file.
7502 - ~%^G~  ::
7504      Prompt for tags, with completion all tags in all agenda files.
7506 - ~%^t~  ::
7508      Like ~%t~, but prompt for date.  Similarly ~%^T~, ~%^u~, ~%^U~.  You may
7509      define a prompt like ~%^{Birthday}t~.
7511 - ~%^C~  ::
7513      Interactive selection of which kill or clip to use.
7515 - ~%^L~  ::
7517      Like ~%^C~, but insert as link.
7519 - ~%^{PROP}p~ ::
7521      Prompt the user for a value for property PROP.
7523 - ~%^{PROMPT}~ ::
7525      Prompt the user for a string and replace this sequence with it.
7526      You may specify a default value and a completion table with
7527      ~%^{prompt|default|completion2|completion3...}~.  The arrow keys
7528      access a prompt-specific history.
7530 - ~%\n~ ::
7532      Insert the text entered at the Nth ~%^{PROMPT}~, where N is
7533      a number, starting from 1.
7535 - ~%?~ ::
7537      After completing the template, position cursor here.
7539 #+texinfo: @noindent
7540 #+vindex: org-store-link-props
7541 For specific link types, the following keywords are defined[fn:84]:
7543 #+vindex: org-from-is-user-regexp
7544 | Link type    | Available keywords                                       |
7545 |--------------+----------------------------------------------------------|
7546 | bbdb         | ~%:name~, ~%:company~                                    |
7547 | irc          | ~%:server~, ~%:port~, ~%:nick~                           |
7548 | mh, rmail    | ~%:type~, ~%:subject~, ~%:message-id~                    |
7549 |              | ~%:from~, ~%:fromname~, ~%:fromaddress~                  |
7550 |              | ~%:to~, ~%:toname~, ~%:toaddress~                        |
7551 |              | ~%:date~ (message date header field)                     |
7552 |              | ~%:date-timestamp~ (date as active timestamp)            |
7553 |              | ~%:date-timestamp-inactive~ (date as inactive timestamp) |
7554 |              | ~%:fromto~ (either "to NAME" or "from NAME")[fn:85]      |
7555 | gnus         | ~%:group~, for messages also all email fields            |
7556 | w3, w3m      | ~%:url~                                                  |
7557 | info         | ~%:file~, ~%:node~                                       |
7558 | calendar     | ~%:date~                                                 |
7559 | org-protocol | ~%:link~, ~%:description~, ~%:annotation~                |
7561 **** Templates in contexts
7562 :PROPERTIES:
7563 :DESCRIPTION: Only show a template in a specific context.
7564 :END:
7566 #+vindex: org-capture-templates-contexts
7567 To control whether a capture template should be accessible from
7568 a specific context, you can customize
7569 ~org-capture-templates-contexts~.  Let's say, for example, that you
7570 have a capture template "p" for storing Gnus emails containing
7571 patches.  Then you would configure this option like this:
7573 #+begin_src emacs-lisp
7574   (setq org-capture-templates-contexts
7575         '(("p" (in-mode . "message-mode"))))
7576 #+end_src
7578 You can also tell that the command key {{{kbd(p)}}} should refer to
7579 another template.  In that case, add this command key like this:
7581 #+begin_src emacs-lisp
7582   (setq org-capture-templates-contexts
7583         '(("p" "q" (in-mode . "message-mode"))))
7584 #+end_src
7586 See the docstring of the variable for more information.
7588 ** Attachments
7589 :PROPERTIES:
7590 :DESCRIPTION: Add files to tasks.
7591 :END:
7592 #+cindex: attachments
7593 #+vindex: org-attach-directory
7595 It is often useful to associate reference material with an outline
7596 node/task.  Small chunks of plain text can simply be stored in the
7597 subtree of a project.  Hyperlinks (see [[*Hyperlinks]]) can establish
7598 associations with files that live elsewhere on your computer or in the
7599 cloud, like emails or source code files belonging to a project.
7600 Another method is /attachments/, which are files located in
7601 a directory belonging to an outline node.  Org uses directories named
7602 by the unique ID of each entry.  These directories are located in the
7603 ~data~ directory which lives in the same directory where your Org file
7604 lives[fn:86].  If you initialize this directory with =git init=, Org
7605 automatically commits changes when it sees them.  The attachment
7606 system has been contributed to Org by John Wiegley.
7608 In cases where it seems better to do so, you can attach a directory of
7609 your choice to an entry.  You can also make children inherit the
7610 attachment directory from a parent, so that an entire subtree uses the
7611 same attached directory.
7613 #+texinfo: @noindent
7614 The following commands deal with attachments:
7616 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
7618      #+kindex: C-c C-a
7619      #+findex: org-attach
7620      The dispatcher for commands related to the attachment system.
7621      After these keys, a list of commands is displayed and you must
7622      press an additional key to select a command:
7624      - {{{kbd(a)}}} (~org-attach-attach~) ::
7626           #+kindex: C-c C-a a
7627           #+findex: org-attach-attach
7628           #+vindex: org-attach-method
7629           Select a file and move it into the task's attachment
7630           directory.  The file is copied, moved, or linked, depending
7631           on ~org-attach-method~.  Note that hard links are not
7632           supported on all systems.
7634      - {{{kbd(c)}}}/{{{kbd(m)}}}/{{{kbd(l)}}} ::
7636           #+kindex: C-c C-a c
7637           #+kindex: C-c C-a m
7638           #+kindex: C-c C-a l
7639           Attach a file using the copy/move/link method.  Note that
7640           hard links are not supported on all systems.
7642      - {{{kbd(n)}}} (~org-attach-new~) ::
7644           #+kindex: C-c C-a n
7645           #+findex: org-attach-new
7646           Create a new attachment as an Emacs buffer.
7648      - {{{kbd(z)}}} (~org-attach-sync~) ::
7650           #+kindex: C-c C-a z
7651           #+findex: org-attach-sync
7652           Synchronize the current task with its attachment directory, in case
7653           you added attachments yourself.
7655      - {{{kbd(o)}}} (~org-attach-open~) ::
7657           #+kindex: C-c C-a o
7658           #+findex: org-attach-open
7659           #+vindex: org-file-apps
7660           Open current task's attachment.  If there is more than one,
7661           prompt for a file name first.  Opening follows the rules set
7662           by ~org-file-apps~.  For more details, see the information
7663           on following hyperlinks (see [[*Handling Links]]).
7665      - {{{kbd(O)}}} (~org-attach-open-in-emacs~) ::
7667           #+kindex: C-c C-a O
7668           #+findex: org-attach-open-in-emacs
7669           Also open the attachment, but force opening the file in
7670           Emacs.
7672      - {{{kbd(f)}}} (~org-attach-reveal~) ::
7674           #+kindex: C-c C-a f
7675           #+findex: org-attach-reveal
7676           Open the current task's attachment directory.
7678      - {{{kbd(F)}}} (~org-attach-reveal-in-emacs~) ::
7680           #+kindex: C-c C-a F
7681           #+findex: org-attach-reveal-in-emacs
7682           Also open the directory, but force using Dired in Emacs.
7684      - {{{kbd(d)}}} (~org-attach-delete-one~) ::
7686           #+kindex: C-c C-a d
7687           Select and delete a single attachment.
7689      - {{{kbd(D)}}} (~org-attach-delete-all~) ::
7691           #+kindex: C-c C-a D
7692           Delete all of a task's attachments.  A safer way is to open
7693           the directory in Dired and delete from there.
7695      - {{{kbd(s)}}} (~org-attach-set-directory~) ::
7697           #+kindex: C-c C-a s
7698           #+cindex: ATTACH_DIR, property
7699           Set a specific directory as the entry's attachment
7700           directory.  This works by putting the directory path into
7701           the =ATTACH_DIR= property.
7703      - {{{kbd(i)}}} (~org-attach-set-inherit~) ::
7705           #+kindex: C-c C-a i
7706           #+cindex: ATTACH_DIR_INHERIT, property
7707           Set the =ATTACH_DIR_INHERIT= property, so that children use
7708           the same directory for attachments as the parent does.
7710 #+cindex: attach from Dired
7711 #+findex: org-attach-dired-to-subtree
7712 It is possible to attach files to a subtree from a Dired buffer.  To
7713 use this feature, have one window in Dired mode containing the file(s)
7714 to be attached and another window with point in the subtree that shall
7715 get the attachments.  In the Dired window, with point on a file,
7716 {{{kbd(M-x org-attach-dired-to-subtree)}}} attaches the file to the
7717 subtree using the attachment method set by variable
7718 ~org-attach-method~.  When files are marked in the Dired window then
7719 all marked files get attached.
7721 Add the following lines to the Emacs init file to have {{{kbd(C-c C-x
7722 a)}}} attach files in Dired buffers.
7724 #+begin_src emacs-lisp
7725   (add-hook 'dired-mode-hook
7726             (lambda ()
7727               (define-key dired-mode-map
7728                 (kbd "C-c C-x a")
7729                 #'org-attach-dired-to-subtree))))
7730 #+end_src
7732 The following code shows how to bind the previous command with
7733 a specific attachment method.
7735 #+begin_src emacs-lisp
7736   (add-hook 'dired-mode-hook
7737             (lambda ()
7738               (define-key dired-mode-map (kbd "C-c C-x c")
7739                 (lambda ()
7740                   (interactive)
7741                   (let ((org-attach-method 'cp))
7742                     (call-interactively #'org-attach-dired-to-subtree))))))
7743 #+end_src
7745 ** RSS Feeds
7746 :PROPERTIES:
7747 :DESCRIPTION: Getting input from RSS feeds.
7748 :END:
7749 #+cindex: RSS feeds
7750 #+cindex: Atom feeds
7752 Org can add and change entries based on information found in RSS feeds
7753 and Atom feeds.  You could use this to make a task out of each new
7754 podcast in a podcast feed.  Or you could use a phone-based
7755 note-creating service on the web to import tasks into Org.  To access
7756 feeds, configure the variable ~org-feed-alist~.  The docstring of this
7757 variable has detailed information.  With the following
7759 #+begin_src emacs-lisp
7760   (setq org-feed-alist
7761         '(("Slashdot"
7762            "http://rss.slashdot.org/Slashdot/slashdot"
7763            "~/txt/org/feeds.org" "Slashdot Entries")))
7764 #+end_src
7766 #+texinfo: @noindent
7767 new items from the feed provided by =rss.slashdot.org= result in new
7768 entries in the file =~/org/feeds.org= under the heading =Slashdot
7769 Entries=, whenever the following command is used:
7771 - {{{kbd(C-c C-x g)}}} (~org-feed-update-all~) ::
7773      #+kindex: C-c C-x g
7774      Collect items from the feeds configured in ~org-feed-alist~ and
7775      act upon them.
7777 - {{{kbd(C-c C-x G)}}} (~org-feed-goto-inbox~) ::
7779      #+kindex: C-c C-x G
7780      Prompt for a feed name and go to the inbox configured for this feed.
7782 Under the same headline, Org creates a drawer =FEEDSTATUS= in which it
7783 stores information about the status of items in the feed, to avoid
7784 adding the same item several times.
7786 For more information, including how to read atom feeds, see
7787 =org-feed.el= and the docstring of ~org-feed-alist~.
7789 ** Protocols for External Access
7790 :PROPERTIES:
7791 :DESCRIPTION: External access to Emacs and Org.
7792 :ALT_TITLE: Protocols
7793 :END:
7794 #+cindex: protocols, for external access
7796 Org protocol is a means to trigger custom actions in Emacs from
7797 external applications.  Any application that supports calling external
7798 programs with an URL as argument may be used with this functionality.
7799 For example, you can configure bookmarks in your web browser to send
7800 a link to the current page to Org and create a note from it using
7801 capture (see [[*Capture]]).  You can also create a bookmark that tells
7802 Emacs to open the local source file of a remote website you are
7803 browsing.
7805 #+cindex: Org protocol, set-up
7806 #+cindex: Installing Org protocol
7807 In order to use Org protocol from an application, you need to register
7808 =org-protocol://= as a valid scheme-handler.  External calls are
7809 passed to Emacs through the =emacsclient= command, so you also need to
7810 ensure an Emacs server is running.  More precisely, when the
7811 application calls
7813 : emacsclient org-protocol://PROTOCOL?key1=val1&key2=val2
7815 #+texinfo: @noindent
7816 Emacs calls the handler associated to {{{var(PROTOCOL)}}} with
7817 argument =(:key1 val1 :key2 val2)=.
7819 #+cindex: protocol, new protocol
7820 #+cindex: defining new protocols
7821 Org protocol comes with three predefined protocols, detailed in the
7822 following sections.  Configure ~org-protocol-protocol-alist~ to define
7823 your own.
7825 *** ~store-link~ protocol
7826 :PROPERTIES:
7827 :DESCRIPTION: Store a link, push URL to kill-ring.
7828 :END:
7829 #+cindex: store-link protocol
7830 #+cindex: protocol, store-link
7832 Using ~store-link~ handler, you can copy links, insertable through
7833 {{{kbd(M-x org-insert-link)}}} or yanking thereafter.  More precisely,
7834 the command
7836 : emacsclient org-protocol://store-link?url=URL&title=TITLE
7838 #+texinfo: @noindent
7839 stores the following link:
7841 : [[URL][TITLE]]
7843 In addition, {{{var(URL)}}} is pushed on the kill-ring for yanking.
7844 You need to encode {{{var(URL)}}} and {{{var(TITLE)}}} if they contain
7845 slashes, and probably quote those for the shell.
7847 To use this feature from a browser, add a bookmark with an arbitrary
7848 name, e.g., =Org: store-link= and enter this as /Location/:
7850 #+begin_example
7851 javascript:location.href='org-protocol://store-link?url='+
7852       encodeURIComponent(location.href);
7853 #+end_example
7855 *** ~capture~ protocol
7856 :PROPERTIES:
7857 :DESCRIPTION: Fill a buffer with external information.
7858 :END:
7859 #+cindex: capture protocol
7860 #+cindex: protocol, capture
7862 Activating "capture" handler pops up a =Capture= buffer and fills the
7863 capture template associated to the =X= key with them.
7865 : emacsclient org-protocol://capture?template=X?url=URL?title=TITLE?body=BODY
7867 To use this feature, add a bookmark with an arbitrary name, e.g.
7868 =Org: capture= and enter this as =Location=:
7870 #+begin_example
7871   javascript:location.href='org-protocol://template=x'+
7872         '&url='+encodeURIComponent(window.location.href)+
7873         '&title='+encodeURIComponent(document.title)+
7874         '&body='+encodeURIComponent(window.getSelection());
7875 #+end_example
7877 #+vindex: org-protocol-default-template-key
7878 The result depends on the capture template used, which is set in the
7879 bookmark itself, as in the example above, or in
7880 ~org-protocol-default-template-key~.
7882 The following template placeholders are available:
7884 #+begin_example
7885   %:link          The URL
7886   %:description   The webpage title
7887   %:annotation    Equivalent to [[%:link][%:description]]
7888   %i              The selected text
7889 #+end_example
7891 *** ~open-source~ protocol
7892 :PROPERTIES:
7893 :DESCRIPTION: Edit published contents.
7894 :END:
7895 #+cindex: open-source protocol
7896 #+cindex: protocol, open-source
7898 The ~open-source~ handler is designed to help with editing local
7899 sources when reading a document.  To that effect, you can use
7900 a bookmark with the following location:
7902 #+begin_example
7903   javascript:location.href='org-protocol://open-source?&url='+
7904         encodeURIComponent(location.href)
7905 #+end_example
7907 #+vindex: org-protocol-project-alist
7908 The variable ~org-protocol-project-alist~ maps URLs to local file
7909 names, by stripping URL parameters from the end and replacing the
7910 ~:base-url~ with ~:working-directory~ and ~:online-suffix~ with
7911 ~:working-suffix~.  For example, assuming you own a local copy of
7912 =https://orgmode.org/worg/= contents at =/home/user/worg=, you can set
7913 ~org-protocol-project-alist~ to the following
7915 #+begin_src emacs-lisp
7916   (setq org-protocol-project-alist
7917         '(("Worg"
7918            :base-url "https://orgmode.org/worg/"
7919            :working-directory "/home/user/worg/"
7920            :online-suffix ".html"
7921            :working-suffix ".org")))
7922 #+end_src
7924 #+texinfo: @noindent
7925 If you are now browsing
7926 =https://orgmode.org/worg/org-contrib/org-protocol.html= and find
7927 a typo or have an idea about how to enhance the documentation, simply
7928 click the bookmark and start editing.
7930 #+cindex: rewritten URL in open-source protocol
7931 #+cindex: protocol, open-source rewritten URL
7932 However, such mapping may not yield the desired results.  Suppose you
7933 maintain an online store located at =http://example.com/=.  The local
7934 sources reside in =/home/user/example/=.  It is common practice to
7935 serve all products in such a store through one file and rewrite URLs
7936 that do not match an existing file on the server.  That way, a request
7937 to =http://example.com/print/posters.html= might be rewritten on the
7938 server to something like
7939 =http://example.com/shop/products.php/posters.html.php=.  The
7940 ~open-source~ handler probably cannot find a file named
7941 =/home/user/example/print/posters.html.php= and fails.
7943 Such an entry in ~org-protocol-project-alist~ may hold an additional
7944 property ~:rewrites~.  This property is a list of cons cells, each of
7945 which maps a regular expression to a path relative to the
7946 ~:working-directory~.
7948 Now map the URL to the path =/home/user/example/products.php= by
7949 adding ~:rewrites~ rules like this:
7951 #+begin_src emacs-lisp
7952   (setq org-protocol-project-alist
7953         '(("example.com"
7954            :base-url "http://example.com/"
7955            :working-directory "/home/user/example/"
7956            :online-suffix ".php"
7957            :working-suffix ".php"
7958            :rewrites (("example.com/print/" . "products.php")
7959                       ("example.com/$" . "index.php")))))
7960 #+end_src
7962 #+texinfo: @noindent
7963 Since =example.com/$= is used as a regular expression, it maps
7964 =http://example.com/=, =https://example.com=,
7965 =http://www.example.com/= and similar to
7966 =/home/user/example/index.php=.
7968 The ~:rewrites~ rules are searched as a last resort if and only if no
7969 existing file name is matched.
7971 #+cindex: protocol, open-source, set-up mapping
7972 #+cindex: mappings in open-source protocol
7973 #+findex: org-protocol-create
7974 #+findex: org-protocol-create-for-org
7975 Two functions can help you filling ~org-protocol-project-alist~ with
7976 valid contents: ~org-protocol-create~ and
7977 ~org-protocol-create-for-org~.  The latter is of use if you're editing
7978 an Org file that is part of a publishing project.
7980 ** Refile and Copy
7981 :PROPERTIES:
7982 :DESCRIPTION: Moving/copying a tree from one place to another.
7983 :END:
7984 #+cindex: refiling notes
7985 #+cindex: copying notes
7987 When reviewing the captured data, you may want to refile or to copy
7988 some of the entries into a different list, for example into a project.
7989 Cutting, finding the right location, and then pasting the note is
7990 cumbersome.  To simplify this process, you can use the following
7991 special command:
7993 - {{{kbd(C-c M-w)}}} (~org-copy~) ::
7995      #+kindex: C-c M-w
7996      #+findex: org-copy
7997      Copying works like refiling, except that the original note is not
7998      deleted.
8000 - {{{kbd(C-c C-w)}}} (~org-refile~) ::
8002      #+kindex: C-c C-w
8003      #+findex: org-refile
8004      #+vindex: org-reverse-note-order
8005      #+vindex: org-refile-targets
8006      #+vindex: org-refile-use-outline-path
8007      #+vindex: org-outline-path-complete-in-steps
8008      #+vindex: org-refile-allow-creating-parent-nodes
8009      #+vindex: org-log-refile
8010      Refile the entry or region at point.  This command offers
8011      possible locations for refiling the entry and lets you select one
8012      with completion.  The item (or all items in the region) is filed
8013      below the target heading as a subitem.  Depending on
8014      ~org-reverse-note-order~, it is either the first or last subitem.
8016      By default, all level 1 headlines in the current buffer are
8017      considered to be targets, but you can have more complex
8018      definitions across a number of files.  See the variable
8019      ~org-refile-targets~ for details.  If you would like to select
8020      a location via a file-path-like completion along the outline
8021      path, see the variables ~org-refile-use-outline-path~ and
8022      ~org-outline-path-complete-in-steps~.  If you would like to be
8023      able to create new nodes as new parents for refiling on the fly,
8024      check the variable ~org-refile-allow-creating-parent-nodes~.
8025      When the variable ~org-log-refile~[fn:87] is set, a timestamp or
8026      a note is recorded whenever an entry is refiled.
8028 - {{{kbd(C-u C-c C-w)}}} ::
8030      #+kindex: C-u C-c C-w
8031      Use the refile interface to jump to a heading.
8033 - {{{kbd(C-u C-u C-c C-w)}}} (~org-refile-goto-last-stored~) ::
8035      #+kindex: C-u C-u C-c C-w
8036      #+findex: org-refile-goto-last-stored
8037      Jump to the location where ~org-refile~ last moved a tree to.
8039 - {{{kbd(C-2 C-c C-w)}}} ::
8041      #+kindex: C-2 C-c C-w
8042      Refile as the child of the item currently being clocked.
8044 - {{{kbd(C-3 C-c C-w)}}} ::
8046      #+kindex: C-3 C-c C-w
8047      #+vindex: org-refile-keep
8048      Refile and keep the entry in place.  Also see ~org-refile-keep~
8049      to make this the default behavior, and beware that this may
8050      result in duplicated ~ID~ properties.
8052 - {{{kbd(C-0 C-c C-w)}}} or {{{kbd(C-u C-u C-u C-c C-w)}}} (~org-refile-cache-clear~) ::
8054      #+kindex: C-u C-u C-u C-c C-w
8055      #+kindex: C-0 C-c C-w
8056      #+findex: org-refile-cache-clear
8057      #+vindex: org-refile-use-cache
8058      Clear the target cache.  Caching of refile targets can be turned
8059      on by setting ~org-refile-use-cache~.  To make the command see
8060      new possible targets, you have to clear the cache with this
8061      command.
8063 ** Archiving
8064 :PROPERTIES:
8065 :DESCRIPTION: What to do with finished products.
8066 :END:
8067 #+cindex: archiving
8069 When a project represented by a (sub)tree is finished, you may want to
8070 move the tree out of the way and to stop it from contributing to the
8071 agenda.  Archiving is important to keep your working files compact and
8072 global searches like the construction of agenda views fast.
8074 - {{{kbd(C-c C-x C-a)}}} (~org-archive-subtree-default~) ::
8076      #+kindex: C-c C-x C-a
8077      #+findex: org-archive-subtree-default
8078      #+vindex: org-archive-default-command
8079      Archive the current entry using the command specified in the
8080      variable ~org-archive-default-command~.
8082 *** Moving a tree to an archive file
8083 :PROPERTIES:
8084 :DESCRIPTION: Moving a tree to an archive file.
8085 :ALT_TITLE: Moving subtrees
8086 :END:
8087 #+cindex: external archiving
8089 The most common archiving action is to move a project tree to another
8090 file, the archive file.
8092 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd(C-c $)}}} (~org-archive-subtree~) ::
8094      #+kindex: C-c C-x C-s
8095      #+kindex: C-c $
8096      #+findex: org-archive-subtree
8097      #+vindex: org-archive-location
8098      Archive the subtree starting at the cursor position to the
8099      location given by ~org-archive-location~.
8101 - {{{kbd(C-u C-c C-x C-s)}}} ::
8103      #+kindex: C-u C-c C-x C-s
8104      Check if any direct children of the current headline could be
8105      moved to the archive.  To do this, check each subtree for open
8106      TODO entries.  If none is found, the command offers to move it to
8107      the archive location.  If the cursor is /not/ on a headline when
8108      this command is invoked, check level 1 trees.
8110 - {{{kbd(C-u C-u C-c C-x C-s)}}} ::
8112      #+kindex: C-u C-u C-c C-x C-s
8113      As above, but check subtree for timestamps instead of TODO
8114      entries.  The command offers to archive the subtree if it /does/
8115      contain a timestamp, and that timestamp is in the past.
8117 #+cindex: archive locations
8118 The default archive location is a file in the same directory as the
8119 current file, with the name derived by appending =_archive= to the
8120 current file name.  You can also choose what heading to file archived
8121 items under, with the possibility to add them to a datetree in a file.
8122 For information and examples on how to specify the file and the
8123 heading, see the documentation string of the variable
8124 ~org-archive-location~.
8126 There is also an in-buffer option for setting this variable, for
8127 example:
8129 #+cindex: ARCHIVE, keyword
8130 : #+ARCHIVE: %s_done::
8132 #+texinfo: @noindent
8133 #+cindex: ARCHIVE, property
8134 If you would like to have a special archive location for a single
8135 entry or a (sub)tree, give the entry an =ARCHIVE= property with the
8136 location as the value (see [[*Properties and Columns]]).
8138 #+vindex: org-archive-save-context-info
8139 When a subtree is moved, it receives a number of special properties
8140 that record context information like the file from where the entry
8141 came, its outline path the archiving time etc.  Configure the variable
8142 ~org-archive-save-context-info~ to adjust the amount of information
8143 added.
8145 *** Internal archiving
8146 :PROPERTIES:
8147 :DESCRIPTION: Switch off a tree but keep it in the file.
8148 :END:
8150 If you want to just switch off---for agenda views---certain subtrees
8151 without moving them to a different file, you can use the =ARCHIVE=
8152 tag.
8154 A headline that is marked with the =ARCHIVE= tag (see [[*Tags]]) stays at
8155 its location in the outline tree, but behaves in the following way:
8158   #+vindex: org-cycle-open-archived-trees
8159   It does not open when you attempt to do so with a visibility cycling
8160   command (see [[*Visibility Cycling]]).  You can force cycling archived
8161   subtrees with {{{kbd(C-TAB)}}}, or by setting the option
8162   ~org-cycle-open-archived-trees~.  Also normal outline commands, like
8163   ~outline-show-all~, open archived subtrees.
8166   #+vindex: org-sparse-tree-open-archived-trees
8167   During sparse tree construction (see [[*Sparse Trees]]), matches in
8168   archived subtrees are not exposed, unless you configure the option
8169   ~org-sparse-tree-open-archived-trees~.
8172   #+vindex: org-agenda-skip-archived-trees
8173   During agenda view construction (see [[*Agenda Views]]), the content of
8174   archived trees is ignored unless you configure the option
8175   ~org-agenda-skip-archived-trees~, in which case these trees are
8176   always included.  In the agenda you can press {{{kbd(v a)}}} to get
8177   archives temporarily included.
8180   #+vindex: org-export-with-archived-trees
8181   Archived trees are not exported (see [[*Exporting]]), only the headline
8182   is.  Configure the details using the variable
8183   ~org-export-with-archived-trees~.
8186   #+vindex: org-columns-skip-archived-trees
8187   Archived trees are excluded from column view unless the variable
8188   ~org-columns-skip-archived-trees~ is configured to ~nil~.
8190 The following commands help manage the =ARCHIVE= tag:
8192 - {{{kbd(C-c C-x a)}}} (~org-toggle-archive-tag~) ::
8194      #+kindex: C-c C-x a
8195      #+findex: org-toggle-archive-tag
8196      Toggle the archive tag for the current headline.  When the tag is
8197      set, the headline changes to a shadowed face, and the subtree
8198      below it is hidden.
8200 - {{{kbd(C-u C-c C-x a)}}} ::
8202      #+kindex: C-u C-c C-x a
8203      Check if any direct children of the current headline should be
8204      archived.  To do this, check each subtree for open TODO entries.
8205      If none is found, the command offers to set the =ARCHIVE= tag for
8206      the child.  If the cursor is /not/ on a headline when this
8207      command is invoked, check the level 1 trees.
8209 - {{{kbd(C-TAB)}}}, ~org-force-cycle-archived~ ::
8211      #+kindex: C-TAB
8212      Cycle a tree even if it is tagged with =ARCHIVE=.
8214 - {{{kbd(C-c C-x A)}}} (~org-archive-to-archive-sibling~) ::
8216      #+kindex: C-c C-x A
8217      #+findex: org-archive-to-archive-sibling
8218      Move the current entry to the /Archive Sibling/.  This is
8219      a sibling of the entry with the heading =Archive= and the archive
8220      tag.  The entry becomes a child of that sibling and in this way
8221      retains a lot of its original context, including inherited tags
8222      and approximate position in the outline.
8224 * Agenda Views
8225 :PROPERTIES:
8226 :DESCRIPTION: Collecting information into views.
8227 :END:
8228 #+cindex: agenda views
8230 Due to the way Org works, TODO items, time-stamped items, and tagged
8231 headlines can be scattered throughout a file or even a number of
8232 files.  To get an overview of open action items, or of events that are
8233 important for a particular date, this information must be collected,
8234 sorted and displayed in an organized way.
8236 Org can select items based on various criteria and display them in
8237 a separate buffer.  Seven different view types are provided:
8239 - an /agenda/ that is like a calendar and shows information for
8240   specific dates,
8242 - a /TODO list/ that covers all unfinished action items,
8244 - a /match view/, showings headlines based on the tags, properties,
8245   and TODO state associated with them,
8247 - a /timeline view/ that shows all events in a single Org file, in
8248   time-sorted view,
8250 - a /text search view/ that shows all entries from multiple files that
8251   contain specified keywords,
8253 - a /stuck projects view/ showing projects that currently do not move
8254   along, and
8256 - /custom views/ that are special searches and combinations of
8257   different views.
8259 #+texinfo: @noindent
8260 The extracted information is displayed in a special /agenda buffer/.
8261 This buffer is read-only, but provides commands to visit the
8262 corresponding locations in the original Org files, and even to edit
8263 these files remotely.
8265 #+vindex: org-agenda-skip-comment-trees
8266 #+vindex: org-agenda-skip-archived-trees
8267 #+cindex: commented entries, in agenda views
8268 #+cindex: archived entries, in agenda views
8269 By default, the report ignores commented (see [[*Comment Lines]]) and
8270 archived (see [[*Internal archiving]]) entries.  You can override this by
8271 setting ~org-agenda-skip-comment-trees~ and
8272 ~org-agenda-skip-archived-trees~ to ~nil~.
8274 #+vindex: org-agenda-window-setup
8275 #+vindex: org-agenda-restore-windows-after-quit
8276 Two variables control how the agenda buffer is displayed and whether
8277 the window configuration is restored when the agenda exits:
8278 ~org-agenda-window-setup~ and ~org-agenda-restore-windows-after-quit~.
8280 ** Agenda Files
8281 :PROPERTIES:
8282 :DESCRIPTION: Files being searched for agenda information.
8283 :END:
8284 #+cindex: agenda files
8285 #+cindex: files for agenda
8287 #+vindex: org-agenda-files
8288 The information to be shown is normally collected from all /agenda
8289 files/, the files listed in the variable ~org-agenda-files~[fn:88].
8290 If a directory is part of this list, all files with the extension
8291 =.org= in this directory are part of the list.
8293 Thus, even if you only work with a single Org file, that file should
8294 be put into the list[fn:89].  You can customize ~org-agenda-files~,
8295 but the easiest way to maintain it is through the following commands
8297 #+attr_texinfo: :sep and
8298 - {{{kbd(C-c [)}}} (~org-agenda-file-to-front~) ::
8300      #+kindex: C-c [
8301      #+findex: org-agenda-file-to-front
8302      #+cindex: files, adding to agenda list
8303      Add current file to the list of agenda files.  The file is added
8304      to the front of the list.  If it was already in the list, it is
8305      moved to the front.  With a prefix argument, file is added/moved
8306      to the end.
8308 - {{{kbd(C-c ])}}} (~org-remove-file~) ::
8310      #+kindex: C-c ]
8311      #+findex: org-remove-file
8312      Remove current file from the list of agenda files.
8314 - {{{kbd(C-')}}} and {{{kbd(C-\,)}}} (~org-cycle-agenda-files~) ::
8316      #+kindex: C-'
8317      #+kindex: C-,
8318      #+findex: org-cycle-agenda-files
8319      #+cindex: cycling, of agenda files
8320      Cycle through agenda file list, visiting one file after the other.
8322 - {{{kbd(M-x org-iswitchb)}}} ::
8324      #+findex: org-iswitchb
8325      Command to use an ~iswitchb~-like interface to switch to and
8326      between Org buffers.
8328 #+texinfo: @noindent
8329 The Org menu contains the current list of files and can be used to
8330 visit any of them.
8332 If you would like to focus the agenda temporarily on a file not in
8333 this list, or on just one file in the list, or even on only a subtree
8334 in a file, then this can be done in different ways.  For a single
8335 agenda command, you may press {{{kbd(<)}}} once or several times in
8336 the dispatcher (see [[*The Agenda Dispatcher]]).  To restrict the agenda
8337 scope for an extended period, use the following commands:
8339 - {{{kbd(C-c C-x <)}}} (~org-agenda-set-restriction-lock~) ::
8341      #+kindex: C-c C-x <
8342      #+findex: org-agenda-set-restriction-lock
8343      Permanently restrict the agenda to the current subtree.  When
8344      called with a prefix argument, or with the cursor before the
8345      first headline in a file, set the agenda scope to the entire
8346      file.  This restriction remains in effect until removed with
8347      {{{kbd(C-c C-x >)}}}, or by typing either {{{kbd(<)}}} or
8348      {{{kbd(>)}}} in the agenda dispatcher.  If there is a window
8349      displaying an agenda view, the new restriction takes effect
8350      immediately.
8352 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
8354      #+kindex: C-c C-x >
8355      #+findex: org-agenda-remove-restriction-lock
8356      Remove the permanent restriction created by {{{kbd(C-c C-x <)}}}.
8358 #+texinfo: @noindent
8359 When working with =speedbar.el=, you can use the following commands in
8360 the Speedbar frame:
8362 - {{{kbd(<)}}} (~org-speedbar-set-agenda-restriction~) ::
8364      #+findex: org-speedbar-set-agenda-restriction
8365      Permanently restrict the agenda to the item---either an Org file
8366      or a subtree in such a file---at the cursor in the Speedbar
8367      frame.  If there is a window displaying an agenda view, the new
8368      restriction takes effect immediately.
8370 - {{{kbd(>)}}} (~org-agenda-remove-restriction-lock~) ::
8372      #+findex: org-agenda-remove-restriction-lock
8373      Lift the restriction.
8375 ** The Agenda Dispatcher
8376 :PROPERTIES:
8377 :DESCRIPTION: Keyboard access to agenda views.
8378 :ALT_TITLE: Agenda Dispatcher
8379 :END:
8380 #+cindex: agenda dispatcher
8381 #+cindex: dispatching agenda commands
8383 The views are created through a dispatcher, which should be bound to
8384 a global key---for example {{{kbd(C-c a)}}} (see [[*Activation]]).  In
8385 the following we will assume that {{{kbd(C-c a)}}} is indeed how the
8386 dispatcher is accessed and list keyboard access to commands
8387 accordingly.  After pressing {{{kbd(C-c a)}}}, an additional letter is
8388 required to execute a command.  The dispatcher offers the following
8389 default commands:
8391 - {{{kbd(a)}}} ::
8393      #+kindex: C-c a a
8394      Create the calendar-like agenda (see [[*Weekly/daily agenda]]).
8396 - {{{kbd(t)}}} or {{{kbd(T)}}} ::
8398      #+kindex: C-c a t
8399      #+kindex: C-c a T
8400      Create a list of all TODO items (see [[*The global TODO list]]).
8402 - {{{kbd(m)}}} or {{{kbd(M)}}} ::
8404      #+kindex: C-c a m
8405      #+kindex: C-c a M
8406      Create a list of headlines matching a given expression (see
8407      [[*Matching tags and properties]]).
8409 - {{{kbd(s)}}} ::
8411      #+kindex: C-c a s
8412      Create a list of entries selected by a boolean expression of
8413      keywords and/or regular expressions that must or must not occur
8414      in the entry.
8416 - {{{kbd(/)}}} ::
8418      #+kindex: C-c a /
8419      #+vindex: org-agenda-text-search-extra-files
8420      Search for a regular expression in all agenda files and
8421      additionally in the files listed in
8422      ~org-agenda-text-search-extra-files~.  This uses the Emacs
8423      command ~multi-occur~.  A prefix argument can be used to specify
8424      the number of context lines for each match, default is
8425      1.
8427 - {{{kbd(#)}}} or {{{kbd(!)}}} ::
8429      #+kindex: C-c a #
8430      #+kindex: C-c a !
8431      Create a list of stuck projects (see [[*Stuck projects]]).
8433 - {{{kbd(<)}}} ::
8435      #+kindex: C-c a <
8436      Restrict an agenda command to the current buffer[fn:90].  After
8437      pressing {{{kbd(<)}}}, you still need to press the character
8438      selecting the command.
8440 - {{{kbd(< <)}}} ::
8442      #+kindex: C-c a < <
8443      If there is an active region, restrict the following agenda
8444      command to the region.  Otherwise, restrict it to the current
8445      subtree[fn:91].  After pressing {{{kbd(< <)}}}, you still need to
8446      press the character selecting the command.
8448 - {{{kbd(*)}}} ::
8450      #+kindex: C-c a *
8451      #+vindex: org-agenda-sticky
8452      #+findex: org-toggle-sticky-agenda
8453      Toggle sticky agenda views.  By default, Org maintains only
8454      a single agenda buffer and rebuilds it each time you change the
8455      view, to make sure everything is always up to date.  If you
8456      switch between views often and the build time bothers you, you
8457      can turn on sticky agenda buffers (make this the default by
8458      customizing the variable ~org-agenda-sticky~).  With sticky
8459      agendas, the dispatcher only switches to the selected view, you
8460      need to update it by hand with {{{kbd(r)}}} or {{{kbd(g)}}}.  You
8461      can toggle sticky agenda view any time with
8462      ~org-toggle-sticky-agenda~.
8464 You can also define custom commands that are accessible through the
8465 dispatcher, just like the default commands.  This includes the
8466 possibility to create extended agenda buffers that contain several
8467 blocks together, for example the weekly agenda, the global TODO list
8468 and a number of special tags matches.  See [[*Custom Agenda Views]].
8470 ** The Built-in Agenda Views
8471 :PROPERTIES:
8472 :DESCRIPTION: What is available out of the box?
8473 :ALT_TITLE: Built-in Agenda Views
8474 :END:
8476 In this section we describe the built-in views.
8478 *** Weekly/daily agenda
8479 :PROPERTIES:
8480 :DESCRIPTION: The calendar page with current tasks.
8481 :END:
8482 #+cindex: agenda
8483 #+cindex: weekly agenda
8484 #+cindex: daily agenda
8486 The purpose of the weekly/daily /agenda/ is to act like a page of
8487 a paper agenda, showing all the tasks for the current week or day.
8489 - {{{kbd(C-c a a)}}} (~org-agenda-list~) ::
8491      #+kindex: C-c a a
8492      #+findex: org-agenda-list
8493      #+cindex: org-agenda, command
8494      Compile an agenda for the current week from a list of Org files.
8495      The agenda shows the entries for each day.  With a numeric
8496      prefix[fn:92] (like {{{kbd(C-u 2 1 C-c a a)}}}) you may set the
8497      number of days to be displayed.
8499 #+vindex: org-agenda-span
8500 #+vindex: org-agenda-start-day
8501 #+vindex: org-agenda-start-on-weekday
8502 The default number of days displayed in the agenda is set by the
8503 variable ~org-agenda-span~.  This variable can be set to any number of
8504 days you want to see by default in the agenda, or to a span name, such
8505 a ~day~, ~week~, ~month~ or ~year~.  For weekly agendas, the default
8506 is to start on the previous Monday (see
8507 ~org-agenda-start-on-weekday~).  You can also set the start date using
8508 a date shift: ~(setq org-agenda-start-day "+10d")~ starts the agenda
8509 ten days from today in the future.
8511 Remote editing from the agenda buffer means, for example, that you can
8512 change the dates of deadlines and appointments from the agenda buffer.
8513 The commands available in the Agenda buffer are listed in [[*Commands in
8514 the Agenda Buffer]].
8516 **** Calendar/Diary integration
8517 :PROPERTIES:
8518 :UNNUMBERED: notoc
8519 :END:
8520 #+cindex: calendar integration
8521 #+cindex: diary integration
8523 Emacs contains the calendar and diary by Edward M. Reingold.  The
8524 calendar displays a three-month calendar with holidays from different
8525 countries and cultures.  The diary allows you to keep track of
8526 anniversaries, lunar phases, sunrise/set, recurrent appointments
8527 (weekly, monthly) and more.  In this way, it is quite complementary to
8528 Org.  It can be very useful to combine output from Org with the diary.
8530 In order to include entries from the Emacs diary into Org mode's
8531 agenda, you only need to customize the variable
8533 #+begin_src emacs-lisp
8534   (setq org-agenda-include-diary t)
8535 #+end_src
8537 #+texinfo: @noindent
8538 After that, everything happens automatically.  All diary entries
8539 including holidays, anniversaries, etc., are included in the agenda
8540 buffer created by Org mode.  {{{kbd(SPC)}}}, {{{kbd(TAB)}}}, and
8541 {{{kbd(RET)}}} can be used from the agenda buffer to jump to the diary
8542 file in order to edit existing diary entries.  The {{{kbd(i)}}}
8543 command to insert new entries for the current date works in the agenda
8544 buffer, as well as the commands {{{kbd(S)}}}, {{{kbd(M)}}}, and
8545 {{{kbd(C)}}} to display Sunrise/Sunset times, show lunar phases and to
8546 convert to other calendars, respectively.  {{{kbd(c)}}} can be used to
8547 switch back and forth between calendar and agenda.
8549 If you are using the diary only for S-exp entries and holidays, it is
8550 faster to not use the above setting, but instead to copy or even move
8551 the entries into an Org file.  Org mode evaluates diary-style sexp
8552 entries, and does it faster because there is no overhead for first
8553 creating the diary display.  Note that the sexp entries must start at
8554 the left margin, no whitespace is allowed before them, as seen in the
8555 following segment of an Org file:[fn:93]
8557 #+begin_example
8558   ,* Holidays
8559     :PROPERTIES:
8560     :CATEGORY: Holiday
8561     :END:
8562   %%(org-calendar-holiday)   ; special function for holiday names
8564   ,* Birthdays
8565     :PROPERTIES:
8566     :CATEGORY: Ann
8567     :END:
8568   %%(org-anniversary 1956  5 14) Arthur Dent is %d years old
8569   %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
8570 #+end_example
8572 **** Anniversaries from BBDB
8573 :PROPERTIES:
8574 :UNNUMBERED: notoc
8575 :END:
8576 #+cindex: BBDB, anniversaries
8577 #+cindex: anniversaries, from BBDB
8579 #+findex: org-bbdb-anniversaries
8580 If you are using the Insidious Big Brother Database to store your
8581 contacts, you very likely prefer to store anniversaries in BBDB rather
8582 than in a separate Org or diary file.  Org supports this and can show
8583 BBDB anniversaries as part of the agenda.  All you need to do is to
8584 add the following to one of your agenda files:
8586 #+begin_example
8587   ,* Anniversaries
8588     :PROPERTIES:
8589     :CATEGORY: Anniv
8590     :END:
8591   %%(org-bbdb-anniversaries)
8592 #+end_example
8594 You can then go ahead and define anniversaries for a BBDB record.
8595 Basically, you need to press {{{kbd(C-o anniversary RET)}}} with the
8596 cursor in a BBDB record and then add the date in the format
8597 =YYYY-MM-DD= or =MM-DD=, followed by a space and the class of the
8598 anniversary (=birthday=, =wedding=, or a format string).  If you omit
8599 the class, it defaults to =birthday=.  Here are a few examples, the
8600 header for the file =org-bbdb.el= contains more detailed information.
8602 #+begin_example
8603   1973-06-22
8604   06-22
8605   1955-08-02 wedding
8606   2008-04-14 %s released version 6.01 of Org mode, %d years ago
8607 #+end_example
8609 After a change to BBDB, or for the first agenda display during an
8610 Emacs session, the agenda display suffers a short delay as Org updates
8611 its hash with anniversaries.  However, from then on things will be
8612 very fast, much faster in fact than a long list of
8613 =%%(diary-anniversary)= entries in an Org or Diary file.
8615 #+findex: org-bbdb-anniversaries-future
8616 If you would like to see upcoming anniversaries with a bit of
8617 forewarning, you can use the following instead:
8619 #+begin_example
8620   ,* Anniversaries
8621     :PROPERTIES:
8622     :CATEGORY: Anniv
8623     :END:
8624   %%(org-bbdb-anniversaries-future 3)
8625 #+end_example
8627 That will give you three days' warning: on the anniversary date itself
8628 and the two days prior.  The argument is optional: if omitted, it
8629 defaults to 7.
8631 **** Appointment reminders
8632 :PROPERTIES:
8633 :UNNUMBERED: notoc
8634 :END:
8635 #+cindex: @file{appt.el}
8636 #+cindex: appointment reminders
8637 #+cindex: appointment
8638 #+cindex: reminders
8640 #+cindex: APPT_WARNTIME, keyword
8641 Org can interact with Emacs appointments notification facility.  To
8642 add the appointments of your agenda files, use the command
8643 ~org-agenda-to-appt~.  This command lets you filter through the list
8644 of your appointments and add only those belonging to a specific
8645 category or matching a regular expression.  It also reads
8646 a =APPT_WARNTIME= property which overrides the value of
8647 ~appt-message-warning-time~ for this appointment.  See the docstring
8648 for details.
8650 *** The global TODO list
8651 :PROPERTIES:
8652 :DESCRIPTION: All unfinished action items.
8653 :ALT_TITLE: Global TODO list
8654 :END:
8655 #+cindex: global TODO list
8656 #+cindex: TODO list, global
8658 The global TODO list contains all unfinished TODO items formatted and
8659 collected into a single place.
8661 - {{{kbd(C-c a t)}}} (~org-todo-list~) ::
8663      #+kindex: C-c a t
8664      #+findex: org-todo-list
8665      Show the global TODO list.  This collects the TODO items from all
8666      agenda files (see [[*Agenda Views]]) into a single buffer.  By
8667      default, this lists items with a state the is not a DONE state.
8668      The buffer is in ~agenda-mode~, so there are commands to examine
8669      and manipulate the TODO entries directly from that buffer (see
8670      [[*Commands in the Agenda Buffer]]).
8672 - {{{kbd(C-c a T)}}} (~org-todo-list~) ::
8674      #+kindex: C-c a T
8675      #+findex: org-todo-list
8676      #+cindex: TODO keyword matching
8677      #+vindex: org-todo-keywords
8678      Like the above, but allows selection of a specific TODO keyword.
8679      You can also do this by specifying a prefix argument to
8680      {{{kbd(C-c a t)}}}.  You are prompted for a keyword, and you may
8681      also specify several keywords by separating them with =|= as the
8682      boolean OR operator.  With a numeric prefix, the Nth keyword in
8683      ~org-todo-keywords~ is selected.
8685      #+kindex: r
8686      The {{{kbd(r)}}} key in the agenda buffer regenerates it, and you
8687      can give a prefix argument to this command to change the selected
8688      TODO keyword, for example {{{kbd(3 r)}}}.  If you often need
8689      a search for a specific keyword, define a custom command for it
8690      (see [[*The Agenda Dispatcher]]).
8692      Matching specific TODO keywords can also be done as part of
8693      a tags search (see [[*Tag Searches]]).
8695 Remote editing of TODO items means that you can change the state of
8696 a TODO entry with a single key press.  The commands available in the
8697 TODO list are described in [[*Commands in the Agenda Buffer]].
8699 #+cindex: sublevels, inclusion into TODO list
8700 Normally the global TODO list simply shows all headlines with TODO
8701 keywords.  This list can become very long.  There are two ways to keep
8702 it more compact:
8705   #+vindex: org-agenda-todo-ignore-scheduled
8706   #+vindex: org-agenda-todo-ignore-deadlines
8707   #+vindex: org-agenda-todo-ignore-timestamp
8708   #+vindex: org-agenda-todo-ignore-with-date
8709   Some people view a TODO item that has been /scheduled/ for execution
8710   or have a /deadline/ (see [[*Timestamps, Deadlines and Scheduling]]) as
8711   no longer /open/.  Configure the variables
8712   ~org-agenda-todo-ignore-scheduled~,
8713   ~org-agenda-todo-ignore-deadlines~,
8714   ~org-agenda-todo-ignore-timestamp~ and/or
8715   ~org-agenda-todo-ignore-with-date~ to exclude such items from the
8716   global TODO list.
8719   #+vindex: org-agenda-todo-list-sublevels
8720   TODO items may have sublevels to break up the task into subtasks.
8721   In such cases it may be enough to list only the highest level TODO
8722   headline and omit the sublevels from the global list.  Configure the
8723   variable ~org-agenda-todo-list-sublevels~ to get this behavior.
8725 *** Matching tags and properties
8726 :PROPERTIES:
8727 :DESCRIPTION: Structured information with fine-tuned search.
8728 :END:
8729 #+cindex: matching, of tags
8730 #+cindex: matching, of properties
8731 #+cindex: tags view
8732 #+cindex: match view
8734 If headlines in the agenda files are marked with /tags/ (see [[*Tags]]),
8735 or have properties (see [[*Properties and Columns]]), you can select
8736 headlines based on this metadata and collect them into an agenda
8737 buffer.  The match syntax described here also applies when creating
8738 sparse trees with {{{kbd(C-c / m)}}}.
8740 - {{{kbd(C-c a m)}}} (~org-tags-view~) ::
8742      #+kindex: C-c a m
8743      #+findex: org-tags-view
8744      Produce a list of all headlines that match a given set of tags.
8745      The command prompts for a selection criterion, which is a boolean
8746      logic expression with tags, like =+work+urgent-withboss= or
8747      =work|home= (see [[*Tags]]).  If you often need a specific search,
8748      define a custom command for it (see [[*The Agenda Dispatcher]]).
8750 - {{{kbd(C-c a M)}}} (~org-tags-view~) ::
8752      #+kindex: C-c a M
8753      #+findex: org-tags-view
8754      #+vindex: org-tags-match-list-sublevels
8755      #+vindex: org-agenda-tags-todo-honor-ignore-options
8756      Like {{{kbd(C-c a m)}}}, but only select headlines that are also
8757      TODO items and force checking subitems (see the variable
8758      ~org-tags-match-list-sublevels~).  To exclude scheduled/deadline
8759      items, see the variable
8760      ~org-agenda-tags-todo-honor-ignore-options~.  Matching specific
8761      TODO keywords together with a tags match is also possible, see
8762      [[*Tag Searches]].
8764 The commands available in the tags list are described in [[*Commands in
8765 the Agenda Buffer]].
8767 #+cindex: boolean logic, for agenda searches
8768 A search string can use Boolean operators =&= for AND and =|= for OR.
8769 =&= binds more strongly than =|=.  Parentheses are currently not
8770 implemented.  Each element in the search is either a tag, a regular
8771 expression matching tags, or an expression like =PROPERTY OPERATOR
8772 VALUE= with a comparison operator, accessing a property value.  Each
8773 element may be preceded by =-= to select against it, and =+= is
8774 syntactic sugar for positive selection.  The AND operator =&= is
8775 optional when =+= or =-= is present.  Here are some examples, using
8776 only tags.
8778 - ~+work-boss~ ::
8780      Select headlines tagged =work=, but discard those also tagged
8781      =boss=.
8783 - ~work|laptop~ ::
8785      Selects lines tagged =work= or =laptop=.
8787 - ~work|laptop+night~ ::
8789      Like before, but require the =laptop= lines to be tagged
8790      also =night=.
8792 #+cindex: regular expressions, with tags search
8793 Instead of a tag, you may also specify a regular expression enclosed
8794 in curly braces.  For example, =work+{^boss.*}= matches headlines that
8795 contain the tag =:work:= and any tag /starting/ with =boss=.
8797 #+cindex: group tags, as regular expressions
8798 Group tags (see [[*Tag Hierarchy]]) are expanded as regular expressions.
8799 E.g., if =work= is a group tag for the group =:work:lab:conf:=, then
8800 searching for =work= also searches for ={\(?:work\|lab\|conf\)}= and
8801 searching for =-work= searches for all headlines but those with one of
8802 the tags in the group (i.e., =-{\(?:work\|lab\|conf\)}=).
8804 #+cindex: TODO keyword matching, with tags search
8805 #+cindex: level, for tags/property match
8806 #+cindex: category, for tags/property match
8807 #+vindex: org-odd-levels-only
8808 You may also test for properties (see [[*Properties and Columns]]) at the
8809 same time as matching tags.  The properties may be real properties, or
8810 special properties that represent other metadata (see [[*Special
8811 Properties]]).  For example, the property =TODO= represents the TODO
8812 keyword of the entry.  Or, the property =LEVEL= represents the level
8813 of an entry.  So searching =+LEVEL=3+boss-TODO​="DONE"= lists all level
8814 three headlines that have the tag =boss= and are /not/ marked with the
8815 TODO keyword =DONE=.  In buffers with ~org-odd-levels-only~ set,
8816 =LEVEL= does not count the number of stars, but =LEVEL=2= corresponds
8817 to 3 stars etc.
8819 Here are more examples:
8821 - =work+TODO​="WAITING"= ::
8823      Select =work=-tagged TODO lines with the specific TODO keyword
8824      =WAITING=.
8826 - =work+TODO​="WAITING"|home+TODO​="WAITING"= ::
8828      Waiting tasks both at work and at home.
8830 When matching properties, a number of different operators can be used
8831 to test the value of a property.  Here is a complex example:
8833 #+begin_example
8834   +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2
8835            +With={Sarah|Denny}+SCHEDULED>="<2008-10-11>"
8836 #+end_example
8838 #+texinfo: @noindent
8839 The type of comparison depends on how the comparison value is written:
8841 - If the comparison value is a plain number, a numerical comparison is
8842   done, and the allowed operators are =<=, ===, =>=, =<==, =>==, and
8843   =<>=.
8845 - If the comparison value is enclosed in double-quotes, a string
8846   comparison is done, and the same operators are allowed.
8848 - If the comparison value is enclosed in double-quotes /and/ angular
8849   brackets (like =DEADLINE<​="<2008-12-24 18:30>"=), both values are
8850   assumed to be date/time specifications in the standard Org way, and
8851   the comparison is done accordingly.  Valid values also include
8852   ="<now>"= for now (including time), ="<today>"=, and ="<tomorrow>"=
8853   for these days at 0:00 hours, i.e., without a time specification.
8854   You can also use strings like ="<+5d>"= or ="<-2m>"= with units =d=,
8855   =w=, =m=, and =y= for day, week, month, and year, respectively.
8857 - If the comparison value is enclosed in curly braces, a regexp match
8858   is performed, with === meaning that the regexp matches the property
8859   value, and =<>= meaning that it does not match.
8861 So the search string in the example finds entries tagged =work= but
8862 not =boss=, which also have a priority value =A=, a =Coffee= property
8863 with the value =unlimited=, an =EFFORT= property that is numerically
8864 smaller than 2, a =With= property that is matched by the regular
8865 expression =Sarah|Denny=, and that are scheduled on or after October
8866 11, 2008.
8868 You can configure Org mode to use property inheritance during
8869 a search, but beware that this can slow down searches considerably.
8870 See [[*Property Inheritance]], for details.
8872 For backward compatibility, and also for typing speed, there is also
8873 a different way to test TODO states in a search.  For this, terminate
8874 the tags/property part of the search string (which may include several
8875 terms connected with =|=) with a =/= and then specify a Boolean
8876 expression just for TODO keywords.  The syntax is then similar to that
8877 for tags, but should be applied with care: for example, a positive
8878 selection on several TODO keywords cannot meaningfully be combined
8879 with boolean AND.  However, /negative selection/ combined with AND can
8880 be meaningful.  To make sure that only lines are checked that actually
8881 have any TODO keyword (resulting in a speed-up), use {{{kbd(C-c
8882 a M)}}}, or equivalently start the TODO part after the slash with =!=.
8883 Using {{{kbd(C-c a M)}}} or =/!= does not match TODO keywords in
8884 a DONE state.  Examples:
8886 - =work/WAITING= ::
8888      Same as =work+TODO​="WAITING"=.
8890 - =work/!-WAITING-NEXT= ::
8892      Select =work=-tagged TODO lines that are neither =WAITING= nor
8893      =NEXT=.
8895 - =work/!+WAITING|+NEXT= ::
8897      Select =work=-tagged TODO lines that are either =WAITING= or
8898      =NEXT=.
8900 *** Search view
8901 :PROPERTIES:
8902 :DESCRIPTION: Find entries by searching for text.
8903 :END:
8904 #+cindex: search view
8905 #+cindex: text search
8906 #+cindex: searching, for text
8908 This agenda view is a general text search facility for Org mode
8909 entries.  It is particularly useful to find notes.
8911 - {{{kbd(C-c a s)}}} (~org-search-view~) ::
8913      #+kindex: C-c a s
8914      #+findex: org-search-view
8915      This is a special search that lets you select entries by matching
8916      a substring or specific words using a boolean logic.
8918 For example, the search string =computer equipment= matches entries
8919 that contain =computer equipment= as a substring, even if the two
8920 words are separated by more space or a line break.
8922 Search view can also search for specific keywords in the entry, using
8923 Boolean logic.  The search string =+computer
8924 +wifi -ethernet -{8\.11[bg]}= matches note entries that contain the
8925 keywords =computer= and =wifi=, but not the keyword =ethernet=, and
8926 which are also not matched by the regular expression =8\.11[bg]=,
8927 meaning to exclude both =8.11b= and =8.11g=.  The first =+= is
8928 necessary to turn on boolean search, other =+= characters are
8929 optional.  For more details, see the docstring of the command
8930 ~org-search-view~.
8932 You can incrementally adjust a boolean search with the following keys
8934 #+attr_texinfo: :columns 0.1 0.6
8935 | {{{kbd([)}}} | Add a positive search word        |
8936 | {{{kbd(])}}} | Add a negative search word        |
8937 | {{{kbd({)}}} | Add a positive regular expression |
8938 | {{{kbd(})}}} | Add a negative regular expression |
8940 #+vindex: org-agenda-text-search-extra-files
8941 Note that in addition to the agenda files, this command also searches
8942 the files listed in ~org-agenda-text-search-extra-files~.
8944 *** Stuck projects
8945 :PROPERTIES:
8946 :DESCRIPTION: Find projects you need to review.
8947 :END:
8948 #+pindex: GTD, Getting Things Done
8950 If you are following a system like David Allen's GTD to organize your
8951 work, one of the "duties" you have is a regular review to make sure
8952 that all projects move along.  A /stuck/ project is a project that has
8953 no defined next actions, so it never shows up in the TODO lists Org
8954 mode produces.  During the review, you need to identify such projects
8955 and define next actions for them.
8957 - {{{kbd(C-c a #)}}} (~org-agenda-list-stuck-projects~) ::
8959      #+kindex: C-c a #
8960      #+findex: org-agenda-list-stuck-projects
8961      List projects that are stuck.
8963 - {{{kbd(C-c a !)}}} ::
8965      #+kindex: C-c a !
8966      #+vindex: org-stuck-projects
8967      Customize the variable ~org-stuck-projects~ to define what
8968      a stuck project is and how to find it.
8970 You almost certainly need to configure this view before it works for
8971 you.  The built-in default assumes that all your projects are level-2
8972 headlines, and that a project is not stuck if it has at least one
8973 entry marked with a TODO keyword =TODO= or =NEXT= or =NEXTACTION=.
8975 Let's assume that you, in your own way of using Org mode, identify
8976 projects with a tag =:PROJECT:=, and that you use a TODO keyword
8977 =MAYBE= to indicate a project that should not be considered yet.
8978 Let's further assume that the TODO keyword =DONE= marks finished
8979 projects, and that =NEXT= and =TODO= indicate next actions.  The tag
8980 =:@shop:= indicates shopping and is a next action even without the
8981 NEXT tag.  Finally, if the project contains the special word =IGNORE=
8982 anywhere, it should not be listed either.  In this case you would
8983 start by identifying eligible projects with a tags/TODO match (see
8984 [[*Tag Searches]]) =+PROJECT/-MAYBE-DONE=, and then check for =TODO=,
8985 =NEXT=, =@shop=, and =IGNORE= in the subtree to identify projects that
8986 are not stuck.  The correct customization for this is:
8988 #+begin_src emacs-lisp
8989   (setq org-stuck-projects
8990         '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@shop")
8991           "\\<IGNORE\\>"))
8992 #+end_src
8994 Note that if a project is identified as non-stuck, the subtree of this
8995 entry is searched for stuck projects.
8997 ** Presentation and Sorting
8998 :PROPERTIES:
8999 :DESCRIPTION: How agenda items are prepared for display.
9000 :END:
9001 #+cindex: presentation, of agenda items
9003 #+vindex: org-agenda-prefix-format
9004 #+vindex: org-agenda-tags-column
9005 Before displaying items in an agenda view, Org mode visually prepares
9006 the items and sorts them.  Each item occupies a single line.  The line
9007 starts with a /prefix/ that contains the /category/ (see [[*Categories]])
9008 of the item and other important information.  You can customize in
9009 which column tags are displayed through ~org-agenda-tags-column~.  You
9010 can also customize the prefix using the option
9011 ~org-agenda-prefix-format~.  This prefix is followed by a cleaned-up
9012 version of the outline headline associated with the item.
9014 *** Categories
9015 :PROPERTIES:
9016 :DESCRIPTION: Not all tasks are equal.
9017 :END:
9018 #+cindex: category
9019 #+cindex: CATEGORY, keyword
9021 The category is a broad label assigned to each agenda item.  By
9022 default, the category is simply derived from the file name, but you
9023 can also specify it with a special line in the buffer, like
9024 this:
9026 : #+CATEGORY: Thesis
9028 #+texinfo: @noindent
9029 #+cindex: CATEGORY, property
9030 If you would like to have a special category for a single entry or
9031 a (sub)tree, give the entry a =CATEGORY= property with the special
9032 category you want to apply as the value.
9034 #+texinfo: @noindent
9035 The display in the agenda buffer looks best if the category is not
9036 longer than 10 characters.
9038 #+texinfo: @noindent
9039 #+vindex: org-agenda-category-icon-alist
9040 You can set up icons for category by customizing the
9041 ~org-agenda-category-icon-alist~ variable.
9043 *** Time-of-day specifications
9044 :PROPERTIES:
9045 :DESCRIPTION: How the agenda knows the time.
9046 :END:
9047 #+cindex: time-of-day specification
9049 Org mode checks each agenda item for a time-of-day specification.  The
9050 time can be part of the timestamp that triggered inclusion into the
9051 agenda, for example
9053 : <2005-05-10 Tue 19:00>
9055 #+texinfo: @noindent
9056 Time ranges can be specified with two timestamps:
9058 : <2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>
9060 In the headline of the entry itself, a time(range) may also appear as
9061 plain text (like =12:45= or a =8:30-1pm=).  If the agenda integrates
9062 the Emacs diary (see [[*Weekly/daily agenda]]), time specifications in
9063 diary entries are recognized as well.
9065 For agenda display, Org mode extracts the time and displays it in
9066 a standard 24 hour format as part of the prefix.  The example times in
9067 the previous paragraphs would end up in the agenda like this:
9069 #+begin_example
9070    8:30-13:00 Arthur Dent lies in front of the bulldozer
9071   12:45...... Ford Prefect arrives and takes Arthur to the pub
9072   19:00...... The Vogon reads his poem
9073   20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9074 #+end_example
9076 #+cindex: time grid
9077 If the agenda is in single-day mode, or for the display of today, the
9078 timed entries are embedded in a time grid, like
9080 #+begin_example
9081    8:00...... ------------------
9082    8:30-13:00 Arthur Dent lies in front of the bulldozer
9083   10:00...... ------------------
9084   12:00...... ------------------
9085   12:45...... Ford Prefect arrives and takes Arthur to the pub
9086   14:00...... ------------------
9087   16:00...... ------------------
9088   18:00...... ------------------
9089   19:00...... The Vogon reads his poem
9090   20:00...... ------------------
9091   20:30-22:15 Marvin escorts the Hitchhikers to the bridge
9092 #+end_example
9094 #+vindex: org-agenda-use-time-grid
9095 #+vindex: org-agenda-time-grid
9096 The time grid can be turned on and off with the variable
9097 ~org-agenda-use-time-grid~, and can be configured with
9098 ~org-agenda-time-grid~.
9100 *** Sorting of agenda items
9101 :PROPERTIES:
9102 :DESCRIPTION: The order of things.
9103 :END:
9104 #+cindex: sorting, of agenda items
9105 #+cindex: priorities, of agenda items
9107 Before being inserted into a view, the items are sorted.  How this is
9108 done depends on the type of view.
9111   #+vindex: org-agenda-files
9112   For the daily/weekly agenda, the items for each day are sorted.  The
9113   default order is to first collect all items containing an explicit
9114   time-of-day specification.  These entries are shown at the beginning
9115   of the list, as a /schedule/ for the day.  After that, items remain
9116   grouped in categories, in the sequence given by ~org-agenda-files~.
9117   Within each category, items are sorted by priority (see
9118   [[*Priorities]]), which is composed of the base priority (2000 for
9119   priority =A=, 1000 for =B=, and 0 for =C=), plus additional
9120   increments for overdue scheduled or deadline items.
9122 - For the TODO list, items remain in the order of categories, but
9123   within each category, sorting takes place according to priority (see
9124   [[*Priorities]]).  The priority used for sorting derives from the
9125   priority cookie, with additions depending on how close an item is to
9126   its due or scheduled date.
9128 - For tags matches, items are not sorted at all, but just appear in
9129   the sequence in which they are found in the agenda files.
9131 #+vindex: org-agenda-sorting-strategy
9132 Sorting can be customized using the variable
9133 ~org-agenda-sorting-strategy~, and may also include criteria based on
9134 the estimated effort of an entry (see [[*Effort Estimates]]).
9136 *** Filtering/limiting agenda times
9137 :PROPERTIES:
9138 :DESCRIPTION: Dynamically narrow the agenda.
9139 :END:
9141 Agenda built-in or customized commands are statically defined.  Agenda
9142 filters and limits provide two ways of dynamically narrowing down the
9143 list of agenda entries: /filters/ and /limits/.  Filters only act on
9144 the display of the items, while limits take effect before the list of
9145 agenda entries is built.  Filters are more often used interactively,
9146 while limits are mostly useful when defined as local variables within
9147 custom agenda commands.
9149 **** Filtering in the agenda
9150 :PROPERTIES:
9151 :UNNUMBERED: notoc
9152 :END:
9153 #+cindex: agenda filtering
9154 #+cindex: filtering entries, in agenda
9155 #+cindex: tag filtering, in agenda
9156 #+cindex: category filtering, in agenda
9157 #+cindex: top headline filtering, in agenda
9158 #+cindex: effort filtering, in agenda
9159 #+cindex: query editing, in agenda
9161 - {{{kbd(/)}}} (~org-agenda-filter-by-tag~) ::
9163      #+findex: org-agenda-filter-by-tag
9164      #+vindex: org-agenda-tag-filter-preset
9165      Filter the agenda view with respect to a tag and/or effort
9166      estimates.  The difference between this and a custom agenda
9167      command is that filtering is very fast, so that you can switch
9168      quickly between different filters without having to recreate the
9169      agenda.[fn:94]
9171      You are prompted for a tag selection letter; {{{kbd(SPC)}}} means
9172      any tag at all.  Pressing {{{kbd(TAB)}}} at that prompt offers
9173      completion to select a tag, including any tags that do not have
9174      a selection character.  The command then hides all entries that
9175      do not contain or inherit this tag.  When called with prefix
9176      argument, remove the entries that /do/ have the tag.  A second
9177      {{{kbd(/)}}} at the prompt turns off the filter and shows any
9178      hidden entries.  Pressing {{{kbd(+)}}} or {{{kbd(-)}}} switches
9179      between filtering and excluding the next tag.
9181      #+vindex: org-agenda-auto-exclude-function
9182      Org also supports automatic, context-aware tag filtering.  If the
9183      variable ~org-agenda-auto-exclude-function~ is set to
9184      a user-defined function, that function can decide which tags
9185      should be excluded from the agenda automatically.  Once this is
9186      set, the {{{kbd(/)}}} command then accepts {{{kbd(RET)}}} as
9187      a sub-option key and runs the auto exclusion logic.  For example,
9188      let's say you use a =Net= tag to identify tasks which need
9189      network access, an =Errand= tag for errands in town, and a =Call=
9190      tag for making phone calls.  You could auto-exclude these tags
9191      based on the availability of the Internet, and outside of
9192      business hours, with something like this:
9194      #+begin_src emacs-lisp
9195        (defun org-my-auto-exclude-function (tag)
9196          (and (cond
9197                ((string= tag "Net")
9198                 (/= 0 (call-process "/sbin/ping" nil nil nil
9199                                     "-c1" "-q" "-t1" "mail.gnu.org")))
9200                ((or (string= tag "Errand") (string= tag "Call"))
9201                 (let ((hour (nth 2 (decode-time))))
9202                   (or (< hour 8) (> hour 21)))))
9203               (concat "-" tag)))
9205        (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
9206      #+end_src
9208 - {{{kbd(<)}}} (~org-agenda-filter-by-category~) ::
9210      #+findex: org-agenda-filter-by-category
9211      Filter the current agenda view with respect to the category of
9212      the item at point.  Pressing {{{kbd(<)}}} another time removes
9213      this filter.  When called with a prefix argument exclude the
9214      category of the item at point from the agenda.
9216      #+vindex: org-agenda-category-filter-preset
9217      You can add a filter preset in custom agenda commands through the
9218      option ~org-agenda-category-filter-preset~.  See [[*Setting options
9219      for custom commands]].
9221 - {{{kbd(^)}}} (~org-agenda-filter-by-top-headline~) ::
9223      #+findex: org-agenda-filter-by-top-headline
9224      Filter the current agenda view and only display the siblings and
9225      the parent headline of the one at point.
9227 - {{{kbd(=)}}} (~org-agenda-filter-by-regexp~) ::
9229      #+findex: org-agenda-filter-by-regexp
9230      Filter the agenda view by a regular expression: only show agenda
9231      entries matching the regular expression the user entered.  When
9232      called with a prefix argument, it filters /out/ entries matching
9233      the regexp.  With two universal prefix arguments, it removes all
9234      the regexp filters, which can be accumulated.
9236      #+vindex: org-agenda-regexp-filter-preset
9237      You can add a filter preset in custom agenda commands through the
9238      option ~org-agenda-regexp-filter-preset~.  See [[*Setting options
9239      for custom commands]].
9241 - {{{kbd(_)}}} (~org-agenda-filter-by-effort~) ::
9243      #+findex: org-agenda-filter-by-effort
9244      Filter the agenda view with respect to effort estimates.  You
9245      first need to set up allowed efforts globally, for example
9247      #+begin_src emacs-lisp
9248        (setq org-global-properties
9249              '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
9250      #+end_src
9252      #+vindex: org-sort-agenda-noeffort-is-high
9253      You can then filter for an effort by first typing an operator,
9254      one of {{{kbd(<)}}}, {{{kbd(>)}}} and {{{kbd(=)}}}, and then the
9255      one-digit index of an effort estimate in your array of allowed
9256      values, where {{{kbd(0)}}} means the 10th value.  The filter then
9257      restricts to entries with effort smaller-or-equal, equal, or
9258      larger-or-equal than the selected value.  For application of the
9259      operator, entries without a defined effort are treated according
9260      to the value of ~org-sort-agenda-noeffort-is-high~.
9262      When called with a prefix argument, it removes entries matching
9263      the condition.  With two universal prefix arguments, it clears
9264      effort filters, which can be accumulated.
9266      #+vindex: org-agenda-effort-filter-preset
9267      You can add a filter preset in custom agenda commands through the
9268      option ~org-agenda-effort-filter-preset~.  See [[*Setting options
9269      for custom commands]].
9271 - {{{kbd(|)}}} (~org-agenda-filter-remove-all~) ::
9273      Remove all filters in the current agenda view.
9275 **** Setting limits for the agenda
9276 :PROPERTIES:
9277 :UNNUMBERED: notoc
9278 :END:
9279 #+cindex: limits, in agenda
9281 Here is a list of options that you can set, either globally, or
9282 locally in your custom agenda views (see [[*Custom Agenda Views]]).
9284 - ~org-agenda-max-entries~ ::
9286      #+vindex: org-agenda-max-entries
9287      Limit the number of entries.
9289 - ~org-agenda-max-effort~ ::
9291      #+vindex: org-agenda-max-effort
9292      Limit the duration of accumulated efforts (as minutes).
9294 - ~org-agenda-max-todos~ ::
9296      #+vindex: org-agenda-max-todos
9297      Limit the number of entries with TODO keywords.
9299 - ~org-agenda-max-tags~ ::
9301      #+vindex: org-agenda-max-tags
9302      Limit the number of tagged entries.
9304 When set to a positive integer, each option excludes entries from
9305 other categories: for example, ~(setq org-agenda-max-effort 100)~
9306 limits the agenda to 100 minutes of effort and exclude any entry that
9307 has no effort property.  If you want to include entries with no effort
9308 property, use a negative value for ~org-agenda-max-effort~.  One
9309 useful setup is to use ~org-agenda-max-entries~ locally in a custom
9310 command.  For example, this custom command displays the next five
9311 entries with a =NEXT= TODO keyword.
9313 #+begin_src emacs-lisp
9314   (setq org-agenda-custom-commands
9315         '(("n" todo "NEXT"
9316            ((org-agenda-max-entries 5)))))
9317 #+end_src
9319 Once you mark one of these five entry as DONE, rebuilding the agenda
9320 will again the next five entries again, including the first entry that
9321 was excluded so far.
9323 You can also dynamically set temporary limits, which are lost when
9324 rebuilding the agenda:
9326 - {{{kbd(~ )}}} (~org-agenda-limit-interactively~) ::
9328      #+findex: org-agenda-limit-interactively
9329      This prompts for the type of limit to apply and its value.
9331 ** Commands in the Agenda Buffer
9332 :PROPERTIES:
9333 :DESCRIPTION: Remote editing of Org trees.
9334 :ALT_TITLE: Agenda Commands
9335 :END:
9336 #+cindex: commands, in agenda buffer
9338 Entries in the agenda buffer are linked back to the Org file or diary
9339 file where they originate.  You are not allowed to edit the agenda
9340 buffer itself, but commands are provided to show and jump to the
9341 original entry location, and to edit the Org files "remotely" from the
9342 agenda buffer.  In this way, all information is stored only once,
9343 removing the risk that your agenda and note files may diverge.
9345 Some commands can be executed with mouse clicks on agenda lines.  For
9346 the other commands, the cursor needs to be in the desired line.
9348 *** Motion
9349 :PROPERTIES:
9350 :UNNUMBERED: notoc
9351 :END:
9352 #+cindex: motion commands in agenda
9354 - {{{kbd(n)}}} (~org-agenda-next-line~) ::
9356      #+kindex: n
9357      #+findex: org-agenda-next-line
9358      Next line (same as {{{kbd(down)}}} and {{{kbd(C-n)}}}).
9360 - {{{kbd(p)}}} (~org-agenda-previous-line~) ::
9362      #+kindex: p
9363      #+findex: org-agenda-previous-line
9364      Previous line (same as {{{kbd(up)}}} and {{{kbd(C-p)}}}).
9366 *** View/Go to Org file
9367 :PROPERTIES:
9368 :UNNUMBERED: notoc
9369 :END:
9370 #+cindex: view file commands in agenda
9372 - {{{kbd(SPC)}}} or {{{kbd(mouse-3)}}} (~org-agenda-show-and-scroll-up~) ::
9374      #+kindex: SPC
9375      #+kindex: mouse-3
9376      #+findex: org-agenda-show-and-scroll-up
9377      Display the original location of the item in another window.
9378      With a prefix argument, make sure that drawers stay folded.
9380 - {{{kbd(L)}}} (~org-agenda-recenter~) ::
9382      #+findex: org-agenda-recenter
9383      Display original location and recenter that window.
9385 - {{{kbd(TAB)}}} or {{{kbd(mouse-2)}}} (~org-agenda-goto~) ::
9387      #+kindex: TAB
9388      #+kindex: mouse-2
9389      #+findex: org-agenda-goto
9390      Go to the original location of the item in another window.
9392 - {{{kbd(RET)}}} (~org-agenda-switch-to~) ::
9394      #+kindex: RET
9395      #+findex: org-agenda-switch-to
9396      Go to the original location of the item and delete other windows.
9398 - {{{kbd(F)}}} (~org-agenda-follow-mode~) ::
9400      #+kindex: F
9401      #+findex: org-agenda-follow-mode
9402      #+vindex: org-agenda-start-with-follow-mode
9403      Toggle Follow mode.  In Follow mode, as you move the cursor
9404      through the agenda buffer, the other window always shows the
9405      corresponding location in the Org file.  The initial setting for
9406      this mode in new agenda buffers can be set with the variable
9407      ~org-agenda-start-with-follow-mode~.
9409 - {{{kbd(C-c C-x b)}}} (~org-agenda-tree-to-indirect-buffer~) ::
9411      #+kindex: C-c C-x b
9412      #+findex: org-agenda-tree-to-indirect-buffer
9413      Display the entire subtree of the current item in an indirect
9414      buffer.  With a numeric prefix argument N, go up to level N and
9415      then take that tree.  If N is negative, go up that many levels.
9416      With a {{{kbd(C-u)}}} prefix, do not remove the previously used
9417      indirect buffer.
9419 - {{{kbd(C-c C-o)}}} (~org-agenda-open-link~) ::
9421      #+kindex: C-c C-o
9422      #+findex: org-agenda-open-link
9423      Follow a link in the entry.  This offers a selection of any links
9424      in the text belonging to the referenced Org node.  If there is
9425      only one link, follow it without a selection prompt.
9427 *** Change display
9428 :PROPERTIES:
9429 :UNNUMBERED: notoc
9430 :END:
9431 #+cindex: change agenda display
9432 #+cindex: display changing, in agenda
9434 #+attr_texinfo: :sep ,
9435 - {{{kbd(A)}}} ::
9437      #+kindex: A
9438      Interactively select another agenda view and append it to the
9439      current view.
9441 - {{{kbd(o)}}} ::
9443      #+kindex: o
9444      Delete other windows.
9446 - {{{kbd(v d)}}} or short {{{kbd(d)}}} (~org-agenda-day-view~) ::
9448      #+kindex: v d
9449      #+kindex: d
9450      #+findex: org-agenda-day-view
9451      Switch to day view.  When switching to day 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 year.  For example, {{{kbd(32 d)}}} jumps to February 1st.
9455      When setting day view, a year may be encoded in the prefix
9456      argument as well.  For example, {{{kbd(200712 d)}}} jumps to
9457      January 12, 2007.  If such a year specification has only one or
9458      two digits, it is expanded into one of the 30 next years or the
9459      last 69 years.
9461 - {{{kbd(v w)}}} or short {{{kbd(w)}}} (~org-agenda-week-view~) ::
9463      #+kindex: v w
9464      #+kindex: w
9465      #+findex: org-agenda-week-view
9466      Switch to week view.  When switching week view, this setting
9467      becomes the default for subsequent agenda refreshes.  A numeric
9468      prefix argument may be used to jump directly to a specific day of
9469      the ISO week.  For example {{{kbd(9 w)}}} to ISO week number 9.
9470      When setting week view, a year may be encoded in the prefix
9471      argument as well.  For example, {{{kbd(200712 w)}}} jumps to week
9472      12 in 2007.  If such a year specification has only one or two
9473      digits, it is expanded into one of the 30 next years or the last
9474      69 years.
9476 - {{{kbd(v m)}}} (~org-agenda-month-view~) ::
9478      #+kindex: v m
9479      #+findex: org-agenda-month-view
9480      Switch to month view.  Because month views are slow to create,
9481      they do not become the default for subsequent agenda refreshes.
9482      A numeric prefix argument may be used to jump directly to
9483      a specific day of the month.  When setting month view, a year may
9484      be encoded in the prefix argument as well.  For example,
9485      {{{kbd(200712 m)}}} jumps to December, 2007.  If such a year
9486      specification has only one or two digits, it is expanded into one
9487      of the 30 next years or the last 69 years.
9489 - {{{kbd(v y)}}} (~org-agenda-year-view~) ::
9491      #+kindex: v y
9492      #+findex: org-agenda-year-view
9493      Switch to year view.  Because year views are slow to create, they
9494      do not become the default for subsequent agenda refreshes.
9495      A numeric prefix argument may be used to jump directly to
9496      a specific day of the year.
9498 - {{{kbd(v SPC)}}} (~org-agenda-reset-view~) ::
9500      #+kindex: v SPC
9501      #+findex: org-agenda-reset-view
9502      #+vindex: org-agenda-span
9503      Reset the current view to ~org-agenda-span~.
9505 - {{{kbd(f)}}} (~org-agenda-later~) ::
9507      #+kindex: f
9508      #+findex: org-agenda-later
9509      Go forward in time to display the span following the current one.
9510      For example, if the display covers a week, switch to the
9511      following week.  With a prefix argument, repeat that many times.
9513 - {{{kbd(b)}}} (~org-agenda-earlier~) ::
9515      #+kindex: b
9516      #+findex: org-agenda-earlier
9517      Go backward in time to display earlier dates.
9519 - {{{kbd(.)}}} (~org-agenda-goto-today~) ::
9521      #+kindex: .
9522      #+findex: org-agenda-goto-today
9523      Go to today.
9525 - {{{kbd(j)}}} (~org-agenda-goto-date~) ::
9527      #+kindex: j
9528      #+findex: org-agenda-goto-date
9529      Prompt for a date and go there.
9531 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9533      #+kindex: J
9534      #+findex: org-agenda-clock-goto
9535      Go to the currently clocked-in task /in the agenda buffer/.
9537 - {{{kbd(D)}}} (~org-agenda-toggle-diary~) ::
9539      #+kindex: D
9540      #+findex: org-agenda-toggle-diary
9541      Toggle the inclusion of diary entries.  See [[*Weekly/daily agenda]].
9543 - {{{kbd(v l)}}} or {{{kbd(v L)}}} or short {{{kbd(l)}}} (~org-agenda-log-mode~) ::
9545      #+kindex: v l
9546      #+kindex: l
9547      #+kindex: v L
9548      #+findex: org-agenda-log-mode
9549      #+vindex: org-log-done
9550      #+vindex: org-agenda-log-mode-items
9551      Toggle Logbook mode.  In Logbook mode, entries that were marked
9552      DONE while logging was on (see the variable ~org-log-done~) are
9553      shown in the agenda, as are entries that have been clocked on
9554      that day.  You can configure the entry types that should be
9555      included in log mode using the variable
9556      ~org-agenda-log-mode-items~.  When called with a {{{kbd(C-u)}}}
9557      prefix, show all possible logbook entries, including state
9558      changes.  When called with two prefix arguments {{{kbd(C-u
9559      C-u)}}}, show only logging information, nothing else.  {{{kbd(v
9560      L)}}} is equivalent to {{{kbd(C-u v l)}}}.
9562 - {{{kbd(v [)}}} or short {{{kbd([)}}} (~org-agenda-manipulate-query-add~) ::
9564      #+kindex: v [
9565      #+kindex: [
9566      #+findex: org-agenda-manipulate-query-add
9567      Include inactive timestamps into the current view.  Only for
9568      weekly/daily agenda and timeline views.
9570 - {{{kbd(v a)}}} (~org-agenda-archives-mode~) ::
9572      #+kindex: v a
9573      #+findex: org-agenda-archives-mode
9574      Toggle Archives mode.  In Archives mode, trees that are archived
9575      (see [[*Internal archiving]]) are also scanned when producing the
9576      agenda.  To exit archives mode, press {{{kbd(v a)}}} again.
9578 - {{{kbd(v A)}}} ::
9580      #+kindex: v A
9581      Toggle Archives mode.  Include all archive files as well.
9583 - {{{kbd(v R)}}} or short {{{kbd(R)}}} (~org-agenda-clockreport-mode~) ::
9585      #+kindex: v R
9586      #+kindex: R
9587      #+findex: org-agenda-clockreport-mode
9588      #+vindex: org-agenda-start-with-clockreport-mode
9589      #+vindex: org-clock-report-include-clocking-task
9590      Toggle Clockreport mode.  In Clockreport mode, the daily/weekly
9591      agenda always shows a table with the clocked times for the time
9592      span and file scope covered by the current agenda view.  The
9593      initial setting for this mode in new agenda buffers can be set
9594      with the variable ~org-agenda-start-with-clockreport-mode~.  By
9595      using a prefix argument when toggling this mode (i.e., {{{kbd(C-u
9596      R)}}}), the clock table does not show contributions from entries
9597      that are hidden by agenda filtering[fn:95].  See also the
9598      variable ~org-clock-report-include-clocking-task~.
9600 - {{{kbd(v c)}}} ::
9602      #+kindex: v c
9603      #+vindex: org-agenda-clock-consistency-checks
9604      Show overlapping clock entries, clocking gaps, and other clocking
9605      problems in the current agenda range.  You can then visit
9606      clocking lines and fix them manually.  See the variable
9607      ~org-agenda-clock-consistency-checks~ for information on how to
9608      customize the definition of what constituted a clocking problem.
9609      To return to normal agenda display, press {{{kbd(l)}}} to exit
9610      Logbook mode.
9612 - {{{kbd(v E)}}} or short {{{kbd(E)}}} (~org-agenda-entry-text-mode~) ::
9614      #+kindex: v E
9615      #+kindex: E
9616      #+findex: org-agenda-entry-text-mode
9617      #+vindex: org-agenda-start-with-entry-text-mode
9618      #+vindex: org-agenda-entry-text-maxlines
9619      Toggle entry text mode.  In entry text mode, a number of lines
9620      from the Org outline node referenced by an agenda line are
9621      displayed below the line.  The maximum number of lines is given
9622      by the variable ~org-agenda-entry-text-maxlines~.  Calling this
9623      command with a numeric prefix argument temporarily modifies that
9624      number to the prefix value.
9626 - {{{kbd(G)}}} (~org-agenda-toggle-time-grid~) ::
9628      #+kindex: G
9629      #+vindex: org-agenda-use-time-grid
9630      #+vindex: org-agenda-time-grid
9631      Toggle the time grid on and off.  See also the variables
9632      ~org-agenda-use-time-grid~ and ~org-agenda-time-grid~.
9634 - {{{kbd(r)}}} (~org-agenda-redo~), {{{kbd(g)}}} ::
9636      #+kindex: r
9637      #+kindex: g
9638      #+findex: org-agenda-redo
9639      Recreate the agenda buffer, for example to reflect the changes
9640      after modification of the timestamps of items with
9641      {{{kbd(S-left)}}} and {{{kbd(S-right)}}}.  When the
9642      buffer is the global TODO list, a prefix argument is interpreted
9643      to create a selective list for a specific TODO keyword.
9645 - {{{kbd(C-x C-s)}}} or short {{{kbd(s)}}} (~org-save-all-org-buffers~) ::
9647      #+kindex: C-x C-s
9648      #+findex: org-save-all-org-buffers
9649      #+kindex: s
9650      Save all Org buffers in the current Emacs session, and also the
9651      locations of IDs.
9653 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
9655      #+kindex: C-c C-x C-c
9656      #+findex: org-agenda-columns
9657      #+vindex: org-columns-default-format
9658      Invoke column view (see [[*Column View]]) in the agenda buffer.  The
9659      column view format is taken from the entry at point, or, if there
9660      is no entry at point, from the first entry in the agenda view.
9661      So whatever the format for that entry would be in the original
9662      buffer (taken from a property, from a =COLUMNS= keyword, or from
9663      the default variable ~org-columns-default-format~) is used in the
9664      agenda.
9666 - {{{kbd(C-c C-x >)}}} (~org-agenda-remove-restriction-lock~) ::
9668      #+kindex: C-c C-x >
9669      #+findex: org-agenda-remove-restriction-lock
9670      Remove the restriction lock on the agenda, if it is currently
9671      restricted to a file or subtree (see [[*Agenda Files]]).
9673 - {{{kbd(M-up)}}} (~org-agenda-drag-line-backward~) ::
9675      #+kindex: M-up
9676      #+findex: org-agenda-drag-line-backward
9677      Drag the line at point backward one line.  With a numeric prefix
9678      argument, drag backward by that many lines.
9680      Moving agenda lines does not persist after an agenda refresh and
9681      does not modify the contributing Org files.
9683 - {{{kbd(M-down)}}} (~org-agenda-drag-line-forward~) ::
9685      #+kindex: M-down
9686      #+findex: org-agenda-drag-line-forward
9687      Drag the line at point forward one line.  With a numeric prefix
9688      argument, drag forward by that many lines.
9690 *** Remote editing
9691 :PROPERTIES:
9692 :UNNUMBERED: notoc
9693 :END:
9694 #+cindex: remote editing, from agenda
9696 - {{{kbd(0--9)}}} ::
9698      Digit argument.
9700 - {{{kbd(C-_)}}} (~org-agenda-undo~) ::
9702      #+kindex: C-_
9703      #+findex: org-agenda-undo
9704      #+cindex: undoing remote-editing events
9705      #+cindex: remote editing, undo
9706      Undo a change due to a remote editing command.  The change is
9707      undone both in the agenda buffer and in the remote buffer.
9709 - {{{kbd(t)}}} (~org-agenda-todo~) ::
9711      #+kindex: t
9712      #+findex: org-agenda-todo
9713      Change the TODO state of the item, both in the agenda and in the
9714      original Org file.
9716 - {{{kbd(C-S-right)}}} (~org-agenda-todo-nextset~) ::
9718      #+kindex: C-S-right
9719      #+findex: org-agenda-todo-nextset
9720      Switch to the next set of TODO keywords.
9722 - {{{kbd(C-S-left)}}}, ~org-agenda-todo-previousset~ ::
9724      #+kindex: C-S-left
9725      Switch to the previous set of TODO keywords.
9727 - {{{kbd(C-k)}}} (~org-agenda-kill~) ::
9729      #+kindex: C-k
9730      #+findex: org-agenda-kill
9731      #+vindex: org-agenda-confirm-kill
9732      Delete the current agenda item along with the entire subtree
9733      belonging to it in the original Org file.  If the text to be
9734      deleted remotely is longer than one line, the kill needs to be
9735      confirmed by the user.  See variable ~org-agenda-confirm-kill~.
9737 - {{{kbd(C-c C-w)}}} (~org-agenda-refile~) ::
9739      #+kindex: C-c C-w
9740      #+findex: org-agenda-refile
9741      Refile the entry at point.
9743 - {{{kbd(C-c C-x C-a)}}} or short {{{kbd(a)}}} (~org-agenda-archive-default-with-confirmation~) ::
9745      #+kindex: C-c C-x C-a
9746      #+kindex: a
9747      #+findex: org-agenda-archive-default-with-confirmation
9748      #+vindex: org-archive-default-command
9749      Archive the subtree corresponding to the entry at point using the
9750      default archiving command set in ~org-archive-default-command~.
9751      When using the {{{kbd(a)}}} key, confirmation is required.
9753 - {{{kbd(C-c C-x a)}}} (~org-agenda-toggle-archive-tag~) ::
9755      #+kindex: C-c C-x a
9756      #+findex: org-agenda-toggle-archive-tag
9757      Toggle the archive tag (see [[*Internal archiving]]) for the current
9758      headline.
9760 - {{{kbd(C-c C-x A)}}} (~org-agenda-archive-to-archive-sibling~) ::
9762      #+kindex: C-c C-x A
9763      #+findex: org-agenda-archive-to-archive-sibling
9764      Move the subtree corresponding to the current entry to its
9765      /archive sibling/.
9767 - {{{kbd(C-c C-x C-s)}}} or short {{{kbd($)}}} (~org-agenda-archive~) ::
9769      #+kindex: C-c C-x C-s
9770      #+kindex: $
9771      #+findex: org-agenda-archive
9772      Archive the subtree corresponding to the current headline.  This
9773      means the entry is moved to the configured archive location, most
9774      likely a different file.
9776 - {{{kbd(T)}}} (~org-agenda-show-tags~) ::
9778      #+kindex: T
9779      #+findex: org-agenda-show-tags
9780      #+vindex: org-agenda-show-inherited-tags
9781      Show all tags associated with the current item.  This is useful
9782      if you have turned off ~org-agenda-show-inherited-tags~, but
9783      still want to see all tags of a headline occasionally.
9785 - {{{kbd(:)}}} (~org-agenda-set-tags~) ::
9787      #+kindex: :
9788      #+findex: org-agenda-set-tags
9789      Set tags for the current headline.  If there is an active region
9790      in the agenda, change a tag for all headings in the region.
9792 - {{{kbd(\,)}}} (~org-agenda-priority~) ::
9794      #+kindex: ,
9795      #+findex: org-agenda-priority
9796      Set the priority for the current item.  Org mode prompts for the
9797      priority character.  If you reply with {{{kbd(SPC)}}}, the
9798      priority cookie is removed from the entry.
9800 - {{{kbd(P)}}} (~org-agenda-show-priority~) ::
9802      #+kindex: P
9803      #+findex: org-agenda-show-priority
9804      Display weighted priority of current item.
9806 - {{{kbd(+)}}} or {{{kbd(S-up)}}} (~org-agenda-priority-up~) ::
9808      #+kindex: +
9809      #+kindex: C-up
9810      #+findex: org-agenda-priority-up
9811      Increase the priority of the current item.  The priority is
9812      changed in the original buffer, but the agenda is not resorted.
9813      Use the {{{kbd(r)}}} key for this.
9815 - {{{kbd(-)}}} or {{{kbd(S-down)}}} (~org-agenda-priority-down~) ::
9817      #+kindex: -
9818      #+kindex: C-down
9819      #+findex: orga-agenda-priority-down
9820      Decrease the priority of the current item.
9822 - {{{kbd(C-c C-z)}}} or short {{{kbd(z)}}} (~org-agenda-add-note~) ::
9824      #+kindex: z
9825      #+kindex: C-c C-z
9826      #+findex: org-agenda-add-note
9827      #+vindex: org-log-into-drawer
9828      Add a note to the entry.  This note is recorded, and then filed
9829      to the same location where state change notes are put.  Depending
9830      on ~org-log-into-drawer~, this may be inside a drawer.
9832 - {{{kbd(C-c C-a)}}} (~org-attach~) ::
9834      #+kindex: C-c C-a
9835      #+findex: org-attach
9836      Dispatcher for all command related to attachments.
9838 - {{{kbd(C-c C-s)}}} (~org-agenda-schedule~) ::
9840      #+kindex: C-c C-s
9841      #+findex: org-agenda-schedule
9842      Schedule this item.  With a prefix argument, remove the
9843      scheduling timestamp
9845 - {{{kbd(C-c C-d)}}} (~org-agenda-deadline~) ::
9847      #+kindex: C-c C-d
9848      #+findex: org-agenda-deadline
9849      Set a deadline for this item.  With a prefix argument, remove the
9850      deadline.
9852 - {{{kbd(S-right)}}} (~org-agenda-do-date-later~) ::
9854      #+kindex: S-right
9855      #+findex: org-agenda-do-date-later
9856      Change the timestamp associated with the current line by one day
9857      into the future.  If the date is in the past, the first call to
9858      this command moves it to today.  With a numeric prefix argument,
9859      change it by that many days.  For example, {{{kbd(3
9860      6 5 S-right)}}} changes it by a year.  With a {{{kbd(C-u)}}}
9861      prefix, change the time by one hour.  If you immediately repeat
9862      the command, it will continue to change hours even without the
9863      prefix argument.  With a double {{{kbd(C-u C-u)}}} prefix, do the
9864      same for changing minutes.  The stamp is changed in the original
9865      Org file, but the change is not directly reflected in the agenda
9866      buffer.  Use {{{kbd(r)}}} or {{{kbd(g)}}} to update the buffer.
9868 - {{{kbd(S-left)}}} (~org-agenda-do-date-earlier~) ::
9870      #+kindex: S-left
9871      #+findex: org-agenda-do-date-earlier
9872      Change the timestamp associated with the current line by one day
9873      into the past.
9875 - {{{kbd(>)}}} (~org-agenda-date-prompt~) ::
9877      #+kindex: >
9878      #+findex: org-agenda-date-prompt
9879      Change the timestamp associated with the current line.  The key
9880      {{{kbd(>)}}} has been chosen, because it is the same as
9881      {{{kbd(S-.)}}}  on my keyboard.
9883 - {{{kbd(I)}}} (~org-agenda-clock-in~) ::
9885      #+kindex: I
9886      #+findex: org-agenda-clock-in
9887      Start the clock on the current item.  If a clock is running
9888      already, it is stopped first.
9890 - {{{kbd(O)}}} (~org-agenda-clock-out~) ::
9892      #+kindex: O
9893      #+findex: org-agenda-clock-out
9894      Stop the previously started clock.
9896 - {{{kbd(X)}}} (~org-agenda-clock-cancel~) ::
9898      #+kindex: X
9899      #+findex: org-agenda-clock-cancel
9900      Cancel the currently running clock.
9902 - {{{kbd(J)}}} (~org-agenda-clock-goto~) ::
9904      #+kindex: J
9905      #+findex: org-agenda-clock-goto
9906      Jump to the running clock in another window.
9908 - {{{kbd(k)}}} (~org-agenda-capture~) ::
9910      #+kindex: k
9911      #+findex: org-agenda-capture
9912      #+cindex: capturing, from agenda
9913      #+vindex: org-capture-use-agenda-date
9914      Like ~org-capture~, but use the date at point as the default date
9915      for the capture template.  See ~org-capture-use-agenda-date~ to
9916      make this the default behavior of ~org-capture~.
9918 *** Bulk remote editing selected entries
9919 :PROPERTIES:
9920 :UNNUMBERED: notoc
9921 :END:
9922 #+cindex: remote editing, bulk, from agenda
9923 #+vindex: org-agenda-bulk-custom-functions
9925 - {{{kbd(m)}}} (~org-agenda-bulk-mark~) ::
9926      #+kindex: m
9927      #+findex: org-agenda-bulk-mark
9929      Mark the entry at point for bulk action.  If there is an active
9930      region in the agenda, mark the entries in the region.  With
9931      numeric prefix argument, mark that many successive entries.
9933 - {{{kbd(*)}}} (~org-agenda-bulk-mark-all~) ::
9934      #+kindex: *
9935      #+findex: org-agenda-bulk-mark-all
9937      Mark all visible agenda entries for bulk action.
9939 - {{{kbd(u)}}} (~org-agenda-bulk-unmark~) ::
9940      #+kindex: u
9941      #+findex: org-agenda-bulk-unmark
9943      Unmark entry for bulk action.
9945 - {{{kbd(U)}}} (~org-agenda-bulk-remove-all-marks~) ::
9946      #+kindex: U
9947      #+findex: org-agenda-bulk-remove-all-marks
9949      Unmark all marked entries for bulk action.
9951 - {{{kbd(M-m)}}} (~org-agenda-bulk-toggle~) ::
9952      #+kindex: M-m
9953      #+findex: org-agenda-bulk-toggle
9955      Toggle mark of the entry at point for bulk action.
9957 - {{{kbd(M-*)}}} (~org-agenda-bulk-toggle-all~) ::
9958      #+kindex: M-*
9959      #+findex: org-agenda-bulk-toggle-all
9961      Mark entries matching a regular expression for bulk action.
9963 - {{{kbd(%)}}} (~org-agenda-bulk-mark-regexp~) ::
9964      #+kindex: %
9965      #+findex: org-agenda-bulk-mark-regexp
9967      Mark entries matching a regular expression for bulk action.
9969 - {{{kbd(B)}}} (~org-agenda-bulk-action~) ::
9970      #+kindex: B
9971      #+findex: org-agenda-bulk-action
9972      #+vindex: org-agenda-bulk-persistent-marks
9974      Bulk action: act on all marked entries in the agenda.  This
9975      prompts for another key to select the action to be applied.  The
9976      prefix argument to {{{kbd(B)}}} is passed through to the
9977      {{{kbd(s)}}} and {{{kbd(d)}}} commands, to bulk-remove these
9978      special timestamps.  By default, marks are removed after the
9979      bulk.  If you want them to persist, set
9980      ~org-agenda-bulk-persistent-marks~ to ~t~ or hit {{{kbd(p)}}} at
9981      the prompt.
9983      - {{{kbd(*)}}} ::
9985           Toggle persistent marks.
9987      - {{{kbd($)}}} ::
9989           Archive all selected entries.
9991      - {{{kbd(A)}}} ::
9993           Archive entries by moving them to their respective archive
9994           siblings.
9996      - {{{kbd(t)}}} ::
9998           Change TODO state.  This prompts for a single TODO keyword and
9999           changes the state of all selected entries, bypassing blocking
10000           and suppressing logging notes---but not timestamps.
10002      - {{{kbd(+)}}}  ::
10004           Add a tag to all selected entries.
10006      - {{{kbd(-)}}}  ::
10008           Remove a tag from all selected entries.
10010      - {{{kbd(s)}}}  ::
10012           Schedule all items to a new date.  To shift existing schedule
10013           dates by a fixed number of days, use something starting with
10014           double plus at the prompt, for example =++8d= or =++2w=.
10016      - {{{kbd(d)}}}  ::
10018           Set deadline to a specific date.
10020      - {{{kbd(r)}}}  ::
10022           Prompt for a single refile target and move all entries.  The
10023           entries are no longer in the agenda; refresh ({{{kbd(g)}}}) to
10024           bring them back.
10026      - {{{kbd(S)}}}  ::
10028           Reschedule randomly into the coming N days.  N is prompted for.
10029           With a prefix argument ({{{kbd(C-u B S)}}}), scatter only
10030           across weekdays.
10032      - {{{kbd(f)}}}  ::
10034           #+vindex: org-agenda-bulk-custom-functions
10035           Apply a function[fn:96] to marked entries.  For example, the
10036           function below sets the =CATEGORY= property of the entries to
10037           =web=.
10039           #+begin_src emacs-lisp
10040             (defun set-category ()
10041               (interactive "P")
10042               (let ((marker (or (org-get-at-bol 'org-hd-marker)
10043                                 (org-agenda-error))))
10044                 (org-with-point-at marker
10045                   (org-back-to-heading t)
10046                   (org-set-property "CATEGORY" "web"))))
10047           #+end_src
10049 *** Calendar commands
10050 :PROPERTIES:
10051 :UNNUMBERED: notoc
10052 :END:
10053 #+cindex: calendar commands, from agenda
10055 - {{{kbd(c)}}} (~org-agenda-goto-calendar~) ::
10057      #+kindex: c
10058      #+findex: org-agenda-goto-calendar
10059      Open the Emacs calendar and move to the date at the agenda
10060      cursor.
10062 - {{{kbd(c)}}} (~org-calendar-goto-agenda~) ::
10064      #+kindex: c
10065      #+findex: org-calendar-goto-agenda
10066      When in the calendar, compute and show the Org agenda for the
10067      date at the cursor.
10069 - {{{kbd(i)}}} (~org-agenda-diary-entry~) ::
10070      #+kindex: i
10071      #+findex: org-agenda-diary-entry
10073      #+cindex: diary entries, creating from agenda
10074      Insert a new entry into the diary, using the date at the cursor
10075      and (for block entries) the date at the mark.  This adds to the
10076      Emacs diary file[fn:97], in a way similar to the {{{kbd(i)}}}
10077      command in the calendar.  The diary file pops up in another
10078      window, where you can add the entry.
10080      #+vindex: org-agenda-diary-file
10081      If you configure ~org-agenda-diary-file~ to point to an Org file,
10082      Org creates entries in that file instead.  Most entries are
10083      stored in a date-based outline tree that will later make it easy
10084      to archive appointments from previous months/years.  The tree is
10085      built under an entry with a =DATE_TREE= property, or else with
10086      years as top-level entries.  Emacs prompts you for the entry
10087      text---if you specify it, the entry is created in
10088      ~org-agenda-diary-file~ without further interaction.  If you
10089      directly press {{{kbd(RET)}}} at the prompt without typing text,
10090      the target file is shown in another window for you to finish the
10091      entry there.  See also the {{{kbd(k r)}}} command.
10093 - {{{kbd(M)}}} (~org-agenda-phases-of-moon~) ::
10095      #+kindex: M
10096      #+findex: org-agenda-phases-of-moon
10097      Show the phases of the moon for the three months around current
10098      date.
10100 - {{{kbd(S)}}} (~org-agenda-sunrise-sunset~) ::
10102      #+kindex: S
10103      #+findex: org-agenda-sunrise-sunset
10104      Show sunrise and sunset times.  The geographical location must be
10105      set with calendar variables, see the documentation for the Emacs
10106      calendar.
10108 - {{{kbd(C)}}} (~org-agenda-convert-date~) ::
10110      #+kindex: C
10111      #+findex: org-agenda-convert-date
10112      Convert the date at cursor into many other cultural and historic
10113      calendars.
10115 - {{{kbd(H)}}} (~org-agenda-holidays~) ::
10117      #+kindex: H
10118      #+findex: org-agenda-holidays
10119      Show holidays for three months around the cursor date.
10121 *** Quit and exit
10122 :PROPERTIES:
10123 :UNNUMBERED: notoc
10124 :END:
10126 - {{{kbd(q)}}} (~org-agenda-quit~) ::
10127      #+kindex: q
10128      #+findex: org-agenda-quit
10130      Quit agenda, remove the agenda buffer.
10132 - {{{kbd(x)}}} (~org-agenda-exit~) ::
10133      #+kindex: x
10134      #+findex: org-agenda-exit
10136      #+cindex: agenda files, removing buffers
10137      Exit agenda, remove the agenda buffer and all buffers loaded by
10138      Emacs for the compilation of the agenda.  Buffers created by the
10139      user to visit Org files are not removed.
10141 ** Custom Agenda Views
10142 :PROPERTIES:
10143 :DESCRIPTION: Defining special searches and views.
10144 :END:
10145 #+cindex: custom agenda views
10146 #+cindex: agenda views, custom
10148 Custom agenda commands serve two purposes: to store and quickly access
10149 frequently used TODO and tags searches, and to create special
10150 composite agenda buffers.  Custom agenda commands are accessible
10151 through the dispatcher (see [[*The Agenda Dispatcher]]), just like the
10152 default commands.
10154 *** Storing searches
10155 :PROPERTIES:
10156 :DESCRIPTION: Type once, use often.
10157 :END:
10159 The first application of custom searches is the definition of keyboard
10160 shortcuts for frequently used searches, either creating an agenda
10161 buffer, or a sparse tree (the latter covering of course only the
10162 current buffer).
10164 #+kindex: C-c a C
10165 #+vindex: org-agenda-custom-commands
10166 #+cindex: agenda views, main example
10167 #+cindex: agenda, as an agenda views
10168 #+cindex: agenda*, as an agenda views
10169 #+cindex: tags, as an agenda view
10170 #+cindex: todo, as an agenda view
10171 #+cindex: tags-todo
10172 #+cindex: todo-tree
10173 #+cindex: occur-tree
10174 #+cindex: tags-tree
10175 Custom commands are configured in the variable
10176 ~org-agenda-custom-commands~.  You can customize this variable, for
10177 example by pressing {{{kbd(C-c a C)}}}.  You can also directly set it
10178 with Emacs Lisp in the Emacs init file.  The following example
10179 contains all valid agenda views:
10181 #+begin_src emacs-lisp
10182   (setq org-agenda-custom-commands
10183         '(("x" agenda)
10184           ("y" agenda*)
10185           ("w" todo "WAITING")
10186           ("W" todo-tree "WAITING")
10187           ("u" tags "+boss-urgent")
10188           ("v" tags-todo "+boss-urgent")
10189           ("U" tags-tree "+boss-urgent")
10190           ("f" occur-tree "\\<FIXME\\>")
10191           ("h" . "HOME+Name tags searches") ;description for "h" prefix
10192           ("hl" tags "+home+Lisa")
10193           ("hp" tags "+home+Peter")
10194           ("hk" tags "+home+Kim")))
10195 #+end_src
10197 #+texinfo: @noindent
10198 The initial string in each entry defines the keys you have to press
10199 after the dispatcher command {{{kbd(C-c a)}}} in order to access the
10200 command.  Usually this will be just a single character, but if you
10201 have many similar commands, you can also define two-letter
10202 combinations where the first character is the same in several
10203 combinations and serves as a prefix key[fn:98].  The second parameter
10204 is the search type, followed by the string or regular expression to be
10205 used for the matching.  The example above will therefore define:
10207 - {{{kbd(C-c a x)}}} ::
10209      as a global search for agenda entries planned[fn:99] this
10210      week/day.
10212 - {{{kbd(C-c a y)}}} ::
10214      as the same search, but only for entries with an hour
10215      specification like =[h]h:mm=---think of them as appointments.
10217 - {{{kbd(C-c a w)}}} ::
10219      as a global search for TODO entries with =WAITING= as the TODO
10220      keyword.
10222 - {{{kbd(C-c a W)}}} ::
10224      as the same search, but only in the current buffer and displaying
10225      the results as a sparse tree.
10227 - {{{kbd(C-c a u)}}} ::
10229      as a global tags search for headlines tagged =boss= but not
10230      =urgent=.
10232 - {{{kbd(C-c a v)}}} ::
10234      The same search, but limiting it to headlines that are also TODO
10235      items.
10237 - {{{kbd(C-c a U)}}} ::
10239      as the same search, but only in the current buffer and displaying
10240      the result as a sparse tree.
10242 - {{{kbd(C-c a f)}}} ::
10244      to create a sparse tree (again, current buffer only) with all
10245      entries containing the word =FIXME=.
10247 - {{{kbd(C-c a h)}}} ::
10249      as a prefix command for a =HOME= tags search where you have to
10250      press an additional key ({{{kbd(l)}}}, {{{kbd(p)}}} or
10251      {{{kbd(k)}}}) to select a name (Lisa, Peter, or Kim) as
10252      additional tag to match.
10254 Note that ~*-tree~ agenda views need to be called from an Org buffer
10255 as they operate on the current buffer only.
10256 *** Block agenda
10257 :PROPERTIES:
10258 :DESCRIPTION: All the stuff you need in a single buffer.
10259 :END:
10260 #+cindex: block agenda
10261 #+cindex: agenda, with block views
10263 Another possibility is the construction of agenda views that comprise
10264 the results of /several/ commands, each of which creates a block in
10265 the agenda buffer.  The available commands include ~agenda~ for the
10266 daily or weekly agenda (as created with {{{kbd(C-c a a)}}}), ~alltodo~
10267 for the global TODO list (as constructed with {{{kbd(C-c a t)}}}), and
10268 the matching commands discussed above: ~todo~, ~tags~, and
10269 ~tags-todo~.  Here are two examples:
10271 #+begin_src emacs-lisp
10272   (setq org-agenda-custom-commands
10273         '(("h" "Agenda and Home-related tasks"
10274            ((agenda "")
10275             (tags-todo "home")
10276             (tags "garden")))
10277           ("o" "Agenda and Office-related tasks"
10278            ((agenda "")
10279             (tags-todo "work")
10280             (tags "office")))))
10281 #+end_src
10283 #+texinfo: @noindent
10284 This defines {{{kbd(C-c a h)}}} to create a multi-block view for stuff
10285 you need to attend to at home.  The resulting agenda buffer contains
10286 your agenda for the current week, all TODO items that carry the tag
10287 =home=, and also all lines tagged with =garden=.  Finally the command
10288 {{{kbd(C-c a o)}}} provides a similar view for office tasks.
10290 *** Setting options for custom commands
10291 :PROPERTIES:
10292 :DESCRIPTION: Changing the rules.
10293 :ALT_TITLE: Setting options
10294 :END:
10295 #+cindex: options, for custom agenda views
10297 #+vindex: org-agenda-custom-commands
10298 Org mode contains a number of variables regulating agenda construction
10299 and display.  The global variables define the behavior for all agenda
10300 commands, including the custom commands.  However, if you want to
10301 change some settings just for a single custom view, you can do so.
10302 Setting options requires inserting a list of variable names and values
10303 at the right spot in ~org-agenda-custom-commands~.  For example:
10305 #+begin_src emacs-lisp
10306   (setq org-agenda-custom-commands
10307         '(("w" todo "WAITING"
10308            ((org-agenda-sorting-strategy '(priority-down))
10309             (org-agenda-prefix-format "  Mixed: ")))
10310           ("U" tags-tree "+boss-urgent"
10311            ((org-show-context-detail 'minimal)))
10312           ("N" search ""
10313            ((org-agenda-files '("~org/notes.org"))
10314             (org-agenda-text-search-extra-files nil)))))
10315 #+end_src
10317 #+texinfo: @noindent
10318 Now the {{{kbd(C-c a w)}}} command sorts the collected entries only by
10319 priority, and the prefix format is modified to just say =Mixed:=
10320 instead of giving the category of the entry.  The sparse tags tree of
10321 {{{kbd(C-c a U)}}} now turns out ultra-compact, because neither the
10322 headline hierarchy above the match, nor the headline following the
10323 match are shown.  The command {{{kbd(C-c a N)}}} does a text search
10324 limited to only a single file.
10326 For command sets creating a block agenda, ~org-agenda-custom-commands~
10327 has two separate spots for setting options.  You can add options that
10328 should be valid for just a single command in the set, and options that
10329 should be valid for all commands in the set.  The former are just
10330 added to the command entry; the latter must come after the list of
10331 command entries.  Going back to the block agenda example (see [[*Block
10332 agenda]]), let's change the sorting strategy for the {{{kbd(C-c a h)}}}
10333 commands to ~priority-down~, but let's sort the results for GARDEN
10334 tags query in the opposite order, ~priority-up~.  This would look like
10335 this:
10337 #+begin_src emacs-lisp
10338   (setq org-agenda-custom-commands
10339         '(("h" "Agenda and Home-related tasks"
10340            ((agenda)
10341             (tags-todo "home")
10342             (tags "garden"
10343                   ((org-agenda-sorting-strategy '(priority-up)))))
10344            ((org-agenda-sorting-strategy '(priority-down))))
10345           ("o" "Agenda and Office-related tasks"
10346            ((agenda)
10347             (tags-todo "work")
10348             (tags "office")))))
10349 #+end_src
10351 As you see, the values and parentheses setting is a little complex.
10352 When in doubt, use the customize interface to set this variable---it
10353 fully supports its structure.  Just one caveat: when setting options
10354 in this interface, the /values/ are just Lisp expressions.  So if the
10355 value is a string, you need to add the double-quotes around the value
10356 yourself.
10358 #+vindex: org-agenda-custom-commands-contexts
10359 To control whether an agenda command should be accessible from
10360 a specific context, you can customize
10361 ~org-agenda-custom-commands-contexts~.  Let's say for example that you
10362 have an agenda command {{{kbd(o)}}} displaying a view that you only
10363 need when reading emails.  Then you would configure this option like
10364 this:
10366 #+begin_src emacs-lisp
10367   (setq org-agenda-custom-commands-contexts
10368         '(("o" (in-mode . "message-mode"))))
10369 #+end_src
10371 You can also tell that the command key {{{kbd(o)}}} should refer to
10372 another command key {{{kbd(r)}}}.  In that case, add this command key
10373 like this:
10375 #+begin_src emacs-lisp
10376   (setq org-agenda-custom-commands-contexts
10377         '(("o" "r" (in-mode . "message-mode"))))
10378 #+end_src
10380 See the docstring of the variable for more information.
10382 ** Exporting Agenda Views
10383 :PROPERTIES:
10384 :DESCRIPTION: Writing a view to a file.
10385 :END:
10386 #+cindex: agenda views, exporting
10388 If you are away from your computer, it can be very useful to have
10389 a printed version of some agenda views to carry around.  Org mode can
10390 export custom agenda views as plain text, HTML[fn:100], Postscript,
10391 PDF[fn:101], and iCalendar files.  If you want to do this only
10392 occasionally, use the following command:
10394 - {{{kbd(C-x C-w)}}} (~org-agenda-write~) ::
10395      #+kindex: C-x C-w
10396      #+findex: org-agenda-write
10397      #+cindex: exporting agenda views
10398      #+cindex: agenda views, exporting
10400      #+vindex: org-agenda-exporter-settings
10401      Write the agenda view to a file.
10403 If you need to export certain agenda views frequently, you can
10404 associate any custom agenda command with a list of output file
10405 names[fn:102].  Here is an example that first defines custom commands
10406 for the agenda and the global TODO list, together with a number of
10407 files to which to export them.  Then we define two block agenda
10408 commands and specify file names for them as well.  File names can be
10409 relative to the current working directory, or absolute.
10411 #+begin_src emacs-lisp
10412   (setq org-agenda-custom-commands
10413         '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
10414           ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
10415           ("h" "Agenda and Home-related tasks"
10416            ((agenda "")
10417             (tags-todo "home")
10418             (tags "garden"))
10419            nil
10420            ("~/views/home.html"))
10421           ("o" "Agenda and Office-related tasks"
10422            ((agenda)
10423             (tags-todo "work")
10424             (tags "office"))
10425            nil
10426            ("~/views/office.ps" "~/calendars/office.ics"))))
10427 #+end_src
10429 The extension of the file name determines the type of export.  If it
10430 is =.html=, Org mode uses the htmlize package to convert the buffer to
10431 HTML and save it to this file name.  If the extension is =.ps=,
10432 ~ps-print-buffer-with-faces~ is used to produce Postscript output.  If
10433 the extension is =.ics=, iCalendar export is run export over all files
10434 that were used to construct the agenda, and limit the export to
10435 entries listed in the agenda.  Any other extension produces a plain
10436 ASCII file.
10438 The export files are /not/ created when you use one of those
10439 commands interactively because this might use too much overhead.
10440 Instead, there is a special command to produce /all/ specified
10441 files in one step:
10443 #+attr_texinfo: :table-type table :indic @asis
10444 - {{{kbd(C-c a e)}}} (~org-store-agenda-views~) ::
10445      #+kindex: C-c a e
10446      #+findex: org-store-agenda-views
10448      Export all agenda views that have export file names associated
10449      with them.
10451 You can use the options section of the custom agenda commands to also
10452 set options for the export commands.  For example:
10454 #+begin_src emacs-lisp
10455   (setq org-agenda-custom-commands
10456         '(("X" agenda ""
10457            ((ps-number-of-columns 2)
10458             (ps-landscape-mode t)
10459             (org-agenda-prefix-format " [ ] ")
10460             (org-agenda-with-colors nil)
10461             (org-agenda-remove-tags t))
10462            ("theagenda.ps"))))
10463 #+end_src
10465 #+texinfo: @noindent
10466 #+vindex: org-agenda-exporter-settings
10467 This command sets two options for the Postscript exporter, to make it
10468 print in two columns in landscape format---the resulting page can be
10469 cut in two and then used in a paper agenda.  The remaining settings
10470 modify the agenda prefix to omit category and scheduling information,
10471 and instead include a checkbox to check off items.  We also remove the
10472 tags to make the lines compact, and we do not want to use colors for
10473 the black-and-white printer.  Settings specified in
10474 ~org-agenda-exporter-settings~ also apply, e.g.,
10476 #+begin_src emacs-lisp
10477   (setq org-agenda-exporter-settings
10478         '((ps-number-of-columns 2)
10479           (ps-landscape-mode t)
10480           (org-agenda-add-entry-text-maxlines 5)
10481           (htmlize-output-type 'css)))
10482 #+end_src
10484 #+texinfo: @noindent
10485 but the settings in ~org-agenda-custom-commands~ take precedence.
10487 #+texinfo: @noindent
10488 From the command line you may also use:
10490 #+begin_src shell
10491   emacs -eval (org-batch-store-agenda-views) -kill
10492 #+end_src
10494 #+texinfo: @noindent
10495 or, if you need to modify some parameters[fn:103]
10497 #+begin_src shell
10498   emacs -eval '(org-batch-store-agenda-views                      \
10499                 org-agenda-span (quote month)                     \
10500                 org-agenda-start-day "2007-11-01"                 \
10501                 org-agenda-include-diary nil                      \
10502                 org-agenda-files (quote ("~/org/project.org")))'  \
10503         -kill
10504 #+end_src
10506 #+texinfo: @noindent
10507 which creates the agenda views restricted to the file
10508 =~/org/project.org=, without diary entries and with a 30-day extent.
10510 You can also extract agenda information in a way that allows further
10511 processing by other programs.  See [[*Extracting Agenda Information]], for
10512 more information.
10514 ** Using Column View in the Agenda
10515 :PROPERTIES:
10516 :DESCRIPTION: Using column view for collected entries.
10517 :ALT_TITLE: Agenda Column View
10518 :END:
10519 #+cindex: column view, in agenda
10520 #+cindex: agenda, column view
10522 Column view (see [[*Column View]]) is normally used to view and edit
10523 properties embedded in the hierarchical structure of an Org file.  It
10524 can be quite useful to use column view also from the agenda, where
10525 entries are collected by certain criteria.
10527 - {{{kbd(C-c C-x C-c)}}} (~org-agenda-columns~) ::
10528      #+kindex: C-c C-x C-c
10529      #+findex: org-agenda-columns
10531      Turn on column view in the agenda.
10533 To understand how to use this properly, it is important to realize
10534 that the entries in the agenda are no longer in their proper outline
10535 environment.  This causes the following issues:
10538    #+vindex: org-columns-default-format
10539    #+vindex: org-overriding-columns-format
10540    Org needs to make a decision which columns format to use.  Since
10541    the entries in the agenda are collected from different files, and
10542    different files may have different columns formats, this is
10543    a non-trivial problem.  Org first checks if the variable
10544    ~org-agenda-overriding-columns-format~ is currently set, and if so,
10545    takes the format from there.  Otherwise it takes the format
10546    associated with the first item in the agenda, or, if that item does
10547    not have a specific format (defined in a property, or in its file),
10548    it uses ~org-columns-default-format~.
10551    #+cindex: CLOCKSUM, special property
10552    If any of the columns has a summary type defined (see [[*Column
10553    attributes]]), turning on column view in the agenda visits all
10554    relevant agenda files and make sure that the computations of this
10555    property are up to date.  This is also true for the special
10556    =CLOCKSUM= property.  Org then sums the values displayed in the
10557    agenda.  In the daily/weekly agenda, the sums cover a single day;
10558    in all other views they cover the entire block.
10560    It is important to realize that the agenda may show the same entry
10561    /twice/---for example as scheduled and as a deadline---and it may
10562    show two entries from the same hierarchy (for example a /parent/
10563    and its /child/).  In these cases, the summation in the agenda
10564    leads to incorrect results because some values count double.
10566 3. When the column view in the agenda shows the =CLOCKSUM= property,
10567    that is always the entire clocked time for this item.  So even in
10568    the daily/weekly agenda, the clocksum listed in column view may
10569    originate from times outside the current view.  This has the
10570    advantage that you can compare these values with a column listing
10571    the planned total effort for a task---one of the major
10572    applications for column view in the agenda.  If you want
10573    information about clocked time in the displayed period use clock
10574    table mode (press {{{kbd(R)}}} in the agenda).
10577    #+cindex: CLOCKSUM_T, special property
10578    When the column view in the agenda shows the =CLOCKSUM_T= property,
10579    that is always today's clocked time for this item.  So even in the
10580    weekly agenda, the clocksum listed in column view only originates
10581    from today.  This lets you compare the time you spent on a task for
10582    today, with the time already spent---via =CLOCKSUM=---and with
10583    the planned total effort for it.
10585 * Markup for Rich Export
10586 :PROPERTIES:
10587 :DESCRIPTION: Prepare text for rich export.
10588 :ALT_TITLE: Markup
10589 :END:
10591 When exporting Org documents, the exporter tries to reflect the
10592 structure of the document as accurately as possible in the back-end.
10593 Since export targets like HTML and LaTeX allow much richer formatting,
10594 Org mode has rules on how to prepare text for rich export.  This
10595 section summarizes the markup rules used in an Org mode buffer.
10597 ** Paragraphs
10598 :PROPERTIES:
10599 :DESCRIPTION: The basic unit of text.
10600 :END:
10601 #+cindex: paragraphs, markup rules
10603 Paragraphs are separated by at least one empty line.  If you need to
10604 enforce a line break within a paragraph, use ~\\~ at the end of
10605 a line.
10607 To preserve the line breaks, indentation and blank lines in a region,
10608 but otherwise use normal formatting, you can use this construct, which
10609 can also be used to format poetry.
10611 #+cindex: BEGIN_VERSE
10612 #+cindex: verse blocks
10613 #+begin_example
10614   ,#+BEGIN_VERSE
10615    Great clouds overhead
10616    Tiny black birds rise and fall
10617    Snow covers Emacs
10619       ---AlexSchroeder
10620   ,#+END_VERSE
10621 #+end_example
10623 When quoting a passage from another document, it is customary to
10624 format this as a paragraph that is indented on both the left and the
10625 right margin.  You can include quotations in Org documents like this:
10627 #+cindex: BEGIN_QUOTE
10628 #+cindex: quote blocks
10629 #+begin_example
10630   ,#+BEGIN_QUOTE
10631   Everything should be made as simple as possible,
10632   but not any simpler ---Albert Einstein
10633   ,#+END_QUOTE
10634 #+end_example
10636 If you would like to center some text, do it like this:
10638 #+cindex: BEGIN_CENTER
10639 #+cindex: center blocks
10640 #+begin_example
10641   ,#+BEGIN_CENTER
10642   Everything should be made as simple as possible, \\
10643   but not any simpler
10644   ,#+END_CENTER
10645 #+end_example
10647 ** Emphasis and Monospace
10648 :PROPERTIES:
10649 :DESCRIPTION: Bold, italic, etc.
10650 :END:
10651 #+cindex: underlined text, markup rules
10652 #+cindex: bold text, markup rules
10653 #+cindex: italic text, markup rules
10654 #+cindex: verbatim text, markup rules
10655 #+cindex: code text, markup rules
10656 #+cindex: strike-through text, markup rules
10658 You can make words =*bold*=, =/italic/=, =_underlined_=, ==verbatim==
10659 and =~code~=, and, if you must, =+strike-through+=.  Text in the code
10660 and verbatim string is not processed for Org mode specific syntax; it
10661 is exported verbatim.
10663 #+vindex: org-fontify-emphasized-text
10664 To turn off fontification for marked up text, you can set
10665 ~org-fontify-emphasized-text~ to ~nil~.  To narrow down the list of
10666 available markup syntax, you can customize ~org-emphasis-alist~.
10668 ** Horizontal Rules
10669 :PROPERTIES:
10670 :DESCRIPTION: Make a line.
10671 :END:
10672 #+cindex: horizontal rules, markup rules
10674 A line consisting of only dashes, and at least 5 of them, is exported
10675 as a horizontal line.
10677 ** Images and Tables
10678 :PROPERTIES:
10679 :DESCRIPTION: Images, tables and caption mechanism.
10680 :END:
10681 #+cindex: tables, markup rules
10682 #+cindex: CAPTION, keyword
10683 #+cindex: NAME, keyword
10685 Both the native Org mode tables (see [[*Tables]]) and tables formatted
10686 with the =table.el= package are exported properly.  For Org mode
10687 tables, the lines before the first horizontal separator line become
10688 table header lines.  You can use the following lines somewhere before
10689 the table to assign a caption and a label for cross references, and in
10690 the text you can refer to the object with =[[tab:basic-data]]= (see
10691 [[*Internal Links]]):
10693 #+begin_example
10694   ,#+CAPTION: This is the caption for the next table (or link)
10695   ,#+NAME:   tab:basic-data
10696   | ... | ... |
10697   |-----+-----|
10698 #+end_example
10700 Optionally, the caption can take the form:
10702 : #+CAPTION[Caption for list of tables]: Caption for table.
10704 #+cindex: inlined images, markup rules
10705 Some back-ends allow you to directly include images into the exported
10706 document.  Org does this, if a link to an image file does not have
10707 a description part, for example =[[./img/a.jpg]]=.  If you wish to define
10708 a caption for the image and maybe a label for internal cross
10709 references, make sure that the link is on a line by itself and precede
10710 it with =CAPTION= and =NAME= keywords as follows:
10712 #+begin_example
10713   ,#+CAPTION: This is the caption for the next figure link (or table)
10714   ,#+NAME:   fig:SED-HR4049
10715   [[./img/a.jpg]]
10716 #+end_example
10718 #+texinfo: @noindent
10719 Such images can be displayed within the buffer.  See [[*Handling Links][the discussion of
10720 image links]].
10722 Even though images and tables are prominent examples of captioned
10723 structures, the same caption mechanism can apply to many
10724 others---e.g., LaTeX equations, source code blocks.  Depending on the
10725 export back-end, those may or may not be handled.
10727 ** Literal Examples
10728 :PROPERTIES:
10729 :DESCRIPTION: Source code examples with special formatting.
10730 :END:
10731 #+cindex: literal examples, markup
10732 #+cindex: code line references, markup
10734 You can include literal examples that should not be subjected to
10735 markup.  Such examples are typeset in monospace, so this is well
10736 suited for source code and similar examples.
10738 #+cindex: BEGIN_EXAMPLE
10739 #+cindex: example block
10740 #+begin_example
10741   ,#+BEGIN_EXAMPLE
10742     Some example from a text file.
10743   ,#+END_EXAMPLE
10744 #+end_example
10746 Note that such blocks may be /indented/ in order to align nicely with
10747 indented text and in particular with plain list structure (see
10748 [[*Plain Lists]]).  For simplicity when using small examples, you can
10749 also start the example lines with a colon followed by a space.  There
10750 may also be additional whitespace before the colon:
10752 #+begin_example
10753   Here is an example
10754      : Some example from a text file.
10755 #+end_example
10757 #+cindex: formatting source code, markup rules
10758 #+vindex: org-latex-listings
10759 If the example is source code from a programming language, or any
10760 other text that can be marked up by Font Lock in Emacs, you can ask
10761 for the example to look like the fontified Emacs buffer[fn:104].  This
10762 is done with the code block, where you also need to specify the name
10763 of the major mode that should be used to fontify the example[fn:105],
10764 see [[*Structure Templates]] for shortcuts to easily insert code blocks.
10766 #+cindex: BEGIN_SRC
10767 #+cindex: src block
10768 #+begin_example
10769   ,#+BEGIN_SRC emacs-lisp
10770     (defun org-xor (a b)
10771       "Exclusive or."
10772       (if a (not b) b))
10773    ,#+END_SRC
10774 #+end_example
10776 Both in =example= and in =src= snippets, you can add a =-n= switch to
10777 the end of the =#+BEGIN= line, to get the lines of the example
10778 numbered.  The =-n= takes an optional numeric argument specifying the
10779 starting line number of the block.  If you use a =+n= switch, the
10780 numbering from the previous numbered snippet is continued in the
10781 current one.  The =+n= switch can also take a numeric argument.  This
10782 adds the value of the argument to the last line of the previous block
10783 to determine the starting line number.
10785 #+begin_example
10786   ,#+BEGIN_SRC emacs-lisp -n 20
10787     ;; This exports with line number 20.
10788     (message "This is line 21")
10789   ,#+END_SRC
10791   ,#+BEGIN_SRC emacs-lisp +n 10
10792     ;; This is listed as line 31.
10793     (message "This is line 32")
10794   ,#+END_SRC
10795 #+end_example
10797 In literal examples, Org interprets strings like =(ref:name)= as
10798 labels, and use them as targets for special hyperlinks like
10799 =[[(name)]]=---i.e., the reference name enclosed in single parenthesis.
10800 In HTML, hovering the mouse over such a link remote-highlights the
10801 corresponding code line, which is kind of cool.
10803 You can also add a =-r= switch which /removes/ the labels from the
10804 source code[fn:106].  With the =-n= switch, links to these references
10805 are labeled by the line numbers from the code listing.  Otherwise
10806 links use the labels with no parentheses.  Here is an example:
10808 #+begin_example -l "(dumb-reference:%s)"
10809   ,#+BEGIN_SRC emacs-lisp -n -r
10810     (save-excursion                 (ref:sc)
10811        (goto-char (point-min))      (ref:jump)
10812   ,#+END_SRC
10813   In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]]
10814   jumps to point-min.
10815 #+end_example
10817 #+cindex: indentation, in source blocks
10818 Finally, you can use =-i= to preserve the indentation of a specific
10819 code block (see [[*Editing Source Code]]).
10821 #+vindex: org-coderef-label-format
10822 If the syntax for the label format conflicts with the language syntax,
10823 use a =-l= switch to change the format, for example
10825 : #+BEGIN_SRC pascal -n -r -l "((%s))"
10827 #+texinfo: @noindent
10828 See also the variable ~org-coderef-label-format~.
10830 HTML export also allows examples to be published as text areas (see
10831 [[*Text areas in HTML export]]).
10833 Because the =#+BEGIN= ... =#+END= patterns need to be added so often,
10834 a shortcut is provided (see [[*Structure Templates]]).
10836 - {{{kbd(C-c ')}}} (~org-edit-special~) ::
10838      #+kindex: C-c '
10839      #+findex: org-edit-special
10840      Edit the source code example at point in its native mode.  This
10841      works by switching to a temporary buffer with the source code.
10842      You need to exit by pressing {{{kbd(C-c ')}}} again[fn:107].  The
10843      edited version then replaces the old version in the Org buffer.
10844      Fixed-width regions---where each line starts with a colon
10845      followed by a space---are edited using ~artist-mode~[fn:108] to
10846      allow creating ASCII drawings easily.  Using this command in an
10847      empty line creates a new fixed-width region.
10849 - {{{kbd(C-c l)}}} (~org-store-link~) ::
10851      #+kindex: C-c l
10852      #+findex: org-store-link
10853      Calling ~org-store-link~ while editing a source code example in
10854      a temporary buffer created with {{{kbd(C-c ')}}} prompts for
10855      a label.  Make sure that it is unique in the current buffer, and
10856      insert it with the proper formatting like =(ref:label)= at the
10857      end of the current line.  Then the label is stored as a link
10858      =(label)=, for retrieval with {{{kbd(C-c C-l)}}}.
10860 ** Special Symbols
10861 :PROPERTIES:
10862 :DESCRIPTION: Greek letters and other symbols.
10863 :END:
10864 #+cindex: math symbols
10865 #+cindex: special symbols
10866 #+cindex: @TeX{} macros
10867 #+cindex: @LaTeX{} fragments, markup rules
10868 #+cindex: HTML entities
10869 #+cindex: @LaTeX{} entities
10871 You can use LaTeX-like syntax to insert special symbols---named
10872 entities---like =\alpha= to indicate the Greek letter, or =\to= to indicate
10873 an arrow.  Completion for these symbols is available, just type =\=
10874 and maybe a few letters, and press {{{kbd(M-TAB)}}} to see possible
10875 completions.  If you need such a symbol inside a word, terminate it
10876 with a pair of curly brackets.  For example
10878 #+begin_example
10879   Pro tip: Given a circle \Gamma of diameter d, the length of its
10880   circumference is \pi{}d.
10881 #+end_example
10883 #+findex: org-entities-help
10884 #+vindex: org-entities-user
10885 A large number of entities is provided, with names taken from both
10886 HTML and LaTeX; you can comfortably browse the complete list from
10887 a dedicated buffer using the command ~org-entities-help~.  It is also
10888 possible to provide your own special symbols in the variable
10889 ~org-entities-user~.
10891 During export, these symbols are transformed into the native format of
10892 the exporter back-end.  Strings like =\alpha= are exported as =&alpha;= in
10893 the HTML output, and as =\(\alpha\)= in the LaTeX output.  Similarly, =\nbsp=
10894 becomes =&nbsp;= in HTML and =~= in LaTeX.
10896 #+cindex: escaping characters
10897 Entities may also be used as a way to escape markup in an Org
10898 document, e.g., =\under{}not underlined\under= exports as =_not underlined_=.
10900 #+cindex: special symbols, in-buffer display
10901 If you would like to see entities displayed as UTF-8 characters, use
10902 the following command[fn:109]:
10904 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~) ::
10905      #+kindex: C-c C-x \
10906      #+findex: org-toggle-pretty-entities
10908      Toggle display of entities as UTF-8 characters.  This does not
10909      change the buffer content which remains plain ASCII, but it
10910      overlays the UTF-8 character for display purposes only.
10912 #+cindex: shy hyphen, special symbol
10913 #+cindex: dash, special symbol
10914 #+cindex: ellipsis, special symbol
10915 In addition to regular entities defined above, Org exports in
10916 a special way[fn:110] the following commonly used character
10917 combinations: =\-= is treated as a shy hyphen, =--= and =---= are
10918 converted into dashes, and =...= becomes a compact set of dots.
10920 ** Subscripts and Superscripts
10921 :PROPERTIES:
10922 :DESCRIPTION: Simple syntax for raising/lowering text.
10923 :END:
10924 #+cindex: subscript
10925 #+cindex: superscript
10927 =^= and =_= are used to indicate super- and subscripts.  To increase
10928 the readability of ASCII text, it is not necessary, but OK, to
10929 surround multi-character sub- and superscripts with curly braces.  For
10930 example
10932 #+begin_example
10933   The radius of the sun is R_sun = 6.96 x 10^8 m.  On the other hand,
10934   the radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
10935 #+end_example
10937 #+vindex: org-use-sub-superscripts
10938 If you write a text where the underscore is often used in a different
10939 context, Org's convention to always interpret these as subscripts can
10940 get in your way.  Configure the variable ~org-use-sub-superscripts~ to
10941 change this convention.  For example, when setting this variable to
10942 ~{}~, =a_b= is not interpreted as a subscript, but =a_{b}= is.
10944 - {{{kbd(C-c C-x \)}}} (~org-toggle-pretty-entities~~) ::
10945      #+kindex: C-c C-x \
10946      #+findex: org-toggle-pretty-entities
10948      In addition to showing entities as UTF-8 characters, this command
10949      also formats sub- and superscripts in a WYSIWYM way.
10951 ** Embedded LaTeX
10952 :PROPERTIES:
10953 :DESCRIPTION: LaTeX can be freely used inside Org documents.
10954 :END:
10955 #+cindex: @TeX{} interpretation
10956 #+cindex: @LaTeX{} interpretation
10958 Plain ASCII is normally sufficient for almost all note taking.
10959 Exceptions include scientific notes, which often require mathematical
10960 symbols and the occasional formula.  LaTeX[fn:111] is widely used to
10961 typeset scientific documents.  Org mode supports embedding LaTeX code
10962 into its files, because many academics are used to writing and reading
10963 LaTeX source code, and because it can be readily processed to produce
10964 pretty output for a number of export back-ends.
10966 *** LaTeX fragments
10967 :PROPERTIES:
10968 :DESCRIPTION: Complex formulas made easy.
10969 :END:
10970 #+cindex: @LaTeX{} fragments
10972 #+vindex: org-format-latex-header
10973 Org mode can contain LaTeX math fragments, and it supports ways to
10974 process these for several export back-ends.  When exporting to LaTeX,
10975 the code is left as it is.  When exporting to HTML, Org can use either
10976 [[http://www.mathjax.org][MathJax]] (see [[*Math formatting in HTML export]]) or transcode the math
10977 into images (see [[*Previewing LaTeX fragments]]).
10979 LaTeX fragments do not need any special marking at all.  The following
10980 snippets are identified as LaTeX source code:
10982 - Environments of any kind[fn:112].  The only requirement is that the
10983   =\begin= statement appears on a new line, preceded by only
10984   whitespace.
10986 - Text within the usual LaTeX math delimiters.  To avoid conflicts
10987   with currency specifications, single =$= characters are only
10988   recognized as math delimiters if the enclosed text contains at most
10989   two line breaks, is directly attached to the =$= characters with no
10990   whitespace in between, and if the closing =$= is followed by
10991   whitespace, punctuation or a dash.  For the other delimiters, there
10992   is no such restriction, so when in doubt, use =\(...\)= as inline
10993   math delimiters.
10995 #+texinfo: @noindent
10996 For example:
10998 #+begin_example
10999   \begin{equation}                        % arbitrary environments,
11000   x=\sqrt{b}                              % even tables, figures
11001   \end{equation}                          % etc
11003   If $a^2=b$ and \( b=2 \), then the solution must be
11004   either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
11005 #+end_example
11007 #+vindex: org-export-with-latex
11008 LaTeX processing can be configured with the variable
11009 ~org-export-with-latex~.  The default setting is ~t~ which means
11010 MathJax for HTML, and no processing for ASCII and LaTeX back-ends.
11011 You can also set this variable on a per-file basis using one of these
11012 lines:
11014 | =#+OPTIONS: tex:t=        | Do the right thing automatically (MathJax) |
11015 | =#+OPTIONS: tex:nil=      | Do not process LaTeX fragments at all      |
11016 | =#+OPTIONS: tex:verbatim= | Verbatim export, for jsMath or so          |
11018 *** Previewing LaTeX fragments
11019 :PROPERTIES:
11020 :DESCRIPTION: What will this snippet look like?
11021 :END:
11022 #+cindex: @LaTeX{} fragments, preview
11024 #+vindex: org-preview-latex-default-process
11025 If you have a working LaTeX installation and =dvipng=, =dvisvgm= or
11026 =convert= installed[fn:113], LaTeX fragments can be processed to
11027 produce images of the typeset expressions to be used for inclusion
11028 while exporting to HTML (see [[*LaTeX fragments]]), or for inline
11029 previewing within Org mode.
11031 #+vindex: org-format-latex-options
11032 #+vindex: org-format-latex-header
11033 You can customize the variables ~org-format-latex-options~ and
11034 ~org-format-latex-header~ to influence some aspects of the preview.
11035 In particular, the ~:scale~ (and for HTML export, ~:html-scale~)
11036 property of the former can be used to adjust the size of the preview
11037 images.
11039 - {{{kbd(C-c C-x C-l)}}} (~org-toggle-latex-fragment~) ::
11040      #+kindex: C-c C-x C-l
11041      #+findex: org-toggle-latex-fragment
11043      Produce a preview image of the LaTeX fragment at point and
11044      overlay it over the source code.  If there is no fragment at
11045      point, process all fragments in the current entry (between two
11046      headlines).  When called with a prefix argument, process the
11047      entire subtree.  When called with two prefix arguments, or when
11048      the cursor is before the first headline, process the entire
11049      buffer.
11051 #+vindex: org-startup-with-latex-preview
11052 You can turn on the previewing of all LaTeX fragments in a file with
11054 : #+STARTUP: latexpreview
11056 To disable it, simply use
11058 : #+STARTUP: nolatexpreview
11060 *** Using CDLaTeX to enter math
11061 :PROPERTIES:
11062 :DESCRIPTION: Speed up entering of formulas.
11063 :ALT_TITLE: CDLaTeX mode
11064 :END:
11065 #+cindex: CD@LaTeX{}
11067 CDLaTeX mode is a minor mode that is normally used in combination with
11068 a major LaTeX mode like AUCTeX in order to speed-up insertion of
11069 environments and math templates.  Inside Org mode, you can make use of
11070 some of the features of CDLaTeX mode.  You need to install
11071 =cdlatex.el= and =texmathp.el= (the latter comes also with AUCTeX)
11072 from [[http://www.astro.uva.nl/~dominik/Tools/cdlatex]].  Do not use
11073 CDLaTeX mode itself under Org mode, but use the light version
11074 ~org-cdlatex-mode~ that comes as part of Org mode.  Turn it on for the
11075 current buffer with {{{kbd(M-x org-cdlatex-mode)}}}, or for all Org
11076 files with
11078 #+begin_src emacs-lisp
11079   (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
11080 #+end_src
11082 When this mode is enabled, the following features are present (for
11083 more details see the documentation of CDLaTeX mode):
11085 #+attr_texinfo: :sep ,
11086 - {{{kbd(C-c {)}}} ::
11087      #+kindex: C-c @{
11089      Insert an environment template.
11091 - {{{kbd(TAB)}}} ::
11092      #+kindex: TAB
11094      The {{{kbd(TAB)}}} expands the template if the cursor is inside
11095      a LaTeX fragment[fn:114].  For example, {{{kbd(TAB)}}} expands
11096      =fr= to =\frac{}{}= and position the cursor correctly inside the
11097      first brace.  Another {{{kbd(TAB)}}} gets you into the second
11098      brace.
11100      Even outside fragments, {{{kbd(TAB)}}} expands environment
11101      abbreviations at the beginning of a line.  For example, if you
11102      write =equ= at the beginning of a line and press {{{kbd(TAB)}}},
11103      this abbreviation is expanded to an =equation= environment.  To
11104      get a list of all abbreviations, type {{{kbd(M-x
11105      cdlatex-command-help)}}}.
11107 - {{{kbd(^)}}}, {{{kbd(_)}}} ::
11108      #+kindex: _
11109      #+kindex: ^
11110      #+vindex: cdlatex-simplify-sub-super-scripts
11112      Pressing {{{kbd(_)}}} and {{{kbd(^)}}} inside a LaTeX fragment
11113      inserts these characters together with a pair of braces.  If you
11114      use {{{kbd(TAB)}}} to move out of the braces, and if the braces
11115      surround only a single character or macro, they are removed again
11116      (depending on the variable ~cdlatex-simplify-sub-super-scripts~).
11118 - {{{kbd(`)}}} ::
11119      #+kindex: `
11121      Pressing the backquote followed by a character inserts math
11122      macros, also outside LaTeX fragments.  If you wait more than 1.5
11123      seconds after the backquote, a help window pops up.
11125 - {{{kbd(')}}} ::
11126      #+kindex: '
11128      Pressing the single-quote followed by another character modifies
11129      the symbol before point with an accent or a font.  If you wait
11130      more than 1.5 seconds after the single-quote, a help window pops
11131      up.  Character modification works only inside LaTeX fragments;
11132      outside the quote is normal.
11134 * Exporting
11135 :PROPERTIES:
11136 :DESCRIPTION: Sharing and publishing notes.
11137 :END:
11138 #+cindex: exporting
11140 Sometimes, you may want to pretty print your notes, publish them on
11141 the web or even share them with people not using Org.  In these cases,
11142 the Org export facilities can be used to convert your documents to
11143 a variety of other formats, while retaining as much structure (see
11144 [[*Document Structure]]) and markup (see [[*Markup for Rich Export]]) as
11145 possible.
11147 #+cindex: export back-end
11148 Libraries responsible for such translation are called back-ends.  Org
11149 ships with the following ones
11151 - /ascii/ (ASCII format)
11152 - /beamer/ (LaTeX Beamer format)
11153 - /html/ (HTML format)
11154 - /icalendar/ (iCalendar format)
11155 - /latex/ (LaTeX format)
11156 - /md/ (Markdown format)
11157 - /odt/ (OpenDocument Text format)
11158 - /org/ (Org format)
11159 - /texinfo/ (Texinfo format)
11160 - /man/ (Man page format)
11162 #+texinfo: @noindent
11163 Org also uses additional libraries located in =contrib/= directory
11164 (see [[*Installation]]).  Users can install additional export libraries
11165 for additional formats from the Emacs packaging system.  For easy
11166 discovery, these packages have a common naming scheme: ~ox-NAME~,
11167 where {{{var(NAME)}}} is one of the formats.  For example,
11168 ~ox-koma-letter~ /koma-letter/ back-end.
11170 #+vindex: org-export-backends
11171 Org loads back-ends for the following formats by default: ASCII, HTML,
11172 iCalendar, LaTeX and ODT.  Org can load additional back-ends either of
11173 two ways: through the ~org-export-backends~ variable configuration;
11174 or, by requiring the library in the Emacs init file like this:
11176 #+begin_src emacs-lisp
11177   (require 'ox-md)
11178 #+end_src
11180 ** The Export Dispatcher
11181 :PROPERTIES:
11182 :DESCRIPTION: The main interface.
11183 :END:
11184 #+cindex: dispatcher, for export commands
11185 #+cindex: Export, dispatcher
11187 The export dispatcher is the main interface for Org's exports.
11188 A hierarchical menu presents the currently configured export formats.
11189 Options are shown as easy toggle switches on the same screen.
11191 #+vindex: org-export-dispatch-use-expert-ui
11192 Org also has a minimal prompt interface for the export dispatcher.
11193 When the variable ~org-export-dispatch-use-expert-ui~ is set to
11194 a non-~nil~ value, Org prompts in the minibuffer.  To switch back to
11195 the hierarchical menu, press {{{kbd(?)}}}.
11197 - {{{kbd(C-c C-e)}}} (~org-export~) ::
11198      #+kindex: C-c C-e
11199      #+findex: org-export
11201      Invokes the export dispatcher interface.  The options show
11202      default settings.  The {{{kbd(C-u)}}} prefix argument preserves
11203      options from the previous export, including any sub-tree
11204      selections.
11206 Org exports the entire buffer by default.  If the Org buffer has an
11207 active region, then Org exports just that region.
11209 Within the dispatcher interface, the following key combinations can
11210 further alter what is exported, and how.
11212 - {{{kbd(C-a)}}} ::
11213      #+kindex: C-c C-e C-a
11215      Toggle asynchronous export.  Asynchronous export uses an external
11216      Emacs process with a specially configured initialization file to
11217      complete the exporting process in the background thereby
11218      releasing the current interface.  This is particularly useful
11219      when exporting long documents.
11221      Output from an asynchronous export is saved on the "the export
11222      stack".  To view this stack, call the export dispatcher with
11223      a double {{{kbd(C-u)}}} prefix argument.  If already in the
11224      export dispatcher menu, {{{kbd(&)}}} displays the stack.
11226      #+vindex: org-export-async-init-file
11227      To make the background export process the default, customize the
11228      variable, ~org-export-in-background~.  Additionally, you can set
11229      the initialization file used by the background process with
11230      ~org-export-async-init-file~.
11232      #+vindex: org-export-in-background
11233      You can make asynchronous export the default by setting
11234      ~org-export-in-background~.
11236 - {{{kbd(C-b)}}} ::
11237      #+kindex: C-c C-e C-b
11239      Toggle body-only export.  Useful for excluding headers and
11240      footers in the export.  Affects only those back-end formats that
11241      have such sections---like =<head>...</head>= in HTML.
11243 - {{{kbd(C-s}}} ::
11244      #+kindex: C-c C-e C-s
11246      Toggle sub-tree export.  When turned on, Org exports only the
11247      sub-tree starting from the cursor position at the time the export
11248      dispatcher was invoked.  Org uses the top heading of this
11249      sub-tree as the document's title.  If the cursor is not on
11250      a heading, Org uses the nearest enclosing header.  If the cursor
11251      is in the document preamble, Org signals an error and aborts
11252      export.
11254      #+vindex: org-export-initial-scope
11255      To make the sub-tree export the default, customize the variable
11256      ~org-export-initial-scope~.
11258 - {{{kbd(C-v)}}} ::
11259      #+kindex: C-c C-e C-v
11261      Toggle visible-only export.  Useful for exporting only visible
11262      parts of an Org document by adjusting outline visibility
11263      settings.
11265 ** Export Settings
11266 :PROPERTIES:
11267 :DESCRIPTION: Common export settings.
11268 :END:
11269 #+cindex: options, for export
11270 #+cindex: Export, settings
11272 #+cindex: OPTIONS, keyword
11273 Export options can be set: globally with variables; for an individual
11274 file by making variables buffer-local with in-buffer settings (see
11275 [[*Summary of In-Buffer Settings]]), by setting individual keywords, or by
11276 specifying them in a compact form with the =OPTIONS= keyword; or for
11277 a tree by setting properties (see [[*Properties and Columns]]).  Options
11278 set at a specific level override options set at a more general level.
11280 #+cindex: SETUPFILE, keyword
11281 In-buffer settings may appear anywhere in the file, either directly or
11282 indirectly through a file included using =#+SETUPFILE: filename or
11283 URL= syntax.  Option keyword sets tailored to a particular back-end
11284 can be inserted from the export dispatcher (see [[*The Export
11285 Dispatcher]]) using the =Insert template= command by pressing
11286 {{{kbd(#)}}}.  To insert keywords individually, a good way to make
11287 sure the keyword is correct is to type =#+= and then to use
11288 {{{kbd(M-TAB)}}}[fn:16] for completion.
11290 The export keywords available for every back-end, and their equivalent
11291 global variables, include:
11293 - =AUTHOR= ::
11295      #+cindex: AUTHOR, keyword
11296      #+vindex: user-full-name
11297      The document author (~user-full-name~).
11299 - =CREATOR= ::
11301      #+cindex: CREATOR, keyword
11302      #+vindex: org-expot-creator-string
11303      Entity responsible for output generation
11304      (~org-export-creator-string~).
11306 - =DATE= ::
11308      #+cindex: DATE, keyword
11309      #+vindex: org-export-date-timestamp-format
11310      A date or a time-stamp[fn:115].
11312 - =EMAIL= ::
11314      #+cindex: EMAIL, keyword
11315      #+vindex: user-mail-address
11316      The email address (~user-mail-address~).
11318 - =LANGUAGE= ::
11320      #+cindex: LANGUAGE, keyword
11321      #+vindex: org-export-default-language
11322      Language to use for translating certain strings
11323      (~org-export-default-language~).  With =#+LANGUAGE: fr=, for
11324      example, Org translates =Table of contents= to the French =Table
11325      des matières=.
11327 - =SELECT_TAGS= ::
11329      #+cindex: SELECT_TAGS, keyword
11330      #+vindex: org-export-select-tags
11331      The default value is ~("export")~.  When a tree is tagged with
11332      =export= (~org-export-select-tags~), Org selects that tree and
11333      its sub-trees for export.  Org excludes trees with =noexport=
11334      tags, see below.  When selectively exporting files with =export=
11335      tags set, Org does not export any text that appears before the
11336      first headline.
11338 - =EXCLUDE_TAGS= ::
11340      #+cindex: EXCLUDE_TAGS, keyword
11341      #+vindex: org-export-exclude-tags
11342      The default value is ~("noexport")~.  When a tree is tagged with
11343      =noexport= (~org-export-exclude-tags~), Org excludes that tree
11344      and its sub-trees from export.  Entries tagged with =noexport=
11345      are unconditionally excluded from the export, even if they have
11346      an =export= tag.  Even if a sub-tree is not exported, Org
11347      executes any code blocks contained there.
11349 - =TITLE= ::
11351      #+cindex: TITLE, keyword
11352      #+cindex: document title
11353      Org displays this title.  For long titles, use multiple =#+TITLE=
11354      lines.
11356 - =EXPORT_FILE_NAME= ::
11358      #+cindex: EXPORT_FILE_NAME, keyword
11359      The name of the output file to be generated.  Otherwise, Org
11360      generates the file name based on the buffer name and the
11361      extension based on the back-end format.
11363 The =OPTIONS= keyword is a compact form.  To configure multiple
11364 options, use several =OPTIONS= lines.  =OPTIONS= recognizes the
11365 following arguments.
11367 - ~'~ ::
11369      #+vindex: org-export-with-smart-quotes
11370      Toggle smart quotes (~org-export-with-smart-quotes~).  Depending
11371      on the language used, when activated, Org treats pairs of double
11372      quotes as primary quotes, pairs of single quotes as secondary
11373      quotes, and single quote marks as apostrophes.
11375 - ~*~ ::
11377      #+vindex: org-export-with-emphasize
11378      Toggle emphasized text (~org-export-with-emphasize~).
11380 - ~-~ ::
11382      #+vindex: org-export-with-special-strings
11383      Toggle conversion of special strings
11384      (~org-export-with-special-strings~).
11386 - ~:~ ::
11388      #+vindex: org-export-with-fixed-width
11389      Toggle fixed-width sections (~org-export-with-fixed-width~).
11391 - ~<~ ::
11393      #+vindex: org-export-with-timestamps
11394      Toggle inclusion of time/date active/inactive stamps
11395      (~org-export-with-timestamps~).
11397 - ~\n~ ::
11399      #+vindex: org-export-preserve-breaks
11400      Toggles whether to preserve line breaks
11401      (~org-export-preserve-breaks~).
11403 - ~^~ ::
11405      #+vindex: org-export-with-sub-superscripts
11406      Toggle TeX-like syntax for sub- and superscripts.  If you write
11407      =^:{}=, =a_{b}= is interpreted, but the simple =a_b= is left as
11408      it is (~org-export-with-sub-superscripts~).
11410 - ~arch~ ::
11412      #+vindex: org-export-with-archived-trees
11413      Configure how archived trees are exported.  When set to
11414      ~headline~, the export process skips the contents and processes
11415      only the headlines (~org-export-with-archived-trees~).
11417 - ~author~ ::
11419      #+vindex: org-export-with-author
11420      Toggle inclusion of author name into exported file
11421      (~org-export-with-author~).
11423 - ~broken-links~ ::
11425      #+vindex: org-export-with-broken-links
11426      Toggles if Org should continue exporting upon finding a broken
11427      internal link.  When set to ~mark~, Org clearly marks the problem
11428      link in the output (~org-export-with-broken-links~).
11430 - ~c~ ::
11432      #+vindex: org-export-with-clocks
11433      Toggle inclusion of CLOCK keywords (~org-export-with-clocks~).
11435 - ~creator~ ::
11437      #+vindex: org-export-with-creator
11438      Toggle inclusion of creator information in the exported file
11439      (~org-export-with-creator~).
11441 - ~d~ ::
11443      #+vindex: org-export-with-drawers
11444      Toggles inclusion of drawers, or list of drawers to include, or
11445      list of drawers to exclude (~org-export-with-drawers~).
11447 - ~date~ ::
11449      #+vindex: org-export-with-date
11450      Toggle inclusion of a date into exported file
11451      (~org-export-with-date~).
11453 - ~e~ ::
11455      #+vindex: org-export-with-entities
11456      Toggle inclusion of entities (~org-export-with-entities~).
11458 - ~email~ ::
11460      #+vindex: org-export-with-email
11461      Toggle inclusion of the author's e-mail into exported file
11462      (~org-export-with-email~).
11464 - ~f~ ::
11466      #+vindex: org-export-with-footnotes
11467      Toggle the inclusion of footnotes (~org-export-with-footnotes~).
11469 - ~H~ ::
11471      #+vindex: org-export-headline-levels
11472      Set the number of headline levels for export
11473      (~org-export-headline-levels~).  Below that level, headlines are
11474      treated differently.  In most back-ends, they become list items.
11476 - ~inline~ ::
11478      #+vindex: org-export-with-inlinetasks
11479      Toggle inclusion of inlinetasks (~org-export-with-inlinetasks~).
11481 - ~num~ ::
11483      #+vindex: org-export-with-section-numbers
11484      #+cindex: UNNUMBERED, property
11485      Toggle section-numbers (~org-export-with-section-numbers~).  When
11486      set to number N, Org numbers only those headlines at level N or
11487      above.  Set =UNNUMBERED= property to non-~nil~ to disable
11488      numbering of heading and subheadings entirely.  Moreover, when
11489      the value is =notoc= the headline, and all its children, do not
11490      appear in the table of contents either (see [[*Table of Contents]]).
11492 - ~p~ ::
11494      #+vindex: org-export-with-planning
11495      Toggle export of planning information
11496      (~org-export-with-planning~).  "Planning information" comes from
11497      lines located right after the headline and contain any
11498      combination of these cookies: =SCHEDULED=, =DEADLINE=, or
11499      =CLOSED=.
11501 - ~pri~ ::
11503      #+vindex: org-export-with-priority
11504      Toggle inclusion of priority cookies
11505      (~org-export-with-priority~).
11507 - ~prop~ ::
11509      #+vindex: org-export-with-properties
11510      Toggle inclusion of property drawers, or list the properties to
11511      include (~org-export-with-properties~).
11513 - ~stat~ ::
11515      #+vindex: org-export-with-statistics-cookies
11516      Toggle inclusion of statistics cookies
11517      (~org-export-with-statistics-cookies~).
11519 - ~tags~ ::
11521      #+vindex: org-export-with-tags
11522      Toggle inclusion of tags, may also be ~not-in-toc~
11523      (~org-export-with-tags~).
11525 - ~tasks~ ::
11527      #+vindex: org-export-with-tasks
11528      Toggle inclusion of tasks (TODO items); or ~nil~ to remove all
11529      tasks; or ~todo~ to remove DONE tasks; or list the keywords to
11530      keep (~org-export-with-tasks~).
11532 - ~tex~ ::
11534      #+vindex: org-export-with-latex
11535      ~nil~ does not export; ~t~ exports; ~verbatim~ keeps everything
11536      in verbatim (~org-export-with-latex~).
11538 - ~timestamp~ ::
11540      #+vindex: org-export-time-stamp-file
11541      Toggle inclusion of the creation time in the exported file
11542      (~org-export-time-stamp-file~).
11544 - ~title~ ::
11546      #+vindex: org-export-with-title
11547      Toggle inclusion of title (~org-export-with-title~).
11549 - ~toc~ ::
11551      #+vindex: org-export-with-toc
11552      Toggle inclusion of the table of contents, or set the level limit
11553      (~org-export-with-toc~).
11555 - ~todo~ ::
11557      #+vindex: org-export-with-todo-keywords
11558      Toggle inclusion of TODO keywords into exported text
11559      (~org-export-with-todo-keywords~).
11561 - ~|~ ::
11563      #+vindex: org-export-with-tables
11564      Toggle inclusion of tables (~org-export-with-tables~).
11566 When exporting sub-trees, special node properties in them can override
11567 the above keywords.  They are special because they have an =EXPORT_=
11568 prefix.  For example, =DATE= and =EXPORT_FILE_NAME= keywords become,
11569 respectively, =EXPORT_DATE= and =EXPORT_FILE_NAME=.  Except for
11570 =SETUPFILE=, all other keywords listed above have an =EXPORT_=
11571 equivalent.
11573 #+cindex: BIND, keyword
11574 #+vindex: org-export-allow-bind-keywords
11575 If ~org-export-allow-bind-keywords~ is non-~nil~, Emacs variables can
11576 become buffer-local during export by using the =BIND= keyword.  Its
11577 syntax is =#+BIND: variable value=.  This is particularly useful for
11578 in-buffer settings that cannot be changed using keywords.
11580 ** Table of Contents
11581 :PROPERTIES:
11582 :DESCRIPTION: The if and where of the table of contents.
11583 :END:
11584 #+cindex: table of contents
11585 #+cindex: list of tables
11586 #+cindex: list of listings
11588 #+cindex: @samp{toc}, in OPTIONS keyword
11589 #+vindex: org-export-with-toc
11590 The table of contents includes all headlines in the document.  Its
11591 depth is therefore the same as the headline levels in the file.  If
11592 you need to use a different depth, or turn it off entirely, set the
11593 ~org-export-with-toc~ variable accordingly.  You can achieve the same
11594 on a per file basis, using the following =toc= item in =OPTIONS=
11595 keyword:
11597 #+begin_example
11598   ,#+OPTIONS: toc:2          (only include two levels in TOC)
11599   ,#+OPTIONS: toc:nil        (no default TOC at all)
11600 #+end_example
11602 #+cindex: excluding entries from table of contents
11603 #+cindex: table of contents, exclude entries
11604 Org includes both numbered and unnumbered headlines in the table of
11605 contents[fn:116].  If you need to exclude an unnumbered headline,
11606 along with all its children, set the =UNNUMBERED= property to =notoc=
11607 value.
11609 #+begin_example
11610   ,* Subtree not numbered, not in table of contents either
11611     :PROPERTIES:
11612     :UNNUMBERED: notoc
11613     :END:
11614 #+end_example
11616 #+cindex: TOC, keyword
11617 Org normally inserts the table of contents directly before the first
11618 headline of the file.  To move the table of contents to a different
11619 location, first turn off the default with ~org-export-with-toc~
11620 variable or with =#+OPTIONS: toc:nil=.  Then insert =#+TOC: headlines
11621 N= at the desired location(s).
11623 #+begin_example
11624   ,#+OPTIONS: toc:nil
11625   ...
11626   ,#+TOC: headlines 2
11627 #+end_example
11629 To adjust the table of contents depth for a specific section of the
11630 Org document, append an additional =local= parameter.  This parameter
11631 becomes a relative depth for the current level.  The following example
11632 inserts a local table of contents, with direct children only.
11634 #+begin_example
11635   ,* Section
11636   ,#+TOC: headlines 1 local
11637 #+end_example
11639 Note that for this feature to work properly in LaTeX export, the Org
11640 file requires the inclusion of the titletoc package.  Because of
11641 compatibility issues, titletoc has to be loaded /before/ hyperref.
11642 Customize the ~org-latex-default-packages-alist~ variable.
11644 Use the =TOC= keyword to generate list of tables---respectively, all
11645 listings---with captions.
11647 #+begin_example
11648   ,#+TOC: listings
11649   ,#+TOC: tables
11650 #+end_example
11652 #+cindex: ALT_TITLE, property
11653 Normally Org uses the headline for its entry in the table of contents.
11654 But with =ALT_TITLE= property, a different entry can be specified for
11655 the table of contents.
11657 ** Include Files
11658 :PROPERTIES:
11659 :DESCRIPTION: Include additional files into a document.
11660 :END:
11661 #+cindex: include files, during export
11662 #+cindex: Export, include files
11663 #+cindex: INCLUDE, keyword
11665 During export, you can include the content of another file.  For
11666 example, to include your =.emacs= file, you could use:
11668 : #+INCLUDE: "~/.emacs" src emacs-lisp
11670 #+texinfo: @noindent
11671 The optional second and third parameter are the markup (e.g., =quote=,
11672 =example=, or =src=), and, if the markup is =src=, the language for
11673 formatting the contents.  The markup is optional; if it is not given,
11674 assume text is in Org syntax and process it normally.  The =INCLUDE=
11675 keyword also allows additional parameters =:prefix1= and =:prefix= to
11676 specify prefixes for the first line and for each following line,
11677 =:minlevel= in order to get Org mode content demoted to a specified
11678 level, as well as any options accepted by the selected markup.  For
11679 example, to include a file as an item, use:
11681 : #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
11683 You can also include a portion of a file by specifying a lines range
11684 using the =:lines= parameter.  The line at the upper end of the range
11685 is not included.  The start and/or the end of the range may be omitted
11686 to use the obvious defaults.
11688 - =#+INCLUDE: "~/.emacs" :lines "5-10"= ::
11690      Include lines 5 to 10, 10 excluded.
11692 - =#+INCLUDE: "~/.emacs" :lines "-10"=  ::
11694      Include lines 1 to 10, 10 excluded.
11696 - =#+INCLUDE: "~/.emacs" :lines "10-"=  ::
11698      Include lines from 10 to EOF.
11700 You can visit the file being included with the following command.
11702 - {{{kbd(C-c ')}}} (~org-edit~special~) ::
11703      #+kindex: C-c '
11704      #+findex: org-edit-special
11706      Visit the include file at point.
11708 ** Macro Replacement
11709 :PROPERTIES:
11710 :DESCRIPTION: Use macros to create templates.
11711 :END:
11712 #+cindex: macro replacement, during export
11713 #+cindex: MACRO, keyword
11715 #+vindex: org-export-global-macros
11716 Macros replace text snippets during export.  Macros are defined
11717 globally in ~org-export-global-macros~, or document-wise with the
11718 following syntax:
11720 : #+MACRO: name   replacement text; $1, $2 are arguments
11722 #+texinfo: @noindent
11723 which can be referenced using ={{{name(arg1, arg2)}}}=[fn:117].  For
11724 example
11726 #+begin_example
11727   ,#+MACRO: poem The rose is $1, The violet's $2. Life's ordered: Org assists you.
11728   {{{poem(red,blue)}}}
11729 #+end_example
11731 #+texinfo: @noindent
11732 becomes
11734 : The rose is red, The violet's blue. Life's ordered: Org assists you.
11736 As a special case, Org parses any replacement text starting with
11737 =(eval= as an Emacs Lisp expression and evaluates it accordingly.
11738 Within such templates, arguments become strings.  Thus, the following
11739 macro
11741 : #+MACRO: gnucheck (eval (concat "GNU/" (capitalize $1)))
11743 #+texinfo: @noindent
11744 turns ={{{gnucheck(linux)}}}= into =GNU/Linux= during export.
11746 Org recognizes macro references in following Org markup areas:
11747 paragraphs, headlines, verse blocks, tables cells and lists.  Org also
11748 recognizes macro references in keywords, such as =CAPTION=, =TITLE=,
11749 =AUTHOR=, =DATE=, and for some back-end specific export options.
11751 Org comes with following pre-defined macros:
11753 #+attr_texinfo: :sep ;
11754 - ={{{keyword(NAME)}}}=; ={{{title}}}=; ={{{author}}}=; ={{{email}}}= ::
11756      #+cindex: keyword, macro
11757      #+cindex: title, macro
11758      #+cindex: author, macro
11759      #+cindex: email, macro
11760      The =keyword= macro collects all values from {{{var(NAME)}}}
11761      keywords throughout the buffer, separated with white space.
11762      =title=, =author= and =email= macros are shortcuts for,
11763      respectively, ={{{keyword(TITLE)}}}=, ={{{keyword(AUTHOR)}}}= and
11764      ={{{keyword(EMAIL)}}}=.
11766 - ={{{date}}}=; ={{{date(FORMAT)}}}= ::
11768      #+cindex: date, macro
11769      This macro refers to the =DATE= keyword.  {{{var(FORMAT)}}} is an
11770      optional argument to the =date= macro that is used only if =DATE=
11771      is a single timestamp.  {{{var(FORMAT)}}} should be a format
11772      string understood by ~format-time-string~.
11774 - ={{{time(FORMAT)}}}=; ={{{modification-time(FORMAT, VC)}}}= ::
11776      #+cindex: time, macro
11777      #+cindex: modification time, macro
11778      These macros refer to the document's date and time of export and
11779      date and time of modification.  {{{var(FORMAT)}}} is a string
11780      understood by ~format-time-string~.  If the second argument to
11781      the ~modification-time~ macro is non-~nil~, Org uses =vc.el= to
11782      retrieve the document's modification time from the version
11783      control system.  Otherwise Org reads the file attributes.
11785 - ={{{input-file}}}= ::
11787      #+cindex: input file, macro
11788      This macro refers to the filename of the exported file.
11790 - ={{{property(PROPERTY-NAME)}}}=; ={{{property(PROPERTY-NAME, SEARCH OPTION)}}}= ::
11792      #+cindex: property, macro
11793      This macro returns the value of property {{{var(PROPERTY-NAME)}}}
11794      in the current entry.  If {{{var(SEARCH-OPTION)}}} (see [[*Search
11795      Options in File Links]]) refers to a remote entry, use it instead.
11797 - ={{{n}}}=; ={{{n(NAME)}}}=; ={{{n(NAME, ACTION)}}}= ::
11799      #+cindex: n, macro
11800      #+cindex: counter, macro
11801      This macro implements custom counters by returning the number of
11802      times the macro has been expanded so far while exporting the
11803      buffer.  You can create more than one counter using different
11804      {{{var(NAME)}}} values.  If {{{var(ACTION)}}} is =-=, previous
11805      value of the counter is held, i.e., the specified counter is not
11806      incremented.  If the value is a number, the specified counter is
11807      set to that value.  If it is any other non-empty string, the
11808      specified counter is reset to 1.  You may leave {{{var(NAME)}}}
11809      empty to reset the default counter.
11811 #+vindex: org-hide-macro-markers
11812 The surrounding brackets can be made invisible by setting
11813 ~org-hide-macro-markers~ non-~nil~.
11815 Org expands macros at the very beginning of the export process.
11817 ** Comment Lines
11818 :PROPERTIES:
11819 :DESCRIPTION: What will not be exported.
11820 :END:
11821 #+cindex: exporting, not
11823 #+cindex: comment lines
11824 Lines starting with zero or more whitespace characters followed by one
11825 =#= and a whitespace are treated as comments and, as such, are not
11826 exported.
11828 #+cindex: BEGIN_COMMENT
11829 #+cindex: comment block
11830 Likewise, regions surrounded by =#+BEGIN_COMMENT= ... =#+END_COMMENT=
11831 are not exported.
11833 #+cindex: comment trees
11834 Finally, a =COMMENT= keyword at the beginning of an entry, but after
11835 any other keyword or priority cookie, comments out the entire subtree.
11836 In this case, the subtree is not exported and no code block within it
11837 is executed either[fn:118].  The command below helps changing the
11838 comment status of a headline.
11840 - {{{kbd(C-c ;)}}} (~org-toggle-comment~) ::
11841      #+kindex: C-c ;
11842      #+findex: org-toggle-comment
11844      Toggle the =COMMENT= keyword at the beginning of an entry.
11846 ** ASCII/Latin-1/UTF-8 export
11847 :PROPERTIES:
11848 :DESCRIPTION: Exporting to flat files with encoding.
11849 :END:
11850 #+cindex: ASCII export
11851 #+cindex: Latin-1 export
11852 #+cindex: UTF-8 export
11854 ASCII export produces an output file containing only plain ASCII
11855 characters.  This is the simplest and most direct text output.  It
11856 does not contain any Org markup.  Latin-1 and UTF-8 export use
11857 additional characters and symbols available in these encoding
11858 standards.  All three of these export formats offer the most basic of
11859 text output for maximum portability.
11861 #+vindex: org-ascii-text-width
11862 On export, Org fills and justifies text according to the text width
11863 set in ~org-ascii-text-width~.
11865 #+vindex: org-ascii-links-to-notes
11866 Org exports links using a footnote-like style where the descriptive
11867 part is in the text and the link is in a note before the next heading.
11868 See the variable ~org-ascii-links-to-notes~ for details.
11870 *** ASCII export commands
11871 :PROPERTIES:
11872 :UNNUMBERED: notoc
11873 :END:
11875 #+attr_texinfo: :sep ,
11876 - {{{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)}}} ::
11877      #+kindex: C-c C-e t a
11878      #+kindex: C-c C-e t l
11879      #+kindex: C-c C-e t u
11880      #+findex: org-ascii-export-to-ascii
11882      Export as an ASCII file with a =.txt= extension.  For
11883      =myfile.org=, Org exports to =myfile.txt=, overwriting without
11884      warning.  For =myfile.txt=, Org exports to =myfile.txt.txt= in
11885      order to prevent data loss.
11887 #+attr_texinfo: :sep ,
11888 - {{{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)}}} ::
11889      #+kindex: C-c C-e t A
11890      #+kindex: C-c C-e t L
11891      #+kindex: C-c C-e t U
11892      #+findex: org-ascii-export-to-ascii
11894      Export to a temporary buffer.  Does not create a file.
11896 *** ASCII specific export settings
11897 :PROPERTIES:
11898 :UNNUMBERED: notoc
11899 :END:
11901 The ASCII export back-end has one extra keyword for customizing ASCII
11902 output.  Setting this keyword works similar to the general options
11903 (see [[*Export Settings]]).
11905 - =SUBTITLE= ::
11907      #+cindex: SUBTITLE, keyword
11908      The document subtitle.  For long subtitles, use multiple
11909      =#+SUBTITLE= lines in the Org file.  Org prints them on one
11910      continuous line, wrapping into multiple lines if necessary.
11912 *** Header and sectioning structure
11913 :PROPERTIES:
11914 :UNNUMBERED: notoc
11915 :END:
11917 Org converts the first three outline levels into headlines for ASCII
11918 export.  The remaining levels are turned into lists.  To change this
11919 cut-off point where levels become lists, see [[*Export Settings]].
11921 *** Quoting ASCII text
11922 :PROPERTIES:
11923 :UNNUMBERED: notoc
11924 :END:
11926 To insert text within the Org file by the ASCII back-end, use one the
11927 following constructs, inline, keyword, or export block:
11929 #+cindex: ASCII, keyword
11930 #+cindex: BEGIN_EXPORT ascii
11931 #+begin_example
11932   Inline text @@ascii:and additional text@@ within a paragraph.
11934   ,#+ASCII: Some text
11936   ,#+BEGIN_EXPORT ascii
11937   Org exports text in this block only when using ASCII back-end.
11938   ,#+END_EXPORT
11939 #+end_example
11941 *** ASCII specific attributes
11942 :PROPERTIES:
11943 :UNNUMBERED: notoc
11944 :END:
11945 #+cindex: ATTR_ASCII, keyword
11946 #+cindex: horizontal rules, in ASCII export
11948 ASCII back-end recognizes only one attribute, ~:width~, which
11949 specifies the width of an horizontal rule in number of characters.
11950 The keyword and syntax for specifying widths is:
11952 #+begin_example
11953   ,#+ATTR_ASCII: :width 10
11954   -----
11955 #+end_example
11957 *** ASCII special blocks
11958 :PROPERTIES:
11959 :UNNUMBERED: notoc
11960 :END:
11961 #+cindex: special blocks, in ASCII export
11962 #+cindex: BEGIN_JUSTIFYLEFT
11963 #+cindex: BEGIN_JUSTIFYRIGHT
11965 Besides =#+BEGIN_CENTER= blocks (see [[*Paragraphs]]), ASCII back-end has
11966 these two left and right justification blocks:
11968 #+begin_example
11969   ,#+BEGIN_JUSTIFYLEFT
11970   It's just a jump to the left...
11971   ,#+END_JUSTIFYLEFT
11973   ,#+BEGIN_JUSTIFYRIGHT
11974   ...and then a step to the right.
11975   ,#+END_JUSTIFYRIGHT
11976 #+end_example
11978 ** Beamer Export
11979 #+cindex: Beamer export
11981 Org uses Beamer export to convert an Org file tree structure into
11982 high-quality interactive slides for presentations.  Beamer is a LaTeX
11983 document class for creating presentations in PDF, HTML, and other
11984 popular display formats.
11986 *** Beamer export commands
11987 :PROPERTIES:
11988 :DESCRIPTION: For creating Beamer documents.
11989 :END:
11991 - {{{kbd(C-c C-e l b)}}} (~org-beamer-export-to-latex~) ::
11992      #+kindex: C-c C-e l b
11993      #+findex: org-beamer-export-to-latex
11995      Export as LaTeX file with a =.tex= extension.  For =myfile.org=,
11996      Org exports to =myfile.tex=, overwriting without warning.
11998 - {{{kbd(C-c C-e l B)}}} (~org-beamer-export-as-latex~) ::
11999      #+kindex: C-c C-e l B
12000      #+findex: org-beamer-export-as-latex
12002      Export to a temporary buffer.  Does not create a file.
12004 - {{{kbd(C-c C-e l P)}}} (~org-beamer-export-to-pdf~) ::
12005      #+kindex: C-c C-e l P
12006      #+findex: org-beamer-export-to-pdf
12008      Export as LaTeX file and then convert it to PDF format.
12010 - {{{kbd(C-c C-e l O)}}} ::
12011      #+kindex: C-c C-e l O
12013      Export as LaTeX file, convert it to PDF format, and then open the
12014      PDF file.
12016 *** Beamer specific export settings
12017 :PROPERTIES:
12018 :DESCRIPTION: For customizing Beamer export.
12019 :END:
12021 Beamer export back-end has several additional keywords for customizing
12022 Beamer output.  These keywords work similar to the general options
12023 settings (see [[*Export Settings]]).
12025 - =BEAMER_THEME= ::
12027      #+cindex: BEAMER_THEME, keyword
12028      #+vindex: org-beamer-theme
12029      The Beamer layout theme (~org-beamer-theme~).  Use square
12030      brackets for options.  For example:
12032      : #+BEAMER_THEME: Rochester [height=20pt]
12034 - =BEAMER_FONT_THEME= ::
12036      #+cindex: BEAMER_FONT_THEME, keyword
12037      The Beamer font theme.
12039 - =BEAMER_INNER_THEME= ::
12041      #+cindex: BEAMER_INNER_THEME, keyword
12042      The Beamer inner theme.
12044 - =BEAMER_OUTER_THEME= ::
12046      #+cindex: BEAMER_OUTER_THEME, keyword
12047      The Beamer outer theme.
12049 - =BEAMER_HEADER= ::
12051      #+cindex: BEAMER_HEADER, keyword
12052      Arbitrary lines inserted in the preamble, just before the
12053      =hyperref= settings.
12055 - =DESCRIPTION= ::
12057      #+cindex: DESCRIPTION, keyword
12058      The document description.  For long descriptions, use multiple
12059      =DESCRIPTION= keywords.  By default, =hyperref= inserts
12060      =DESCRIPTION= as metadata.  Use ~org-latex-hyperref-template~ to
12061      configure document metadata.  Use ~org-latex-title-command~ to
12062      configure typesetting of description as part of front matter.
12064 - =KEYWORDS= ::
12066      #+cindex: KEYWORDS, keyword
12067      The keywords for defining the contents of the document.  Use
12068      multiple =KEYWORDS= lines if necessary.  By default, =hyperref=
12069      inserts =KEYWORDS= as metadata.  Use
12070      ~org-latex-hyperref-template~ to configure document metadata.
12071      Use ~org-latex-title-command~ to configure typesetting of
12072      keywords as part of front matter.
12074 - =SUBTITLE= ::
12076      #+cindex: SUBTITLE, keyword
12077      Document's subtitle.  For typesetting, use
12078      ~org-beamer-subtitle-format~ string.  Use
12079      ~org-latex-hyperref-template~ to configure document metadata.
12080      Use ~org-latex-title-command~ to configure typesetting of
12081      subtitle as part of front matter.
12083 *** Frames and Blocks in Beamer
12084 :PROPERTIES:
12085 :DESCRIPTION: For composing Beamer slides.
12086 :END:
12088 Org transforms heading levels into Beamer's sectioning elements,
12089 frames and blocks.  Any Org tree with a not-too-deep-level nesting
12090 should in principle be exportable as a Beamer presentation.
12093   #+vindex: org-beamer-frame-level
12094   Org headlines become Beamer frames when the heading level in Org is
12095   equal to ~org-beamer-frame-level~ or =H= value in a =OPTIONS= line
12096   (see [[*Export Settings]]).
12098   #+cindex: BEAMER_ENV, property
12099   Org overrides headlines to frames conversion for the current tree of
12100   an Org file if it encounters the =BEAMER_ENV= property set to
12101   =frame= or =fullframe=.  Org ignores whatever
12102   ~org-beamer-frame-level~ happens to be for that headline level in
12103   the Org tree.  In Beamer terminology, a full frame is a frame
12104   without its title.
12106 - Org exports a Beamer frame's objects as block environments.  Org can
12107   enforce wrapping in special block types when =BEAMER_ENV= property
12108   is set[fn:119].  For valid values see
12109   ~org-beamer-environments-default~.  To add more values, see
12110   ~org-beamer-environments-extra~.
12111   #+vindex: org-beamer-environments-default
12112   #+vindex: org-beamer-environments-extra
12115   #+cindex: BEAMER_REF, property
12116   If =BEAMER_ENV= is set to =appendix=, Org exports the entry as an
12117   appendix.  When set to =note=, Org exports the entry as a note
12118   within the frame or between frames, depending on the entry's heading
12119   level.  When set to =noteNH=, Org exports the entry as a note
12120   without its title.  When set to =againframe=, Org exports the entry
12121   with =\againframe= command, which makes setting the =BEAMER_REF=
12122   property mandatory because =\againframe= needs frame to resume.
12124   When =ignoreheading= is set, Org export ignores the entry's headline
12125   but not its content.  This is useful for inserting content between
12126   frames.  It is also useful for properly closing a =column=
12127   environment.  @end itemize
12129   #+cindex: BEAMER_ACT, property
12130   #+cindex: BEAMER_OPT, property
12131   When =BEAMER_ACT= is set for a headline, Org export translates that
12132   headline as an overlay or action specification.  When enclosed in
12133   square brackets, Org export makes the overlay specification
12134   a default.  Use =BEAMER_OPT= to set any options applicable to the
12135   current Beamer frame or block.  The Beamer export back-end wraps
12136   with appropriate angular or square brackets.  It also adds the
12137   =fragile= option for any code that may require a verbatim block.
12139   #+cindex: BEAMER_COL, property
12140   To create a column on the Beamer slide, use the =BEAMER_COL=
12141   property for its headline in the Org file.  Set the value of
12142   =BEAMER_COL= to a decimal number representing the fraction of the
12143   total text width.  Beamer export uses this value to set the column's
12144   width and fills the column with the contents of the Org entry.  If
12145   the Org entry has no specific environment defined, Beamer export
12146   ignores the heading.  If the Org entry has a defined environment,
12147   Beamer export uses the heading as title.  Behind the scenes, Beamer
12148   export automatically handles LaTeX column separations for contiguous
12149   headlines.  To manually adjust them for any unique configurations
12150   needs, use the =BEAMER_ENV= property.
12152 *** Beamer specific syntax
12153 :PROPERTIES:
12154 :DESCRIPTION: For using in Org documents.
12155 :END:
12157 Since Org's Beamer export back-end is an extension of the LaTeX
12158 back-end, it recognizes other LaTeX specific syntax---for example,
12159 =#+LATEX:= or =#+ATTR_LATEX:=.  See [[*LaTeX Export]], for details.
12161 Beamer export wraps the table of contents generated with =toc:t=
12162 =OPTION= keyword in a =frame= environment.  Beamer export does not
12163 wrap the table of contents generated with =TOC= keyword (see [[*Table of
12164 Contents]]).  Use square brackets for specifying options.
12166 : #+TOC: headlines [currentsection]
12168 Insert Beamer-specific code using the following constructs:
12170 #+cindex: BEAMER, keyword
12171 #+cindex: BEGIN_EXPORT beamer
12172 #+begin_example
12173   ,#+BEAMER: \pause
12175   ,#+BEGIN_EXPORT beamer
12176     Only Beamer export back-end exports this.
12177   ,#+END_BEAMER
12179   Text @@beamer:some code@@ within a paragraph.
12180 #+end_example
12182 Inline constructs, such as the last one above, are useful for adding
12183 overlay specifications to objects with ~bold~, ~item~, ~link~,
12184 ~radio-target~ and ~target~ types.  Enclose the value in angular
12185 brackets and place the specification at the beginning of the object as
12186 shown in this example:
12188 :  A *@@beamer:<2->@@useful* feature
12190 #+cindex: ATTR_BEAMER, keyword
12191 Beamer export recognizes the =ATTR_BEAMER= keyword with the following
12192 attributes from Beamer configurations: =:environment= for changing
12193 local Beamer environment, =:overlay= for specifying Beamer overlays in
12194 angular or square brackets, and =:options= for inserting optional
12195 arguments.
12197 #+begin_example
12198   ,#+ATTR_BEAMER: :environment nonindentlist
12199   - item 1, not indented
12200   - item 2, not indented
12201   - item 3, not indented
12202 #+end_example
12204 #+begin_example
12205   ,#+ATTR_BEAMER: :overlay <+->
12206   - item 1
12207   - item 2
12208 #+end_example
12210 #+begin_example
12211   ,#+ATTR_BEAMER: :options [Lagrange]
12212   Let $G$ be a finite group, and let $H$ be
12213   a subgroup of $G$.  Then the order of $H$ divides the order of $G$.
12214 #+end_example
12216 *** Editing support
12217 :PROPERTIES:
12218 :DESCRIPTION: Editing support.
12219 :END:
12221 The ~org-beamer-mode~ is a special minor mode for faster editing of
12222 Beamer documents.
12224 : #+STARTUP: beamer
12226 - {{{kbd(C-c C-b)}}} (~org-beamer-select-environment~) ::
12227      #+kindex: C-c C-b
12228      #+findex: org-beamer-select-environment
12230      The ~org-beamer-mode~ provides this key for quicker selections in
12231      Beamer normal environments, and for selecting the =BEAMER_COL=
12232      property.
12234 *** A Beamer example
12235 :PROPERTIES:
12236 :DESCRIPTION: A complete presentation.
12237 :END:
12239 Here is an example of an Org document ready for Beamer export.
12241 #+begin_example
12242   ;#+TITLE: Example Presentation
12243   ;#+AUTHOR: Carsten Dominik
12244   ;#+OPTIONS: H:2 toc:t num:t
12245   ;#+LATEX_CLASS: beamer
12246   ;#+LATEX_CLASS_OPTIONS: [presentation]
12247   ;#+BEAMER_THEME: Madrid
12248   ;#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
12250   ,* This is the first structural section
12252   ,** Frame 1
12253   ,*** Thanks to Eric Fraga                                           :B_block:
12254       :PROPERTIES:
12255       :BEAMER_COL: 0.48
12256       :BEAMER_ENV: block
12257       :END:
12258       for the first viable Beamer setup in Org
12259   ,*** Thanks to everyone else                                        :B_block:
12260       :PROPERTIES:
12261       :BEAMER_COL: 0.48
12262       :BEAMER_ACT: <2->
12263       :BEAMER_ENV: block
12264       :END:
12265       for contributing to the discussion
12266   ,**** This will be formatted as a beamer note                       :B_note:
12267        :PROPERTIES:
12268        :BEAMER_env: note
12269        :END:
12270   ,** Frame 2 (where we will not use columns)
12271   ,*** Request
12272       Please test this stuff!
12273 #+end_example
12275 ** HTML Export
12276 :PROPERTIES:
12277 :DESCRIPTION: Exporting to HTML.
12278 :END:
12279 #+cindex: HTML export
12281 Org mode contains an HTML exporter with extensive HTML formatting
12282 compatible with XHTML 1.0 strict standard.
12284 *** HTML export commands
12285 :PROPERTIES:
12286 :DESCRIPTION: Invoking HTML export.
12287 :END:
12289 - {{{kbd(C-c C-e h h)}}} (~org-html-export-to-html~) ::
12290      #+kindex: C-c C-e h h
12291      #+kindex: C-c C-e h o
12292      #+findex: org-html-export-to-html
12294      Export as HTML file with a =.html= extension.  For =myfile.org=,
12295      Org exports to =myfile.html=, overwriting without warning.
12296      {{{kbd{C-c C-e h o)}}} exports to HTML and opens it in a web
12297      browser.
12299 - {{{kbd(C-c C-e h H)}}} (~org-html-export-as-html~) ::
12300      #+kindex: C-c C-e h H
12301      #+findex: org-html-export-as-html
12303      Exports to a temporary buffer.  Does not create a file.
12305 *** HTML specific export settings
12306 :PROPERTIES:
12307 :DESCRIPTION: Settings for HTML export.
12308 :END:
12310 HTML export has a number of keywords, similar to the general options
12311 settings described in [[*Export Settings]].
12313 - =DESCRIPTION= ::
12315      #+cindex: DESCRIPTION, keyword
12316      This is the document's description, which the HTML exporter
12317      inserts it as a HTML meta tag in the HTML file.  For long
12318      descriptions, use multiple =DESCRIPTION= lines.  The exporter
12319      takes care of wrapping the lines properly.
12321 - =HTML_DOCTYPE= ::
12323      #+cindex: HTML_DOCTYPE, keyword
12324      #+vindex: org-html-doctype
12325      Specify the document type, for example: HTML5
12326      (~org-html-doctype~).
12328 - =HTML_CONTAINER= ::
12330      #+cindex: HTML_CONTAINER, keyword
12331      #+vindex: org-html-container-element
12332      Specify the HTML container, such as =div=, for wrapping sections
12333      and elements (~org-html-container-element~).
12335 - =HTML_LINK_HOME= ::
12337      #+cindex: HTML_LINK_HOME, keyword
12338      #+vindex: org-html-link-home
12339      The URL for home link (~org-html-link-home~).
12341 - =HTML_LINK_UP= ::
12343      #+cindex: HTML_LINK_UP, keyword
12344      #+vindex: org-html-link-up
12345      The URL for the up link of exported HTML pages
12346      (~org-html-link-up~).
12348 - =HTML_MATHJAX= ::
12350      #+cindex: HTML_MATHJAX, keyword
12351      #+vindex: org-html-mathjax-options
12352      Options for MathJax (~org-html-mathjax-options~).  MathJax is
12353      used to typeset LaTeX math in HTML documents.  See [[*Math
12354      formatting in HTML export]], for an example.
12356 - =HTML_HEAD= ::
12358      #+cindex: HTML_HEAD, keyword
12359      #+vindex: org-html-head
12360      Arbitrary lines for appending to the HTML document's head
12361      (~org-html-head~).
12363 - =HTML_HEAD_EXTRA= ::
12365      #+cindex: HTML_HEAD_EXTRA, keyword
12366      #+vindex: org-html-head-extra
12367      More arbitrary lines for appending to the HTML document's head
12368      (~org-html-head-extra~).
12370 - =KEYWORDS= ::
12372      #+cindex: KEYWORDS, keyword
12373      Keywords to describe the document's content.  HTML exporter
12374      inserts these keywords as HTML meta tags.  For long keywords, use
12375      multiple =KEYWORDS= lines.
12377 - =LATEX_HEADER= ::
12379      #+cindex: LATEX_HEADER, keyword
12380      Arbitrary lines for appending to the preamble; HTML exporter
12381      appends when transcoding LaTeX fragments to images (see [[*Math
12382      formatting in HTML export]]).
12384 - =SUBTITLE= ::
12386      #+cindex: SUBTITLE, keyword
12387      The document's subtitle.  HTML exporter formats subtitle if
12388      document type is =HTML5= and the CSS has a =subtitle= class.
12390 Some of these keywords are explained in more detail in the following
12391 sections of the manual.
12393 *** HTML doctypes
12394 :PROPERTIES:
12395 :DESCRIPTION: Exporting various (X)HTML flavors.
12396 :END:
12398 Org can export to various (X)HTML flavors.
12400 #+vindex: org-html-doctype
12401 #+vindex: org-html-doctype-alist
12402 Set the ~org-html-doctype~ variable for different (X)HTML variants.
12403 Depending on the variant, the HTML exporter adjusts the syntax of HTML
12404 conversion accordingly.  Org includes the following ready-made
12405 variants:
12407 - ~"html4-strict"~
12408 - ~"html4-transitional"~
12409 - ~"html4-frameset"~
12410 - ~"xhtml-strict"~
12411 - ~"xhtml-transitional"~
12412 - ~"xhtml-frameset"~
12413 - ~"xhtml-11"~
12414 - ~"html5"~
12415 - ~"xhtml5"~
12417 #+texinfo: @noindent
12418 See the variable ~org-html-doctype-alist~ for details.  The default is
12419 ~"xhtml-strict"~.
12421 #+vindex: org-html-html5-fancy
12422 #+cindex: HTML5, export new elements
12423 Org's HTML exporter does not by default enable new block elements
12424 introduced with the HTML5 standard.  To enable them, set
12425 ~org-html-html5-fancy~ to non-~nil~.  Or use an =OPTIONS= line in the
12426 file to set =html5-fancy=.
12428 HTML5 documents can now have arbitrary =#+BEGIN= ... =#+END= blocks.
12429 For example:
12431 #+begin_example
12432   ,#+BEGIN_aside
12433     Lorem ipsum
12434   ,#+END_aside
12435 #+end_example
12437 #+texinfo: @noindent
12438 exports to:
12440 #+begin_src html
12441   <aside>
12442     <p>Lorem ipsum</p>
12443   </aside>
12444 #+end_src
12446 #+texinfo: @noindent
12447 while this:
12449 #+begin_example
12450   ,#+ATTR_HTML: :controls controls :width 350
12451   ,#+BEGIN_video
12452   ,#+HTML: <source src="movie.mp4" type="video/mp4">
12453   ,#+HTML: <source src="movie.ogg" type="video/ogg">
12454   Your browser does not support the video tag.
12455   ,#+END_video
12456 #+end_example
12458 #+texinfo: @noindent
12459 exports to:
12461 #+begin_src html
12462   <video controls="controls" width="350">
12463     <source src="movie.mp4" type="video/mp4">
12464       <source src="movie.ogg" type="video/ogg">
12465         <p>Your browser does not support the video tag.</p>
12466   </video>
12467 #+end_src
12469 #+vindex: org-html-html5-elements
12470 When special blocks do not have a corresponding HTML5 element, the
12471 HTML exporter reverts to standard translation (see
12472 ~org-html-html5-elements~).  For example, =#+BEGIN_lederhosen= exports
12473 to ~<div class="lederhosen">~.
12475 Special blocks cannot have headlines.  For the HTML exporter to wrap
12476 the headline and its contents in ~<section>~ or ~<article>~ tags, set
12477 the =HTML_CONTAINER= property for the headline.
12479 *** HTML preamble and postamble
12480 :PROPERTIES:
12481 :DESCRIPTION: Inserting preamble and postamble.
12482 :END:
12483 #+vindex: org-html-preamble
12484 #+vindex: org-html-postamble
12485 #+vindex: org-html-preamble-format
12486 #+vindex: org-html-postamble-format
12487 #+vindex: org-html-validation-link
12488 #+vindex: org-export-creator-string
12489 #+vindex: org-export-time-stamp-file
12491 The HTML exporter has delineations for preamble and postamble.  The
12492 default value for ~org-html-preamble~ is ~t~, which makes the HTML
12493 exporter insert the preamble.  See the variable
12494 ~org-html-preamble-format~ for the format string.
12496 Set ~org-html-preamble~ to a string to override the default format
12497 string.  If the string is a function, the HTML exporter expects the
12498 function to return a string upon execution.  The HTML exporter inserts
12499 this string in the preamble.  The HTML exporter does not insert
12500 a preamble if ~org-html-preamble~ is set ~nil~.
12502 The default value for ~org-html-postamble~ is ~auto~, which makes the
12503 HTML exporter build a postamble from looking up author's name, email
12504 address, creator's name, and date.  Set ~org-html-postamble~ to ~t~ to
12505 insert the postamble in the format specified in the
12506 ~org-html-postamble-format~ variable.  The HTML exporter does not
12507 insert a postamble if ~org-html-postamble~ is set to ~nil~.
12509 *** Quoting HTML tags
12510 :PROPERTIES:
12511 :DESCRIPTION: Using direct HTML in Org files.
12512 :END:
12514 The HTML export back-end transforms =<= and =>= to =&lt;= and =&gt;=.
12516 To include raw HTML code in the Org file so the HTML export back-end
12517 can insert that HTML code in the output, use this inline syntax:
12518 =@@html:...@@=.  For example:
12520 : @@html:<b>@@bold text@@html:</b>@@
12522 #+cindex: HTML, keyword
12523 #+cindex: BEGIN_EXPORT html
12524 For larger raw HTML code blocks, use these HTML export code blocks:
12526 #+begin_example
12527   ,#+HTML: Literal HTML code for export
12529   ,#+BEGIN_EXPORT html
12530     All lines between these markers are exported literally
12531   ,#+END_EXPORT
12532 #+end_example
12534 *** Links in HTML export
12535 :PROPERTIES:
12536 :DESCRIPTION: Inserting and formatting links.
12537 :END:
12538 #+cindex: links, in HTML export
12539 #+cindex: internal links, in HTML export
12540 #+cindex: external links, in HTML export
12542 The HTML export back-end transforms Org's internal links (see
12543 [[*Internal Links]]) to equivalent HTML links in the output.  The back-end
12544 similarly handles Org's automatic links created by radio targets (see
12545 [[*Radio Targets]]) similarly.  For Org links to external files, the
12546 back-end transforms the links to /relative/ paths.
12548 #+vindex: org-html-link-org-files-as-html
12549 For Org links to other =.org= files, the back-end automatically
12550 changes the file extension to =.html= and makes file paths relative.
12551 If the =.org= files have an equivalent =.html= version at the same
12552 location, then the converted links should work without any further
12553 manual intervention.  However, to disable this automatic path
12554 translation, set ~org-html-link-org-files-as-html~ to ~nil~.  When
12555 disabled, the HTML export back-end substitutes the ID-based links in
12556 the HTML output.  For more about linking files when publishing to
12557 a directory, see [[*Publishing links]].
12559 Org files can also have special directives to the HTML export
12560 back-end.  For example, by using =#+ATTR_HTML= lines to specify new
12561 format attributes to ~<a>~ or ~<img>~ tags.  This example shows
12562 changing the link's title and style:
12564 #+cindex: ATTR_HTML, keyword
12565 #+begin_example
12566   ,#+ATTR_HTML: :title The Org mode homepage :style color:red;
12567   [[https://orgmode.org]]
12568 #+end_example
12570 *** Tables in HTML export
12571 :PROPERTIES:
12572 :DESCRIPTION: How to modify the formatting of tables.
12573 :END:
12574 #+cindex: tables, in HTML
12575 #+vindex: org-export-html-table-tag
12577 The HTML export back-end uses ~org-html-table-default-attributes~ when
12578 exporting Org tables to HTML.  By default, the exporter does not draw
12579 frames and cell borders.  To change for this for a table, use the
12580 following lines before the table in the Org file:
12582 #+cindex: CAPTION, keyword
12583 #+cindex: ATTR_HTML, keyword
12584 #+begin_example
12585    ,#+CAPTION: This is a table with lines around and between cells
12586    ,#+ATTR_HTML: border="2" rules="all" frame="border"
12587 #+end_example
12589 The HTML export back-end preserves column groupings in Org tables (see
12590 [[*Column Groups]]) when exporting to HTML.
12592 Additional options for customizing tables for HTML export.
12594 - ~org-html-table-align-individual-fields~ ::
12596      #+vindex: org-html-table-align-individual-fields
12597      Non-~nil~ attaches style attributes for alignment to each table
12598      field.
12600 - ~org-html-table-caption-above~ ::
12602      #+vindex: org-html-table-caption-above
12603      Non-~nil~ places caption string at the beginning of the table.
12605 - ~org-html-table-data-tags~ ::
12607      #+vindex: org-html-table-data-tags
12608      Opening and ending tags for table data fields.
12610 - ~org-html-table-default-attributes~ ::
12612      #+vindex: org-html-table-default-attributes
12613      Default attributes and values for table tags.
12615 - ~org-html-table-header-tags~ ::
12617      #+vindex: org-html-table-header-tags
12618      Opening and ending tags for table's header fields.
12620 - ~org-html-table-row-tags~ ::
12622      #+vindex: org-html-table-row-tags
12623      Opening and ending tags for table rows.
12625 - ~org-html-table-use-header-tags-for-first-column~ ::
12627      #+vindex: org-html-table-use-header-tags-for-first-column
12628      Non-~nil~ formats column one in tables with header tags.
12630 *** Images in HTML export
12631 :PROPERTIES:
12632 :DESCRIPTION: How to insert figures into HTML output.
12633 :END:
12634 #+cindex: images, inline in HTML
12635 #+cindex: inlining images in HTML
12637 The HTML export back-end has features to convert Org image links to
12638 HTML inline images and HTML clickable image links.
12640 #+vindex: org-html-inline-images
12641 When the link in the Org file has no description, the HTML export
12642 back-end by default in-lines that image.  For example:
12643 =[[file:myimg.jpg]]= is in-lined, while =[[file:myimg.jpg][the image]]= links to the text,
12644 =the image=.  For more details, see the variable
12645 ~org-html-inline-images~.
12647 On the other hand, if the description part of the Org link is itself
12648 another link, such as =file:= or =http:= URL pointing to an image, the
12649 HTML export back-end in-lines this image and links to the main image.
12650 This Org syntax enables the back-end to link low-resolution thumbnail
12651 to the high-resolution version of the image, as shown in this example:
12653 : [[file:highres.jpg][file:thumb.jpg]]
12655 To change attributes of in-lined images, use =#+ATTR_HTML= lines in
12656 the Org file.  This example shows realignment to right, and adds ~alt~
12657 and ~title~ attributes in support of text viewers and modern web
12658 accessibility standards.
12660 #+cindex: CAPTION, keyword
12661 #+cindex: ATTR_HTML, keyword
12662 #+begin_example
12663   ,#+CAPTION: A black cat stalking a spider
12664   ,#+ATTR_HTML: :alt cat/spider image :title Action! :align right
12665   [[./img/a.jpg]]
12666 #+end_example
12668 #+texinfo: @noindent
12669 The HTML export back-end copies the =http= links from the Org file as
12672 *** Math formatting in HTML export
12673 :PROPERTIES:
12674 :DESCRIPTION: Beautiful math also on the web.
12675 :END:
12676 #+cindex: MathJax
12677 #+cindex: dvipng
12678 #+cindex: dvisvgm
12679 #+cindex: ImageMagick
12681 #+vindex: org-html-mathjax-options~
12682 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
12683 different ways on HTML pages.  The default is to use the [[http://www.mathjax.org][MathJax]],
12684 which should work out of the box with Org[fn:120].  Some MathJax
12685 display options can be configured via ~org-html-mathjax-options~, or
12686 in the buffer.  For example, with the following settings,
12688 #+begin_example
12689   ,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
12690   ,#+HTML_MATHJAX: cancel.js noErrors.js
12691 #+end_example
12693 #+texinfo: @noindent
12694 equation labels are displayed on the left margin and equations are
12695 five em from the left margin.  In addition, it loads the two MathJax
12696 extensions =cancel.js= and =noErrors.js=[fn:121].
12698 #+vindex: org-html-mathjax-template
12699 See the docstring of ~org-html-mathjax-options~ for all supported
12700 variables.  The MathJax template can be configure via
12701 ~org-html-mathjax-template~.
12703 If you prefer, you can also request that LaTeX fragments are processed
12704 into small images that will be inserted into the browser page.  Before
12705 the availability of MathJax, this was the default method for Org
12706 files.  This method requires that the dvipng program, dvisvgm or
12707 ImageMagick suite is available on your system.  You can still get this
12708 processing with
12710 : #+OPTIONS: tex:dvipng
12712 : #+OPTIONS: tex:dvisvgm
12714 #+texinfo: @noindent
12717 : #+OPTIONS: tex:imagemagick
12719 *** Text areas in HTML export
12720 :PROPERTIES:
12721 :DESCRIPTION: An alternate way to show an example.
12722 :END:
12724 #+cindex: text areas, in HTML
12725 Before Org mode's Babel, one popular approach to publishing code in
12726 HTML was by using =:textarea=.  The advantage of this approach was
12727 that copying and pasting was built into browsers with simple
12728 JavaScript commands.  Even editing before pasting was made simple.
12730 The HTML export back-end can create such text areas.  It requires an
12731 =#+ATTR_HTML= line as shown in the example below with the =:textarea=
12732 option.  This must be followed by either an example or a source code
12733 block.  Other Org block types do not honor the =:textarea= option.
12735 By default, the HTML export back-end creates a text area 80 characters
12736 wide and height just enough to fit the content.  Override these
12737 defaults with =:width= and =:height= options on the =#+ATTR_HTML=
12738 line.
12740 #+begin_example
12741   ,#+ATTR_HTML: :textarea t :width 40
12742   ,#+BEGIN_EXAMPLE
12743     (defun org-xor (a b)
12744        "Exclusive or."
12745        (if a (not b) b))
12746   ,#+END_EXAMPLE
12747 #+end_example
12749 *** CSS support
12750 :PROPERTIES:
12751 :DESCRIPTION: Changing the appearance of the output.
12752 :END:
12753 #+cindex: CSS, for HTML export
12754 #+cindex: HTML export, CSS
12756 #+vindex: org-export-html-todo-kwd-class-prefix
12757 #+vindex: org-export-html-tag-class-prefix
12758 You can modify the CSS style definitions for the exported file.  The
12759 HTML exporter assigns the following special CSS classes[fn:122] to
12760 appropriate parts of the document---your style specifications may
12761 change these, in addition to any of the standard classes like for
12762 headlines, tables, etc.
12764 | ~p.author~           | author information, including email                    |
12765 | ~p.date~             | publishing date                                        |
12766 | ~p.creator~          | creator info, about org mode version                   |
12767 | ~.title~             | document title                                         |
12768 | ~.subtitle~          | document subtitle                                      |
12769 | ~.todo~              | TODO keywords, all not-done states                     |
12770 | ~.done~              | the DONE keywords, all states that count as done       |
12771 | ~.WAITING~           | each TODO keyword also uses a class named after itself |
12772 | ~.timestamp~         | timestamp                                              |
12773 | ~.timestamp-kwd~     | keyword associated with a timestamp, like =SCHEDULED=  |
12774 | ~.timestamp-wrapper~ | span around keyword plus timestamp                     |
12775 | ~.tag~               | tag in a headline                                      |
12776 | ~._HOME~             | each tag uses itself as a class, "@" replaced by "_"   |
12777 | ~.target~            | target for links                                       |
12778 | ~.linenr~            | the line number in a code example                      |
12779 | ~.code-highlighted~  | for highlighting referenced code lines                 |
12780 | ~div.outline-N~      | div for outline level N (headline plus text)           |
12781 | ~div.outline-text-N~ | extra div for text at outline level N                  |
12782 | ~.section-number-N~  | section number in headlines, different for each level  |
12783 | ~.figure-number~     | label like "Figure 1:"                                 |
12784 | ~.table-number~      | label like "Table 1:"                                  |
12785 | ~.listing-number~    | label like "Listing 1:"                                |
12786 | ~div.figure~         | how to format an in-lined image                        |
12787 | ~pre.src~            | formatted source code                                  |
12788 | ~pre.example~        | normal example                                         |
12789 | ~p.verse~            | verse paragraph                                        |
12790 | ~div.footnotes~      | footnote section headline                              |
12791 | ~p.footnote~         | footnote definition paragraph, containing a footnote   |
12792 | ~.footref~           | a footnote reference number (always a <sup>)           |
12793 | ~.footnum~           | footnote number in footnote definition (always <sup>)  |
12794 | ~.org-svg~           | default class for a linked =.svg= image                |
12796 #+vindex: org-html-style-default
12797 #+vindex: org-html-head
12798 #+vindex: org-html-head-extra
12799 #+cindex: HTML_INCLUDE_STYLE, keyword
12800 The HTML export back-end includes a compact default style in each
12801 exported HTML file.  To override the default style with another style,
12802 use these keywords in the Org file.  They will replace the global
12803 defaults the HTML exporter uses.
12805 #+cindex: HTML_HEAD, keyword
12806 #+cindex: HTML_HEAD_EXTRA, keyword
12807 #+begin_example
12808   ,#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
12809   ,#+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
12810 #+end_example
12812 #+vindex: org-html-head-include-default-style
12813 To just turn off the default style, customize
12814 ~org-html-head-include-default-style~ variable, or use this option
12815 line in the Org file.
12817 #+cindex: html-style, OPTIONS item
12818 : #+OPTIONS: html-style:nil
12820 For longer style definitions, either use several =HTML_HEAD= and
12821 =HTML_HEAD_EXTRA= keywords, or use ~<style> ... </style>~ blocks
12822 around them.  Both of these approaches can avoid referring to an
12823 external file.
12825 #+cindex: HTML_CONTAINER_CLASS, property
12826 In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS=
12827 property to assign a class to the tree.  In order to specify CSS
12828 styles for a particular headline, you can use the id specified in
12829 a =CUSTOM_ID= property.
12831 Never change the ~org-html-style-default~ constant.  Instead use other
12832 simpler ways of customizing as described above.
12834 *** JavaScript supported display of web pages
12835 :PROPERTIES:
12836 :DESCRIPTION: Info and folding in a web browser.
12837 :ALT_TITLE: JavaScript support
12838 :END:
12840 Sebastian Rose has written a JavaScript program especially designed to
12841 enhance the web viewing experience of HTML files created with Org.
12842 This program enhances large files in two different ways of viewing.
12843 One is an /Info/-like mode where each section is displayed separately
12844 and navigation can be done with the {{{kbd(n)}}} and {{{kbd(p)}}}
12845 keys, and some other keys as well, press {{{kbd(?)}}} for an overview
12846 of the available keys.  The second one has a /folding/ view, much like
12847 Org provides inside Emacs.  The script is available at
12848 https://orgmode.org/org-info.js and the documentation at
12849 https://orgmode.org/worg/code/org-info-js/.  The script is hosted on
12850 https://orgmode.org, but for reliability, prefer installing it on your
12851 own web server.
12853 To use this program, just add this line to the Org file:
12855 #+cindex: INFOJS_OPT, keyword
12856 : #+INFOJS_OPT: view:info toc:nil
12858 #+texinfo: @noindent
12859 The HTML header now has the code needed to automatically invoke the
12860 script.  For setting options, use the syntax from the above line for
12861 options described below:
12863 - =path:= ::
12865      The path to the script.  The default is to grab the script from
12866      [[https://orgmode.org/org-info.js]], but you might want to have
12867      a local copy and use a path like =../scripts/org-info.js=.
12869 - =view:= ::
12871      Initial view when the website is first shown.  Possible values are:
12873      | =info=     | Info-like interface with one section per page          |
12874      | =overview= | Folding interface, initially showing only top-level    |
12875      | =content=  | Folding interface, starting with all headlines visible |
12876      | =showall=  | Folding interface, all headlines and text visible      |
12878 - =sdepth:= ::
12880      Maximum headline level still considered as an independent section
12881      for info and folding modes.  The default is taken from
12882      ~org-export-headline-levels~, i.e., the =H= switch in =OPTIONS=.
12883      If this is smaller than in ~org-export-headline-levels~, each
12884      info/folding section can still contain child headlines.
12886 - =toc:= ::
12888      Should the table of contents /initially/ be visible?  Even when
12889      =nil=, you can always get to the "toc" with {{{kbd(i)}}}.
12891 - =tdepth:= ::
12893      The depth of the table of contents.  The defaults are taken from
12894      the variables ~org-export-headline-levels~ and
12895      ~org-export-with-toc~.
12897 - =ftoc:= ::
12899      Does the CSS of the page specify a fixed position for the "toc"?
12900      If yes, the toc is displayed as a section.
12902 - =ltoc:= ::
12904      Should there be short contents (children) in each section?  Make
12905      this =above= if the section should be above initial text.
12907 - =mouse:= ::
12909      Headings are highlighted when the mouse is over them.  Should be
12910      =underline= (default) or a background color like =#cccccc=.
12912 - =buttons:= ::
12914      Should view-toggle buttons be everywhere?  When =nil= (the
12915      default), only one such button is present.
12917 #+texinfo: @noindent
12918 #+vindex: org-infojs-options
12919 #+vindex: org-export-html-use-infojs
12920 You can choose default values for these options by customizing the
12921 variable ~org-infojs-options~.  If you always want to apply the script
12922 to your pages, configure the variable ~org-export-html-use-infojs~.
12924 ** LaTeX Export
12925 :PROPERTIES:
12926 :DESCRIPTION: Exporting to @LaTeX{} and processing to PDF.
12927 :END:
12928 #+cindex: @LaTeX{} export
12929 #+cindex: PDF export
12931 The LaTeX export back-end can handle complex documents, incorporate
12932 standard or custom LaTeX document classes, generate documents using
12933 alternate LaTeX engines, and produce fully linked PDF files with
12934 indexes, bibliographies, and tables of contents, destined for
12935 interactive online viewing or high-quality print publication.
12937 While the details are covered in-depth in this section, here are some
12938 quick references to variables for the impatient: for engines, see
12939 ~org-latex-compiler~; for build sequences, see
12940 ~org-latex-pdf-process~; for packages, see
12941 ~org-latex-default-packages-alist~ and ~org-latex-packages-alist~.
12943 An important note about the LaTeX export back-end: it is sensitive to
12944 blank lines in the Org document.  That's because LaTeX itself depends
12945 on blank lines to tell apart syntactical elements, such as paragraphs.
12947 *** LaTeX/PDF export commands
12948 :PROPERTIES:
12949 :DESCRIPTION: For producing @LaTeX{} and PDF documents.
12950 :END:
12952 - {{{kbd(C-c C-e l l)}}} (~org-latex-export-to-latex~) ::
12954      #+kindex: C-c C-e l l
12955      #+findex: org-latex-export-to-latex~
12956      Export to a LaTeX file with a =.tex= extension.  For
12957      =myfile.org=, Org exports to =myfile.tex=, overwriting without
12958      warning.
12960 - {{{kbd(C-c C-e l L)}}} (~org-latex-export-as-latex~) ::
12962      #+kindex: C-c C-e l L
12963      #+findex: org-latex-export-as-latex
12964      Export to a temporary buffer.  Do not create a file.
12966 - {{{kbd(C-c C-e l p)}}} (~org-latex-export-to-pdf~) ::
12968      #+kindex: C-c C-e l p
12969      #+findex: org-latex-export-to-pdf
12970      Export as LaTeX file and convert it to PDF file.
12972 - {{{kbd(C-c C-e l o)}}} ::
12974      #+kindex: C-c C-e l o
12975      Export as LaTeX file and convert it to PDF, then open the PDF
12976      using the default viewer.
12978 - {{{kbd(M-x org-export-region-as-latex)}}} ::
12980      Convert the region to LaTeX under the assumption that it was in Org
12981      mode syntax before.  This is a global command that can be invoked in
12982      any buffer.
12984 #+vindex: org-latex-compiler
12985 #+vindex: org-latex-bibtex-compiler
12986 #+vindex: org-latex-default-packages-alist
12987 #+cindex: pdflatex
12988 #+cindex: xelatex
12989 #+cindex: lualatex
12990 #+cindex: LATEX_COMPILER, keyword
12991 The LaTeX export back-end can use any of these LaTeX engines:
12992 =pdflatex=, =xelatex=, and =lualatex=.  These engines compile LaTeX
12993 files with different compilers, packages, and output options.  The
12994 LaTeX export back-end finds the compiler version to use from
12995 ~org-latex-compiler~ variable or the =#+LATEX_COMPILER= keyword in the
12996 Org file.  See the docstring for the
12997 ~org-latex-default-packages-alist~ for loading packages with certain
12998 compilers.  Also see ~org-latex-bibtex-compiler~ to set the
12999 bibliography compiler[fn:123].
13001 *** LaTeX specific export settings
13002 :PROPERTIES:
13003 :DESCRIPTION: Unique to this @LaTeX{} back-end.
13004 :END:
13006 The LaTeX export back-end has several additional keywords for
13007 customizing LaTeX output.  Setting these keywords works similar to the
13008 general options (see [[*Export Settings]]).
13010 #+attr_texinfo: :sep ,
13011 - =DESCRIPTION= ::
13012      #+cindex: DESCRIPTION, keyword
13013      #+vindex: org-latex-hyperref-template
13014      #+vindex: org-latex-title-command
13015      The document's description.  The description along with author
13016      name, keywords, and related file metadata are inserted in the
13017      output file by the hyperref package.  See
13018      ~org-latex-hyperref-template~ for customizing metadata items.
13019      See ~org-latex-title-command~ for typesetting description into
13020      the document's front matter.  Use multiple =DESCRIPTION= keywords
13021      for long descriptions.
13023 - =LATEX_CLASS= ::
13025      #+cindex: LATEX_CLASS, keyword
13026      #+vindex: org-latex-default-class
13027      #+vindex: org-latex-classes
13028      This is LaTeX document class, such as /article/, /report/,
13029      /book/, and so on, which contain predefined preamble and headline
13030      level mapping that the LaTeX export back-end needs.  The back-end
13031      reads the default class name from the ~org-latex-default-class~
13032      variable.  Org has /article/ as the default class.  A valid
13033      default class must be an element of ~org-latex-classes~.
13035 - =LATEX_CLASS_OPTIONS= ::
13037      #+cindex: LATEX_CLASS_OPTIONS, keyword
13038      Options the LaTeX export back-end uses when calling the LaTeX
13039      document class.
13041 - =LATEX_COMPILER= ::
13043      #+cindex: LATEX_COMPILER, keyword
13044      #+vindex: org-latex-compiler
13045      The compiler, such as =pdflatex=, =xelatex=, =lualatex=, for
13046      producing the PDF.  See ~org-latex-compiler~.
13048 - =LATEX_HEADER=, =LATEX_HEADER_EXTRA= ::
13050      #+cindex: LATEX_HEADER, keyword
13051      #+cindex: LATEX_HEADER_EXTRA, keyword
13052      #+vindex: org-latex-classes
13053      Arbitrary lines to add to the document's preamble, before the
13054      hyperref settings.  See ~org-latex-classes~ for adjusting the
13055      structure and order of the LaTeX headers.
13057 - =KEYWORDS= ::
13059      #+cindex: KEYWORDS, keyword
13060      #+vindex: org-latex-hyperref-template
13061      #+vindex: org-latex-title-command
13062      The keywords for the document.  The description along with author
13063      name, keywords, and related file metadata are inserted in the
13064      output file by the hyperref package.  See
13065      ~org-latex-hyperref-template~ for customizing metadata items.
13066      See ~org-latex-title-command~ for typesetting description into
13067      the document's front matter.  Use multiple =KEYWORDS= lines if
13068      necessary.
13070 - =SUBTITLE= ::
13072      #+cindex: SUBTITLE, keyword
13073      #+vindex: org-latex-subtitle-separate
13074      #+vindex: org-latex-subtitle-format
13075      The document's subtitle.  It is typeset as per
13076      ~org-latex-subtitle-format~.  If ~org-latex-subtitle-separate~ is
13077      non-~nil~, it is typed as part of the ~\title~ macro.  See
13078      ~org-latex-hyperref-template~ for customizing metadata items.
13079      See ~org-latex-title-command~ for typesetting description
13080      into the document's front matter.
13082 The following sections have further details.
13084 *** LaTeX header and sectioning structure
13085 :PROPERTIES:
13086 :DESCRIPTION: Setting up the export file structure.
13087 :ALT_TITLE: LaTeX header and sectioning
13088 :END:
13089 #+cindex: @LaTeX{} class
13090 #+cindex: @LaTeX{} sectioning structure
13091 #+cindex: @LaTeX{} header
13092 #+cindex: header, for @LaTeX{} files
13093 #+cindex: sectioning structure, for @LaTeX{} export
13095 The LaTeX export back-end converts the first three of Org's outline
13096 levels into LaTeX headlines.  The remaining Org levels are exported as
13097 lists.  To change this globally for the cut-off point between levels
13098 and lists, (see [[*Export Settings]]).
13100 By default, the LaTeX export back-end uses the /article/ class.
13102 #+vindex: org-latex-default-class
13103 #+vindex: org-latex-classes
13104 #+vindex: org-latex-default-packages-alist
13105 #+vindex: org-latex-packages-alist
13106 To change the default class globally, edit ~org-latex-default-class~.
13107 To change the default class locally in an Org file, add option lines
13108 =#+LATEX_CLASS: myclass=.  To change the default class for just a part
13109 of the Org file, set a sub-tree property, =EXPORT_LATEX_CLASS=.  The
13110 class name entered here must be valid member of ~org-latex-classes~.
13111 This variable defines a header template for each class into which the
13112 exporter splices the values of ~org-latex-default-packages-alist~ and
13113 ~org-latex-packages-alist~.  Use the same three variables to define
13114 custom sectioning or custom classes.
13116 #+cindex: LATEX_CLASS, keyword
13117 #+cindex: LATEX_CLASS_OPTIONS, keyword
13118 #+cindex: EXPORT_LATEX_CLASS, property
13119 #+cindex: EXPORT_LATEX_CLASS_OPTIONS, property
13120 The LaTeX export back-end sends the =LATEX_CLASS_OPTIONS= keyword and
13121 =EXPORT_LATEX_CLASS_OPTIONS= property as options to the LaTeX
13122 ~\documentclass~ macro.  The options and the syntax for specifying
13123 them, including enclosing them in square brackets, follow LaTeX
13124 conventions.
13126 : #+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
13128 #+cindex: LATEX_HEADER, keyword
13129 #+cindex: LATEX_HEADER_EXTRA, keyword
13130 The LaTeX export back-end appends values from =LATEX_HEADER= and
13131 =LATEX_HEADER_EXTRA= keywords to the LaTeX header.  The docstring for
13132 ~org-latex-classes~ explains in more detail.  Also note that LaTeX
13133 export back-end does not append =LATEX_HEADER_EXTRA= to the header
13134 when previewing LaTeX snippets (see [[*Previewing LaTeX fragments]]).
13136 A sample Org file with the above headers:
13138 #+begin_example
13139   ,#+LATEX_CLASS: article
13140   ,#+LATEX_CLASS_OPTIONS: [a4paper]
13141   ,#+LATEX_HEADER: \usepackage{xyz}
13143   ,* Headline 1
13144     some text
13145   ,* Headline 2
13146     some more text
13147 #+end_example
13149 *** Quoting LaTeX code
13150 :PROPERTIES:
13151 :DESCRIPTION: Incorporating literal @LaTeX{} code.
13152 :END:
13154 The LaTeX export back-end can insert any arbitrary LaTeX code, see
13155 [[*Embedded LaTeX]].  There are three ways to embed such code in the Org
13156 file and they all use different quoting syntax.
13158 #+cindex: inline, in @LaTeX{} export
13159 Inserting in-line quoted with @ symbols:
13161 : Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
13163 #+cindex: LATEX, keyword
13164 Inserting as one or more keyword lines in the Org file:
13166 : #+LATEX: any arbitrary LaTeX code
13168 #+cindex: BEGIN_EXPORT latex
13169 Inserting as an export block in the Org file, where the back-end
13170 exports any code between begin and end markers:
13172 #+begin_example
13173   ,#+BEGIN_EXPORT latex
13174     any arbitrary LaTeX code
13175   ,#+END_EXPORT
13176 #+end_example
13178 *** Tables in LaTeX export
13179 :PROPERTIES:
13180 :DESCRIPTION: Options for exporting tables to @LaTeX{}.
13181 :END:
13182 #+cindex: tables, in @LaTeX{} export
13184 The LaTeX export back-end can pass several LaTeX attributes for table
13185 contents and layout.  Besides specifying label and caption (see
13186 [[*Images and Tables]]), the other valid LaTeX attributes include:
13188 #+attr_texinfo: :sep ,
13189 - =:mode= ::
13191      #+vindex: org-latex-default-table-mode
13192      The LaTeX export back-end wraps the table differently depending
13193      on the mode for accurate rendering of math symbols.  Mode is
13194      either =table=, =math=, =inline-math= or =verbatim=.
13196      For =math= or =inline-math= mode, LaTeX export back-end wraps the
13197      table in a math environment, but every cell in it is exported
13198      as-is.  The LaTeX export back-end determines the default mode
13199      from ~org-latex-default-table-mode~.  The LaTeX export back-end
13200      merges contiguous tables in the same mode into a single
13201      environment.
13203 - =:environment= ::
13205      #+vindex: org-latex-default-table-environment
13206      Set the default LaTeX table environment for the LaTeX export
13207      back-end to use when exporting Org tables.  Common LaTeX table
13208      environments are provided by these packages: tabularx, longtable,
13209      array, tabu, and bmatrix.  For packages, such as tabularx and
13210      tabu, or any newer replacements, include them in the
13211      ~org-latex-packages-alist~ variable so the LaTeX export back-end
13212      can insert the appropriate load package headers in the converted
13213      LaTeX file.  Look in the docstring for the
13214      ~org-latex-packages-alist~ variable for configuring these
13215      packages for LaTeX snippet previews, if any.
13217 - =:caption= ::
13219      Use =CAPTION= keyword to set a simple caption for a table (see
13220      [[*Images and Tables]]).  For custom captions, use =:caption=
13221      attribute, which accepts raw LaTeX code.  =:caption= value
13222      overrides =CAPTION= value.
13224 - =:float=, =:placement= ::
13226      The table environments by default are not floats in LaTeX.  To
13227      make them floating objects use =:float= with one of the following
13228      options: =sideways=, =multicolumn=, =t=, and =nil=.
13230      LaTeX floats can also have additional layout =:placement=
13231      attributes.  These are the usual =[h t b p ! H]= permissions
13232      specified in square brackets.  Note that for =:float sideways=
13233      tables, the LaTeX export back-end ignores =:placement=
13234      attributes.
13236 - =:align=, =:font=, =:width= ::
13238      The LaTeX export back-end uses these attributes for regular
13239      tables to set their alignments, fonts, and widths.
13241 - =:spread= ::
13243      When =:spread= is non-~nil~, the LaTeX export back-end spreads or
13244      shrinks the table by the =:width= for tabu and longtabu
13245      environments.  =:spread= has no effect if =:width= is not set.
13247 - =:booktabs=, =:center=, =:rmlines= ::
13249      #+vindex: org-latex-tables-booktabs
13250      #+vindex: org-latex-tables-centered
13251      All three commands are toggles.  =:booktabs= brings in modern
13252      typesetting enhancements to regular tables.  The booktabs package
13253      has to be loaded through ~org-latex-packages-alist~.  =:center=
13254      is for centering the table.  =:rmlines= removes all but the very
13255      first horizontal line made of ASCII characters from "table.el"
13256      tables only.
13258 - =:math-prefix=, =:math-suffix=, =:math-arguments= ::
13260      The LaTeX export back-end inserts =:math-prefix= string value in
13261      a math environment before the table.  The LaTeX export back-end
13262      inserts =:math-suffix= string value in a math environment after
13263      the table.  The LaTeX export back-end inserts =:math-arguments=
13264      string value between the macro name and the table's contents.
13265      =:math-arguments= comes in use for matrix macros that require
13266      more than one argument, such as =qbordermatrix=.
13268 LaTeX table attributes help formatting tables for a wide range of
13269 situations, such as matrix product or spanning multiple pages:
13271 #+begin_example
13272   ,#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
13273   | ... | ... |
13274   | ... | ... |
13276   ,#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
13277   | a | b |
13278   | c | d |
13279   ,#+ATTR_LATEX: :mode math :environment bmatrix
13280   | 1 | 2 |
13281   | 3 | 4 |
13282 #+end_example
13284 Set the caption with the LaTeX command
13285 =\bicaption{HeadingA}{HeadingB}=:
13287 #+begin_example
13288   ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13289   | ... | ... |
13290   | ... | ... |
13291 #+end_example
13293 *** Images in LaTeX export
13294 :PROPERTIES:
13295 :DESCRIPTION: How to insert figures into @LaTeX{} output.
13296 :END:
13297 #+cindex: images, inline in LaTeX
13298 #+cindex: inlining images in LaTeX
13299 #+cindex: ATTR_LATEX, keyword
13301 The LaTeX export back-end processes image links in Org files that do
13302 not have descriptions, such as these links =[[file:img.jpg]]= or
13303 =[[./img.jpg]]=, as direct image insertions in the final PDF output.  In
13304 the PDF, they are no longer links but actual images embedded on the
13305 page.  The LaTeX export back-end uses =\includegraphics= macro to
13306 insert the image.  But for TikZ (http://sourceforge.net/projects/pgf/)
13307 images, the back-end uses an ~\input~ macro wrapped within
13308 a ~tikzpicture~ environment.
13310 For specifying image =:width=, =:height=, and other =:options=, use
13311 this syntax:
13313 #+begin_example
13314   ,#+ATTR_LATEX: :width 5cm :options angle=90
13315   [[./img/sed-hr4049.pdf]]
13316 #+end_example
13318 For custom commands for captions, use the =:caption= attribute.  It
13319 overrides the default =#+CAPTION= value:
13321 #+begin_example
13322   ,#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
13323   [[./img/sed-hr4049.pdf]]
13324 #+end_example
13326 When captions follow the method as described in [[*Images and Tables]],
13327 the LaTeX export back-end wraps the picture in a floating =figure=
13328 environment.  To float an image without specifying a caption, set the
13329 =:float= attribute to one of the following:
13331 - =t= ::
13333      For a standard =figure= environment; used by default whenever an
13334      image has a caption.
13336 - =multicolumn= ::
13338      To span the image across multiple columns of a page; the back-end
13339      wraps the image in a =figure*= environment.
13341 - =wrap= ::
13343      For text to flow around the image on the right; the figure
13344      occupies the left half of the page.
13346 - =sideways= ::
13348      For a new page with the image sideways, rotated ninety degrees,
13349      in a =sidewaysfigure= environment; overrides =:placement=
13350      setting.
13352 - =nil= ::
13354      To avoid a =:float= even if using a caption.
13356 #+texinfo: @noindent
13357 Use the =placement= attribute to modify a floating environment's
13358 placement.
13360 #+begin_example
13361   ,#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth}
13362   [[./img/hst.png]]
13363 #+end_example
13365 #+vindex: org-latex-images-centered
13366 #+cindex: center image in LaTeX export
13367 #+cindex: image, centering in LaTeX export
13368 The LaTeX export back-end centers all images by default.  Setting
13369 =:center= to =nil= disables centering.  To disable centering globally,
13370 set ~org-latex-images-centered~ to =t=.
13372 Set the =:comment-include= attribute to non-~nil~ value for the LaTeX
13373 export back-end to comment out the =\includegraphics= macro.
13375 *** Plain lists in LaTeX export
13376 :PROPERTIES:
13377 :DESCRIPTION: Attributes specific to lists.
13378 :END:
13380 #+cindex: plain lists, in @LaTeX{} export
13381 #+cindex: ATTR_LATEX, keyword
13382 The LaTeX export back-end accepts the =environment= and =options=
13383 attributes for plain lists.  Both attributes work together for
13384 customizing lists, as shown in the examples:
13386 #+begin_example
13387   ,#+LATEX_HEADER: \usepackage[inline]{enumitem}
13388   Some ways to say "Hello":
13389   ,#+ATTR_LATEX: :environment itemize*
13390   ,#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}]
13391   - Hola
13392   - Bonjour
13393   - Guten Tag.
13394 #+end_example
13396 Since LaTeX supports only four levels of nesting for lists, use an
13397 external package, such as =enumitem= in LaTeX, for levels deeper than
13398 four:
13400 #+begin_example
13401   ,#+LATEX_HEADER: \usepackage{enumitem}
13402   ,#+LATEX_HEADER: \renewlist{itemize}{itemize}{9}
13403   ,#+LATEX_HEADER: \setlist[itemize]{label=$\circ$}
13404   - One
13405     - Two
13406       - Three
13407         - Four
13408           - Five
13409 #+end_example
13411 *** Source blocks in LaTeX export
13412 :PROPERTIES:
13413 :DESCRIPTION: Attributes specific to source code blocks.
13414 :END:
13415 #+cindex: source blocks, in @LaTeX{} export
13416 #+cindex: ATTR_LATEX, keyword
13418 The LaTeX export back-end can make source code blocks into floating
13419 objects through the attributes =:float= and =:options=.  For =:float=:
13421 - =t= ::
13423      Makes a source block float; by default floats any source block
13424      with a caption.
13426 - =multicolumn= ::
13428      Spans the source block across multiple columns of a page.
13430 - =nil= ::
13432      Avoids a =:float= even if using a caption; useful for source code
13433      blocks that may not fit on a page.
13435 #+begin_example
13436   ,#+ATTR_LATEX: :float nil
13437   ,#+BEGIN_SRC emacs-lisp
13438     Lisp code that may not fit in a single page.
13439   ,#+END_SRC
13440 #+end_example
13442 #+vindex: org-latex-listings-options
13443 #+vindex: org-latex-minted-options
13444 The LaTeX export back-end passes string values in =:options= to LaTeX
13445 packages for customization of that specific source block.  In the
13446 example below, the =:options= are set for Minted.  Minted is a source
13447 code highlighting LaTeX package with many configurable options.
13449 #+begin_example
13450   ,#+ATTR_LATEX: :options commentstyle=\bfseries
13451   ,#+BEGIN_SRC emacs-lisp
13452     (defun Fib (n)
13453       (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
13454   ,#+END_SRC
13455 #+end_example
13457 To apply similar configuration options for all source blocks in
13458 a file, use the ~org-latex-listings-options~ and
13459 ~org-latex-minted-options~ variables.
13461 *** Example blocks in LaTeX export
13462 :PROPERTIES:
13463 :DESCRIPTION: Attributes specific to example blocks.
13464 :END:
13465 #+cindex: example blocks, in @LaTeX{} export
13466 #+cindex: verbatim blocks, in @LaTeX{} export
13467 #+cindex: ATTR_LATEX, keyword
13469 The LaTeX export back-end wraps the contents of example blocks in
13470 a =verbatim= environment.  To change this behavior to use another
13471 environment globally, specify an appropriate export filter (see
13472 [[*Advanced Configuration]]).  To change this behavior to use another
13473 environment for each block, use the =:environment= parameter to
13474 specify a custom environment.
13476 #+begin_example
13477   ,#+ATTR_LATEX: :environment myverbatim
13478   ,#+BEGIN_EXAMPLE
13479     This sentence is false.
13480   ,#+END_EXAMPLE
13481 #+end_example
13483 *** Special blocks in LaTeX export
13484 :PROPERTIES:
13485 :DESCRIPTION: Attributes specific to special blocks.
13486 :END:
13488 #+cindex: special blocks, in @LaTeX{} export
13489 #+cindex: abstract, in @LaTeX{} export
13490 #+cindex: proof, in @LaTeX{} export
13491 #+cindex: ATTR_LATEX, keyword
13493 For other special blocks in the Org file, the LaTeX export back-end
13494 makes a special environment of the same name.  The back-end also takes
13495 =:options=, if any, and appends as-is to that environment's opening
13496 string.  For example:
13498 #+begin_example
13499   ,#+BEGIN_abstract
13500     We demonstrate how to solve the Syracuse problem.
13501   ,#+END_abstract
13503   ,#+ATTR_LATEX: :options [Proof of important theorem]
13504   ,#+BEGIN_proof
13505     ...
13506     Therefore, any even number greater than 2 is the sum of two primes.
13507   ,#+END_proof
13508 #+end_example
13510 #+texinfo: @noindent
13511 exports to
13513 #+begin_example
13514   \begin{abstract}
13515     We demonstrate how to solve the Syracuse problem.
13516   \end{abstract}
13518   \begin{proof}[Proof of important theorem]
13519     ...
13520     Therefore, any even number greater than 2 is the sum of two primes.
13521   \end{proof}
13522 #+end_example
13524 If you need to insert a specific caption command, use =:caption=
13525 attribute.  It overrides standard =CAPTION= value, if any.  For
13526 example:
13528 #+begin_example
13529   ,#+ATTR_LATEX: :caption \MyCaption{HeadingA}
13530   ,#+BEGIN_proof
13531     ...
13532   ,#+END_proof
13533 #+end_example
13535 *** Horizontal rules in LaTeX export
13536 :PROPERTIES:
13537 :DESCRIPTION: Attributes specific to horizontal rules.
13538 :END:
13539 #+cindex: horizontal rules, in @LaTeX{} export
13540 #+cindex: ATTR_LATEX, keyword
13542 The LaTeX export back-end converts horizontal rules by the specified
13543 =:width= and =:thickness= attributes.  For example:
13545 #+begin_example
13546   ,#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
13547   -----
13548 #+end_example
13550 ** Markdown Export
13551 :PROPERTIES:
13552 :DESCRIPTION: Exporting to Markdown.
13553 :END:
13554 #+cindex: Markdown export
13556 The Markdown export back-end, "md", converts an Org file to a Markdown
13557 format, as defined at http://daringfireball.net/projects/markdown/.
13559 Since "md" is built on top of the HTML back-end, any Org constructs
13560 not supported by Markdown, such as tables, the underlying "html"
13561 back-end (see [[*HTML Export]]) converts them.
13563 *** Markdown export commands
13564 :PROPERTIES:
13565 :UNNUMBERED: notoc
13566 :END:
13568 - {{{kbd(C-c C-e m m)}}} (~org-md-export-to-markdown~) ::
13570      #+kindex: C-c C-c m m
13571      #+findex: org-md-export-to-markdown
13572      Export to a text file with Markdown syntax.  For =myfile.org=,
13573      Org exports to =myfile.md=, overwritten without warning.
13575 - {{{kbd(C-c C-e m M)}}} (~org-md-export-as-markdown~) ::
13577      #+kindex: C-c C-c m M
13578      #+findex: org-md-export-as-markdown
13579      Export to a temporary buffer.  Does not create a file.
13581 - {{{kbd(C-c C-e m o)}}} ::
13583      #+kindex: C-c C-e m o
13584      Export as a text file with Markdown syntax, then open it.
13586 *** Header and sectioning structure
13587 :PROPERTIES:
13588 :UNNUMBERED: notoc
13589 :END:
13591 #+vindex: org-md-headline-style
13592 Based on ~org-md-headline-style~, Markdown export can generate
13593 headlines of both /atx/ and /setext/ types.  /atx/ limits headline
13594 levels to two whereas /setext/ limits headline levels to six.  Beyond
13595 these limits, the export back-end converts headlines to lists.  To set
13596 a limit to a level before the absolute limit (see [[*Export Settings]]).
13598 ** OpenDocument Text Export
13599 :PROPERTIES:
13600 :DESCRIPTION: Exporting to OpenDocument Text.
13601 :END:
13602 #+cindex: ODT
13603 #+cindex: OpenDocument
13604 #+cindex: export, OpenDocument
13605 #+cindex: LibreOffice
13607 The ODT export back-end handles creating of OpenDocument Text (ODT)
13608 format.  Documents created by this exporter use the
13609 {{{cite(OpenDocument-v1.2 specification)}}}[fn:124] and are compatible
13610 with LibreOffice 3.4.
13612 *** Pre-requisites for ODT export
13613 :PROPERTIES:
13614 :DESCRIPTION: Required packages.
13615 :END:
13616 #+cindex: zip
13618 The ODT export back-end relies on the zip program to create the final
13619 compressed ODT output.  Check if =zip= is locally available and
13620 executable.  Without it, export cannot finish.
13622 *** ODT export commands
13623 :PROPERTIES:
13624 :DESCRIPTION: Invoking export.
13625 :END:
13627 - {{{kbd(C-c C-e o o)}}} (~org-export-to-odt~) ::
13629      #+kindex: C-c C-e o o
13630      #+findex: org-export-to-odt
13631      Export as OpenDocument Text file.
13633      #+cindex: EXPORT_FILE_NAME, property
13634      #+vindex: org-odt-preferred-output-format
13636      If ~org-odt-preferred-output-format~ is specified, the ODT export
13637      back-end automatically converts the exported file to that format.
13639      For =myfile.org=, Org exports to =myfile.odt=, overwriting
13640      without warning.  The ODT export back-end exports a region only
13641      if a region was active.
13643      If the selected region is a single tree, the ODT export back-end
13644      makes the tree head the document title.  Incidentally, {{{kbd(C-c
13645      @)}}} selects the current sub-tree.  If the tree head entry has,
13646      or inherits, an =EXPORT_FILE_NAME= property, the ODT export
13647      back-end uses that for file name.
13649 - {{{kbd(C-c C-e o O)}}} ::
13651      #+kindex: C-c C-e o O
13652      Export as an OpenDocument Text file and open the resulting file.
13654      #+vindex: org-export-odt-preferred-output-format
13655      If ~org-export-odt-preferred-output-format~ is specified, open
13656      the converted file instead.  See [[*Automatically exporting to
13657      other formats]].
13659 *** ODT specific export settings
13660 :PROPERTIES:
13661 :DESCRIPTION: Configuration options.
13662 :END:
13664 The ODT export back-end has several additional keywords for
13665 customizing ODT output.  Setting these keywords works similar to the
13666 general options (see [[*Export Settings]]).
13668 - =DESCRIPTION= ::
13670      #+cindex: DESCRIPTION, keyword
13671      This is the document's description, which the ODT export back-end
13672      inserts as document metadata.  For long descriptions, use
13673      multiple lines, prefixed with =DESCRIPTION=.
13675 - =KEYWORDS= ::
13677      #+cindex: KEYWORDS, keyword
13678      The keywords for the document.  The ODT export back-end inserts
13679      the description along with author name, keywords, and related
13680      file metadata as metadata in the output file.  Use multiple
13681      =KEYWORDS= if necessary.
13683 - =ODT_STYLES_FILE= ::
13685      #+cindex: ODT_STYLES_FILE, keyword
13686      #+vindex: org-odt-styles-file
13687      The ODT export back-end uses the ~org-odt-styles-file~ by
13688      default.  See [[*Applying custom styles]] for details.
13690 - =SUBTITLE= ::
13692      #+cindex: SUBTITLE, keyword
13693      The document subtitle.
13695 *** Extending ODT export
13696 :PROPERTIES:
13697 :DESCRIPTION: Producing DOC, PDF files.
13698 :END:
13700 The ODT export back-end can produce documents in other formats besides
13701 ODT using a specialized ODT converter process.  Its common interface
13702 works with popular converters to produce formats such as =doc=, or
13703 convert a document from one format, say =csv=, to another format, say
13704 =xls=.
13706 #+cindex: @file{unoconv}
13707 #+vindex: org-odt-convert-process
13708 Customize ~org-odt-convert-process~ variable to point to =unoconv=,
13709 which is the ODT's preferred converter.  Working installations of
13710 LibreOffice would already have =unoconv= installed.  Alternatively,
13711 other converters may be substituted here.  See [[*Configuring
13712 a document converter]].
13714 **** Automatically exporting to other formats
13715 :PROPERTIES:
13716 :UNNUMBERED: notoc
13717 :END:
13719 #+vindex: org-odt-preferred-output-format
13720 If ODT format is just an intermediate step to get to other formats,
13721 such as =doc=, =docx=, =rtf=, or =pdf=, etc., then extend the ODT
13722 export back-end to directly produce that format.  Specify the final
13723 format in the ~org-odt-preferred-output-format~ variable.  This is one
13724 way to extend (see [[*ODT export commands]]).
13726 **** Converting between document formats
13727 :PROPERTIES:
13728 :UNNUMBERED: notoc
13729 :END:
13731 The Org export back-end is made to be inter-operable with a wide range
13732 of text document format converters.  Newer generation converters, such
13733 as LibreOffice and Pandoc, can handle hundreds of formats at once.
13734 Org provides a consistent interaction with whatever converter is
13735 installed.  Here are some generic commands:
13737 - {{{kbd(M-x org-odt-convert)}}} ::
13739      #+findex: org-odt-convert
13740      Convert an existing document from one format to another.  With
13741      a prefix argument, opens the newly produced file.
13743 *** Applying custom styles
13744 :PROPERTIES:
13745 :DESCRIPTION: Styling the output.
13746 :END:
13747 #+cindex: styles, custom
13748 #+cindex: template, custom
13750 The ODT export back-end comes with many OpenDocument styles (see
13751 [[*Working with OpenDocument style files]]).  To expand or further
13752 customize these built-in style sheets, either edit the style sheets
13753 directly or generate them using an application such as LibreOffice.
13754 The example here shows creating a style using LibreOffice.
13756 **** Applying custom styles: the easy way
13757 :PROPERTIES:
13758 :UNNUMBERED: notoc
13759 :END:
13761 1. Create a sample =example.org= file with settings as shown below,
13762    and export it to ODT format.
13764    : #+OPTIONS: H:10 num:t
13766 2. Open the above =example.odt= using LibreOffice.  Use the /Stylist/
13767    to locate the target styles, which typically have the "Org" prefix.
13768    Open one, modify, and save as either OpenDocument Text (ODT) or
13769    OpenDocument Template (OTT) file.
13772    #+vindex: org-odt-styles-file
13773    Customize the variable ~org-odt-styles-file~ and point it to the
13774    newly created file.  For additional configuration options, see
13775    [[x-overriding-factory-styles][Overriding factory styles]].
13777    #+cindex: ODT_STYLES_FILE, keyword
13778    To apply an ODT style to a particular file, use the
13779    =ODT_STYLES_FILE= keyword as shown in the example below:
13781    : #+ODT_STYLES_FILE: "/path/to/example.ott"
13783    #+texinfo: @noindent
13784    or
13786    : #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
13788 **** Using third-party styles and templates
13789 :PROPERTIES:
13790 :UNNUMBERED: notoc
13791 :END:
13793 The ODT export back-end relies on many templates and style names.
13794 Using third-party styles and templates can lead to mismatches.
13795 Templates derived from built in ODT templates and styles seem to have
13796 fewer problems.
13798 *** Links in ODT export
13799 :PROPERTIES:
13800 :DESCRIPTION: Handling and formatting links.
13801 :END:
13802 #+cindex: links, in ODT export
13804 ODT exporter creates native cross-references for internal links.  It
13805 creates Internet-style links for all other links.
13807 A link with no description and pointing to a regular, un-itemized,
13808 outline heading is replaced with a cross-reference and section number
13809 of the heading.
13811 A =\ref{label}=-style reference to an image, table etc., is replaced
13812 with a cross-reference and sequence number of the labeled entity.  See
13813 [[*Labels and captions in ODT export]].
13815 *** Tables in ODT export
13816 :PROPERTIES:
13817 :DESCRIPTION: Org tables conversions.
13818 :END:
13820 #+cindex: tables, in ODT export
13822 The ODT export back-end handles native Org mode tables (see [[*Tables]])
13823 and simple =table.el= tables.  Complex =table.el= tables having column
13824 or row spans are not supported.  Such tables are stripped from the
13825 exported document.
13827 By default, the ODT export back-end exports a table with top and
13828 bottom frames and with ruled lines separating row and column groups
13829 (see [[*Column Groups]]).  All tables are typeset to occupy the same
13830 width.  The ODT export back-end honors any table alignments and
13831 relative widths for columns (see [[*Column Width and Alignment]]).
13833 Note that the ODT export back-end interprets column widths as weighted
13834 ratios, the default weight being 1.
13836 #+cindex: ATTR_ODT, keyword
13837 Specifying =:rel-width= property on an =ATTR_ODT= line controls the
13838 width of the table.  For example:
13840 #+begin_example
13841   ,#+ATTR_ODT: :rel-width 50
13842   | Area/Month    |   Jan |   Feb |   Mar |   Sum |
13843   |---------------+-------+-------+-------+-------|
13844   | /             |     < |       |       |     < |
13845   | <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
13846   | North America |     1 |    21 |   926 |   948 |
13847   | Middle East   |     6 |    75 |   844 |   925 |
13848   | Asia Pacific  |     9 |    27 |   790 |   826 |
13849   |---------------+-------+-------+-------+-------|
13850   | Sum           |    16 |   123 |  2560 |  2699 |
13851 #+end_example
13853 On export, the above table takes 50% of text width area.  The exporter
13854 sizes the columns in the ratio: 13:5:5:5:6.  The first column is
13855 left-aligned and rest of the columns, right-aligned.  Vertical rules
13856 separate the header and the last column.  Horizontal rules separate
13857 the header and the last row.
13859 For even more customization, create custom table styles and associate
13860 them with a table using the =ATTR_ODT= keyword.  See [[*Customizing
13861 tables in ODT export]].
13863 *** Images in ODT export
13864 :PROPERTIES:
13865 :DESCRIPTION: Inserting images.
13866 :END:
13867 #+cindex: images, embedding in ODT
13868 #+cindex: embedding images in ODT
13870 **** Embedding images
13871 :PROPERTIES:
13872 :UNNUMBERED: notoc
13873 :END:
13875 The ODT export back-end processes image links in Org files that do not
13876 have descriptions, such as these links =[[file:img.jpg]]= or =[[./img.jpg]]=,
13877 as direct image insertions in the final output.  Either of these
13878 examples works:
13880 : [[file:img.png]]
13882 : [[./img.png]]
13884 **** Embedding clickable images
13885 :PROPERTIES:
13886 :UNNUMBERED: notoc
13887 :END:
13889 For clickable images, provide a link whose description is another link
13890 to an image file.  For example, to embed a image
13891 =org-mode-unicorn.png= which when clicked jumps to https://orgmode.org
13892 website, do the following
13894 : [[https://orgmode.org][./org-mode-unicorn.png]]
13896 **** Sizing and scaling of embedded images
13897 :PROPERTIES:
13898 :UNNUMBERED: notoc
13899 :END:
13901 #+cindex: ATTR_ODT, keyword
13903 Control the size and scale of the embedded images with the =ATTR_ODT=
13904 attribute.
13906 #+cindex: identify, ImageMagick
13907 #+vindex: org-odt-pixels-per-inch
13908 The ODT export back-end starts with establishing the size of the image
13909 in the final document.  The dimensions of this size are measured in
13910 centimeters.  The back-end then queries the image file for its
13911 dimensions measured in pixels.  For this measurement, the back-end
13912 relies on ImageMagick's identify program or Emacs ~create-image~ and
13913 ~image-size~ API.  ImageMagick is the preferred choice for large file
13914 sizes or frequent batch operations.  The back-end then converts the
13915 pixel dimensions using ~org-odt-pixels-per-inch~ into the familiar 72
13916 dpi or 96 dpi.  The default value for this is in
13917 ~display-pixels-per-inch~, which can be tweaked for better results
13918 based on the capabilities of the output device.  Here are some common
13919 image scaling operations:
13921 - Explicitly size the image ::
13923      To embed =img.png= as a 10 cm x 10 cm image, do the following:
13925      #+begin_example
13926        ,#+ATTR_ODT: :width 10 :height 10
13927        [[./img.png]]
13928      #+end_example
13930 - Scale the image ::
13932      To embed =img.png= at half its size, do the following:
13934      #+begin_example
13935        ,#+ATTR_ODT: :scale 0.5
13936        [[./img.png]]
13937      #+end_example
13939 - Scale the image to a specific width ::
13941      To embed =img.png= with a width of 10 cm while retaining the
13942      original height:width ratio, do the following:
13944      #+begin_example
13945        ,#+ATTR_ODT: :width 10
13946        [[./img.png]]
13947      #+end_example
13949 - Scale the image to a specific height ::
13951      To embed =img.png= with a height of 10 cm while retaining the
13952      original height:width ratio, do the following:
13954      #+begin_example
13955        ,#+ATTR_ODT: :height 10
13956        [[./img.png]]
13957      #+end_example
13959 **** Anchoring of images
13960 :PROPERTIES:
13961 :UNNUMBERED: notoc
13962 :END:
13964 #+cindex: ATTR_ODT, keyword
13965 The ODT export back-end can anchor images to ="as-char"=,
13966 ="paragraph"=, or ="page"=.  Set the preferred anchor using the
13967 =:anchor= property of the =ATTR_ODT= line.
13969 To create an image that is anchored to a page:
13971 #+begin_example
13972   ,#+ATTR_ODT: :anchor "page"
13973   [[./img.png]]
13974 #+end_example
13976 *** Math formatting in ODT export
13977 :PROPERTIES:
13978 :DESCRIPTION: Formatting @LaTeX{} fragments.
13979 :END:
13981 The ODT exporter has special support for handling math.
13983 **** LaTeX math snippets
13984 :PROPERTIES:
13985 :DESCRIPTION: Embedding in @LaTeX{} format.
13986 :END:
13988 LaTeX math snippets (see [[*LaTeX fragments]]) can be embedded in the ODT
13989 document in one of the following ways:
13991 - MathML ::
13993      #+cindex: MathML
13994      Add this line to the Org file.  This option is activated on
13995      a per-file basis.
13997      : #+OPTIONS: tex:t
13999      With this option, LaTeX fragments are first converted into MathML
14000      fragments using an external LaTeX-to-MathML converter program.
14001      The resulting MathML fragments are then embedded as an
14002      OpenDocument Formula in the exported document.
14004      #+vindex: org-latex-to-mathml-convert-command
14005      #+vindex: org-latex-to-mathml-jar-file
14006      You can specify the LaTeX-to-MathML converter by customizing the
14007      variables ~org-latex-to-mathml-convert-command~ and
14008      ~org-latex-to-mathml-jar-file~.
14010      If you prefer to use MathToWeb[fn:125] as your converter, you can
14011      configure the above variables as shown below.
14013      #+begin_src emacs-lisp
14014        (setq org-latex-to-mathml-convert-command
14015              "java -jar %j -unicode -force -df %o %I"
14016              org-latex-to-mathml-jar-file
14017              "/path/to/mathtoweb.jar")
14018      #+end_src
14020      To use LaTeX​ML[fn:126] use
14022      #+begin_src emacs-lisp
14023        (setq org-latex-to-mathml-convert-command
14024              "latexmlmath \"%i\" --presentationmathml=%o")
14025      #+end_src
14027      To quickly verify the reliability of the LaTeX-to-MathML
14028      converter, use the following commands:
14030      - {{{kbd(M-x org-export-as-odf)}}} ::
14032           Convert a LaTeX math snippet to an OpenDocument formula
14033           (=.odf=) file.
14035      - {{{kbd(M-x org-export-as-odf-and-open)}}} ::
14037           Convert a LaTeX math snippet to an OpenDocument formula
14038           (=.odf=) file and open the formula file with the
14039           system-registered application.
14041 - PNG images ::
14043      #+cindex: dvipng
14044      #+cindex: dvisvgm
14045      #+cindex: ImageMagick
14046      Add this line to the Org file.  This option is activated on
14047      a per-file basis.
14049      : #+OPTIONS: tex:dvipng
14051      : #+OPTIONS: tex:dvisvgm
14053      #+texinfo: @noindent
14054      or
14056      : #+OPTIONS: tex:imagemagick
14058      Under this option, LaTeX fragments are processed into PNG or SVG
14059      images and the resulting images are embedded in the exported
14060      document.  This method requires dvipng program, dvisvgm or
14061      ImageMagick programs.
14063 **** MathML and OpenDocument formula files
14064 :PROPERTIES:
14065 :DESCRIPTION: Embedding in native format.
14066 :END:
14068 When embedding LaTeX math snippets in ODT documents is not reliable,
14069 there is one more option to try.  Embed an equation by linking to its
14070 MathML (=.mml=) source or its OpenDocument formula (=.odf=) file as
14071 shown below:
14073 : [[./equation.mml]]
14075 #+texinfo: @noindent
14078 : [[./equation.odf]]
14080 *** Labels and captions in ODT export
14081 :PROPERTIES:
14082 :DESCRIPTION: Rendering objects.
14083 :END:
14085 ODT format handles labeling and captioning of objects based on their
14086 types.  Inline images, tables, LaTeX fragments, and Math formulas are
14087 numbered and captioned separately.  Each object also gets a unique
14088 sequence number based on its order of first appearance in the Org
14089 file.  Each category has its own sequence.  A caption is just a label
14090 applied to these objects.
14092 #+begin_example
14093   ,#+CAPTION: Bell curve
14094   ,#+NAME:   fig:SED-HR4049
14095   [[./img/a.png]]
14096 #+end_example
14098 When rendered, it may show as follows in the exported document:
14100 : Figure 2: Bell curve
14102 #+vindex: org-odt-category-map-alist
14103 To modify the category component of the caption, customize the option
14104 ~org-odt-category-map-alist~.  For example, to tag embedded images
14105 with the string "Illustration" instead of the default string "Figure",
14106 use the following setting:
14108 #+begin_src emacs-lisp
14109   (setq org-odt-category-map-alist
14110         '(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
14111 #+end_src
14113 With the above modification, the previous example changes to:
14115 : Illustration 2: Bell curve
14117 *** Literal examples in ODT export
14118 :PROPERTIES:
14119 :DESCRIPTION: For source code and example blocks.
14120 :END:
14122 The ODT export back-end supports literal examples (see [[*Literal
14123 Examples]]) with full fontification.  Internally, the ODT export
14124 back-end relies on =htmlfontify.el= to generate the style definitions
14125 needed for fancy listings.  The auto-generated styles get =OrgSrc=
14126 prefix and inherit colors from the faces used by Emacs Font Lock
14127 library for that source language.
14129 #+vindex: org-odt-fontify-srcblocks
14130 For custom fontification styles, customize the
14131 ~org-odt-create-custom-styles-for-srcblocks~ option.
14133 #+vindex: org-odt-create-custom-styles-for-srcblocks
14134 To turn off fontification of literal examples, customize the
14135 ~org-odt-fontify-srcblocks~ option.
14137 *** Advanced topics in ODT export
14138 :PROPERTIES:
14139 :DESCRIPTION: For power users.
14140 :END:
14142 The ODT export back-end has extensive features useful for power users
14143 and frequent uses of ODT formats.
14145 **** Configuring a document converter
14146 :PROPERTIES:
14147 :DESCRIPTION: Registering a document converter.
14148 :UNNUMBERED: notoc
14149 :END:
14150 #+cindex: convert
14151 #+cindex: doc, docx, rtf
14152 #+cindex: converter
14154 The ODT export back-end works with popular converters with little or
14155 no extra configuration.  See [[*Extending ODT export]].  The following is
14156 for unsupported converters or tweaking existing defaults.
14158 - Register the converter ::
14160      #+vindex: org-export-odt-convert-processes
14161      Add the name of the converter to the ~org-odt-convert-processes~
14162      variable.  Note that it also requires how the converter is
14163      invoked on the command line.  See the variable's docstring for
14164      details.
14166 - Configure its capabilities ::
14168      #+vindex: org-export-odt-convert-capabilities
14169      Specify which formats the converter can handle by customizing the
14170      variable ~org-odt-convert-capabilities~.  Use the entry for the
14171      default values in this variable for configuring the new
14172      converter.  Also see its docstring for details.
14174 - Choose the converter ::
14176      #+vindex: org-export-odt-convert-process
14177      Select the newly added converter as the preferred one by
14178      customizing the option ~org-odt-convert-process~.
14180 **** Working with OpenDocument style files
14181 :PROPERTIES:
14182 :DESCRIPTION: Exploring internals.
14183 :UNNUMBERED: notoc
14184 :END:
14185 #+cindex: styles, custom
14186 #+cindex: template, custom
14188 This section explores the internals of the ODT exporter; the means by which
14189 it produces styled documents; the use of automatic and custom OpenDocument
14190 styles.
14192 The ODT exporter relies on two files for generating its output.  These
14193 files are bundled with the distribution under the directory pointed to
14194 by the variable ~org-odt-styles-dir~.  The two files are:
14196 - =OrgOdtStyles.xml= <<x-orgodtstyles-xml>> ::
14198      This file contributes to the =styles.xml= file of the final ODT
14199      document.  This file gets modified for the following purposes:
14201      1. To control outline numbering based on user settings;
14203      2. To add styles generated by =htmlfontify.el= for fontification of
14204         code blocks.
14206 - =OrgOdtContentTemplate.xml= <<x-orgodtcontenttemplate-xml>> ::
14208      This file contributes to the =content.xml= file of the final ODT
14209      document.  The contents of the Org outline are inserted between the
14210      =<office:text>= ... =</office:text>= elements of this file.
14212      Apart from serving as a template file for the final =content.xml=,
14213      the file serves the following purposes:
14215      1. It contains automatic styles for formatting of tables which are
14216         referenced by the exporter;
14218      2. It contains =<text:sequence-decl>= ... =</text:sequence-decl>=
14219         elements that control numbering of tables, images, equations, and
14220         similar entities.
14222 <<x-overriding-factory-styles>> The following two variables control
14223 the location from where the ODT exporter picks up the custom styles
14224 and content template files.  Customize these variables to override the
14225 factory styles used by the exporter.
14227 - ~org-odt-styles-file~ ::
14229      The ODT export back-end uses the file pointed to by this
14230      variable, such as =styles.xml=, for the final output.  It can
14231      take one of the following values:
14233      - =FILE.xml= ::
14235           Use this file instead of the default =styles.xml=
14237      - =FILE.odt= or =FILE.ott= ::
14239           Use the =styles.xml= contained in the specified OpenDocument
14240           Text or Template file
14242      - =FILE.odt= or =FILE.ott= and a subset of included files ::
14244           Use the =styles.xml= contained in the specified OpenDocument
14245           Text or Template file.  Additionally extract the specified
14246           member files and embed those within the final ODT document.
14248           Use this option if the =styles.xml= file references additional
14249           files like header and footer images.
14251      - ~nil~ ::
14253           Use the default =styles.xml=.
14255 - ~org-odt-content-template-file~ ::
14257      Use this variable to specify the blank =content.xml= used in the
14258      final output.
14260 **** Creating one-off styles
14261 :PROPERTIES:
14262 :DESCRIPTION: Customizing styles, highlighting...
14263 :UNNUMBERED: notoc
14264 :END:
14266 The ODT export back-end can read embedded raw OpenDocument XML from
14267 the Org file.  Such direct formatting is useful for one-off instances.
14269 - Embedding ODT tags as part of regular text ::
14271      Enclose OpenDocument syntax in =@@odt:...@@= for inline markup.
14272      For example, to highlight a region of text do the following:
14274      #+begin_example
14275        @@odt:<text:span text:style-name="Highlight">This is highlighted
14276        text</text:span>@@.  But this is regular text.
14277      #+end_example
14279      *Hint:* To see the above example in action, edit the =styles.xml=
14280      (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom /Highlight/ style as shown
14281      below:
14283      #+begin_example
14284        <style:style style:name="Highlight" style:family="text">
14285          <style:text-properties fo:background-color="#ff0000"/>
14286        </style:style>
14287      #+end_example
14289 - Embedding a one-line OpenDocument XML ::
14291      #+cindex: ODT, keyword
14292      The ODT export back-end can read one-liner options with =#+ODT:=
14293      in the Org file.  For example, to force a page break:
14295      #+begin_example
14296        ,#+ODT: <text:p text:style-name="PageBreak"/>
14297      #+end_example
14299      *Hint:* To see the above example in action, edit your
14300      =styles.xml= (see [[x-orgodtstyles-xml][Factory styles]]) and add a custom =PageBreak=
14301      style as shown below.
14303      #+begin_example
14304        <style:style style:name="PageBreak" style:family="paragraph"
14305                     style:parent-style-name="Text_20_body">
14306          <style:paragraph-properties fo:break-before="page"/>
14307        </style:style>
14308      #+end_example
14310 - Embedding a block of OpenDocument XML ::
14312      The ODT export back-end can also read ODT export blocks for
14313      OpenDocument XML.  Such blocks use the =#+BEGIN_EXPORT odt=
14314      ... =#+END_EXPORT= constructs.
14316      For example, to create a one-off paragraph that uses bold text,
14317      do the following:
14319      #+begin_example
14320        ,#+BEGIN_EXPORT odt
14321          <text:p text:style-name="Text_20_body_20_bold">
14322          This paragraph is specially formatted and uses bold text.
14323          </text:p>
14324        ,#+END_EXPORT
14325      #+end_example
14327 **** Customizing tables in ODT export
14328 :PROPERTIES:
14329 :DESCRIPTION: Defining table templates.
14330 :UNNUMBERED: notoc
14331 :END:
14332 #+cindex: tables, in ODT export
14333 #+cindex: ATTR_ODT, keyword
14335 Override the default table format by specifying a custom table style
14336 with the =#+ATTR_ODT= line.  For a discussion on default formatting of
14337 tables, see [[*Tables in ODT export]].
14339 This feature closely mimics the way table templates are defined in the
14340 OpenDocument-v1.2 specification.[fn:127]
14342 #+vindex: org-odt-table-styles
14343 For quick preview of this feature, install the settings below and export the
14344 table that follows:
14346 #+begin_src emacs-lisp
14347   (setq org-export-odt-table-styles
14348         (append org-export-odt-table-styles
14349                 '(("TableWithHeaderRowAndColumn" "Custom"
14350                    ((use-first-row-styles . t)
14351                     (use-first-column-styles . t)))
14352                   ("TableWithFirstRowandLastRow" "Custom"
14353                    ((use-first-row-styles . t)
14354                     (use-last-row-styles . t))))))
14355 #+end_src
14357 #+begin_example
14358   ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14359   | Name  | Phone | Age |
14360   | Peter |  1234 |  17 |
14361   | Anna  |  4321 |  25 |
14362 #+end_example
14364 The example above used =Custom= template and installed two table
14365 styles =TableWithHeaderRowAndColumn= and
14366 =TableWithFirstRowandLastRow=.  *Important:* The OpenDocument styles
14367 needed for producing the above template were pre-defined.  They are
14368 available in the section marked =Custom Table Template= in
14369 =OrgOdtContentTemplate.xml= (see [[x-orgodtcontenttemplate-xml][Factory styles]]).  For adding new
14370 templates, define new styles there.
14372 To use this feature proceed as follows:
14374 1. Create a table template[fn:128].
14376    A table template is set of =table-cell= and =paragraph= styles for
14377    each of the following table cell categories:
14379    - Body
14380    - First column
14381    - Last column
14382    - First row
14383    - Last row
14384    - Even row
14385    - Odd row
14386    - Even column
14387    - Odd Column
14389    The names for the above styles must be chosen based on the name of
14390    the table template using a well-defined convention.
14392    The naming convention is better illustrated with an example.  For
14393    a table template with the name =Custom=, the needed style names are
14394    listed in the following table.
14396    | Cell type    | Cell style                   | Paragraph style                   |
14397    |--------------+------------------------------+-----------------------------------|
14398    | Body         | =CustomTableCell=            | =CustomTableParagraph=            |
14399    | First column | =CustomFirstColumnTableCell= | =CustomFirstColumnTableParagraph= |
14400    | Last column  | =CustomLastColumnTableCell=  | =CustomLastColumnTableParagraph=  |
14401    | First row    | =CustomFirstRowTableCell=    | =CustomFirstRowTableParagraph=    |
14402    | Last row     | =CustomLastRowTableCell=     | =CustomLastRowTableParagraph=     |
14403    | Even row     | =CustomEvenRowTableCell=     | =CustomEvenRowTableParagraph=     |
14404    | Odd row      | =CustomOddRowTableCell=      | =CustomOddRowTableParagraph=      |
14405    | Even column  | =CustomEvenColumnTableCell=  | =CustomEvenColumnTableParagraph=  |
14406    | Odd column   | =CustomOddColumnTableCell=   | =CustomOddColumnTableParagraph=   |
14408    To create a table template with the name =Custom=, define the above
14409    styles in the =<office:automatic-styles>= ...
14410    =</office:automatic-styles>= element of the content template file
14411    (see [[x-orgodtcontenttemplate-xml][Factory styles]]).
14413 2. Define a table style[fn:129].
14415    #+vindex: org-odt-table-styles
14416    To define a table style, create an entry for the style in the
14417    variable ~org-odt-table-styles~ and specify the following:
14419    - the name of the table template created in step (1),
14420    - the set of cell styles in that template that are to be activated.
14422    For example, the entry below defines two different table styles
14423    =TableWithHeaderRowAndColumn= and =TableWithFirstRowandLastRow=
14424    based on the same template =Custom=.  The styles achieve their
14425    intended effect by selectively activating the individual cell
14426    styles in that template.
14428    #+begin_src emacs-lisp
14429      (setq org-export-odt-table-styles
14430            (append org-export-odt-table-styles
14431                    '(("TableWithHeaderRowAndColumn" "Custom"
14432                       ((use-first-row-styles . t)
14433                        (use-first-column-styles . t)))
14434                      ("TableWithFirstRowandLastRow" "Custom"
14435                       ((use-first-row-styles . t)
14436                        (use-last-row-styles . t))))))
14437    #+end_src
14439 3. Associate a table with the table style.
14441    To do this, specify the table style created in step (2) as part of
14442    the =ATTR_ODT= line as shown below.
14444    #+begin_example
14445      ,#+ATTR_ODT: :style TableWithHeaderRowAndColumn
14446      | Name  | Phone | Age |
14447      | Peter |  1234 |  17 |
14448      | Anna  |  4321 |  25 |
14449    #+end_example
14451 **** Validating OpenDocument XML
14452 :PROPERTIES:
14453 :DESCRIPTION: Debugging corrupted OpenDocument files.
14454 :UNNUMBERED: notoc
14455 :END:
14457 Sometimes ODT format files may not open due to =.odt= file corruption.
14458 To verify if such a file is corrupt, validate it against the
14459 OpenDocument Relax NG Compact (RNC) syntax schema.  But first the
14460 =.odt= files have to be decompressed using =zip=.  Note that =.odt=
14461 files are ZIP archives: [[info:emacs::File Archives]].  The contents of
14462 ODT files are in XML.  For general help with validation---and
14463 schema-sensitive editing---of XML files:
14464 [[info:nxml-mode::Introduction]].
14466 #+vindex: org-export-odt-schema-dir
14467 Customize ~org-odt-schema-dir~ to point to a directory with
14468 OpenDocument RNC files and the needed schema-locating rules.  The ODT
14469 export back-end takes care of updating the
14470 ~rng-schema-locating-files~.
14472 ** Org Export
14473 :PROPERTIES:
14474 :DESCRIPTION: Exporting to Org.
14475 :END:
14477 #+cindex: Org export
14478 /org/ export back-end creates a normalized version of the Org document
14479 in current buffer.  The exporter evaluates Babel code (see [[*Evaluating
14480 Code Blocks]]) and removes content specific to other back-ends.
14482 *** Org export commands
14483 :PROPERTIES:
14484 :UNNUMBERED: notoc
14485 :END:
14487 - {{{kbd(C-c C-e O o)}}} (~org-org-export-to-org~) ::
14489      #+kindex: C-c C-e O o
14490      #+findex: org-org-export-to-org
14491      Export as an Org file with a =.org= extension.  For =myfile.org=,
14492      Org exports to =myfile.org.org=, overwriting without warning.
14494 - {{{kbd(C-c C-e O v)}}} (~~) ::
14496      #+kindex: C-c C-e O v
14497      Export to an Org file, then open it.
14499 ** Texinfo Export
14500 :PROPERTIES:
14501 :DESCRIPTION: Exporting to Texinfo.
14502 :END:
14504 *** Texinfo export commands
14505 :PROPERTIES:
14506 :DESCRIPTION: Invoking commands.
14507 :END:
14509 - {{{kbd(C-c C-e i t)}}} (~org-texinfo-export-to-texinfo~) ::
14511      #+kindex: C-c C-e i t
14512      #+findex: org-texinfo-export-to-texinfo
14513      Export as a Texinfo file with =.texi= extension.  For
14514      =myfile.org=, Org exports to =myfile.texi=, overwriting without
14515      warning.
14517 - {{{kbd(C-c C-e i i)}}} (~org-texinfo-export-to-info~) ::
14519      #+kindex: C-c C-e i i
14520      #+findex: org-texinfo-export-to-info
14521      #+vindex: org-texinfo-info-process
14522      Export to Texinfo format first and then process it to make an
14523      Info file.  To generate other formats, such as DocBook, customize
14524      the ~org-texinfo-info-process~ variable.
14526 *** Texinfo specific export settings
14527 :PROPERTIES:
14528 :DESCRIPTION: Setting the environment.
14529 :END:
14531 The Texinfo export back-end has several additional keywords for
14532 customizing Texinfo output.  Setting these keywords works similar to
14533 the general options (see [[*Export Settings]]).
14535 - =SUBTITLE= ::
14537      #+cindex: SUBTITLE, keyword
14538      The document subtitle.
14540 - =SUBAUTHOR= ::
14542      #+cindex: SUBAUTHOR, keyword
14543      Additional authors for the document.
14545 - =TEXINFO_FILENAME= ::
14547      #+cindex: TEXINFO_FILENAME, keyword
14548      The Texinfo filename.
14550 - =TEXINFO_CLASS= ::
14552      #+cindex: TEXINFO_CLASS, keyword
14553      #+vindex: org-texinfo-default-class
14554      The default document class (~org-texinfo-default-class~), which
14555      must be a member of ~org-texinfo-classes~.
14557 - =TEXINFO_HEADER= ::
14559      #+cindex: TEXINFO_HEADER, keyword
14560      Arbitrary lines inserted at the end of the header.
14562 - =TEXINFO_POST_HEADER= ::
14564      #+cindex: TEXINFO_POST_HEADER, keyword
14565      Arbitrary lines inserted after the end of the header.
14567 - =TEXINFO_DIR_CATEGORY= ::
14569      #+cindex: TEXINFO_DIR_CATEGORY, keyword
14570      The directory category of the document.
14572 - =TEXINFO_DIR_TITLE= ::
14574      #+cindex: TEXINFO_DIR_TITLE, keyword
14575      The directory title of the document.
14577 - =TEXINFO_DIR_DESC= ::
14579      #+cindex: TEXINFO_DIR_DESC, keyword
14580      The directory description of the document.
14582 - =TEXINFO_PRINTED_TITLE= ::
14584      #+cindex: TEXINFO_PRINTED_TITLE, keyword
14585      The printed title of the document.
14587 *** Texinfo file header
14588 :PROPERTIES:
14589 :DESCRIPTION: Generating the header.
14590 :END:
14592 #+cindex: TEXINFO_FILENAME, keyword
14593 After creating the header for a Texinfo file, the Texinfo back-end
14594 automatically generates a name and destination path for the Info file.
14595 To override this default with a more sensible path and name, specify
14596 the =TEXINFO_FILENAME= keyword.
14598 #+vindex: org-texinfo-coding-system
14599 #+cindex: TEXINFO_HEADER, keyword
14600 Along with the output's file name, the Texinfo header also contains
14601 language details (see [[*Export Settings]]) and encoding system as set in
14602 the ~org-texinfo-coding-system~ variable.  Insert =TEXINFO_HEADER=
14603 keywords for each additional command in the header, for example:
14605 : #+TEXINFO_HEADER: @synindex
14607 #+cindex: TEXINFO_CLASS, keyword
14608 #+vindex: org-texinfo-classes
14609 Instead of repeatedly installing the same set of commands, define
14610 a class in ~org-texinfo-classes~ once, and then activate it in the
14611 document by setting the =TEXINFO_CLASS= keyword to that class.
14613 *** Texinfo title and copyright page
14614 :PROPERTIES:
14615 :DESCRIPTION: Creating preamble pages.
14616 :END:
14618 #+cindex: TEXINFO_PRINTED_TITLE, keyword
14619 The default template for hard copy output has a title page with
14620 =TITLE= and =AUTHOR= keywords (see [[*Export Settings]]).  To replace the
14621 regular title with something different for the printed version, use
14622 the =TEXINFO_PRINTED_TITLE= and =SUBTITLE= keywords.  Both expect raw
14623 Texinfo code for setting their values.
14625 #+cindex: SUBAUTHOR, keyword
14626 If one =AUTHOR= line is not sufficient, add multiple =SUBAUTHOR=
14627 keywords.  They have to be set in raw Texinfo code.
14629 #+begin_example
14630   ,#+AUTHOR: Jane Smith
14631   ,#+SUBAUTHOR: John Doe
14632   ,#+TEXINFO_PRINTED_TITLE: This Long Title@@inlinefmt{tex,@*} Is Broken in @TeX{}
14633 #+end_example
14635 #+cindex: COPYING, property
14636 Copying material is defined in a dedicated headline with a non-~nil~
14637 =COPYING= property.  The back-end inserts the contents within
14638 a =@copying= command at the beginning of the document.  The heading
14639 itself does not appear in the structure of the document.
14641 Copyright information is printed on the back of the title page.
14643 #+begin_example
14644   ,* Legalese
14645     :PROPERTIES:
14646     :COPYING: t
14647     :END:
14649     This is a short example of a complete Texinfo file, version 1.0.
14651     Copyright \copy 2016 Free Software Foundation, Inc.
14652 #+end_example
14654 *** Info directory file
14655 :PROPERTIES:
14656 :DESCRIPTION: Installing a manual in Info file hierarchy.
14657 :END:
14659 #+cindex: @samp{dir} file, in Texinfo export
14660 #+cindex: Info directory file, in Texinfo export
14661 #+cindex: @code{install-info}, in Texinfo export
14663 #+cindex: TEXINFO_DIR_CATEGORY, keyword
14664 #+cindex: TEXINFO_DIR_TITLE, keyword
14665 #+cindex: TEXINFO_DIR_DESC, keyword
14666 The end result of the Texinfo export process is the creation of an
14667 Info file.  This Info file's metadata has variables for category,
14668 title, and description: =TEXINFO_DIR_CATEGORY=, =TEXINFO_DIR_TITLE=,
14669 and =TEXINFO_DIR_DESC= keywords that establish where in the Info
14670 hierarchy the file fits.
14672 Here is an example that writes to the Info directory file:
14674 #+begin_example
14675   ,#+TEXINFO_DIR_CATEGORY: Emacs
14676   ,#+TEXINFO_DIR_TITLE: Org Mode: (org)
14677   ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer
14678 #+end_example
14680 *** Headings and sectioning structure
14681 :PROPERTIES:
14682 :DESCRIPTION: Building document structure.
14683 :END:
14685 #+vindex: org-texinfo-classes
14686 #+vindex: org-texinfo-default-class
14687 #+cindex: TEXINFO_CLASS, keyword
14688 The Texinfo export back-end uses a pre-defined scheme to convert Org
14689 headlines to equivalent Texinfo structuring commands.  A scheme like
14690 this maps top-level headlines to numbered chapters tagged as
14691 ~@chapter~ and lower-level headlines to unnumbered chapters tagged as
14692 ~@unnumbered~.  To override such mappings to introduce ~@part~ or
14693 other Texinfo structuring commands, define a new class in
14694 ~org-texinfo-classes~.  Activate the new class with the
14695 =TEXINFO_CLASS= keyword.  When no new class is defined and activated,
14696 the Texinfo export back-end defaults to the
14697 ~org-texinfo-default-class~.
14699 If an Org headline's level has no associated Texinfo structuring
14700 command, or is below a certain threshold (see [[*Export Settings]]), then
14701 the Texinfo export back-end makes it into a list item.
14703 #+cindex: APPENDIX, property
14704 The Texinfo export back-end makes any headline with a non-~nil~
14705 =APPENDIX= property into an appendix.  This happens independent of the
14706 Org headline level or the =TEXINFO_CLASS= keyword.
14708 #+cindex: ALT_TITLE, property
14709 #+cindex: DESCRIPTION, property
14710 The Texinfo export back-end creates a menu entry after the Org
14711 headline for each regular sectioning structure.  To override this with
14712 a shorter menu entry, use the =ALT_TITLE= property (see [[*Table of
14713 Contents]]).  Texinfo menu entries also have an option for a longer
14714 =DESCRIPTION= property.  Here's an example that uses both to override
14715 the default menu entry:
14717 #+begin_example
14718 ,* Controlling Screen Display
14719   :PROPERTIES:
14720   :ALT_TITLE: Display
14721   :DESCRIPTION: Controlling Screen Display
14722   :END:
14723 #+end_example
14725 #+cindex: Top node, in Texinfo export
14726 The text before the first headline belongs to the /Top/ node, i.e.,
14727 the node in which a reader enters an Info manual.  As such, it is
14728 expected not to appear in printed output generated from the =.texi=
14729 file.  See [[info:texinfo::The%20Top%20Node]], for more information.
14731 *** Indices
14732 :PROPERTIES:
14733 :DESCRIPTION: Creating indices.
14734 :END:
14736 #+cindex: CINDEX, keyword
14737 #+cindex: concept index, in Texinfo export
14738 #+cindex: FINDEX, keyword
14739 #+cindex: function index, in Texinfo export
14740 #+cindex: KINDEX, keyword
14741 #+cindex: keystroke index, in Texinfo export
14742 #+cindex: PINDEX, keyword
14743 #+cindex: program index, in Texinfo export
14744 #+cindex: TINDEX, keyword
14745 #+cindex: data type index, in Texinfo export
14746 #+cindex: VINDEX, keyword
14747 #+cindex: variable index, in Texinfo export
14748 The Texinfo export back-end recognizes these indexing keywords if used
14749 in the Org file: =CINDEX=, =FINDEX=, =KINDEX=, =PINDEX=, =TINDEX= and
14750 =VINDEX=.  Write their value as verbatim Texinfo code; in particular,
14751 ={=, =}= and =@= characters need to be escaped with =@= if they do not
14752 belong to a Texinfo command.
14754 : #+CINDEX: Defining indexing entries
14756 #+cindex: INDEX, property
14757 For the back-end to generate an index entry for a headline, set the
14758 =INDEX= property to =cp= or =vr=.  These abbreviations come from
14759 Texinfo that stand for concept index and variable index.  The Texinfo
14760 manual has abbreviations for all other kinds of indexes.  The back-end
14761 exports the headline as an unnumbered chapter or section command, and
14762 then inserts the index after its contents.
14764 #+begin_example
14765   ,* Concept Index
14766     :PROPERTIES:
14767     :INDEX: cp
14768     :END:
14769 #+end_example
14771 *** Quoting Texinfo code
14772 :PROPERTIES:
14773 :DESCRIPTION: Incorporating literal Texinfo code.
14774 :END:
14776 Use any of the following three methods to insert or escape raw Texinfo
14777 code:
14779 #+cindex: TEXINFO, keyword
14780 #+cindex: BEGIN_EXPORT texinfo
14781 #+begin_example
14782   Richard @@texinfo:@sc{@@Stallman@@texinfo:}@@ commence' GNU.
14784   ,#+TEXINFO: @need800
14785   This paragraph is preceded by...
14787   ,#+BEGIN_EXPORT texinfo
14788     @auindex Johnson, Mark
14789     @auindex Lakoff, George
14790   ,#+END_EXPORT
14791 #+end_example
14793 *** Plain lists in Texinfo export
14794 :PROPERTIES:
14795 :DESCRIPTION: List attributes.
14796 :END:
14798 #+cindex: ATTR_TEXINFO, keyword
14799 #+cindex: two-column tables, in Texinfo export
14801 #+cindex: table types, in Texinfo export
14802 The Texinfo export back-end by default converts description lists in
14803 the Org file using the default command =@table=, which results in
14804 a table with two columns.  To change this behavior, specify
14805 =:table-type= with =ftable= or =vtable= attributes.  For more
14806 information, see [[info:texinfo::Two-column Tables]].
14808 #+vindex: org-texinfo-table-default-markup
14809 The Texinfo export back-end by default also applies a text highlight
14810 based on the defaults stored in ~org-texinfo-table-default-markup~.
14811 To override the default highlight command, specify another one with
14812 the =:indic= attribute.
14814 #+cindex: multiple items in Texinfo lists
14815 Org syntax is limited to one entry per list item.  Nevertheless, the
14816 Texinfo export back-end can split that entry according to any text
14817 provided through the =:sep= attribute.  Each part then becomes a new
14818 entry in the first column of the table.
14820 The following example illustrates all the attributes above:
14822 #+begin_example
14823   ,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
14824   - foo, bar :: This is the common text for variables foo and bar.
14825 #+end_example
14827 #+texinfo: @noindent
14828 becomes
14830 #+begin_example
14831   @vtable @asis
14832   @item foo
14833   @itemx bar
14834   This is the common text for variables foo and bar.
14835   @end table
14836 #+end_example
14838 *** Tables in Texinfo export
14839 :PROPERTIES:
14840 :DESCRIPTION: Table attributes.
14841 :END:
14843 #+cindex: ATTR_TEXINFO, keyword
14844 When exporting tables, the Texinfo export back-end uses the widest
14845 cell width in each column.  To override this and instead specify as
14846 fractions of line length, use the =:columns= attribute.  See example
14847 below.
14849 #+begin_example
14850   ,#+ATTR_TEXINFO: :columns .5 .5
14851   | a cell | another cell |
14852 #+end_example
14854 *** Images in Texinfo export
14855 :PROPERTIES:
14856 :DESCRIPTION: Image attributes.
14857 :END:
14859 #+cindex: ATTR_TEXINFO, keyword
14860 Insert a file link to the image in the Org file, and the Texinfo
14861 export back-end inserts the image.  These links must have the usual
14862 supported image extensions and no descriptions.  To scale the image,
14863 use =:width= and =:height= attributes.  For alternate text, use =:alt=
14864 and specify the text using Texinfo code, as shown in the example:
14866 #+begin_example
14867   ,#+ATTR_TEXINFO: :width 1in :alt Alternate @i{text}
14868   [[ridt.pdf]]
14869 #+end_example
14871 *** Special blocks in Texinfo export
14872 :PROPERTIES:
14873 :DESCRIPTION: Special block attributes.
14874 :END:
14876 #+cindex: ATTR_TEXINFO, keyword
14878 The Texinfo export back-end converts special blocks to commands with
14879 the same name.  It also adds any =:options= attributes to the end of
14880 the command, as shown in this example:
14882 #+begin_example
14883   ,#+ATTR_TEXINFO: :options org-org-export-to-org ...
14884   ,#+BEGIN_defun
14885     A somewhat obsessive function name.
14886   ,#+END_defun
14887 #+end_example
14889 #+texinfo: @noindent
14890 becomes
14892 #+begin_example
14893   @defun org-org-export-to-org ...
14894     A somewhat obsessive function name.
14895   @end defun
14896 #+end_example
14898 *** A Texinfo example
14899 :PROPERTIES:
14900 :DESCRIPTION: Processing Org to Texinfo.
14901 :END:
14903 Here is a more detailed example Org file.  See
14904 [[info:texinfo::GNU%20Sample%20Texts]] for an equivalent example using
14905 Texinfo code.
14907 #+begin_example
14908   ,#+TITLE: GNU Sample {{{version}}}
14909   ,#+SUBTITLE: for version {{{version}}}, {{{updated}}}
14910   ,#+AUTHOR: A.U. Thor
14911   ,#+EMAIL: bug-sample@gnu.org
14913   ,#+OPTIONS: ':t toc:t author:t email:t
14914   ,#+LANGUAGE: en
14916   ,#+MACRO: version 2.0
14917   ,#+MACRO: updated last updated 4 March 2014
14919   ,#+TEXINFO_FILENAME: sample.info
14920   ,#+TEXINFO_HEADER: @syncodeindex pg cp
14922   ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system
14923   ,#+TEXINFO_DIR_TITLE: sample: (sample)
14924   ,#+TEXINFO_DIR_DESC: Invoking sample
14926   ,#+TEXINFO_PRINTED_TITLE: GNU Sample
14928   This manual is for GNU Sample (version {{{version}}},
14929   {{{updated}}}).
14931   ,* Copying
14932     :PROPERTIES:
14933     :COPYING:  t
14934     :END:
14936     This manual is for GNU Sample (version {{{version}}},
14937     {{{updated}}}), which is an example in the Texinfo documentation.
14939     Copyright \copy 2016 Free Software Foundation, Inc.
14941     ,#+BEGIN_QUOTE
14942     Permission is granted to copy, distribute and/or modify this
14943     document under the terms of the GNU Free Documentation License,
14944     Version 1.3 or any later version published by the Free Software
14945     Foundation; with no Invariant Sections, with no Front-Cover Texts,
14946     and with no Back-Cover Texts.  A copy of the license is included in
14947     the section entitled "GNU Free Documentation License".
14948     ,#+END_QUOTE
14950   ,* Invoking sample
14952     ,#+PINDEX: sample
14953     ,#+CINDEX: invoking @command{sample}
14955     This is a sample manual.  There is no sample program to invoke, but
14956     if there were, you could see its basic usage and command line
14957     options here.
14959   ,* GNU Free Documentation License
14960     :PROPERTIES:
14961     :APPENDIX: t
14962     :END:
14964     ,#+TEXINFO: @include fdl.texi
14966   ,* Index
14967     :PROPERTIES:
14968     :INDEX:    cp
14969     :END:
14970 #+end_example
14972 ** iCalendar Export
14973 :PROPERTIES:
14974 :DESCRIPTION: Exporting to iCalendar.
14975 :END:
14976 #+cindex: iCalendar export
14978 A large part of Org mode's interoperability success is its ability to
14979 easily export to or import from external applications.  The iCalendar
14980 export back-end takes calendar data from Org files and exports to the
14981 standard iCalendar format.
14983 #+vindex: org-icalendar-include-todo
14984 #+vindex: org-icalendar-use-deadline
14985 #+vindex: org-icalendar-use-scheduled
14986 The iCalendar export back-end can also incorporate TODO entries based
14987 on the configuration of the ~org-icalendar-include-todo~ variable.
14988 The back-end exports plain timestamps as =VEVENT=, TODO items as
14989 =VTODO=, and also create events from deadlines that are in non-TODO
14990 items.  The back-end uses the deadlines and scheduling dates in Org
14991 TODO items for setting the start and due dates for the iCalendar TODO
14992 entry.  Consult the ~org-icalendar-use-deadline~ and
14993 ~org-icalendar-use-scheduled~ variables for more details.
14995 #+vindex: org-icalendar-categories
14996 #+vindex: org-icalendar-alarm-time
14997 For tags on the headline, the iCalendar export back-end makes them
14998 into iCalendar categories.  To tweak the inheritance of tags and TODO
14999 states, configure the variable ~org-icalendar-categories~.  To assign
15000 clock alarms based on time, configure the ~org-icalendar-alarm-time~
15001 variable.
15003 #+vindex: org-icalendar-store-UID
15004 #+cindex: ID, property
15005 The iCalendar format standard requires globally unique identifier---or
15006 UID---for each entry.  The iCalendar export back-end creates UIDs
15007 during export.  To save a copy of the UID in the Org file set the
15008 variable ~org-icalendar-store-UID~.  The back-end looks for the =ID=
15009 property of the entry for re-using the same UID for subsequent
15010 exports.
15012 Since a single Org entry can result in multiple iCalendar
15013 entries---timestamp, deadline, scheduled item, or TODO item---Org adds
15014 prefixes to the UID, depending on which part of the Org entry
15015 triggered the creation of the iCalendar entry.  Prefixing ensures UIDs
15016 remains unique, yet enable synchronization programs trace the
15017 connections.
15019 - {{{kbd(C-c C-e c f)}}} (~org-icalendar-export-to-ics~) ::
15021      #+kindex: C-c C-e c f
15022      #+findex: org-icalendar-export-to-ics
15023      Create iCalendar entries from the current Org buffer and store
15024      them in the same directory, using a file extension =.ics=.
15026 - {{{kbd(C-c C-e c a)}}} (~org-icalendar-export-agenda-files~) ::
15028      #+kindex: C-c C-e c a
15029      #+findex: org-icalendar-export-agenda-files
15030      Create iCalendar entries from Org files in ~org-agenda-files~ and
15031      store in a separate iCalendar file for each Org file.
15033 - {{{kbd(C-c C-e c c)}}} (~org-icalendar-combine-agenda-files~) ::
15035      #+kindex: C-c C-e c c
15036      #+findex: org-icalendar-combine-agenda-files
15037      #+vindex: org-icalendar-combined-agenda-file
15038      Create a combined iCalendar file from Org files in
15039      ~org-agenda-files~ and write it to
15040      ~org-icalendar-combined-agenda-file~ file name.
15042 #+cindex: SUMMARY, property
15043 #+cindex: DESCRIPTION, property
15044 #+cindex: LOCATION, property
15045 #+cindex: TIMEZONE, property
15046 The iCalendar export back-end includes =SUMMARY=, =DESCRIPTION=,
15047 =LOCATION= and =TIMEZONE= properties from the Org entries when
15048 exporting.  To force the back-end to inherit the =LOCATION= and
15049 =TIMEZONE= properties, configure the ~org-use-property-inheritance~
15050 variable.
15052 #+vindex: org-icalendar-include-body
15053 When Org entries do not have =SUMMARY=, =DESCRIPTION= and =LOCATION=
15054 properties, the iCalendar export back-end derives the summary from the
15055 headline, and derives the description from the body of the Org item.
15056 The ~org-icalendar-include-body~ variable limits the maximum number of
15057 characters of the content are turned into its description.
15059 The =TIMEZONE= property can be used to specify a per-entry time zone,
15060 and is applied to any entry with timestamp information.  Time zones
15061 should be specified as per the IANA time zone database format, e.g.,
15062 =Asia/Almaty=.  Alternately, the property value can be =UTC=, to force
15063 UTC time for this entry only.
15065 Exporting to iCalendar format depends in large part on the
15066 capabilities of the destination application.  Some are more lenient
15067 than others.  Consult the Org mode FAQ for advice on specific
15068 applications.
15070 ** Other Built-in Back-ends
15071 :PROPERTIES:
15072 :DESCRIPTION: Exporting to a man page.
15073 :END:
15075 Other export back-ends included with Org are:
15077 - =ox-man.el=: Export to a man page.
15079 To activate such back-ends, either customize ~org-export-backends~ or
15080 load directly with ~(require 'ox-man)~.  On successful load, the
15081 back-end adds new keys in the export dispatcher (see [[*The Export
15082 Dispatcher]]).
15084 Follow the comment section of such files, for example, =ox-man.el=,
15085 for usage and configuration details.
15087 ** Advanced Configuration
15088 :PROPERTIES:
15089 :DESCRIPTION: Fine-tuning the export output.
15090 :END:
15092 *** Hooks
15093 :PROPERTIES:
15094 :UNNUMBERED: notoc
15095 :END:
15097 #+vindex: org-export-before-processing-hook
15098 #+vindex: org-export-before-parsing-hook
15099 The export process executes two hooks before the actual exporting
15100 begins.  The first hook, ~org-export-before-processing-hook~, runs
15101 before any expansions of macros, Babel code, and include keywords in
15102 the buffer.  The second hook, ~org-export-before-parsing-hook~, runs
15103 before the buffer is parsed.
15105 Functions added to these hooks are called with a single argument: the
15106 export back-end actually used, as a symbol.  You may use them for
15107 heavy duty structural modifications of the document.  For example, you
15108 can remove every headline in the buffer during export like this:
15110 #+begin_src emacs-lisp
15111   (defun my-headline-removal (backend)
15112     "Remove all headlines in the current buffer.
15113   BACKEND is the export back-end being used, as a symbol."
15114     (org-map-entries
15115      (lambda () (delete-region (point) (line-beginning-position 2)))))
15117   (add-hook 'org-export-before-parsing-hook 'my-headline-removal)
15118 #+end_src
15120 *** Filters
15121 :PROPERTIES:
15122 :UNNUMBERED: notoc
15123 :END:
15125 #+cindex: Filters, exporting
15126 Filters are lists of functions to be applied to certain parts for
15127 a given back-end.  The output from the first function in the filter is
15128 passed on to the next function in the filter.  The final output is the
15129 output from the final function in the filter.
15131 The Org export process has many filter sets applicable to different
15132 types of objects, plain text, parse trees, export options, and final
15133 output formats.  The filters are named after the element type or
15134 object type: ~org-export-filter-TYPE-functions~, where {{{var(TYPE)}}}
15135 is the type targeted by the filter.  Valid types are:
15137 #+attr_texinfo: :columns 0.33 0.33 0.33
15138 | body                | bold               | babel-call       |
15139 | center-block        | clock              | code             |
15140 | diary-sexp          | drawer             | dynamic-block    |
15141 | entity              | example-block      | export-block     |
15142 | export-snippet      | final-output       | fixed-width      |
15143 | footnote-definition | footnote-reference | headline         |
15144 | horizontal-rule     | inline-babel-call  | inline-src-block |
15145 | inlinetask          | italic             | item             |
15146 | keyword             | latex-environment  | latex-fragment   |
15147 | line-break          | link               | node-property    |
15148 | options             | paragraph          | parse-tree       |
15149 | plain-list          | plain-text         | planning         |
15150 | property-drawer     | quote-block        | radio-target     |
15151 | section             | special-block      | src-block        |
15152 | statistics-cookie   | strike-through     | subscript        |
15153 | superscript         | table              | table-cell       |
15154 | table-row           | target             | timestamp        |
15155 | underline           | verbatim           | verse-block      |
15157 Here is an example filter that replaces non-breaking spaces ~ ~ in the
15158 Org buffer with =~= for the LaTeX back-end.
15160 #+begin_src emacs-lisp
15161   (defun my-latex-filter-nobreaks (text backend info)
15162     "Ensure \" \" are properly handled in LaTeX export."
15163     (when (org-export-derived-backend-p backend 'latex)
15164       (replace-regexp-in-string " " "~" text)))
15166   (add-to-list 'org-export-filter-plain-text-functions
15167                'my-latex-filter-nobreaks)
15168 #+end_src
15170 A filter requires three arguments: the code to be transformed, the
15171 name of the back-end, and some optional information about the export
15172 process.  The third argument can be safely ignored.  Note the use of
15173 ~org-export-derived-backend-p~ predicate that tests for /latex/
15174 back-end or any other back-end, such as /beamer/, derived from
15175 /latex/.
15177 *** Defining filters for individual files
15178 :PROPERTIES:
15179 :UNNUMBERED: notoc
15180 :END:
15182 The Org export can filter not just for back-ends, but also for
15183 specific files through the =BIND= keyword.  Here is an example with
15184 two filters; one removes brackets from time stamps, and the other
15185 removes strike-through text.  The filter functions are defined in
15186 a code block in the same Org file, which is a handy location for
15187 debugging.
15189 #+begin_example
15190   ,#+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
15191   ,#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
15192   ,#+BEGIN_SRC emacs-lisp :exports results :results none
15193     (defun tmp-f-timestamp (s backend info)
15194       (replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
15195     (defun tmp-f-strike-through (s backend info) "")
15196   ,#+END_SRC
15197 #+end_example
15199 *** Extending an existing back-end
15200 :PROPERTIES:
15201 :UNNUMBERED: notoc
15202 :END:
15204 Some parts of the conversion process can be extended for certain
15205 elements so as to introduce a new or revised translation.  That is how
15206 the HTML export back-end was extended to handle Markdown format.  The
15207 extensions work seamlessly so any aspect of filtering not done by the
15208 extended back-end is handled by the original back-end.  Of all the
15209 export customization in Org, extending is very powerful as it operates
15210 at the parser level.
15212 For this example, make the /ascii/ back-end display the language used
15213 in a source code block.  Also make it display only when some attribute
15214 is non-~nil~, like the following:
15216 : #+ATTR_ASCII: :language t
15218 Then extend /ascii/ back-end with a custom "my-ascii" back-end.
15220 #+begin_src emacs-lisp
15221   (defun my-ascii-src-block (src-block contents info)
15222     "Transcode a SRC-BLOCK element from Org to ASCII.
15223   CONTENTS is nil.  INFO is a plist used as a communication
15224   channel."
15225     (if (not (org-export-read-attribute :attr_ascii src-block :language))
15226         (org-export-with-backend 'ascii src-block contents info)
15227       (concat
15228        (format ",--[ %s ]--\n%s`----"
15229                (org-element-property :language src-block)
15230                (replace-regexp-in-string
15231                 "^" "| "
15232                 (org-element-normalize-string
15233                  (org-export-format-code-default src-block info)))))))
15235   (org-export-define-derived-backend 'my-ascii 'ascii
15236     :translate-alist '((src-block . my-ascii-src-block)))
15237 #+end_src
15239 The ~my-ascii-src-block~ function looks at the attribute above the
15240 current element.  If not true, hands over to /ascii/ back-end.  If
15241 true, which it is in this example, it creates a box around the code
15242 and leaves room for the inserting a string for language.  The last
15243 form creates the new back-end that springs to action only when
15244 translating ~src-block~ type elements.
15246 To use the newly defined back-end, evaluate the following from an Org
15247 buffer:
15249 #+begin_src emacs-lisp
15250   (org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
15251 #+end_src
15253 Further steps to consider would be an interactive function,
15254 self-installing an item in the export dispatcher menu, and other
15255 user-friendly improvements.
15257 ** Export in Foreign Buffers
15258 :PROPERTIES:
15259 :DESCRIPTION: Author tables and lists in Org syntax.
15260 :END:
15262 The export back-ends in Org often include commands to convert selected
15263 regions.  A convenient feature of this in-place conversion is that the
15264 exported output replaces the original source.  Here are such
15265 functions:
15267 - ~org-html-convert-region-to-html~ ::
15269      #+findex: org-html-convert-region-to-html
15270      Convert the selected region into HTML.
15272 - ~org-latex-convert-region-to-latex~ ::
15274      #+findex: org-latex-convert-region-to-latex
15275      Convert the selected region into LaTeX.
15277 - ~org-texinfo-convert-region-to-texinfo~ ::
15279      #+findex: org-texinfo-convert-region-to-texinfo
15280      Convert the selected region into Texinfo.
15282 - ~org-md-convert-region-to-md~ ::
15284      #+findex: org-md-convert-region-to-md
15285      Convert the selected region into Markdown.
15287 In-place conversions are particularly handy for quick conversion of
15288 tables and lists in foreign buffers.  For example, turn on the minor
15289 mode {{{kbd(M-x orgstruct-mode)}}} in an HTML buffer, then use the
15290 convenient Org keyboard commands to create a list, select it, and
15291 covert it to HTML with {{{kbd(M-x org-html-convert-region-to-html)}}}.
15293 * Publishing
15294 :PROPERTIES:
15295 :DESCRIPTION: Create a web site of linked Org files.
15296 :END:
15297 #+cindex: publishing
15299 Org includes a publishing management system that allows you to
15300 configure automatic HTML conversion of /projects/ composed of
15301 interlinked Org files.  You can also configure Org to automatically
15302 upload your exported HTML pages and related attachments, such as
15303 images and source code files, to a web server.
15305 You can also use Org to convert files into PDF, or even combine HTML
15306 and PDF conversion so that files are available in both formats on the
15307 server.
15309 Publishing has been contributed to Org by David O'Toole.
15311 ** Configuration
15312 :PROPERTIES:
15313 :DESCRIPTION: Defining projects.
15314 :END:
15315 Publishing needs significant configuration to specify files,
15316 destination and many other properties of a project.
15318 *** The variable ~org-publish-project-alist~
15319 :PROPERTIES:
15320 :DESCRIPTION: The central configuration variable.
15321 :ALT_TITLE: Project alist
15322 :END:
15323 #+cindex: projects, for publishing
15325 #+cindex: org-publish-project-alist
15326 Publishing is configured almost entirely through setting the value of
15327 one variable, called ~org-publish-project-alist~.  Each element of the
15328 list configures one project, and may be in one of the two following
15329 forms:
15331 #+begin_src emacs-lisp
15332   ("project-name" :property value :property value ...)
15333 #+end_src
15335 #+texinfo: @noindent
15336 i.e., a well-formed property list with alternating keys and values,
15339 #+begin_src emacs-lisp
15340   ("project-name" :components ("project-name" "project-name" ...))
15341 #+end_src
15343 In both cases, projects are configured by specifying property values.
15344 A project defines the set of files that are to be published, as well
15345 as the publishing configuration to use when publishing those files.
15346 When a project takes the second form listed above, the individual
15347 members of the ~:components~ property are taken to be sub-projects,
15348 which group together files requiring different publishing options.
15349 When you publish such a "meta-project", all the components are also
15350 published, in the sequence given.
15352 *** Sources and destinations for files
15353 :PROPERTIES:
15354 :DESCRIPTION: From here to there.
15355 :ALT_TITLE: Sources and destinations
15356 :END:
15357 #+cindex: directories, for publishing
15359 Most properties are optional, but some should always be set.  In
15360 particular, Org needs to know where to look for source files, and
15361 where to put published files.
15363 - ~:base-directory~ ::
15365      Directory containing publishing source files.
15367 - ~:publishing-directory~ ::
15369      Directory where output files are published.  You can directly
15370      publish to a webserver using a file name syntax appropriate for
15371      the Emacs tramp package.  Or you can publish to a local directory
15372      and use external tools to upload your website (see [[*Uploading
15373      Files]]).
15375 - ~:preparation-function~ ::
15377      Function or list of functions to be called before starting the
15378      publishing process, for example, to run =make= for updating files
15379      to be published.  Each preparation function is called with
15380      a single argument, the project property list.
15382 - ~:completion-function~ ::
15384      Function or list of functions called after finishing the
15385      publishing process, for example, to change permissions of the
15386      resulting files.  Each completion function is called with
15387      a single argument, the project property list.
15389 *** Selecting files
15390 :PROPERTIES:
15391 :DESCRIPTION: What files are part of the project?
15392 :END:
15393 #+cindex: files, selecting for publishing
15395 By default, all files with extension =.org= in the base directory are
15396 considered part of the project.  This can be modified by setting the
15397 following properties
15399 - ~:base-extension~ ::
15401      Extension---without the dot---of source files.  This actually
15402      is a regular expression.  Set this to the symbol ~any~ if you
15403      want to get all files in ~:base-directory~, even without
15404      extension.
15406 - ~:exclude~ ::
15408      Regular expression to match file names that should not be published,
15409      even though they have been selected on the basis of their extension.
15411 - ~:include~ ::
15413      List of files to be included regardless of ~:base-extension~ and
15414      ~:exclude~.
15416 - ~:recursive~ ::
15418      Non-~nil~ means, check base-directory recursively for files to
15419      publish.
15421 *** Publishing action
15422 :PROPERTIES:
15423 :DESCRIPTION: Setting the function doing the publishing.
15424 :END:
15425 #+cindex: action, for publishing
15427 Publishing means that a file is copied to the destination directory
15428 and possibly transformed in the process.  The default transformation
15429 is to export Org files as HTML files, and this is done by the function
15430 ~org-publish-org-to-html~ which calls the HTML exporter (see [[*HTML
15431 Export]]).  But you can also publish your content as PDF files using
15432 ~org-publish-org-to-pdf~, or as ASCII, Texinfo, etc., using the
15433 corresponding functions.
15435 If you want to publish the Org file as an =.org= file but with
15436 /archived/, /commented/, and /tag-excluded/ trees removed, use
15437 ~org-publish-org-to-org~.  This produces =file.org= and put it in the
15438 publishing directory.  If you want a htmlized version of this file,
15439 set the parameter ~:htmlized-source~ to ~t~.  It produces
15440 =file.org.html= in the publishing directory[fn:130].
15442 Other files like images only need to be copied to the publishing
15443 destination; for this you can use ~org-publish-attachment~.  For
15444 non-Org files, you always need to specify the publishing function:
15446 - ~:publishing-function~ ::
15448      Function executing the publication of a file.  This may also be
15449      a list of functions, which are all called in turn.
15451 - ~:plain-source~ ::
15453      Non-~nil~ means, publish plain source.
15455 - ~:htmlized-source~ ::
15457      Non-~nil~ means, publish htmlized source.
15459 The function must accept three arguments: a property list containing
15460 at least a ~:publishing-directory~ property, the name of the file to
15461 be published, and the path to the publishing directory of the output
15462 file.  It should take the specified file, make the necessary
15463 transformation, if any, and place the result into the destination
15464 folder.
15466 *** Options for the exporters
15467 :PROPERTIES:
15468 :DESCRIPTION: Tweaking HTML/@LaTeX{} export.
15469 :ALT_TITLE: Publishing options
15470 :END:
15471 #+cindex: options, for publishing
15472 #+cindex: publishing options
15474 The property list can be used to set many export options for the HTML
15475 and LaTeX exporters.  In most cases, these properties correspond to
15476 user variables in Org.  The table below lists these properties along
15477 with the variable they belong to.  See the documentation string for
15478 the respective variable for details.
15480 #+vindex: org-publish-project-alist
15481 When a property is given a value in ~org-publish-project-alist~, its
15482 setting overrides the value of the corresponding user variable, if
15483 any, during publishing.  Options set within a file (see [[*Export
15484 Settings]]), however, override everything.
15486 **** Generic properties
15487 :PROPERTIES:
15488 :UNNUMBERED: notoc
15489 :END:
15491 | ~:archived-trees~       | ~org-export-with-archived-trees~   |
15492 | ~:exclude-tags~         | ~org-export-exclude-tags~          |
15493 | ~:headline-levels~      | ~org-export-headline-levels~       |
15494 | ~:language~             | ~org-export-default-language~      |
15495 | ~:preserve-breaks~      | ~org-export-preserve-breaks~       |
15496 | ~:section-numbers~      | ~org-export-with-section-numbers~  |
15497 | ~:select-tags~          | ~org-export-select-tags~           |
15498 | ~:with-author~          | ~org-export-with-author~           |
15499 | ~:with-broken-links~    | ~org-export-with-broken-links~     |
15500 | ~:with-clocks~          | ~org-export-with-clocks~           |
15501 | ~:with-creator~         | ~org-export-with-creator~          |
15502 | ~:with-date~            | ~org-export-with-date~             |
15503 | ~:with-drawers~         | ~org-export-with-drawers~          |
15504 | ~:with-email~           | ~org-export-with-email~            |
15505 | ~:with-emphasize~       | ~org-export-with-emphasize~        |
15506 | ~:with-fixed-width~     | ~org-export-with-fixed-width~      |
15507 | ~:with-footnotes~       | ~org-export-with-footnotes~        |
15508 | ~:with-latex~           | ~org-export-with-latex~            |
15509 | ~:with-planning~        | ~org-export-with-planning~         |
15510 | ~:with-priority~        | ~org-export-with-priority~         |
15511 | ~:with-properties~      | ~org-export-with-properties~       |
15512 | ~:with-special-strings~ | ~org-export-with-special-strings~  |
15513 | ~:with-sub-superscript~ | ~org-export-with-sub-superscripts~ |
15514 | ~:with-tables~          | ~org-export-with-tables~           |
15515 | ~:with-tags~            | ~org-export-with-tags~             |
15516 | ~:with-tasks~           | ~org-export-with-tasks~            |
15517 | ~:with-timestamps~      | ~org-export-with-timestamps~       |
15518 | ~:with-title~           | ~org-export-with-title~            |
15519 | ~:with-toc~             | ~org-export-with-toc~              |
15520 | ~:with-todo-keywords~   | ~org-export-with-todo-keywords~    |
15522 **** ASCII specific properties
15523 :PROPERTIES:
15524 :UNNUMBERED: notoc
15525 :END:
15527 | ~:ascii-bullets~                       | ~org-ascii-bullets~                       |
15528 | ~:ascii-caption-above~                 | ~org-ascii-caption-above~                 |
15529 | ~:ascii-charset~                       | ~org-ascii-charset~                       |
15530 | ~:ascii-global-margin~                 | ~org-ascii-global-margin~                 |
15531 | ~:ascii-format-drawer-function~        | ~org-ascii-format-drawer-function~        |
15532 | ~:ascii-format-inlinetask-function~    | ~org-ascii-format-inlinetask-function~    |
15533 | ~:ascii-headline-spacing~              | ~org-ascii-headline-spacing~              |
15534 | ~:ascii-indented-line-width~           | ~org-ascii-indented-line-width~           |
15535 | ~:ascii-inlinetask-width~              | ~org-ascii-inlinetask-width~              |
15536 | ~:ascii-inner-margin~                  | ~org-ascii-inner-margin~                  |
15537 | ~:ascii-links-to-notes~                | ~org-ascii-links-to-notes~                |
15538 | ~:ascii-list-margin~                   | ~org-ascii-list-margin~                   |
15539 | ~:ascii-paragraph-spacing~             | ~org-ascii-paragraph-spacing~             |
15540 | ~:ascii-quote-margin~                  | ~org-ascii-quote-margin~                  |
15541 | ~:ascii-table-keep-all-vertical-lines~ | ~org-ascii-table-keep-all-vertical-lines~ |
15542 | ~:ascii-table-use-ascii-art~           | ~org-ascii-table-use-ascii-art~           |
15543 | ~:ascii-table-widen-columns~           | ~org-ascii-table-widen-columns~           |
15544 | ~:ascii-text-width~                    | ~org-ascii-text-width~                    |
15545 | ~:ascii-underline~                     | ~org-ascii-underline~                     |
15546 | ~:ascii-verbatim-format~               | ~org-ascii-verbatim-format~               |
15548 **** Beamer specific properties
15549 :PROPERTIES:
15550 :UNNUMBERED: notoc
15551 :END:
15553 | ~:beamer-theme~                 | ~org-beamer-theme~                 |
15554 | ~:beamer-column-view-format~    | ~org-beamer-column-view-format~    |
15555 | ~:beamer-environments-extra~    | ~org-beamer-environments-extra~    |
15556 | ~:beamer-frame-default-options~ | ~org-beamer-frame-default-options~ |
15557 | ~:beamer-outline-frame-options~ | ~org-beamer-outline-frame-options~ |
15558 | ~:beamer-outline-frame-title~   | ~org-beamer-outline-frame-title~   |
15559 | ~:beamer-subtitle-format~       | ~org-beamer-subtitle-format~       |
15561 **** HTML specific properties
15562 :PROPERTIES:
15563 :UNNUMBERED: notoc
15564 :END:
15566 | ~:html-allow-name-attribute-in-anchors~        | ~org-html-allow-name-attribute-in-anchors~        |
15567 | ~:html-checkbox-type~                          | ~org-html-checkbox-type~                          |
15568 | ~:html-container~                              | ~org-html-container-element~                      |
15569 | ~:html-divs~                                   | ~org-html-divs~                                   |
15570 | ~:html-doctype~                                | ~org-html-doctype~                                |
15571 | ~:html-extension~                              | ~org-html-extension~                              |
15572 | ~:html-footnote-format~                        | ~org-html-footnote-format~                        |
15573 | ~:html-footnote-separator~                     | ~org-html-footnote-separator~                     |
15574 | ~:html-footnotes-section~                      | ~org-html-footnotes-section~                      |
15575 | ~:html-format-drawer-function~                 | ~org-html-format-drawer-function~                 |
15576 | ~:html-format-headline-function~               | ~org-html-format-headline-function~               |
15577 | ~:html-format-inlinetask-function~             | ~org-html-format-inlinetask-function~             |
15578 | ~:html-head-extra~                             | ~org-html-head-extra~                             |
15579 | ~:html-head-include-default-style~             | ~org-html-head-include-default-style~             |
15580 | ~:html-head-include-scripts~                   | ~org-html-head-include-scripts~                   |
15581 | ~:html-head~                                   | ~org-html-head~                                   |
15582 | ~:html-home/up-format~                         | ~org-html-home/up-format~                         |
15583 | ~:html-html5-fancy~                            | ~org-html-html5-fancy~                            |
15584 | ~:html-indent~                                 | ~org-html-indent~                                 |
15585 | ~:html-infojs-options~                         | ~org-html-infojs-options~                         |
15586 | ~:html-infojs-template~                        | ~org-html-infojs-template~                        |
15587 | ~:html-inline-image-rules~                     | ~org-html-inline-image-rules~                     |
15588 | ~:html-inline-images~                          | ~org-html-inline-images~                          |
15589 | ~:html-link-home~                              | ~org-html-link-home~                              |
15590 | ~:html-link-org-files-as-html~                 | ~org-html-link-org-files-as-html~                 |
15591 | ~:html-link-up~                                | ~org-html-link-up~                                |
15592 | ~:html-link-use-abs-url~                       | ~org-html-link-use-abs-url~                       |
15593 | ~:html-mathjax-options~                        | ~org-html-mathjax-options~                        |
15594 | ~:html-mathjax-template~                       | ~org-html-mathjax-template~                       |
15595 | ~:html-metadata-timestamp-format~              | ~org-html-metadata-timestamp-format~              |
15596 | ~:html-postamble-format~                       | ~org-html-postamble-format~                       |
15597 | ~:html-postamble~                              | ~org-html-postamble~                              |
15598 | ~:html-preamble-format~                        | ~org-html-preamble-format~                        |
15599 | ~:html-preamble~                               | ~org-html-preamble~                               |
15600 | ~:html-table-align-individual-field~           | ~de{org-html-table-align-individual-fields~       |
15601 | ~:html-table-attributes~                       | ~org-html-table-default-attributes~               |
15602 | ~:html-table-caption-above~                    | ~org-html-table-caption-above~                    |
15603 | ~:html-table-data-tags~                        | ~org-html-table-data-tags~                        |
15604 | ~:html-table-header-tags~                      | ~org-html-table-header-tags~                      |
15605 | ~:html-table-row-tags~                         | ~org-html-table-row-tags~                         |
15606 | ~:html-table-use-header-tags-for-first-column~ | ~org-html-table-use-header-tags-for-first-column~ |
15607 | ~:html-tag-class-prefix~                       | ~org-html-tag-class-prefix~                       |
15608 | ~:html-text-markup-alist~                      | ~org-html-text-markup-alist~                      |
15609 | ~:html-todo-kwd-class-prefix~                  | ~org-html-todo-kwd-class-prefix~                  |
15610 | ~:html-toplevel-hlevel~                        | ~org-html-toplevel-hlevel~                        |
15611 | ~:html-use-infojs~                             | ~org-html-use-infojs~                             |
15612 | ~:html-validation-link~                        | ~org-html-validation-link~                        |
15613 | ~:html-viewport~                               | ~org-html-viewport~                               |
15614 | ~:html-xml-declaration~                        | ~org-html-xml-declaration~                        |
15616 **** LaTeX specific properties
15617 :PROPERTIES:
15618 :UNNUMBERED: notoc
15619 :END:
15621 | ~:latex-active-timestamp-format~       | ~org-latex-active-timestamp-format~       |
15622 | ~:latex-caption-above~                 | ~org-latex-caption-above~                 |
15623 | ~:latex-classes~                       | ~org-latex-classes~                       |
15624 | ~:latex-class~                         | ~org-latex-default-class~                 |
15625 | ~:latex-compiler~                      | ~org-latex-compiler~                      |
15626 | ~:latex-default-figure-position~       | ~org-latex-default-figure-position~       |
15627 | ~:latex-default-table-environment~     | ~org-latex-default-table-environment~     |
15628 | ~:latex-default-table-mode~            | ~org-latex-default-table-mode~            |
15629 | ~:latex-diary-timestamp-format~        | ~org-latex-diary-timestamp-format~        |
15630 | ~:latex-footnote-defined-format~       | ~org-latex-footnote-defined-format~       |
15631 | ~:latex-footnote-separator~            | ~org-latex-footnote-separator~            |
15632 | ~:latex-format-drawer-function~        | ~org-latex-format-drawer-function~        |
15633 | ~:latex-format-headline-function~      | ~org-latex-format-headline-function~      |
15634 | ~:latex-format-inlinetask-function~    | ~org-latex-format-inlinetask-function~    |
15635 | ~:latex-hyperref-template~             | ~org-latex-hyperref-template~             |
15636 | ~:latex-image-default-height~          | ~org-latex-image-default-height~          |
15637 | ~:latex-image-default-option~          | ~org-latex-image-default-option~          |
15638 | ~:latex-image-default-width~           | ~org-latex-image-default-width~           |
15639 | ~:latex-images-centered~               | ~org-latex-images-centered~               |
15640 | ~:latex-inactive-timestamp-format~     | ~org-latex-inactive-timestamp-format~     |
15641 | ~:latex-inline-image-rules~            | ~org-latex-inline-image-rules~            |
15642 | ~:latex-link-with-unknown-path-format~ | ~org-latex-link-with-unknown-path-format~ |
15643 | ~:latex-listings-langs~                | ~org-latex-listings-langs~                |
15644 | ~:latex-listings-options~              | ~org-latex-listings-options~              |
15645 | ~:latex-listings~                      | ~org-latex-listings~                      |
15646 | ~:latex-minted-langs~                  | ~org-latex-minted-langs~                  |
15647 | ~:latex-minted-options~                | ~org-latex-minted-options~                |
15648 | ~:latex-prefer-user-labels~            | ~org-latex-prefer-user-labels~            |
15649 | ~:latex-subtitle-format~               | ~org-latex-subtitle-format~               |
15650 | ~:latex-subtitle-separate~             | ~org-latex-subtitle-separate~             |
15651 | ~:latex-table-scientific-notation~     | ~org-latex-table-scientific-notation~     |
15652 | ~:latex-tables-booktabs~               | ~org-latex-tables-booktabs~               |
15653 | ~:latex-tables-centered~               | ~org-latex-tables-centered~               |
15654 | ~:latex-text-markup-alist~             | ~org-latex-text-markup-alist~             |
15655 | ~:latex-title-command~                 | ~org-latex-title-command~                 |
15656 | ~:latex-toc-command~                   | ~org-latex-toc-command~                   |
15658 **** Markdown specific properties
15659 :PROPERTIES:
15660 :UNNUMBERED: notoc
15661 :END:
15663 | ~:md-footnote-format~   | ~org-md-footnote-format~   |
15664 | ~:md-footnotes-section~ | ~org-md-footnotes-section~ |
15665 | ~:md-headline-style~    | ~org-md-headline-style~    |
15667 **** ODT specific properties
15668 :PROPERTIES:
15669 :UNNUMBERED: notoc
15670 :END:
15672 | ~:odt-content-template-file~      | ~org-odt-content-template-file~      |
15673 | ~:odt-display-outline-level~      | ~org-odt-display-outline-level~      |
15674 | ~:odt-fontify-srcblocks~          | ~org-odt-fontify-srcblocks~          |
15675 | ~:odt-format-drawer-function~     | ~org-odt-format-drawer-function~     |
15676 | ~:odt-format-headline-function~   | ~org-odt-format-headline-function~   |
15677 | ~:odt-format-inlinetask-function~ | ~org-odt-format-inlinetask-function~ |
15678 | ~:odt-inline-formula-rules~       | ~org-odt-inline-formula-rules~       |
15679 | ~:odt-inline-image-rules~         | ~org-odt-inline-image-rules~         |
15680 | ~:odt-pixels-per-inch~            | ~org-odt-pixels-per-inch~            |
15681 | ~:odt-styles-file~                | ~org-odt-styles-file~                |
15682 | ~:odt-table-styles~               | ~org-odt-table-styles~               |
15683 | ~:odt-use-date-fields~            | ~org-odt-use-date-fields~            |
15685 **** Texinfo specific properties
15686 :PROPERTIES:
15687 :UNNUMBERED: notoc
15688 :END:
15690 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
15691 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
15692 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
15693 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
15694 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
15695 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |
15696 | ~:texinfo-format-drawer-function~        | ~org-texinfo-format-drawer-function~        |
15697 | ~:texinfo-format-headline-function~      | ~org-texinfo-format-headline-function~      |
15698 | ~:texinfo-format-inlinetask-function~    | ~org-texinfo-format-inlinetask-function~    |
15699 | ~:texinfo-inactive-timestamp-format~     | ~org-texinfo-inactive-timestamp-format~     |
15700 | ~:texinfo-link-with-unknown-path-format~ | ~org-texinfo-link-with-unknown-path-format~ |
15701 | ~:texinfo-node-description-column~       | ~org-texinfo-node-description-column~       |
15702 | ~:texinfo-table-scientific-notation~     | ~org-texinfo-table-scientific-notation~     |
15703 | ~:texinfo-tables-verbatim~               | ~org-texinfo-tables-verbatim~               |
15704 | ~:texinfo-text-markup-alist~             | ~org-texinfo-text-markup-alist~             |
15706 *** Publishing links
15707 :PROPERTIES:
15708 :DESCRIPTION: Which links keep working after publishing?
15709 :END:
15710 #+cindex: links, publishing
15712 To create a link from one Org file to another, you would use something
15713 like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]).  When
15714 published, this link becomes a link to =foo.html=.  You can thus
15715 interlink the pages of your "Org web" project and the links will work
15716 as expected when you publish them to HTML.  If you also publish the
15717 Org source file and want to link to it, use an =http= link instead of
15718 a =file:= link, because =file= links are converted to link to the
15719 corresponding =.html= file.
15721 You may also link to related files, such as images.  Provided you are
15722 careful with relative file names, and provided you have also
15723 configured Org to upload the related files, these links will work too.
15724 See [[*Example: complex publishing configuration]], for an example of this
15725 usage.
15727 Eventually, links between published documents can contain some search
15728 options (see [[*Search Options in File Links]]), which will be resolved to
15729 the appropriate location in the linked file.  For example, once
15730 published to HTML, the following links all point to a dedicated anchor
15731 in =foo.html=.
15733 #+begin_example
15734   [[file:foo.org::*heading]]
15735   [[file:foo.org::#custom-id]]
15736   [[file:foo.org::target]]
15737 #+end_example
15739 *** Generating a sitemap
15740 :PROPERTIES:
15741 :DESCRIPTION: Generating a list of all pages.
15742 :ALT_TITLE: Site map
15743 :END:
15744 #+cindex: sitemap, of published pages
15746 The following properties may be used to control publishing of
15747 a map of files for a given project.
15749 - ~:auto-sitemap~ ::
15751      When non-~nil~, publish a sitemap during
15752      ~org-publish-current-project~ or ~org-publish-all~.
15754 - ~:sitemap-filename~ ::
15756      Filename for output of sitemap.  Defaults to =sitemap.org=, which
15757      becomes =sitemap.html=.
15759 - ~:sitemap-title~ ::
15761      Title of sitemap page.  Defaults to name of file.
15763 - ~:sitemap-format-entry~ ::
15765      #+findex: org-publish-find-date
15766      #+findex: org-publish-find-property
15767      #+findex: org-publish-find-title
15768      With this option one can tell how a site-map entry is formatted
15769      in the site-map.  It is a function called with three arguments:
15770      the file or directory name relative to base directory of the
15771      project, the site-map style and the current project.  It is
15772      expected to return a string.  Default value turns file names into
15773      links and use document titles as descriptions.  For specific
15774      formatting needs, one can use ~org-publish-find-date~,
15775      ~org-publish-find-title~ and ~org-publish-find-property~, to
15776      retrieve additional information about published documents.
15778 - ~:sitemap-function~ ::
15780      Plug-in function to use for generation of the sitemap.  It is
15781      called with two arguments: the title of the site-map and
15782      a representation of the files and directories involved in the
15783      project as a nested list, which can further be transformed using
15784      ~org-list-to-generic~, ~org-list-to-subtree~ and alike.  Default
15785      value generates a plain list of links to all files in the
15786      project.
15788 - ~:sitemap-sort-folders~ ::
15790      Where folders should appear in the sitemap.  Set this to ~first~
15791      (default) or ~last~ to display folders first or last,
15792      respectively.  When set to ~ignore~, folders are ignored
15793      altogether.  Any other value mixes files and folders.  This
15794      variable has no effect when site-map style is ~tree~.
15796 - ~:sitemap-sort-files~ ::
15798      How the files are sorted in the site map.  Set this to
15799      ~alphabetically~ (default), ~chronologically~ or
15800      ~anti-chronologically~.  ~chronologically~ sorts the files with
15801      older date first while ~anti-chronologically~ sorts the files
15802      with newer date first.  ~alphabetically~ sorts the files
15803      alphabetically.  The date of a file is retrieved with
15804      ~org-publish-find-date~.
15806 - ~:sitemap-ignore-case~ ::
15808      Should sorting be case-sensitive?  Default ~nil~.
15810 - ~:sitemap-file-entry-format~ ::
15812      With this option one can tell how a sitemap's entry is formatted
15813      in the sitemap.  This is a format string with some escape
15814      sequences: ~%t~ stands for the title of the file, ~%a~ stands for
15815      the author of the file and ~%d~ stands for the date of the file.
15816      The date is retrieved with the ~org-publish-find-date~ function
15817      and formatted with ~org-publish-sitemap-date-format~.  Default
15818      ~%t~.
15820 - ~:sitemap-date-format~ ::
15822      Format string for the ~format-time-string~ function that tells
15823      how a sitemap entry's date is to be formatted.  This property
15824      bypasses ~org-publish-sitemap-date-format~ which defaults to
15825      ~%Y-%m-%d~.
15827 *** Generating an index
15828 :PROPERTIES:
15829 :DESCRIPTION: An index that reaches across pages.
15830 :END:
15831 #+cindex: index, in a publishing project
15833 Org mode can generate an index across the files of a publishing project.
15835 - ~:makeindex~ ::
15837      When non-~nil~, generate in index in the file =theindex.org= and
15838      publish it as =theindex.html=.
15840 The file is created when first publishing a project with the
15841 ~:makeindex~ set.  The file only contains a statement =#+INCLUDE:
15842 "theindex.inc"=.  You can then build around this include statement by
15843 adding a title, style information, etc.
15845 #+cindex: INDEX, keyword
15846 Index entries are specified with =INDEX= keyword.  An entry that
15847 contains an exclamation mark creates a sub item.
15849 #+begin_example
15850   ,*** Curriculum Vitae
15851   ,#+INDEX: CV
15852   ,#+INDEX: Application!CV
15853 #+end_example
15855 ** Uploading Files
15856 :PROPERTIES:
15857 :DESCRIPTION: How to get files up on the server.
15858 :END:
15859 #+cindex: rsync
15860 #+cindex: unison
15862 For those people already utilizing third party sync tools such as
15863 Rsync or Unison, it might be preferable not to use the built-in remote
15864 publishing facilities of Org mode which rely heavily on Tramp.  Tramp,
15865 while very useful and powerful, tends not to be so efficient for
15866 multiple file transfer and has been known to cause problems under
15867 heavy usage.
15869 Specialized synchronization utilities offer several advantages.  In
15870 addition to timestamp comparison, they also do content and
15871 permissions/attribute checks.  For this reason you might prefer to
15872 publish your web to a local directory---possibly even /in place/ with
15873 your Org files---and then use Unison or Rsync to do the
15874 synchronization with the remote host.
15876 Since Unison, for example, can be configured as to which files to
15877 transfer to a certain remote destination, it can greatly simplify the
15878 project publishing definition.  Simply keep all files in the correct
15879 location, process your Org files with ~org-publish~ and let the
15880 synchronization tool do the rest.  You do not need, in this scenario,
15881 to include attachments such as JPG, CSS or PNG files in the project
15882 definition since the third-party tool syncs them.
15884 Publishing to a local directory is also much faster than to a remote
15885 one, so that you can afford more easily to republish entire projects.
15886 If you set ~org-publish-use-timestamps-flag~ to ~nil~, you gain the
15887 main benefit of re-including any changed external files such as source
15888 example files you might include with =INCLUDE= keyword.  The timestamp
15889 mechanism in Org is not smart enough to detect if included files have
15890 been modified.
15892 ** Sample Configuration
15893 :PROPERTIES:
15894 :DESCRIPTION: Example projects.
15895 :END:
15897 Below we provide two example configurations.  The first one is
15898 a simple project publishing only a set of Org files.  The second
15899 example is more complex, with a multi-component project.
15901 *** Example: simple publishing configuration
15902 :PROPERTIES:
15903 :DESCRIPTION: One-component publishing.
15904 :ALT_TITLE: Simple example
15905 :END:
15907 This example publishes a set of Org files to the =public_html=
15908 directory on the local machine.
15910 #+begin_src emacs-lisp
15911   (setq org-publish-project-alist
15912         '(("org"
15913            :base-directory "~/org/"
15914            :publishing-directory "~/public_html"
15915            :section-numbers nil
15916            :table-of-contents nil
15917            :style "<link rel=\"stylesheet\"
15918                   href=\"../other/mystyle.css\"
15919                   type=\"text/css\"/>")))
15920 #+end_src
15922 *** Example: complex publishing configuration
15923 :PROPERTIES:
15924 :DESCRIPTION: A multi-component publishing example.
15925 :ALT_TITLE: Complex example
15926 :END:
15928 This more complicated example publishes an entire website, including
15929 Org files converted to HTML, image files, Emacs Lisp source code, and
15930 style sheets.  The publishing directory is remote and private files
15931 are excluded.
15933 To ensure that links are preserved, care should be taken to replicate
15934 your directory structure on the web server, and to use relative file
15935 paths.  For example, if your Org files are kept in =~/org/= and your
15936 publishable images in =~/images/=, you would link to an image with
15938 : file:../images/myimage.png
15940 On the web server, the relative path to the image should be the same.
15941 You can accomplish this by setting up an =images/= folder in the right
15942 place on the web server, and publishing images to it.
15944 #+begin_src emacs-lisp
15945   (setq org-publish-project-alist
15946         '(("orgfiles"
15947            :base-directory "~/org/"
15948            :base-extension "org"
15949            :publishing-directory "/ssh:user@host:~/html/notebook/"
15950            :publishing-function org-html-publish-to-html
15951            :exclude "PrivatePage.org" ;; regexp
15952            :headline-levels 3
15953            :section-numbers nil
15954            :with-toc nil
15955            :html-head "<link rel=\"stylesheet\"
15956                     href=\"../other/mystyle.css\" type=\"text/css\"/>"
15957            :html-preamble t)
15959           ("images"
15960            :base-directory "~/images/"
15961            :base-extension "jpg\\|gif\\|png"
15962            :publishing-directory "/ssh:user@host:~/html/images/"
15963            :publishing-function org-publish-attachment)
15965           ("other"
15966            :base-directory "~/other/"
15967            :base-extension "css\\|el"
15968            :publishing-directory "/ssh:user@host:~/html/other/"
15969            :publishing-function org-publish-attachment)
15970           ("website" :components ("orgfiles" "images" "other"))))
15971 #+end_src
15973 ** Triggering Publication
15974 :PROPERTIES:
15975 :DESCRIPTION: Publication commands.
15976 :END:
15978 Once properly configured, Org can publish with the following commands:
15980 - {{{kbd(C-c C-e X)}}} (~org-publish~) ::
15982      #+kindex: C-c C-e X
15983      #+findex: org-publish
15984      Prompt for a specific project and publish all files that belong
15985      to it.
15987 - {{{kbd(C-c C-e P)}}} (~org-publish-current-project~) ::
15989      #+kindex: C-c C-e P
15990      #+findex: org-publish-current-project
15991      Publish the project containing the current file.
15993 - {{{kbd(C-c C-e F)}}} (~org-publish-current-file~) ::
15995      #+kindex: C-c C-e F
15996      #+findex: org-publish-current-file
15997      Publish only the current file.
15999 - {{{kbd(C-c C-e E)}}} (~org-publish-all~) ::
16001      #+kindex: C-c C-e E
16002      #+findex: org-publish-all
16003      Publish every project.
16005 #+vindex: org-publish-use-timestamps-flag
16006 Org uses timestamps to track when a file has changed.  The above
16007 functions normally only publish changed files.  You can override this
16008 and force publishing of all files by giving a prefix argument to any
16009 of the commands above, or by customizing the variable
16010 ~org-publish-use-timestamps-flag~.  This may be necessary in
16011 particular if files include other files via =SETUPFILE= or =INCLUDE=
16012 keywords.
16014 * Working with Source Code
16015 :PROPERTIES:
16016 :DESCRIPTION: Export, evaluate, and tangle code blocks.
16017 :END:
16018 #+cindex: source code, working with
16020 Source code here refers to any plain text collection of computer
16021 instructions, possibly with comments, written using a human-readable
16022 programming language.  Org can manage source code in an Org document
16023 when the source code is identified with begin and end markers.
16024 Working with source code begins with identifying source code blocks.
16025 A source code block can be placed almost anywhere in an Org document;
16026 it is not restricted to the preamble or the end of the document.
16027 However, Org cannot manage a source code block if it is placed inside
16028 an Org comment or within a fixed width section.
16030 Here is an example source code block in the Emacs Lisp language:
16032 #+begin_example
16033   ,#+BEGIN_SRC emacs-lisp
16034     (defun org-xor (a b)
16035        "Exclusive or."
16036        (if a (not b) b))
16037   ,#+END_SRC
16038 #+end_example
16040 Org can manage the source code in the block delimited by =#+BEGIN_SRC=
16041 ... =#+END_SRC= in several ways that can simplify housekeeping tasks
16042 essential to modern source code maintenance.  Org can edit, format,
16043 extract, export, and publish source code blocks.  Org can also compile
16044 and execute a source code block, then capture the results.  The Org
16045 mode literature sometimes refers to source code blocks as /live code/
16046 blocks because they can alter the content of the Org document or the
16047 material that it exports.  Users can control how live they want each
16048 source code block by tweaking the header arguments (see [[*Using
16049 Header Arguments]]) for compiling, execution, extraction, and
16050 exporting.
16052 Source code blocks are one of many Org block types, which also include
16053 =quote=, =export=, =verse=, =latex=, =example=, and =verbatim=.  This
16054 section pertains to blocks between =#+BEGIN_SRC= and =#+END_SRC=.
16056 For editing and formatting a source code block, Org uses an
16057 appropriate Emacs major mode that includes features specifically
16058 designed for source code in that language.
16060 Org can extract one or more source code blocks and write them to one
16061 or more source files---a process known as /tangling/ in literate
16062 programming terminology.
16064 For exporting and publishing, Org's back-ends can format a source code
16065 block appropriately, often with native syntax highlighting.
16067 For executing and compiling a source code block, the user can
16068 configure Org to select the appropriate compiler.  Org provides
16069 facilities to collect the result of the execution or compiler output,
16070 insert it into the Org document, and/or export it.  In addition to
16071 text results, Org can insert links to other data types, including
16072 audio, video, and graphics.  Org can also link a compiler error
16073 message to the appropriate line in the source code block.
16075 An important feature of Org's management of source code blocks is the
16076 ability to pass variables, functions, and results to one another using
16077 a common syntax for source code blocks in any language.  Although most
16078 literate programming facilities are restricted to one language or
16079 another, Org's language-agnostic approach lets the literate programmer
16080 match each programming task with the appropriate computer language and
16081 to mix them all together in a single Org document.  This
16082 interoperability among languages explains why Org's source code
16083 management facility was named /Org Babel/ by its originators, Eric
16084 Schulte and Dan Davison.
16086 Org mode fulfills the promise of easy verification and maintenance of
16087 publishing reproducible research by keeping text, data, code,
16088 configuration settings of the execution environment, the results of
16089 the execution, and associated narratives, claims, references, and
16090 internal and external links in a single Org document.
16092 Details of Org's facilities for working with source code are described
16093 in the following sections.
16095 ** Structure of Code Blocks
16096 :PROPERTIES:
16097 :DESCRIPTION: Code block syntax described.
16098 :END:
16099 #+cindex: code block, structure
16100 #+cindex: source code, block structure
16101 #+cindex: NAME keyword, in source blocks
16102 #+cindex: BEGIN_SRC
16104 Org offers two ways to structure source code in Org documents: in
16105 a source code block, and directly inline.  Both specifications are
16106 shown below.
16108 A source code block conforms to this structure:
16110 #+begin_example
16111   ,#+NAME: <name>
16112   ,#+BEGIN_SRC <language> <switches> <header arguments>
16113     <body>
16114   ,#+END_SRC
16115 #+end_example
16117 Do not be put-off by having to remember the source block syntax.  Org
16118 mode offers a command for wrapping existing text in a block (see
16119 [[*Structure Templates]]).  Org also works with other completion systems
16120 in Emacs, some of which predate Org and have custom domain-specific
16121 languages for defining templates.  Regular use of templates reduces
16122 errors, increases accuracy, and maintains consistency.
16124 #+cindex: source code, inline
16125 An inline code block conforms to this structure:
16127 : src_<language>{<body>}
16129 #+texinfo: @noindent
16132 : src_<language>[<header arguments>]{<body>}
16134 - =#+NAME: <name>= ::
16136      Optional.  Names the source block so it can be called, like
16137      a function, from other source blocks or inline code to evaluate
16138      or to capture the results.  Code from other blocks, other files,
16139      and from table formulas (see [[*The spreadsheet]]) can use the name
16140      to reference a source block.  This naming serves the same purpose
16141      as naming Org tables.  Org mode requires unique names.  For
16142      duplicate names, Org mode's behavior is undefined.
16144 - =#+BEGIN_SRC= ... =#+END_SRC= ::
16146      Mandatory.  They mark the start and end of a block that Org
16147      requires.  The =#+BEGIN_SRC= line takes additional arguments, as
16148      described next.
16150 - =<language>= ::
16152      #+cindex: language, in code blocks
16153      Mandatory.  It is the identifier of the source code language in
16154      the block.  See [[*Languages]], for identifiers of supported
16155      languages.
16157 - =<switches>= ::
16159      #+cindex: switches, in code blocks
16160      Optional.  Switches provide finer control of the code execution,
16161      export, and format (see the discussion of switches in [[*Literal
16162      Examples]]).
16164 - =<header arguments>= ::
16166      #+cindex: header arguments, in code blocks
16167      Optional.  Heading arguments control many aspects of evaluation,
16168      export and tangling of code blocks (see [[*Using Header Arguments]]).
16169      Using Org's properties feature, header arguments can be
16170      selectively applied to the entire buffer or specific sub-trees of
16171      the Org document.
16173 - =<body>= ::
16175      Source code in the dialect of the specified language identifier.
16177 ** Using Header Arguments
16178 :PROPERTIES:
16179 :DESCRIPTION: Different ways to set header arguments.
16180 :END:
16182 Org comes with many header arguments common to all languages.  New
16183 header arguments are added for specific languages as they become
16184 available for use in source code blocks.  A header argument is
16185 specified with an initial colon followed by the argument's name in
16186 lowercase.
16188 Since header arguments can be set in several ways, Org prioritizes
16189 them in case of overlaps or conflicts by giving local settings
16190 a higher priority.  Header values in function calls, for example,
16191 override header values from global defaults.
16193 *** System-wide header arguments
16194 :PROPERTIES:
16195 :UNNUMBERED: notoc
16196 :END:
16197 #+vindex: org-babel-default-header-args
16199 #+vindex: org-babel-default-header-args
16200 System-wide values of header arguments can be specified by customizing
16201 the ~org-babel-default-header-args~ variable, which defaults to the
16202 following values:
16204 #+begin_example
16205   :session    => "none"
16206   :results    => "replace"
16207   :exports    => "code"
16208   :cache      => "no"
16209   :noweb      => "no"
16210 #+end_example
16212 The example below sets =:noweb= header arguments to =yes=, which makes
16213 Org expand =:noweb= references by default.
16215 #+begin_src emacs-lisp
16216   (setq org-babel-default-header-args
16217         (cons '(:noweb . "yes")
16218               (assq-delete-all :noweb org-babel-default-header-args)))
16219 #+end_src
16221 #+cindex: language specific default header arguments
16222 #+cindex: default header arguments per language
16223 Each language can have separate default header arguments by
16224 customizing the variable ~org-babel-default-header-args:<LANG>~, where
16225 {{{var(<LANG>)}}} is the name of the language.  For details, see the
16226 language-specific online documentation at
16227 https://orgmode.org/worg/org-contrib/babel/.
16229 *** Header arguments in Org mode properties
16230 :PROPERTIES:
16231 :UNNUMBERED: notoc
16232 :END:
16234 For header arguments applicable to the buffer, use =PROPERTY= keyword
16235 anywhere in the Org file (see [[*Property Syntax]]).
16237 The following example makes all the R code blocks execute in the same
16238 session.  Setting =:results= to =silent= ignores the results of
16239 executions for all blocks, not just R code blocks; no results inserted
16240 for any block.
16242 #+begin_example
16243   ,#+PROPERTY: header-args:R  :session *R*
16244   ,#+PROPERTY: header-args    :results silent
16245 #+end_example
16247 #+vindex: org-use-property-inheritance
16248 Header arguments set through Org's property drawers (see [[*Property
16249 Syntax]]) apply at the sub-tree level on down.  Since these property
16250 drawers can appear anywhere in the file hierarchy, Org uses outermost
16251 call or source block to resolve the values.  Org ignores
16252 ~org-use-property-inheritance~ setting.
16254 In this example, =:cache= defaults to =yes= for all code blocks in the
16255 sub-tree.
16257 #+begin_example
16258   ,* sample header
16259     :PROPERTIES:
16260     :header-args:    :cache yes
16261     :END:
16262 #+end_example
16264 #+kindex: C-c C-x p
16265 #+findex: org-set-property
16266 Properties defined through ~org-set-property~ function, bound to
16267 {{{kbd(C-c C-x p)}}}, apply to all active languages.  They override
16268 properties set in ~org-babel-default-header-args~.
16270 #+cindex: language specific header arguments properties
16271 #+cindex: header arguments per language
16272 Language-specific header arguments are also read from properties
16273 =header-args:<LANG>= where {{{var(<LANG>)}}} is the language
16274 identifier.  For example,
16276 #+begin_example
16277   ,* Heading
16278     :PROPERTIES:
16279     :header-args:clojure:    :session *clojure-1*
16280     :header-args:R:          :session *R*
16281     :END:
16282   ,** Subheading
16283     :PROPERTIES:
16284     :header-args:clojure:    :session *clojure-2*
16285     :END:
16286 #+end_example
16288 #+texinfo: @noindent
16289 would force separate sessions for Clojure blocks in =Heading= and
16290 =Subheading=, but use the same session for all R blocks.  Blocks in
16291 =Subheading= inherit settings from =Heading=.
16293 *** Code block specific header arguments
16294 :PROPERTIES:
16295 :UNNUMBERED: notoc
16296 :END:
16298 Header arguments are most commonly set at the source code block level,
16299 on the =#+BEGIN_SRC= line.  Arguments set at this level take
16300 precedence over those set in the ~org-babel-default-header-args~
16301 variable, and also those set as header properties.
16303 In the following example, setting =:results= to =silent= makes it
16304 ignore results of the code execution.  Setting =:exports= to =code=
16305 exports only the body of the code block to HTML or LaTeX.
16307 #+begin_example
16308   ,#+NAME: factorial
16309   ,#+BEGIN_SRC haskell :results silent :exports code :var n=0
16310     fac 0 = 1
16311     fac n = n * fac (n-1)
16312   ,#+END_SRC
16313 #+end_example
16315 The same header arguments in an inline code block:
16317 : src_haskell[:exports both]{fac 5}
16319 #+cindex: HEADER, keyword
16320 Code block header arguments can span multiple lines using =#+HEADER:=
16321 on each line.  Note that Org currently accepts the plural spelling of
16322 =#+HEADER:= only as a convenience for backward-compatibility.  It may
16323 be removed at some point.
16325 Multi-line header arguments on an unnamed code block:
16327 #+begin_example
16328   ,#+HEADER: :var data1=1
16329   ,#+BEGIN_SRC emacs-lisp :var data2=2
16330      (message "data1:%S, data2:%S" data1 data2)
16331   ,#+END_SRC
16333   ,#+RESULTS:
16334   : data1:1, data2:2
16335 #+end_example
16337 Multi-line header arguments on a named code block:
16339 #+begin_example
16340   ,#+NAME: named-block
16341   ,#+HEADER: :var data=2
16342   ,#+BEGIN_SRC emacs-lisp
16343     (message "data:%S" data)
16344   ,#+END_SRC
16346   ,#+RESULTS: named-block
16347     : data:2
16348 #+end_example
16350 *** Header arguments in function calls
16351 :PROPERTIES:
16352 :UNNUMBERED: notoc
16353 :END:
16355 Header arguments in function calls are the most specific and override
16356 all other settings in case of an overlap.  They get the highest
16357 priority.  Two =#+CALL:= examples are shown below.  For the complete
16358 syntax of =CALL= keyword, see [[*Evaluating Code Blocks]].
16360 In this example, =:exports results= header argument is applied to the
16361 evaluation of the =#+CALL:= line.
16363 : #+CALL: factorial(n=5) :exports results
16365 In this example, =:session special= header argument is applied to the
16366 evaluation of =factorial= code block.
16368 : #+CALL: factorial[:session special](n=5)
16370 ** Environment of a Code Block
16371 :PROPERTIES:
16372 :DESCRIPTION: Arguments, sessions, working directory...
16373 :END:
16375 *** Passing arguments
16376 :PROPERTIES:
16377 :UNNUMBERED: notoc
16378 :END:
16380 #+cindex: passing arguments to code blocks
16381 #+cindex: arguments, in code blocks
16382 #+cindex: @samp{var}, header argument
16383 Use =var= for passing arguments to source code blocks.  The specifics
16384 of variables in code blocks vary by the source language and are
16385 covered in the language-specific documentation.  The syntax for =var=,
16386 however, is the same for all languages.  This includes declaring
16387 a variable, and assigning a default value.
16389 The following syntax is used to pass arguments to code blocks using
16390 the =var= header argument.
16392 : :var NAME=ASSIGN
16394 #+texinfo: @noindent
16395 {{{var(NAME)}}} is the name of the variable bound in the code block
16396 body.  {{{var(ASSIGN)}}} is a literal value, such as a string,
16397 a number, a reference to a table, a list, a literal example, another
16398 code block---with or without arguments---or the results of evaluating
16399 a code block.
16401 Here are examples of passing values by reference:
16403 - table ::
16405      A table named with a =NAME= keyword.
16407      #+begin_example
16408        ,#+NAME: example-table
16409        | 1 |
16410        | 2 |
16411        | 3 |
16412        | 4 |
16414        ,#+NAME: table-length
16415        ,#+BEGIN_SRC emacs-lisp :var table=example-table
16416          (length table)
16417        ,#+END_SRC
16419        ,#+RESULTS: table-length
16420        : 4
16421      #+end_example
16423      When passing a table, you can treat specially the row, or the
16424      column, containing labels for the columns, or the rows, in the
16425      table.
16427      #+cindex: @samp{colnames}, header argument
16428      The =colnames= header argument accepts =yes=, =no=, or =nil=
16429      values.  The default value is =nil=: if an input table has column
16430      names---because the second row is a horizontal rule---then Org
16431      removes the column names, processes the table, puts back the
16432      column names, and then writes the table to the results block.
16433      Using =yes=, Org does the same to the first row, even if the
16434      initial table does not contain any horizontal rule.  When set to
16435      =no=, Org does not pre-process column names at all.
16437      #+begin_example
16438        ,#+NAME: less-cols
16439        | a |
16440        |---|
16441        | b |
16442        | c |
16444        ,#+BEGIN_SRC python :var tab=less-cols :colnames nil
16445          return [[val + '*' for val in row] for row in tab]
16446        ,#+END_SRC
16448        ,#+RESULTS:
16449        | a  |
16450        |----|
16451        | b* |
16452        | c* |
16453      #+end_example
16455      #+cindex: @samp{rownames}, header argument
16456      Similarly, the =rownames= header argument can take two values:
16457      =yes= or =no=.  When set to =yes=, Org removes the first column,
16458      processes the table, puts back the first column, and then writes
16459      the table to the results block.  The default is =no=, which means
16460      Org does not pre-process the first column.  Note that Emacs Lisp
16461      code blocks ignore =rownames= header argument because of the ease
16462      of table-handling in Emacs.
16464      #+begin_example
16465        ,#+NAME: with-rownames
16466        | one | 1 | 2 | 3 | 4 |  5 |
16467        | two | 6 | 7 | 8 | 9 | 10 |
16469        ,#+BEGIN_SRC python :var tab=with-rownames :rownames yes
16470          return [[val + 10 for val in row] for row in tab]
16471        ,#+END_SRC
16473        ,#+RESULTS:
16474        | one | 11 | 12 | 13 | 14 | 15 |
16475        | two | 16 | 17 | 18 | 19 | 20 |
16476      #+end_example
16478 - list ::
16480      A simple named list.
16482      #+begin_example
16483        ,#+NAME: example-list
16484        - simple
16485          - not
16486          - nested
16487        - list
16489        ,#+BEGIN_SRC emacs-lisp :var x=example-list
16490          (print x)
16491        ,#+END_SRC
16493        ,#+RESULTS:
16494        | simple | list |
16495      #+end_example
16497      Note that only the top level list items are passed along.  Nested
16498      list items are ignored.
16500 - code block without arguments ::
16502      A code block name, as assigned by =NAME= keyword from the example
16503      above, optionally followed by parentheses.
16505      #+begin_example
16506        ,#+BEGIN_SRC emacs-lisp :var length=table-length()
16507          (* 2 length)
16508        ,#+END_SRC
16510        ,#+RESULTS:
16511        : 8
16512      #+end_example
16514 - code block with arguments ::
16516      A code block name, as assigned by =NAME= keyword, followed by
16517      parentheses and optional arguments passed within the parentheses.
16519      #+begin_example
16520        ,#+NAME: double
16521        ,#+BEGIN_SRC emacs-lisp :var input=8
16522          (* 2 input)
16523        ,#+END_SRC
16525        ,#+RESULTS: double
16526        : 16
16528        ,#+NAME: squared
16529        ,#+BEGIN_SRC emacs-lisp :var input=double(input=1)
16530          (* input input)
16531        ,#+END_SRC
16533        ,#+RESULTS: squared
16534        : 4
16535      #+end_example
16537 - literal example ::
16539      A literal example block named with a =NAME= keyword.
16541      #+begin_example
16542        ,#+NAME: literal-example
16543        ,#+BEGIN_EXAMPLE
16544          A literal example
16545          on two lines
16546        ,#+END_EXAMPLE
16548        ,#+NAME: read-literal-example
16549        ,#+BEGIN_SRC emacs-lisp :var x=literal-example
16550          (concatenate #'string x " for you.")
16551        ,#+END_SRC
16553        ,#+RESULTS: read-literal-example
16554        : A literal example
16555        : on two lines for you.
16556      #+end_example
16558 Indexing variable values enables referencing portions of a variable.
16559 Indexes are 0 based with negative values counting backwards from the
16560 end.  If an index is separated by commas then each subsequent section
16561 indexes as the next dimension.  Note that this indexing occurs
16562 /before/ other table-related header arguments are applied, such as
16563 =hlines=, =colnames= and =rownames=.  The following example assigns
16564 the last cell of the first row the table =example-table= to the
16565 variable =data=:
16567 #+begin_example
16568   ,#+NAME: example-table
16569   | 1 | a |
16570   | 2 | b |
16571   | 3 | c |
16572   | 4 | d |
16574   ,#+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
16575     data
16576   ,#+END_SRC
16578   ,#+RESULTS:
16579   : a
16580 #+end_example
16582 Two integers separated by a colon reference a range of variable
16583 values.  In that case the entire inclusive range is referenced.  For
16584 example the following assigns the middle three rows of =example-table=
16585 to =data=.
16587 #+begin_example
16588   ,#+NAME: example-table
16589   | 1 | a |
16590   | 2 | b |
16591   | 3 | c |
16592   | 4 | d |
16593   | 5 | 3 |
16595   ,#+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
16596     data
16597   ,#+END_SRC
16599   ,#+RESULTS:
16600   | 2 | b |
16601   | 3 | c |
16602   | 4 | d |
16603 #+end_example
16605 To pick the entire range, use an empty index, or the single character
16606 =*=.  =0:-1= does the same thing.  Example below shows how to
16607 reference the first column only.
16609 #+begin_example
16610   ,#+NAME: example-table
16611   | 1 | a |
16612   | 2 | b |
16613   | 3 | c |
16614   | 4 | d |
16616   ,#+BEGIN_SRC emacs-lisp :var data=example-table[,0]
16617     data
16618   ,#+END_SRC
16620   ,#+RESULTS:
16621   | 1 | 2 | 3 | 4 |
16622 #+end_example
16624 Index referencing can be used for tables and code blocks.  Index
16625 referencing can handle any number of dimensions.  Commas delimit
16626 multiple dimensions, as shown below.
16628 #+begin_example
16629   ,#+NAME: 3D
16630   ,#+BEGIN_SRC emacs-lisp
16631     '(((1  2  3)  (4  5  6)  (7  8  9))
16632       ((10 11 12) (13 14 15) (16 17 18))
16633       ((19 20 21) (22 23 24) (25 26 27)))
16634   ,#+END_SRC
16636   ,#+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
16637     data
16638   ,#+END_SRC
16640   ,#+RESULTS:
16641   | 11 | 14 | 17 |
16642 #+end_example
16644 Note that row names and column names are not removed prior to variable
16645 indexing.  You need to take them into account, even when =colnames= or
16646 =rownames= header arguments remove them.
16648 Emacs lisp code can also set the values for variables.  To
16649 differentiate a value from Lisp code, Org interprets any value
16650 starting with =(=, =[=, ='= or =`= as Emacs Lisp code.  The result of
16651 evaluating that code is then assigned to the value of that variable.
16652 The following example shows how to reliably query and pass the file
16653 name of the Org mode buffer to a code block using headers.  We need
16654 reliability here because the file's name could change once the code in
16655 the block starts executing.
16657 #+begin_example
16658   ,#+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
16659     wc -w $filename
16660   ,#+END_SRC
16661 #+end_example
16663 Note that values read from tables and lists are not mistakenly
16664 evaluated as Emacs Lisp code, as illustrated in the following example.
16666 #+begin_example
16667   ,#+NAME: table
16668   | (a b c) |
16670   ,#+HEADERS: :var data=table[0,0]
16671   ,#+BEGIN_SRC perl
16672     $data
16673   ,#+END_SRC
16675   ,#+RESULTS:
16676   : (a b c)
16677 #+end_example
16679 *** Using sessions
16680 :PROPERTIES:
16681 :UNNUMBERED: notoc
16682 :END:
16684 #+cindex: using sessions in code blocks
16685 #+cindex: @samp{session}, header argument
16686 Two code blocks can share the same environment.  The =session= header
16687 argument is for running multiple source code blocks under one session.
16688 Org runs code blocks with the same session name in the same
16689 interpreter process.
16691 - =none= ::
16693      Default.  Each code block gets a new interpreter process to
16694      execute.  The process terminates once the block is evaluated.
16696 - {{{var(STRING)}}} ::
16698      Any string besides =none= turns that string into the name of that
16699      session.  For example, =:session STRING= names it =STRING=.  If
16700      =session= has no value, then the session name is derived from the
16701      source language identifier.  Subsequent blocks with the same
16702      source code language use the same session.  Depending on the
16703      language, state variables, code from other blocks, and the
16704      overall interpreted environment may be shared.  Some interpreted
16705      languages support concurrent sessions when subsequent source code
16706      language blocks change session names.
16708 Only languages that provide interactive evaluation can have session
16709 support.  Not all languages provide this support, such as C and ditaa.
16710 Even languages, such as Python and Haskell, that do support
16711 interactive evaluation impose limitations on allowable language
16712 constructs that can run interactively.  Org inherits those limitations
16713 for those code blocks running in a session.
16715 *** Choosing a working directory
16716 :PROPERTIES:
16717 :UNNUMBERED: notoc
16718 :END:
16720 #+cindex: working directory, in a code block
16721 #+cindex: @samp{dir}, header argument
16722 The =dir= header argument specifies the default directory during code
16723 block execution.  If it is absent, then the directory associated with
16724 the current buffer is used.  In other words, supplying =:dir PATH=
16725 temporarily has the same effect as changing the current directory with
16726 {{{kbd(M-x cd PATH)}}}, and then not setting =dir=.  Under the
16727 surface, =dir= simply sets the value of the Emacs variable
16728 ~default-directory~.
16730 For example, to save the plot file in the =Work/= folder of the home
16731 directory---notice tilde is expanded:
16733 #+begin_example
16734   ,#+BEGIN_SRC R :file myplot.png :dir ~/Work
16735     matplot(matrix(rnorm(100), 10), type="l")
16736   ,#+END_SRC
16737 #+end_example
16739 To evaluate the code block on a remote machine, supply a remote
16740 directory name using Tramp syntax.  For example:
16742 #+begin_example
16743   ,#+BEGIN_SRC R :file plot.png :dir /scp:dand@yakuba.princeton.edu:
16744     plot(1:10, main=system("hostname", intern=TRUE))
16745   ,#+END_SRC
16746 #+end_example
16748 Org first captures the text results as usual for insertion in the Org
16749 file.  Then Org also inserts a link to the remote file, thanks to
16750 Emacs Tramp.  Org constructs the remote path to the file name from
16751 =dir= and ~default-directory~, as illustrated here:
16753 : [[file:/scp:dand@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
16755 When =dir= is used with =session=, Org sets the starting directory for
16756 a new session.  But Org does not alter the directory of an already
16757 existing session.
16759 Do not use =dir= with =:exports results= or with =:exports both= to
16760 avoid Org inserting incorrect links to remote files.  That is because
16761 Org does not expand ~default directory~ to avoid some underlying
16762 portability issues.
16764 *** Inserting headers and footers
16765 :PROPERTIES:
16766 :UNNUMBERED: notoc
16767 :END:
16769 #+cindex: headers, in code blocks
16770 #+cindex: footers, in code blocks
16771 #+cindex: @samp{prologue}, header argument
16772 The =prologue= header argument is for appending to the top of the code
16773 block for execution, like a reset instruction.  For example, you may
16774 use =:prologue "reset"= in a Gnuplot code block or, for every such
16775 block:
16777 #+begin_src emacs-lisp
16778   (add-to-list 'org-babel-default-header-args:gnuplot
16779                '((:prologue . "reset")))
16781 #+end_src
16783 #+cindex: @samp{epilogue}, header argument
16784 Likewise, the value of the =epilogue= header argument is for appending
16785 to the end of the code block for execution.
16787 ** Evaluating Code Blocks
16788 :PROPERTIES:
16789 :DESCRIPTION: Place results of evaluation in the Org buffer.
16790 :END:
16791 #+cindex: code block, evaluating
16792 #+cindex: source code, evaluating
16793 #+cindex: RESULTS, keyword
16795 A note about security: With code evaluation comes the risk of harm.
16796 Org safeguards by prompting for user's permission before executing any
16797 code in the source block.  To customize this safeguard, or disable it,
16798 see [[*Code Evaluation and Security Issues]].
16800 *** How to evaluate source code
16801 :PROPERTIES:
16802 :UNNUMBERED: notoc
16803 :END:
16805 Org captures the results of the code block evaluation and inserts them
16806 in the Org file, right after the code block.  The insertion point is
16807 after a newline and the =RESULTS= keyword.  Org creates the =RESULTS=
16808 keyword if one is not already there.
16810 By default, Org enables only Emacs Lisp code blocks for execution.
16811 See [[*Languages]] to enable other languages.
16813 #+kindex: C-c C-c
16814 #+kindex: C-c C-v e
16815 #+findex: org-babel-execute-src-block
16816 Org provides many ways to execute code blocks.  {{{kbd(C-c C-c)}}} or
16817 {{{kbd(C-c C-v e)}}} with the point on a code block[fn:131] calls the
16818 ~org-babel-execute-src-block~ function, which executes the code in the
16819 block, collects the results, and inserts them in the buffer.
16821 #+cindex: CALL, keyword
16822 #+vindex: org-babel-inline-result-wrap
16823 By calling a named code block[fn:132] from an Org mode buffer or
16824 a table.  Org can call the named code blocks from the current Org mode
16825 buffer or from the "Library of Babel" (see [[*Library of Babel]]).
16827 The syntax for =CALL= keyword is:
16829 #+begin_example
16830   ,#+CALL: <name>(<arguments>)
16831   ,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
16832 #+end_example
16834 The syntax for inline named code blocks is:
16836 #+begin_example
16837   ... call_<name>(<arguments>) ...
16838   ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
16839 #+end_example
16841 When inline syntax is used, the result is wrapped based on the
16842 variable ~org-babel-inline-result-wrap~, which by default is set to
16843 ~"=%s="~ to produce verbatim text suitable for markup.
16845 - =<name>= ::
16847      This is the name of the code block (see [[*Structure of Code
16848      Blocks]]) to be evaluated in the current document.  If the block is
16849      located in another file, start =<name>= with the file name
16850      followed by a colon. For example, in order to execute a block
16851      named =clear-data= in =file.org=, you can write the following:
16853      : #+CALL: file.org:clear-data()
16855 - =<arguments>= ::
16857      Org passes arguments to the code block using standard function
16858      call syntax.  For example, a =#+CALL:= line that passes =4= to
16859      a code block named =double=, which declares the header argument
16860      =:var n=2=, would be written as:
16862      : #+CALL: double(n=4)
16864      #+texinfo: @noindent
16865      Note how this function call syntax is different from the header
16866      argument syntax.
16868 - =<inside header arguments>= ::
16870      Org passes inside header arguments to the named code block using
16871      the header argument syntax.  Inside header arguments apply to
16872      code block evaluation.  For example, =[:results output]= collects
16873      results printed to stdout during code execution of that block.
16874      Note how this header argument syntax is different from the
16875      function call syntax.
16877 - =<end header arguments>= ::
16879      End header arguments affect the results returned by the code
16880      block.  For example, =:results html= wraps the results in
16881      a =#+BEGIN_EXPORT html= block before inserting the results in the
16882      Org buffer.
16884 *** Limit code block evaluation
16885 :PROPERTIES:
16886 :UNNUMBERED: notoc
16887 :END:
16889 #+cindex: @samp{eval}, header argument
16890 #+cindex: control code block evaluation
16891 The =eval= header argument can limit evaluation of specific code
16892 blocks and =CALL= keyword.  It is useful for protection against
16893 evaluating untrusted code blocks by prompting for a confirmation.
16895 - =never= or =no= ::
16897      Org never evaluates the source code.
16899 - =query= ::
16901      Org prompts the user for permission to evaluate the source code.
16903 - =never-export= or =no-export= ::
16905      Org does not evaluate the source code when exporting, yet the
16906      user can evaluate it interactively.
16908 - =query-export= ::
16910      Org prompts the user for permission to evaluate the source code
16911      during export.
16913 If =eval= header argument is not set, then Org determines whether to
16914 evaluate the source code from the ~org-confirm-babel-evaluate~
16915 variable (see [[*Code Evaluation and Security Issues]]).
16917 *** Cache results of evaluation
16918 :PROPERTIES:
16919 :UNNUMBERED: notoc
16920 :END:
16922 #+cindex: @samp{cache}, header argument
16923 #+cindex: cache results of code evaluation
16924 The =cache= header argument is for caching results of evaluating code
16925 blocks.  Caching results can avoid re-evaluating a code block that
16926 have not changed since the previous run.  To benefit from the cache
16927 and avoid redundant evaluations, the source block must have a result
16928 already present in the buffer, and neither the header
16929 arguments---including the value of =var= references---nor the text of
16930 the block itself has changed since the result was last computed.  This
16931 feature greatly helps avoid long-running calculations.  For some edge
16932 cases, however, the cached results may not be reliable.
16934 The caching feature is best for when code blocks are pure functions,
16935 that is functions that return the same value for the same input
16936 arguments (see [[*Environment of a Code Block]]), and that do not have
16937 side effects, and do not rely on external variables other than the
16938 input arguments.  Functions that depend on a timer, file system
16939 objects, and random number generators are clearly unsuitable for
16940 caching.
16942 A note of warning: when =cache= is used in a session, caching may
16943 cause unexpected results.
16945 When the caching mechanism tests for any source code changes, it does
16946 not expand Noweb style references (see [[*Noweb Reference Syntax]]).  For
16947 reasons why, see http://thread.gmane.org/gmane.emacs.orgmode/79046.
16949 The =cache= header argument can have one of two values: =yes= or =no=.
16951 - =no= ::
16953      Default.  No caching of results; code block evaluated every
16954      time.
16956 - =yes= ::
16958      Whether to run the code or return the cached results is
16959      determined by comparing the SHA1 hash value of the combined code
16960      block and arguments passed to it.  This hash value is packed on
16961      the =#+RESULTS:= line from previous evaluation.  When hash values
16962      match, Org does not evaluate the code block.  When hash values
16963      mismatch, Org evaluates the code block, inserts the results,
16964      recalculates the hash value, and updates =#+RESULTS:= line.
16966 In this example, both functions are cached.  But =caller= runs only if
16967 the result from =random= has changed since the last run.
16969 #+begin_example
16970   ,#+NAME: random
16971   ,#+BEGIN_SRC R :cache yes
16972     runif(1)
16973   ,#+END_SRC
16975   ,#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
16976   0.4659510825295
16978   ,#+NAME: caller
16979   ,#+BEGIN_SRC emacs-lisp :var x=random :cache yes
16980     x
16981   ,#+END_SRC
16983   ,#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
16984   0.254227238707244
16985 #+end_example
16987 ** Results of Evaluation
16988 :PROPERTIES:
16989 :DESCRIPTION: Choosing a results type, post-processing...
16990 :END:
16991 #+cindex: code block, results of evaluation
16992 #+cindex: source code, results of evaluation
16994 #+cindex: @samp{results}, header argument
16995 How Org handles results of a code block execution depends on many
16996 header arguments working together.  The primary determinant, however,
16997 is the =results= header argument.  It accepts four classes of options.
16998 Each code block can take only one option per class:
17000 - collection ::
17002      For how the results should be collected from the code block;
17004 - type ::
17006      For which type of result the code block will return; affects how
17007      Org processes and inserts results in the Org buffer;
17009 - format ::
17011      For the result; affects how Org processes and inserts results in
17012      the Org buffer;
17014 - handling ::
17016      For processing results after evaluation of the code block;
17018 *** Collection
17019 :PROPERTIES:
17020 :UNNUMBERED: notoc
17021 :END:
17023 Collection options specify the results.  Choose one of the options;
17024 they are mutually exclusive.
17026 - =value= ::
17028      Default.  Functional mode.  Org gets the value by wrapping the
17029      code in a function definition in the language of the source
17030      block.  That is why when using =:results value=, code should
17031      execute like a function and return a value.  For languages like
17032      Python, an explicit ~return~ statement is mandatory when using
17033      =:results value=.  Result is the value returned by the last
17034      statement in the code block.
17036      When evaluating the code block in a session (see [[*Environment of
17037      a Code Block]]), Org passes the code to an interpreter running as
17038      an interactive Emacs inferior process. Org gets the value from
17039      the source code interpreter's last statement output.  Org has to
17040      use language-specific methods to obtain the value.  For example,
17041      from the variable ~_~ in Python and Ruby, and the value of
17042      ~.Last.value~ in R.
17044 - =output= ::
17046      Scripting mode.  Org passes the code to an external process
17047      running the interpreter.  Org returns the contents of the
17048      standard output stream as text results.
17050      When using a session, Org passes the code to the interpreter
17051      running as an interactive Emacs inferior process.  Org
17052      concatenates any text output from the interpreter and returns the
17053      collection as a result.
17055      Note that this collection is not the same as that would be
17056      collected from stdout of a non-interactive interpreter running as
17057      an external process.  Compare for example these two blocks:
17059      #+begin_example
17060        ,#+BEGIN_SRC python :results output
17061          print "hello"
17062          2
17063          print "bye"
17064        ,#+END_SRC
17066        ,#+RESULTS:
17067        : hello
17068        : bye
17069      #+end_example
17071      In the above non-session mode, the "2" is not printed; so it does
17072      not appear in results.
17074      #+begin_example
17075        ,#+BEGIN_SRC python :results output :session
17076          print "hello"
17077          2
17078          print "bye"
17079        ,#+END_SRC
17081        ,#+RESULTS:
17082        : hello
17083        : 2
17084        : bye
17085      #+end_example
17087      In the above session, the interactive interpreter receives and
17088      prints "2".  Results show that.
17090 *** Type
17091 :PROPERTIES:
17092 :UNNUMBERED: notoc
17093 :END:
17095 Type tells what result types to expect from the execution of the code
17096 block.  Choose one of the options; they are mutually exclusive.  The
17097 default behavior is to automatically determine the result type.
17099 #+attr_texinfo: :sep ,
17100 - =table=, =vector= ::
17102      Interpret the results as an Org table.  If the result is a single
17103      value, create a table with one row and one column.  Usage
17104      example: =:results value table=.
17106      #+cindex: @samp{hlines}, header argument
17107      In-between each table row or below the table headings, sometimes
17108      results have horizontal lines, which are also known as "hlines".
17109      The =hlines= argument with the default =no= value strips such
17110      lines from the input table.  For most code, this is desirable, or
17111      else those =hline= symbols raise unbound variable errors.
17112      A =yes= accepts such lines, as demonstrated in the following
17113      example.
17115      #+begin_example
17116        ,#+NAME: many-cols
17117        | a | b | c |
17118        |---+---+---|
17119        | d | e | f |
17120        |---+---+---|
17121        | g | h | i |
17123        ,#+NAME: no-hline
17124        ,#+BEGIN_SRC python :var tab=many-cols :hlines no
17125          return tab
17126        ,#+END_SRC
17128        ,#+RESULTS: no-hline
17129        | a | b | c |
17130        | d | e | f |
17131        | g | h | i |
17133        ,#+NAME: hlines
17134        ,#+BEGIN_SRC python :var tab=many-cols :hlines yes
17135          return tab
17136        ,#+END_SRC
17138        ,#+RESULTS: hlines
17139        | a | b | c |
17140        |---+---+---|
17141        | d | e | f |
17142        |---+---+---|
17143        | g | h | i |
17144      #+end_example
17146 - =list= ::
17148      Interpret the results as an Org list.  If the result is a single
17149      value, create a list of one element.
17151 - =scalar=, =verbatim= ::
17153      Interpret literally and insert as quoted text.  Do not create
17154      a table.  Usage example: =:results value verbatim=.
17156 - =file= ::
17158      Interpret as a filename.  Save the results of execution of the
17159      code block to that file, then insert a link to it.  You can
17160      control both the filename and the description associated to the
17161      link.
17163      #+cindex: @samp{file}, header argument
17164      #+cindex: @samp{output-dir}, header argument
17165      Org first tries to generate the filename from the value of the
17166      =file= header argument and the directory specified using the
17167      =output-dir= header arguments.  If =output-dir= is not specified,
17168      Org assumes it is the current directory.
17170      #+begin_example
17171        ,#+BEGIN_SRC asymptote :results value file :file circle.pdf :output-dir img/
17172          size(2cm);
17173          draw(unitcircle);
17174        ,#+END_SRC
17175      #+end_example
17177      #+cindex: @samp{file-ext}, header argument
17178      If =file= is missing, Org generates the base name of the output
17179      file from the name of the code block, and its extension from the
17180      =file-ext= header argument.  In that case, both the name and the
17181      extension are mandatory.
17183      #+begin_example
17184        ,#+name: circle
17185        ,#+BEGIN_SRC asymptote :results value file :file-ext pdf
17186          size(2cm);
17187          draw(unitcircle);
17188        ,#+END_SRC
17189      #+end_example
17191      #+cindex: @samp{file-desc}, header argument
17192      The =file-desc= header argument defines the description (see
17193      [[*Link Format]]) for the link.  If =file-desc= has no value, Org
17194      uses the generated file name for both the "link" and
17195      "description" parts of the link.
17197 *** Format
17198 :PROPERTIES:
17199 :UNNUMBERED: notoc
17200 :END:
17202 Format pertains to the type of the result returned by the code block.
17203 Choose one of the options; they are mutually exclusive.  The default
17204 follows from the type specified above.
17206 - =raw= ::
17208      Interpreted as raw Org mode.  Inserted directly into the buffer.
17209      Aligned if it is a table.  Usage example: =:results value raw=.
17211 - =org= ::
17213      Results enclosed in a =BEGIN_SRC org= block.  For comma-escape,
17214      either {{{kbd(TAB)}}} in the block, or export the file.  Usage
17215      example: =:results value org=.
17217 - =html= ::
17219      Results enclosed in a =BEGIN_EXPORT html= block.  Usage example:
17220      =:results value html=.
17222 - =latex= ::
17224      Results enclosed in a =BEGIN_EXPORT latex= block.  Usage example:
17225      =:results value latex=.
17227 - =code= ::
17229      Result enclosed in a code block.  Useful for parsing.  Usage
17230      example: =:results value code=.
17232 - =pp= ::
17234      Result converted to pretty-print source code.  Enclosed in a code
17235      block.  Languages supported: Emacs Lisp, Python, and Ruby.  Usage
17236      example: =:results value pp=.
17238 - =drawer= ::
17240      Result wrapped in a =RESULTS= drawer.  Useful for containing
17241      =raw= or =org= results for later scripting and automated
17242      processing.  Usage example: =:results value drawer=.
17244 *** Handling
17245 :PROPERTIES:
17246 :UNNUMBERED: notoc
17247 :END:
17249 Handling options after collecting the results.
17251 - =silent= ::
17253      Do not insert results in the Org mode buffer, but echo them in
17254      the minibuffer.  Usage example: =:results output silent=.
17256 - =replace= ::
17258      Default.  Insert results in the Org buffer.  Remove previous
17259      results.  Usage example: =:results output replace=.
17261 - =append= ::
17263      Append results to the Org buffer.  Latest results are at the
17264      bottom.  Does not remove previous results.  Usage example:
17265      =:results output append=.
17267 - =prepend= ::
17269      Prepend results to the Org buffer.  Latest results are at the
17270      top.  Does not remove previous results.  Usage example: =:results
17271      output prepend=.
17273 *** Post-processing
17274 :PROPERTIES:
17275 :UNNUMBERED: notoc
17276 :END:
17278 #+cindex: @samp{post}, header argument
17279 #+cindex: @samp{*this*}, in @samp{post} header argument
17280 The =post= header argument is for post-processing results from block
17281 evaluation.  When =post= has any value, Org binds the results to
17282 ~*this*~ variable for easy passing to =var= header argument
17283 specifications (see [[*Environment of a Code Block]]).  That makes results
17284 available to other code blocks, or even for direct Emacs Lisp code
17285 execution.
17287 The following two examples illustrate =post= header argument in
17288 action.  The first one shows how to attach an =ATTR_LATEX= keyword
17289 using =post=.
17291 #+begin_example
17292   ,#+NAME: attr_wrap
17293   ,#+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
17294     echo "#+ATTR_LATEX: :width $width"
17295     echo "$data"
17296   ,#+END_SRC
17298   ,#+HEADER: :file /tmp/it.png
17299   ,#+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
17300     digraph{
17301             a -> b;
17302             b -> c;
17303             c -> a;
17304     }
17305   ,#+end_src
17307   ,#+RESULTS:
17308   :RESULTS:
17309   ,#+ATTR_LATEX :width 5cm
17310   [[file:/tmp/it.png]]
17311   :END:
17312 #+end_example
17314 The second example shows use of =colnames= header argument in =post=
17315 to pass data between code blocks.
17317 #+begin_example
17318   ,#+NAME: round-tbl
17319   ,#+BEGIN_SRC emacs-lisp :var tbl="" fmt="%.3f"
17320     (mapcar (lambda (row)
17321               (mapcar (lambda (cell)
17322                         (if (numberp cell)
17323                             (format fmt cell)
17324                           cell))
17325                       row))
17326             tbl)
17327   ,#+end_src
17329   ,#+BEGIN_SRC R :colnames yes :post round-tbl[:colnames yes](*this*)
17330     set.seed(42)
17331     data.frame(foo=rnorm(1))
17332   ,#+END_SRC
17334   ,#+RESULTS:
17335   |   foo |
17336   |-------|
17337   | 1.371 |
17338 #+end_example
17340 ** Exporting Code Blocks
17341 :PROPERTIES:
17342 :DESCRIPTION: Export contents and/or results.
17343 :END:
17344 #+cindex: code block, exporting
17345 #+cindex: source code, exporting
17347 It is possible to export the /code/ of code blocks, the /results/ of
17348 code block evaluation, /both/ the code and the results of code block
17349 evaluation, or /none/.  Org defaults to exporting /code/ for most
17350 languages.  For some languages, such as ditaa, Org defaults to
17351 /results/.  To export just the body of code blocks, see [[*Literal
17352 Examples]].  To selectively export sub-trees of an Org document, see
17353 [[*Exporting]].
17355 #+cindex: @samp{export}, header argument
17356 The =exports= header argument is to specify if that part of the Org
17357 file is exported to, say, HTML or LaTeX formats.
17359 - =code= ::
17361      The default.  The body of code is included into the exported
17362      file.  Example: =:exports code=.
17364 - =results= ::
17366      The results of evaluation of the code is included in the exported
17367      file.  Example: =:exports results=.
17369 - =both= ::
17371      Both the code and results of evaluation are included in the
17372      exported file.  Example: =:exports both=.
17374 - =none= ::
17376      Neither the code nor the results of evaluation is included in the
17377      exported file.  Whether the code is evaluated at all depends on
17378      other options.  Example: =:exports none=.
17380 #+vindex: org-export-use-babel
17381 To stop Org from evaluating code blocks to speed exports, use the
17382 header argument =:eval never-export= (see [[*Evaluating Code Blocks]]).
17383 To stop Org from evaluating code blocks for greater security, set the
17384 ~org-export-use-babel~ variable to ~nil~, but understand that header
17385 arguments will have no effect.
17387 Turning off evaluation comes in handy when batch processing.  For
17388 example, markup languages for wikis, which have a high risk of
17389 untrusted code.  Stopping code block evaluation also stops evaluation
17390 of all header arguments of the code block.  This may not be desirable
17391 in some circumstances.  So during export, to allow evaluation of just
17392 the header arguments but not any code evaluation in the source block,
17393 set =:eval never-export= (see [[*Evaluating Code Blocks]]).
17395 Org never evaluates code blocks in commented sub-trees when exporting
17396 (see [[*Comment Lines]]).  On the other hand, Org does evaluate code
17397 blocks in sub-trees excluded from export (see [[*Export Settings]]).
17399 ** Extracting Source Code
17400 :PROPERTIES:
17401 :DESCRIPTION: Create pure source code files.
17402 :END:
17403 #+cindex: tangling
17404 #+cindex: source code, extracting
17405 #+cindex: code block, extracting source code
17407 Extracting source code from code blocks is a basic task in literate
17408 programming.  Org has features to make this easy.  In literate
17409 programming parlance, documents on creation are /woven/ with code and
17410 documentation, and on export, the code is tangled for execution by
17411 a computer.  Org facilitates weaving and tangling for producing,
17412 maintaining, sharing, and exporting literate programming documents.
17413 Org provides extensive customization options for extracting source
17414 code.
17416 When Org tangles code blocks, it expands, merges, and transforms them.
17417 Then Org recomposes them into one or more separate files, as
17418 configured through the options.  During this tangling process, Org
17419 expands variables in the source code, and resolves any Noweb style
17420 references (see [[*Noweb Reference Syntax]]).
17422 *** Header arguments
17423 :PROPERTIES:
17424 :UNNUMBERED: notoc
17425 :END:
17427 #+cindex: @samp{tangle}, header argument
17428 The =tangle= header argument specifies if the code block is exported
17429 to source file(s).
17431 - =yes= ::
17433      Export the code block to source file.  The file name for the
17434      source file is derived from the name of the Org file, and the
17435      file extension is derived from the source code language
17436      identifier.  Example: =:tangle yes=.
17438 - =no= ::
17440      The default.  Do not extract the code in a source code file.
17441      Example: =:tangle no=.
17443 - {{{var(FILENAME)}}} ::
17445      Export the code block to source file whose file name is derived
17446      from any string passed to the =tangle= header argument.  Org
17447      derives the file name as being relative to the directory of the
17448      Org file's location.  Example: =:tangle FILENAME=.
17450 #+cindex: @samp{mkdirp}, header argument
17451 The =mkdirp= header argument creates parent directories for tangled
17452 files if the directory does not exist.  =yes= enables directory
17453 creation and =no= inhibits directory creation.
17455 #+cindex: @samp{comments}, header argument
17456 The =comments= header argument controls inserting comments into
17457 tangled files.  These are above and beyond whatever comments may
17458 already exist in the code block.
17460 - =no= ::
17462      The default.  Do not insert any extra comments during tangling.
17464 - =link= ::
17466      Wrap the code block in comments.  Include links pointing back to
17467      the place in the Org file from where the code was tangled.
17469 - =yes= ::
17471      Kept for backward compatibility; same as =link=.
17473 - =org= ::
17475      Nearest headline text from Org file is inserted as comment.  The
17476      exact text that is inserted is picked from the leading context of
17477      the source block.
17479 - =both= ::
17481      Includes both =link= and =org= options.
17483 - =noweb= ::
17485      Includes =link= option, expands Noweb references (see [[*Noweb
17486      Reference Syntax]]), and wraps them in link comments inside the
17487      body of the code block.
17489 #+cindex: @samp{padline}, header argument
17490 The =padline= header argument controls insertion of newlines to pad
17491 source code in the tangled file.
17493 - =yes= ::
17495      Default.  Insert a newline before and after each code block in
17496      the tangled file.
17498 - =no= ::
17500      Do not insert newlines to pad the tangled code blocks.
17502 #+cindex: @samp{shebang}, header argument
17503 The =shebang= header argument can turn results into executable script
17504 files.  By setting it to a string value---for example, =:shebang
17505 "#!/bin/bash"=---Org inserts that string as the first line of the
17506 tangled file that the code block is extracted to.  Org then turns on
17507 the tangled file's executable permission.
17509 #+cindex: @samp{no-expand}, header argument
17510 By default Org expands code blocks during tangling.  The =no-expand=
17511 header argument turns off such expansions.  Note that one side-effect
17512 of expansion by ~org-babel-expand-src-block~ also assigns values (see
17513 [[*Environment of a Code Block]]) to variables.  Expansions also replace
17514 Noweb references with their targets (see [[*Noweb Reference Syntax]]).
17515 Some of these expansions may cause premature assignment, hence this
17516 option.  This option makes a difference only for tangling.  It has no
17517 effect when exporting since code blocks for execution have to be
17518 expanded anyway.
17520 *** Functions
17521 :PROPERTIES:
17522 :UNNUMBERED: notoc
17523 :END:
17525 - ~org-babel-tangle~ ::
17527      #+findex: org-babel-tangle
17528      #+kindex: C-c C-v t
17529      Tangle the current file.  Bound to {{{kbd(C-c C-v t)}}}.
17531      With prefix argument only tangle the current code block.
17533 - ~org-babel-tangle-file~ ::
17535      #+findex: org-babel-tangle-file
17536      #+kindex: C-c C-v f
17537      Choose a file to tangle.  Bound to {{{kbd(C-c C-v f)}}}.
17539 *** Hooks
17540 :PROPERTIES:
17541 :UNNUMBERED: notoc
17542 :END:
17544 - ~org-babel-post-tangle-hook~ ::
17546      #+vindex: org-babel-post-tangle-hook
17547      This hook is run from within code files tangled by
17548      ~org-babel-tangle~, making it suitable for post-processing,
17549      compilation, and evaluation of code in the tangled files.
17551 *** Jumping between code and Org
17552 :PROPERTIES:
17553 :UNNUMBERED: notoc
17554 :END:
17556 #+findex: org-babel-tangle-jump-to-org
17557 Debuggers normally link errors and messages back to the source code.
17558 But for tangled files, we want to link back to the Org file, not to
17559 the tangled source file.  To make this extra jump, Org uses
17560 ~org-babel-tangle-jump-to-org~ function with two additional source
17561 code block header arguments:
17563 1. Set =padline= to true---this is the default setting.
17564 2. Set =comments= to =link=, which makes Org insert links to the Org
17565    file.
17567 ** Languages
17568 :PROPERTIES:
17569 :DESCRIPTION: List of supported code block languages.
17570 :END:
17571 #+cindex: babel, languages
17572 #+cindex: source code, languages
17573 #+cindex: code block, languages
17575 Code blocks in the following languages are supported.
17577 | Language   | Identifier | Language       | Identifier |
17578 |------------+------------+----------------+------------|
17579 | Asymptote  | asymptote  | Awk            | awk        |
17580 | C          | C          | C++            | C++        |
17581 | Clojure    | clojure    | CSS            | css        |
17582 | D          | d          | ditaa          | ditaa      |
17583 | Graphviz   | dot        | Emacs Calc     | calc       |
17584 | Emacs Lisp | emacs-lisp | Fortran        | fortran    |
17585 | Gnuplot    | gnuplot    | Haskell        | haskell    |
17586 | Java       | java       | Javascript     | js         |
17587 | LaTeX      | latex      | Ledger         | ledger     |
17588 | Lisp       | lisp       | Lilypond       | lilypond   |
17589 | Lua        | lua        | MATLAB         | matlab     |
17590 | Mscgen     | mscgen     | Objective Caml | ocaml      |
17591 | Octave     | octave     | Org mode       | org        |
17592 | Oz         | oz         | Perl           | perl       |
17593 | Plantuml   | plantuml   | Processing.js  | processing |
17594 | Python     | python     | R              | R          |
17595 | Ruby       | ruby       | Sass           | sass       |
17596 | Scheme     | scheme     | GNU Screen     | screen     |
17597 | Sed        | sed        | shell          | sh         |
17598 | SQL        | sql        | SQLite         | sqlite     |
17599 | Vala       | vala       |                |            |
17601 Additional documentation for some languages is at
17602 https://orgmode.org/worg/org-contrib/babel/languages.html.
17604 #+vindex: org-babel-load-languages
17605 By default, only Emacs Lisp is enabled for evaluation.  To enable or
17606 disable other languages, customize the ~org-babel-load-languages~
17607 variable either through the Emacs customization interface, or by
17608 adding code to the init file as shown next.
17610 In this example, evaluation is disabled for Emacs Lisp, and enabled
17611 for R.
17613 #+begin_src emacs-lisp
17614   (org-babel-do-load-languages
17615    'org-babel-load-languages
17616    '((emacs-lisp . nil)
17617      (R . t)))
17618 #+end_src
17620 Note that this is not the only way to enable a language.  Org also
17621 enables languages when loaded with ~require~ statement.  For example,
17622 the following enables execution of Clojure code blocks:
17624 #+begin_src emacs-lisp
17625   (require 'ob-clojure)
17626 #+end_src
17628 ** Editing Source Code
17629 :PROPERTIES:
17630 :DESCRIPTION: Language major-mode editing.
17631 :END:
17632 #+cindex: code block, editing
17633 #+cindex: source code, editing
17635 #+kindex: C-c '
17636 Use {{{kbd(C-c ')}}} to edit the current code block.  It opens a new
17637 major-mode edit buffer containing the body of the source code block,
17638 ready for any edits.  Use {{{kbd(C-c ')}}} again to close the buffer
17639 and return to the Org buffer.
17641 #+kindex: C-x C-s
17642 #+vindex: org-edit-src-auto-save-idle-delay
17643 #+cindex: auto-save, in code block editing
17644 {{{kbd(C-x C-s)}}} saves the buffer and updates the contents of the
17645 Org buffer.  Set ~org-edit-src-auto-save-idle-delay~ to save the base
17646 buffer after a certain idle delay time.  Set
17647 ~org-edit-src-turn-on-auto-save~ to auto-save this buffer into
17648 a separate file using Auto-save mode.
17650 While editing the source code in the major mode, the Org Src minor
17651 mode remains active.  It provides these customization variables as
17652 described below.  For even more variables, look in the customization
17653 group ~org-edit-structure~.
17655 - ~org-src-lang-modes~ ::
17657      #+vindex: org-src-lang-modes
17658      If an Emacs major-mode named ~<LANG>-mode~ exists, where
17659      {{{var(<LANG>)}}} is the language identifier from code block's
17660      header line, then the edit buffer uses that major mode.  Use this
17661      variable to arbitrarily map language identifiers to major modes.
17663 - ~org-src-window-setup~ ::
17665      #+vindex: org-src-window-setup
17666      For specifying Emacs window arrangement when the new edit buffer
17667      is created.
17669 - ~org-src-preserve-indentation~ ::
17671      #+cindex: indentation, in code blocks
17672      #+vindex: org-src-preserve-indentation
17673      Default is ~nil~.  Source code is indented.  This indentation
17674      applies during export or tangling, and depending on the context,
17675      may alter leading spaces and tabs.  When non-~nil~, source code
17676      is aligned with the leftmost column.  No lines are modified
17677      during export or tangling, which is very useful for white-space
17678      sensitive languages, such as Python.
17680 - ~org-src-ask-before-returning-to-edit-buffer~ ::
17682      #+vindex: org-src-ask-before-returning-to-edit-buffer
17683      When ~nil~, Org returns to the edit buffer without further
17684      prompts.  The default prompts for a confirmation.
17686 #+vindex: org-src-fontify-natively
17687 #+vindex: org-src-block-faces
17688 Set ~org-src-fontify-natively~ to non-~nil~ to turn on native code
17689 fontification in the /Org/ buffer.  Fontification of code blocks can
17690 give visual separation of text and code on the display page.  To
17691 further customize the appearance of ~org-block~ for specific
17692 languages, customize ~org-src-block-faces~.  The following example
17693 shades the background of regular blocks, and colors source blocks only
17694 for Python and Emacs Lisp languages.
17696 #+begin_src emacs-lisp
17697   (require 'color)
17698   (set-face-attribute 'org-block nil :background
17699                       (color-darken-name
17700                        (face-attribute 'default :background) 3))
17702   (setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
17703                               ("python" (:background "#E5FFB8"))))
17704 #+end_src
17706 ** Noweb Reference Syntax
17707 :PROPERTIES:
17708 :DESCRIPTION: Literate programming in Org mode.
17709 :END:
17710 #+cindex: code block, Noweb reference
17711 #+cindex: syntax, Noweb
17712 #+cindex: source code, Noweb reference
17714 Org supports named blocks in Noweb[fn:133] style syntax:
17716 : <<CODE-BLOCK-ID>>
17718 Org can replace the construct with the source code, or the results of
17719 evaluation, of the code block identified as {{{var(CODE-BLOCK-ID)}}}.
17721 #+cindex: @samp{noweb}, header argument
17722 The =noweb= header argument controls expansion of Noweb syntax
17723 references.  Expansions occur when source code blocks are evaluated,
17724 tangled, or exported.
17726 - =no= ::
17728      Default.  No expansion of Noweb syntax references in the body of
17729      the code when evaluating, tangling, or exporting.
17731 - =yes= ::
17733      Expansion of Noweb syntax references in the body of the code
17734      block when evaluating, tangling, or exporting.
17736 - =tangle= ::
17738      Expansion of Noweb syntax references in the body of the code
17739      block when tangling.  No expansion when evaluating or exporting.
17741 - =no-export= ::
17743      Expansion of Noweb syntax references in the body of the code
17744      block when evaluating or tangling.  No expansion when exporting.
17746 - =strip-export= ::
17748      Expansion of Noweb syntax references in the body of the code
17749      block when expanding prior to evaluating or tangling.  Removes
17750      Noweb syntax references when exporting.
17752 - =eval= ::
17754      Expansion of Noweb syntax references in the body of the code
17755      block only before evaluating.
17757 In the following example,
17759 #+begin_example
17760   ,#+NAME: initialization
17761   ,#+BEGIN_SRC emacs-lisp
17762     (setq sentence "Never a foot too far, even.")
17763   ,#+END_SRC
17765   ,#+BEGIN_SRC emacs-lisp :noweb yes
17766     <<initialization>>
17767     (reverse sentence)
17768   ,#+END_SRC
17769 #+end_example
17771 #+texinfo: @noindent
17772 the second code block is expanded as
17774 #+begin_example
17775   ,#+BEGIN_SRC emacs-lisp :noweb yes
17776     (setq sentence "Never a foot too far, even.")
17777     (reverse sentence)
17778   ,#+END_SRC
17779 #+end_example
17781 Noweb insertions honor prefix characters that appear before the Noweb
17782 syntax reference.  This behavior is illustrated in the following
17783 example.  Because the =<<example>>= Noweb reference appears behind the
17784 SQL comment syntax, each line of the expanded Noweb reference is
17785 commented.  With:
17787 #+begin_example
17788   ,#+NAME: example
17789   ,#+BEGIN_SRC text
17790     this is the
17791     multi-line body of example
17792   ,#+END_SRC
17793 #+end_example
17795 #+texinfo: @noindent
17796 this code block:
17798 #+begin_example
17799   ,#+BEGIN_SRC sql :noweb yes
17800    ---<<example>>
17801   ,#+END_SRC
17802 #+end_example
17804 #+texinfo: @noindent
17805 expands to:
17807 #+begin_example
17808   ,#+BEGIN_SRC sql :noweb yes
17809    ---this is the
17810    ---multi-line body of example
17811   ,#+END_SRC
17812 #+end_example
17814 Since this change does not affect Noweb replacement text without
17815 newlines in them, inline Noweb references are acceptable.
17817 This feature can also be used for management of indentation in
17818 exported code snippets.  With:
17820 #+begin_example
17821   ,#+NAME: if-true
17822   ,#+BEGIN_SRC python :exports none
17823     print('do things when true')
17824   ,#+end_src
17826   ,#+name: if-false
17827   ,#+begin_src python :exports none
17828     print('do things when false')
17829   ,#+end_src
17830 #+end_example
17832 #+texinfo: @noindent
17833 this code block:
17835 #+begin_example
17836   ,#+begin_src python :noweb yes :results output
17837     if true:
17838         <<if-true>>
17839     else:
17840         <<if-false>>
17841   ,#+end_src
17842 #+end_example
17844 #+texinfo: @noindent
17845 expands to:
17847 #+begin_example
17848   if true:
17849       print('do things when true')
17850   else:
17851       print('do things when false')
17852 #+end_example
17854 #+cindex: @samp{noweb-ref}, header argument
17855 When expanding Noweb style references, Org concatenates code blocks by
17856 matching the reference name to either the code block name or, if none
17857 is found, to the =noweb-ref= header argument.
17859 For simple concatenation, set this =noweb-ref= header argument at the
17860 sub-tree or file level.  In the example Org file shown next, the body
17861 of the source code in each block is extracted for concatenation to
17862 a pure code file when tangled.
17864 #+begin_example
17865   ,#+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
17866     <<fullest-disk>>
17867   ,#+END_SRC
17868   ,* the mount point of the fullest disk
17869     :PROPERTIES:
17870     :header-args: :noweb-ref fullest-disk
17871     :END:
17873   ,** query all mounted disks
17874   ,#+BEGIN_SRC sh
17875     df \
17876   ,#+END_SRC
17878   ,** strip the header row
17879   ,#+BEGIN_SRC sh
17880     |sed '1d' \
17881   ,#+END_SRC
17883   ,** output mount point of fullest disk
17884   ,#+BEGIN_SRC sh
17885     |awk '{if (u < +$5) {u = +$5; m = $6}} END {print m}'
17886   ,#+END_SRC
17887 #+end_example
17889 #+cindex: @samp{noweb-sep}, header argument
17890 By default a newline separates each noweb reference concatenation.  To
17891 change this newline separator, edit the =noweb-sep= header argument.
17893 Eventually, Org can include the results of a code block rather than
17894 its body.  To that effect, append parentheses, possibly including
17895 arguments, to the code block name, as shown below.
17897 : <<code-block-name(optional arguments)>>
17899 Note that when using the above approach to a code block's results, the
17900 code block name set by =NAME= keyword is required; the reference set
17901 by =noweb-ref= does not work in that case.
17903 Here is an example that demonstrates how the exported content changes
17904 when Noweb style references are used with parentheses versus without.
17905 With:
17907 #+begin_example
17908   ,#+NAME: some-code
17909   ,#+BEGIN_SRC python :var num=0 :results output :exports none
17910     print(num*10)
17911   ,#+END_SRC
17912 #+end_example
17914 #+texinfo: @noindent
17915 this code block:
17917 #+begin_example
17918   ,#+BEGIN_SRC text :noweb yes
17919     <<some-code>>
17920   ,#+END_SRC
17921 #+end_example
17923 #+texinfo: @noindent
17924 expands to:
17926 : print(num*10)
17928 Below, a similar Noweb style reference is used, but with parentheses,
17929 while setting a variable =num= to 10:
17931 #+begin_example
17932   ,#+BEGIN_SRC text :noweb yes
17933     <<some-code(num=10)>>
17934   ,#+END_SRC
17935 #+end_example
17937 #+texinfo: @noindent
17938 Note that now the expansion contains the results of the code block
17939 =some-code=, not the code block itself:
17941 : 100
17943 ** Library of Babel
17944 :PROPERTIES:
17945 :DESCRIPTION: Use and contribute to a library of useful code blocks.
17946 :END:
17947 #+cindex: babel, library of
17948 #+cindex: source code, library
17949 #+cindex: code block, library
17951 The "Library of Babel" is a collection of code blocks.  Like
17952 a function library, these code blocks can be called from other Org
17953 files.  A collection of useful code blocks is available on [[https://orgmode.org/worg/library-of-babel.html][Worg]].  For
17954 remote code block evaluation syntax, see [[*Evaluating Code Blocks]].
17956 #+kindex: C-c C-v i
17957 #+findex: org-babel-lob-ingest
17958 For any user to add code to the library, first save the code in
17959 regular code blocks of an Org file, and then load the Org file with
17960 ~org-babel-lob-ingest~, which is bound to {{{kbd(C-c C-v i)}}}.
17962 ** Key bindings and Useful Functions
17963 :PROPERTIES:
17964 :DESCRIPTION: Work quickly with code blocks.
17965 :END:
17966 #+cindex: code block, key bindings
17968 Many common Org mode key sequences are re-bound depending on
17969 the context.
17971 Active key bindings in code blocks:
17973 #+kindex: C-c C-c
17974 #+findex: org-babel-execute-src-block
17975 #+kindex: C-c C-o
17976 #+findex: org-babel-open-src-block-result
17977 #+kindex: M-up
17978 #+findex: org-babel-load-in-session
17979 #+kindex: M-down
17980 #+findex: org-babel-pop-to-session
17981 #+attr_texinfo: :columns 0.2 0.55
17982 | Key binding        | Function                          |
17983 |--------------------+-----------------------------------|
17984 | {{{kbd(C-c C-c)}}} | ~org-babel-execute-src-block~     |
17985 | {{{kbd(C-c C-o)}}} | ~org-babel-open-src-block-result~ |
17986 | {{{kbd(M-up)}}}    | ~org-babel-load-in-session~       |
17987 | {{{kbd(M-down)}}}  | ~org-babel-pop-to-session~        |
17989 Active key bindings in Org mode buffer:
17991 #+kindex: C-c C-v p
17992 #+kindex: C-c C-v C-p
17993 #+kindex: C-c C-v n
17994 #+kindex: C-c C-v C-n
17995 #+kindex: C-c C-v e
17996 #+kindex: C-c C-v C-e
17997 #+kindex: C-c C-v o
17998 #+kindex: C-c C-v C-o
17999 #+kindex: C-c C-v v
18000 #+kindex: C-c C-v C-v
18001 #+kindex: C-c C-v u
18002 #+kindex: C-c C-v C-u
18003 #+kindex: C-c C-v g
18004 #+kindex: C-c C-v C-g
18005 #+kindex: C-c C-v r
18006 #+kindex: C-c C-v C-r
18007 #+kindex: C-c C-v b
18008 #+kindex: C-c C-v C-b
18009 #+kindex: C-c C-v s
18010 #+kindex: C-c C-v C-s
18011 #+kindex: C-c C-v d
18012 #+kindex: C-c C-v C-d
18013 #+kindex: C-c C-v t
18014 #+kindex: C-c C-v C-t
18015 #+kindex: C-c C-v f
18016 #+kindex: C-c C-v C-f
18017 #+kindex: C-c C-v c
18018 #+kindex: C-c C-v C-c
18019 #+kindex: C-c C-v j
18020 #+kindex: C-c C-v C-j
18021 #+kindex: C-c C-v l
18022 #+kindex: C-c C-v C-l
18023 #+kindex: C-c C-v i
18024 #+kindex: C-c C-v C-i
18025 #+kindex: C-c C-v I
18026 #+kindex: C-c C-v C-I
18027 #+kindex: C-c C-v z
18028 #+kindex: C-c C-v C-z
18029 #+kindex: C-c C-v a
18030 #+kindex: C-c C-v C-a
18031 #+kindex: C-c C-v h
18032 #+kindex: C-c C-v C-h
18033 #+kindex: C-c C-v x
18034 #+kindex: C-c C-v C-x
18035 #+findex: org-babel-previous-src-block
18036 #+findex: org-babel-next-src-block
18037 #+findex: org-babel-execute-maybe
18038 #+findex: org-babel-open-src-block-result
18039 #+findex: org-babel-expand-src-block
18040 #+findex: org-babel-goto-src-block-head
18041 #+findex: org-babel-goto-named-src-block
18042 #+findex: org-babel-goto-named-result
18043 #+findex: org-babel-execute-buffer
18044 #+findex: org-babel-execute-subtree
18045 #+findex: org-babel-demarcate-block
18046 #+findex: org-babel-tangle
18047 #+findex: org-babel-tangle-file
18048 #+findex: org-babel-check-src-block
18049 #+findex: org-babel-insert-header-arg
18050 #+findex: org-babel-load-in-session
18051 #+findex: org-babel-lob-ingest
18052 #+findex: org-babel-view-src-block-info
18053 #+findex: org-babel-switch-to-session-with-code
18054 #+findex: org-babel-sha1-hash
18055 #+findex: org-babel-describe-bindings
18056 #+findex: org-babel-do-key-sequence-in-edit-buffer
18057 #+attr_texinfo: :columns 0.45 0.55
18058 | Key binding                                    | Function                                   |
18059 |------------------------------------------------+--------------------------------------------|
18060 | {{{kbd(C-c C-v p)}}} or {{{kbd(C-c C-v C-p)}}} | ~org-babel-previous-src-block~             |
18061 | {{{kbd(C-c C-v n)}}} or {{{kbd(C-c C-v C-n)}}} | ~org-babel-next-src-block~                 |
18062 | {{{kbd(C-c C-v e)}}} or {{{kbd(C-c C-v C-e)}}} | ~org-babel-execute-maybe~                  |
18063 | {{{kbd(C-c C-v o)}}} or {{{kbd(C-c C-v C-o)}}} | ~org-babel-open-src-block-result~          |
18064 | {{{kbd(C-c C-v v)}}} or {{{kbd(C-c C-v C-v)}}} | ~org-babel-expand-src-block~               |
18065 | {{{kbd(C-c C-v u)}}} or {{{kbd(C-c C-v C-u)}}} | ~org-babel-goto-src-block-head~            |
18066 | {{{kbd(C-c C-v g)}}} or {{{kbd(C-c C-v C-g)}}} | ~org-babel-goto-named-src-block~           |
18067 | {{{kbd(C-c C-v r)}}} or {{{kbd(C-c C-v C-r)}}} | ~org-babel-goto-named-result~              |
18068 | {{{kbd(C-c C-v b)}}} or {{{kbd(C-c C-v C-b)}}} | ~org-babel-execute-buffer~                 |
18069 | {{{kbd(C-c C-v s)}}} or {{{kbd(C-c C-v C-s)}}} | ~org-babel-execute-subtree~                |
18070 | {{{kbd(C-c C-v d)}}} or {{{kbd(C-c C-v C-d)}}} | ~org-babel-demarcate-block~                |
18071 | {{{kbd(C-c C-v t)}}} or {{{kbd(C-c C-v C-t)}}} | ~org-babel-tangle~                         |
18072 | {{{kbd(C-c C-v f)}}} or {{{kbd(C-c C-v C-f)}}} | ~org-babel-tangle-file~                    |
18073 | {{{kbd(C-c C-v c)}}} or {{{kbd(C-c C-v C-c)}}} | ~org-babel-check-src-block~                |
18074 | {{{kbd(C-c C-v j)}}} or {{{kbd(C-c C-v C-j)}}} | ~org-babel-insert-header-arg~              |
18075 | {{{kbd(C-c C-v l)}}} or {{{kbd(C-c C-v C-l)}}} | ~org-babel-load-in-session~                |
18076 | {{{kbd(C-c C-v i)}}} or {{{kbd(C-c C-v C-i)}}} | ~org-babel-lob-ingest~                     |
18077 | {{{kbd(C-c C-v I)}}} or {{{kbd(C-c C-v C-I)}}} | ~org-babel-view-src-block-info~            |
18078 | {{{kbd(C-c C-v z)}}} or {{{kbd(C-c C-v C-z)}}} | ~org-babel-switch-to-session-with-code~    |
18079 | {{{kbd(C-c C-v a)}}} or {{{kbd(C-c C-v C-a)}}} | ~org-babel-sha1-hash~                      |
18080 | {{{kbd(C-c C-v h)}}} or {{{kbd(C-c C-v C-h)}}} | ~org-babel-describe-bindings~              |
18081 | {{{kbd(C-c C-v x)}}} or {{{kbd(C-c C-v C-x)}}} | ~org-babel-do-key-sequence-in-edit-buffer~ |
18083 ** Batch Execution
18084 :PROPERTIES:
18085 :DESCRIPTION: Call functions from the command line.
18086 :END:
18087 #+cindex: code block, batch execution
18088 #+cindex: source code, batch execution
18090 Org mode features, including working with source code facilities can
18091 be invoked from the command line.  This enables building shell scripts
18092 for batch processing, running automated system tasks, and expanding
18093 Org mode's usefulness.
18095 The sample script shows batch processing of multiple files using
18096 ~org-babel-tangle~.
18098 #+begin_example
18099   #!/bin/sh
18100   # Tangle files with Org mode
18101   #
18102   emacs -Q --batch --eval "
18103       (progn
18104         (require 'ob-tangle)
18105         (dolist (file command-line-args-left)
18106           (with-current-buffer (find-file-noselect file)
18107             (org-babel-tangle))))
18108     " "$@"
18109 #+end_example
18111 * Miscellaneous
18112 :PROPERTIES:
18113 :DESCRIPTION: All the rest which did not fit elsewhere.
18114 :END:
18116 ** Completion
18117 :PROPERTIES:
18118 :DESCRIPTION: M-TAB guesses completions.
18119 :END:
18120 #+cindex: completion, of @TeX{} symbols
18121 #+cindex: completion, of TODO keywords
18122 #+cindex: completion, of dictionary words
18123 #+cindex: completion, of option keywords
18124 #+cindex: completion, of tags
18125 #+cindex: completion, of property keys
18126 #+cindex: completion, of link abbreviations
18127 #+cindex: @TeX{} symbol completion
18128 #+cindex: TODO keywords completion
18129 #+cindex: dictionary word completion
18130 #+cindex: option keyword completion
18131 #+cindex: tag completion
18132 #+cindex: link abbreviations, completion of
18134 Org has in-buffer completions.  Unlike minibuffer completions, which
18135 are useful for quick command interactions, Org's in-buffer completions
18136 are more suitable for content creation in Org documents.  Type one or
18137 more letters and invoke the hot key to complete the text in-place.
18138 Depending on the context and the keys, Org offers different types of
18139 completions.  No minibuffer is involved.  Such mode-specific hot keys
18140 have become an integral part of Emacs and Org provides several
18141 shortcuts.
18143 - {{{kbd(M-TAB)}}} ::
18144      #+kindex: M-TAB
18146      Complete word at point.
18148      - At the beginning of a headline, complete TODO keywords.
18150      - After =\=, complete TeX symbols supported by the exporter.
18152      - After =*=, complete headlines in the current buffer so that
18153        they can be used in search links like:
18155        : [[*find this headline]]
18157      - After =:= in a headline, complete tags.  Org deduces the list
18158        of tags from the =TAGS= in-buffer option (see [[*Setting Tags]]),
18159        the variable ~org-tag-alist~, or from all tags used in the
18160        current buffer.
18162      - After =:= and not in a headline, complete property keys.  The
18163        list of keys is constructed dynamically from all keys used in
18164        the current buffer.
18166      - After =[=, complete link abbreviations (see [[*Link
18167        Abbreviations]]).
18169      - After =#+=, complete the special keywords like =TYP_TODO= or
18170        file-specific =OPTIONS=.  After option keyword is complete,
18171        pressing {{{kbd(M-TAB)}}} again inserts example settings for
18172        this keyword.
18174      - After =STARTUP= keyword, complete startup items.
18176      - When point is anywhere else, complete dictionary words using
18177        Ispell.
18179 ** Structure Templates
18180 :PROPERTIES:
18181 :DESCRIPTION: Quick insertion of structural elements.
18182 :END:
18183 #+cindex: template insertion
18184 #+cindex: insertion, of templates
18186 With just a few keystrokes, it is possible to insert empty structural
18187 blocks, such as =#+BEGIN_SRC= ... =#+END_SRC=, or to wrap existing
18188 text in such a block.
18190 - {{{kbd(C-c C-x w)}}} (~org-insert-structure-template~) ::
18192      Prompt for a type of block structure, and insert the block at
18193      point.  If the region is active, it is wrapped in the block.
18194      First prompts the user for a key, which is used to look up
18195      a structure type from the values below.  If the key is
18196      {{{kbd(TAB)}}}, the user is prompted to enter a 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 #+vindex: org-structure-template-alist
18208 Org Tempo expands snippets to structures defined in
18209 ~org-structure-template-alist~ and ~org-tempo-keywords-alist~.  For
18210 example, {{{kbd(< s TAB)}}} creates a code block.  Enable it by
18211 customizing ~org-modules~ or add ~(require 'org-tempo)~ to your Emacs
18212 init file[fn:134].
18215 #+attr_texinfo: :columns 0.1 0.9
18216 | {{{kbd(a)}}} | =#+BEGIN_EXPORT ascii= ... =#+END_EXPORT= |
18217 | {{{kbd(c)}}} | =#+BEGIN_CENTER= ... =#+END_CENTER=       |
18218 | {{{kbd(C)}}} | =#+BEGIN_COMMENT= ... =#+END_COMMENT=     |
18219 | {{{kbd(e)}}} | =#+BEGIN_EXAMPLE= ... =#+END_EXAMPLE=     |
18220 | {{{kbd(h)}}} | =#+BEGIN_EXPORT html= ... =#+END_EXPORT=  |
18221 | {{{kbd(l)}}} | =#+BEGIN_EXPORT latex= ... =#+END_EXPORT= |
18222 | {{{kbd(q)}}} | =#+BEGIN_QUOTE= ... =#+END_QUOTE=         |
18223 | {{{kbd(s)}}} | =#+BEGIN_SRC= ... =#+END_SRC=             |
18224 | {{{kbd(v)}}} | =#+BEGIN_VERSE= ... =#+END_VERSE=         |
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 the #+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: 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: CATEGORY, keyword
18371      Sets the category of the agenda file, which applies to the entire
18372      document.
18374 - =#+COLUMNS: %25ITEM ...= ::
18376      #+cindex: 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: 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: 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: 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: 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: 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: 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: 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:135]
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      #+cindex: 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      #+cindex: 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: 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: SEQ_TODO, keyword
18710      #+cindex: TODO, keyword
18711      #+cindex: 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: 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:136].
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:137].
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:138].
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.25 0.1 0.25
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      | S-UP      \rArr{}  M-p   | S-DOWN     \rArr{}  M-n   |
19044      | S-LEFT    \rArr{}  M--   | S-RIGHT    \rArr{}  M-+   |
19045      | C-S-LEFT  \rArr{}  M-S-- | C-S-RIGHT  \rArr{}  M-S-+ |
19047      #+vindex: org-disputed-keys
19048      Yes, these are unfortunately more difficult to remember.  If you
19049      want to have other replacement keys, look at the variable
19050      ~org-disputed-keys~.
19052 - =ecomplete.el= by Lars Magne Ingebrigtsen ::
19054      #+cindex: @file{ecomplete.el}
19055      Ecomplete provides "electric" address completion in address
19056      header lines in message buffers.  Sadly Orgtbl mode cuts
19057      Ecomplete's power supply: no completion happens when Orgtbl mode
19058      is enabled in message buffers while entering text in address
19059      header lines.  If one wants to use ecomplete one should /not/
19060      follow the advice to automagically turn on Orgtbl mode in message
19061      buffers (see [[*The Orgtbl Minor Mode]]), but instead---after
19062      filling in the message headers---turn on Orgtbl mode manually
19063      when needed in the messages body.
19065 - =filladapt.el= by Kyle Jones ::
19067      #+cindex: @file{filladapt.el}
19068      Org mode tries to do the right thing when filling paragraphs,
19069      list items and other elements.  Many users reported problems
19070      using both =filladapt.el= and Org mode, so a safe thing to do is
19071      to disable filladapt like this:
19073      #+begin_src emacs-lisp
19074        (add-hook 'org-mode-hook 'turn-off-filladapt-mode)
19075      #+end_src
19077 - =viper.el= by Michael Kifer ::
19078      #+cindex: @file{viper.el}
19079      #+kindex: C-c /
19081      Viper uses {{{kbd(C-c /)}}} and therefore makes this key not
19082      access the corresponding Org mode command ~org-sparse-tree~.  You
19083      need to find another key for this command, or override the key in
19084      ~viper-vi-global-user-map~ with
19086      #+begin_src emacs-lisp
19087        (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
19088      #+end_src
19090 - =windmove.el= by Hovav Shacham ::
19091      #+cindex: @file{windmove.el}
19093      This package also uses the {{{kbd(S-<cursor>)}}} keys, so
19094      everything written in the paragraph above about CUA mode also
19095      applies here.  If you want to make the windmove function active
19096      in locations where Org mode does not have special functionality
19097      on {{{kbd(S-<cursor>)}}}, add this to your configuration:
19099      #+begin_src emacs-lisp
19100        ;; Make windmove work in Org mode:
19101        (add-hook 'org-shiftup-final-hook 'windmove-up)
19102        (add-hook 'org-shiftleft-final-hook 'windmove-left)
19103        (add-hook 'org-shiftdown-final-hook 'windmove-down)
19104        (add-hook 'org-shiftright-final-hook 'windmove-right)
19105      #+end_src
19107 - =yasnippet.el= ::
19109      #+cindex: @file{yasnippet.el}
19110      The way Org mode binds the {{{kbd(TAB)}}} key (binding to ~[tab]~
19111      instead of ~"\t"~) overrules YASnippet's access to this key.  The
19112      following code fixed this problem:
19114      #+begin_src emacs-lisp
19115        (add-hook 'org-mode-hook
19116                  (lambda ()
19117                    (setq-local yas/trigger-key [tab])
19118                    (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
19119      #+end_src
19121      The latest version of YASnippet does not play well with Org mode.
19122      If the above code does not fix the conflict, start by defining
19123      the following function:
19125      #+begin_src emacs-lisp
19126        (defun yas/org-very-safe-expand ()
19127          (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
19128      #+end_src
19130      Then, tell Org mode to use that function:
19132      #+begin_src emacs-lisp
19133        (add-hook 'org-mode-hook
19134                  (lambda ()
19135                    (make-variable-buffer-local 'yas/trigger-key)
19136                    (setq yas/trigger-key [tab])
19137                    (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
19138                    (define-key yas/keymap [tab] 'yas/next-field)))
19139      #+end_src
19141 ** Org Crypt
19142 :PROPERTIES:
19143 :DESCRIPTION: Encrypting Org files.
19144 :END:
19146 Org Crypt encrypts the text of an entry, but not the headline, or
19147 properties.  Behind the scene, it uses the Emacs EasyPG library to
19148 encrypt and decrypt files.
19150 #+vindex: org-crypt-tag-matcher
19151 Any text below a headline that has a =crypt= tag is automatically
19152 encrypted when the file is saved.  To use a different tag, customize
19153 the ~org-crypt-tag-matcher~ setting.
19155 Here is a suggestion for Org Crypt settings in Emacs init file:
19157 #+begin_src emacs-lisp
19158   (require 'org-crypt)
19159   (org-crypt-use-before-save-magic)
19160   (setq org-tags-exclude-from-inheritance '("crypt"))
19162   (setq org-crypt-key nil)
19163   ;; GPG key to use for encryption
19164   ;; Either the Key ID or set to nil to use symmetric encryption.
19166   (setq auto-save-default nil)
19167   ;; Auto-saving does not cooperate with org-crypt.el: so you need to
19168   ;; turn it off if you plan to use org-crypt.el quite often.  Otherwise,
19169   ;; you'll get an (annoying) message each time you start Org.
19171   ;; To turn it off only locally, you can insert this:
19172   ;;
19173   ;; # -*- buffer-auto-save-file-name: nil; -*-
19174 #+end_src
19176 Excluding the =crypt= tag from inheritance prevents already encrypted
19177 text from being encrypted again.
19179 * Hacking
19180 :PROPERTIES:
19181 :DESCRIPTION: How to hack your way around.
19182 :APPENDIX: Appendix
19183 :END:
19184 #+cindex: hacking
19186 This appendix describes some ways a user can extend the functionality
19187 of Org.
19189 ** Hooks
19190 :PROPERTIES:
19191 :DESCRIPTION: How to reach into Org's internals.
19192 :END:
19193 #+cindex: hooks
19195 Org has a large number of hook variables for adding functionality.
19196 This appendix illustrates using a few.  A complete list of hooks with
19197 documentation is maintained by the Worg project at
19198 https://orgmode.org/worg/doc.html#hooks.
19200 ** Add-on Packages
19201 :PROPERTIES:
19202 :DESCRIPTION: Available extensions.
19203 :END:
19204 #+cindex: add-on packages
19206 Various authors wrote a large number of add-on packages for Org.
19208 These packages are not part of Emacs, but they are distributed as
19209 contributed packages with the separate release available at
19210 https://orgmode.org.  See the =contrib/README= file in the source code
19211 directory for a list of contributed files.  Worg page with more
19212 information is at: https://orgmode.org/worg/org-contrib/.
19214 ** Adding Hyperlink Types
19215 :PROPERTIES:
19216 :DESCRIPTION: New custom link types.
19217 :END:
19218 #+cindex: hyperlinks, adding new types
19220 Org has many built-in hyperlink types (see [[*Hyperlinks]]), and an
19221 interface for adding new link types.  The example file, =org-man.el=,
19222 shows the process of adding Org links to Unix man pages, which look
19223 like this
19225 : [[man:printf][The printf manual]]
19227 #+begin_src emacs-lisp
19228   ;;; org-man.el - Support for links to manpages in Org
19230   (require 'org)
19232   (org-add-link-type "man" 'org-man-open)
19233   (add-hook 'org-store-link-functions 'org-man-store-link)
19235   (defcustom org-man-command 'man
19236     "The Emacs command to be used to display a man page."
19237     :group 'org-link
19238     :type '(choice (const man) (const woman)))
19240   (defun org-man-open (path)
19241     "Visit the manpage on PATH.
19242   PATH should be a topic that can be thrown at the man command."
19243     (funcall org-man-command path))
19245   (defun org-man-store-link ()
19246     "Store a link to a manpage."
19247     (when (memq major-mode '(Man-mode woman-mode))
19248       ;; This is a man page, we do make this link
19249       (let* ((page (org-man-get-page-name))
19250              (link (concat "man:" page))
19251              (description (format "Manpage for %s" page)))
19252         (org-store-link-props
19253          :type "man"
19254          :link link
19255          :description description))))
19257   (defun org-man-get-page-name ()
19258     "Extract the page name from the buffer name."
19259     ;; This works for both `Man-mode' and `woman-mode'.
19260     (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
19261         (match-string 1 (buffer-name))
19262       (error "Cannot create link to this man page")))
19264   (provide 'org-man)
19266   ;;; org-man.el ends here
19267 #+end_src
19269 #+texinfo: @noindent
19270 To activate links to man pages in Org, enter this in the init file:
19272 #+begin_src emacs-lisp
19273   (require 'org-man)
19274 #+end_src
19276 #+texinfo: @noindent
19277 A review of =org-man.el=:
19279 1. First, ~(require 'org)~ ensures =org.el= is loaded.
19281 2. Then ~org-add-link-type~ defines a new link type with =man= prefix.
19282    The call contains the function to call that follows the link type.
19285    #+vindex: org-store-link-functions
19286    The next line adds a function to ~org-store-link-functions~ that
19287    records a useful link with the command {{{kbd(C-c l)}}} in a buffer
19288    displaying a man page.
19290 The rest of the file defines necessary variables and functions.  First
19291 is the customization variable ~org-man-command~.  It has two options,
19292 ~man~ and ~woman~.  Next is a function whose argument is the link
19293 path, which for man pages is the topic of the man command.  To follow
19294 the link, the function calls the ~org-man-command~ to display the man
19295 page.
19297 {{{kbd(C-c l)}}} constructs and stores the link.
19299 {{{kbd(C-c l)}}} calls the function ~org-man-store-link~, which first
19300 checks if the ~major-mode~ is appropriate.  If check fails, the
19301 function returns ~nil~.  Otherwise the function makes a link string by
19302 combining the =man:= prefix with the man topic.  The function then
19303 calls ~org-store-link-props~ with ~:type~ and ~:link~ properties.
19304 A ~:description~ property is an optional string that is displayed when
19305 the function inserts the link in the Org buffer.
19307 {{{kbd(C-c C-l)}}} inserts the stored link.
19309 To define new link types, define a function that implements completion
19310 support with {{{kbd(C-c C-l)}}}.  This function should not accept any
19311 arguments but return the appropriate prefix and complete link string.
19313 ** Adding Export Back-ends
19314 :PROPERTIES:
19315 :DESCRIPTION: How to write new export back-ends.
19316 :END:
19317 #+cindex: Export, writing back-ends
19319 Org's export engine makes it easy for writing new back-ends.  The
19320 framework on which the engine was built makes it easy to derive new
19321 back-ends from existing ones.
19323 #+findex: org-export-define-backend
19324 #+findex: org-export-define-derived-backend
19325 The two main entry points to the export engine are:
19326 ~org-export-define-backend~ and ~org-export-define-derived-backend~.
19327 To grok these functions, see =ox-latex.el= for an example of defining
19328 a new back-end from scratch, and =ox-beamer.el= for an example of
19329 deriving from an existing engine.
19331 For creating a new back-end from scratch, first set its name as
19332 a symbol in an alist consisting of elements and export functions.  To
19333 make the back-end visible to the export dispatcher, set ~:menu-entry~
19334 keyword.  For export options specific to this back-end, set the
19335 ~:options-alist~.
19337 For creating a new back-end from an existing one, set
19338 ~:translate-alist~ to an alist of export functions.  This alist
19339 replaces the parent back-end functions.
19341 For complete documentation, see [[https://orgmode.org/worg/dev/org-export-reference.html][the Org Export Reference on Worg]].
19343 ** Tables in Arbitrary Syntax
19344 :PROPERTIES:
19345 :DESCRIPTION: Orgtbl for LaTeX and other programs.
19346 :END:
19347 #+cindex: tables, in other modes
19348 #+cindex: lists, in other modes
19349 #+cindex: Orgtbl mode
19351 Due to Org's success in handling tables with Orgtbl, a frequently
19352 requested feature is the use of Org's table functions in other modes,
19353 e.g., LaTeX.  This would be hard to do in a general way without
19354 complicated customization nightmares.  Moreover, that would take Org
19355 away from its simplicity roots that Orgtbl has proven.  There is,
19356 however, an alternate approach to accomplishing the same.
19358 This approach involves implementing a custom /translate/ function that
19359 operates on a native Org /source table/ to produce a table in another
19360 format.  This strategy would keep the excellently working Orgtbl
19361 simple and isolate complications, if any, confined to the translate
19362 function.  To add more alien table formats, we just add more translate
19363 functions.  Also the burden of developing custom translate functions
19364 for new table formats is in the hands of those who know those formats
19365 best.
19367 *** Radio tables
19368 :PROPERTIES:
19369 :DESCRIPTION: Sending and receiving radio tables.
19370 :END:
19371 #+cindex: radio tables
19373 Radio tables are target locations for translated tables that are not near
19374 their source.  Org finds the target location and inserts the translated
19375 table.
19377 The key to finding the target location is the magic words =BEGIN/END
19378 RECEIVE ORGTBL=.  They have to appear as comments in the current mode.
19379 If the mode is C, then:
19381 #+begin_example
19382    /* BEGIN RECEIVE ORGTBL table_name */
19383    /* END RECEIVE ORGTBL table_name */
19384 #+end_example
19386 #+texinfo: @noindent
19387 At the location of source, Org needs a special line to direct Orgtbl
19388 to translate and to find the target for inserting the translated
19389 table.  For example:
19391 #+cindex: ORGTBL, keyword
19392 : #+ORGTBL: SEND table_name translation_function arguments ...
19394 #+texinfo: @noindent
19395 =table_name= is the table's reference name, which is also used in the
19396 receiver lines, and the =translation_function= is the Lisp function
19397 that translates.  This line, in addition, may also contain alternating
19398 key and value arguments at the end.  The translation function gets
19399 these values as a property list.  A few standard parameters are
19400 already recognized and acted upon before the translation function is
19401 called:
19403 - =:skip N= ::
19405      Skip the first N lines of the table.  Hlines do count; include
19406      them if they are to be skipped.
19408 - =:skipcols (n1 n2 ...)= ::
19410      List of columns to be skipped.  First Org automatically discards
19411      columns with calculation marks and then sends the table to the
19412      translator function, which then skips columns as specified in
19413      =skipcols=.
19415 #+texinfo: @noindent
19416 To keep the source table intact in the buffer without being disturbed
19417 when the source file is compiled or otherwise being worked on, use one
19418 of these strategies:
19420 - Place the table in a block comment.  For example, in C mode you
19421   could wrap the table between =/*= and =*/= lines.
19423 - Put the table after an "end" statement.  For example ~\bye~ in TeX
19424   and ~\end{document}~ in LaTeX.
19426 - Comment and un-comment each line of the table during edits.  The
19427   {{{kbd(M-x orgtbl-toggle-comment)}}} command makes toggling easy.
19429 *** A LaTeX example of radio tables
19430 :PROPERTIES:
19431 :DESCRIPTION: Step by step, almost a tutorial.
19432 :ALT_TITLE: A LaTeX example
19433 :END:
19434 #+cindex: @LaTeX{}, and Orgtbl mode
19436 To wrap a source table in LaTeX, use the =comment= environment
19437 provided by =comment.sty=[fn:139].  To activate it, put
19438 ~\usepackage{comment}~ in the document header.  Orgtbl mode inserts
19439 a radio table skeleton[fn:138] with the command {{{kbd(M-x
19440 orgtbl-insert-radio-table)}}}, which prompts for a table name.  For
19441 example, if =salesfigures= is the name, the template inserts:
19443 #+begin_example
19444   % BEGIN RECEIVE ORGTBL salesfigures
19445   % END RECEIVE ORGTBL salesfigures
19446   \begin{comment}
19447   ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19448   | | |
19449   \end{comment}
19450 #+end_example
19452 #+vindex: @LaTeX{}-verbatim-environments
19453 #+texinfo: @noindent
19454 The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
19455 ~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
19456 the table at the target (receive) location named =salesfigures=.  Now
19457 the table is ready for data entry.  It can even use spreadsheet
19458 features[fn:140]:
19460 #+begin_example
19461   % BEGIN RECEIVE ORGTBL salesfigures
19462   % END RECEIVE ORGTBL salesfigures
19463   \begin{comment}
19464   ,#+ORGTBL: SEND salesfigures orgtbl-to-latex
19465   | Month | Days | Nr sold | per day |
19466   |-------+------+---------+---------|
19467   | Jan   |   23 |      55 |     2.4 |
19468   | Feb   |   21 |      16 |     0.8 |
19469   | March |   22 |     278 |    12.6 |
19470   ,#+TBLFM: $4=$3/$2;%.1f
19471   % $ (optional extra dollar to keep Font Lock happy, see footnote)
19472   \end{comment}
19473 #+end_example
19475 #+texinfo: @noindent
19476 After editing, {{{kbd(C-c C-c)}}} inserts the translated table at the
19477 target location, between the two marker lines.
19479 For hand-made custom tables, note that the translator needs to skip
19480 the first two lines of the source table.  Also the command has to
19481 /splice/ out the target table without the header and footer.
19483 #+begin_example
19484   \begin{tabular}{lrrr}
19485   Month & \multicolumn{1}{c}{Days} & Nr.\ sold & per day\\
19486   % BEGIN RECEIVE ORGTBL salesfigures
19487   % END RECEIVE ORGTBL salesfigures
19488   \end{tabular}
19489   %
19490   \begin{comment}
19491   ,#+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
19492   | Month | Days | Nr sold | per day |
19493   |-------+------+---------+---------|
19494   | Jan   |   23 |      55 |     2.4 |
19495   | Feb   |   21 |      16 |     0.8 |
19496   | March |   22 |     278 |    12.6 |
19497   ,#+TBLFM: $4=$3/$2;%.1f
19498   \end{comment}
19499 #+end_example
19501 The LaTeX translator function ~orgtbl-to-latex~ is already part of
19502 Orgtbl mode and uses a =tabular= environment to typeset the table and
19503 marks horizontal lines with ~\hline~.  For additional parameters to
19504 control output, see [[*Translator functions]]:
19506 - ~:splice nil/t~ ::
19508      When non-~nil~, return only table body lines; not wrapped in
19509      tabular environment.  Default is ~nil~.
19511 - ~:fmt FMT~ ::
19513      Format to warp each field.  It should contain =%s= for the
19514      original field value.  For example, to wrap each field value in
19515      dollar symbol, you could use =:fmt "$%s$"=.  Format can also wrap
19516      a property list with column numbers and formats, for example
19517      =:fmt (2 "$%s$" 4 "%s\\%%")=.  In place of a string, a function
19518      of one argument can be used; the function must return a formatted
19519      string.
19521 - ~:efmt EFMT~ ::
19523      Format numbers as exponentials.  The spec should have =%s= twice
19524      for inserting mantissa and exponent, for example
19525      ="%s\\times10^{%s}"=.  This may also be a property list with
19526      column numbers and formats, for example =:efmt (2
19527      "$%s\\times10^{%s}$" 4 "$%s\\cdot10^{%s}$")=.  After
19528      {{{var(EFMT)}}} has been applied to a value, {{{var(FMT)}}}---see
19529      above---is also be applied.  Functions with two arguments can be
19530      supplied instead of strings.  By default, no special formatting
19531      is applied.
19533 *** Translator functions
19534 :PROPERTIES:
19535 :DESCRIPTION: Copy and modify.
19536 :END:
19537 #+cindex: HTML, and Orgtbl mode
19538 #+cindex: translator function
19540 #+findex: orgtbl-to-csv
19541 #+findex: orgtbl-to-tsv
19542 #+findex: orgtbl-to-latex
19543 #+findex: orgtbl-to-html
19544 #+findex: orgtbl-to-texinfo
19545 #+findex: orgtbl-to-unicode
19546 #+findex: orgtbl-to-orgtbl
19547 #+findex: orgtbl-to-generic
19548 Orgtbl mode has built-in translator functions: ~orgtbl-to-csv~
19549 (comma-separated values), ~orgtbl-to-tsv~ (TAB-separated values),
19550 ~orgtbl-to-latex~, ~orgtbl-to-html~, ~orgtbl-to-texinfo~,
19551 ~orgtbl-to-unicode~ and ~orgtbl-to-orgtbl~.  They use the generic
19552 translator, ~orgtbl-to-generic~, which delegates translations to
19553 various export back-ends.
19555 Properties passed to the function through the =ORGTBL SEND= line take
19556 precedence over properties defined inside the function.  For example,
19557 this overrides the default LaTeX line endings, ~\\~, with ~\\[2mm]~:
19559 : #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
19561 For a new language translator, define a converter function.  It can be
19562 a generic function, such as shown in this example.  It marks
19563 a beginning and ending of a table with =!BTBL!= and =!ETBL!=;
19564 a beginning and ending of lines with =!BL!= and =!EL!=; and uses a TAB
19565 for a field separator:
19567 #+begin_src emacs-lisp
19568   (defun orgtbl-to-language (table params)
19569     "Convert the orgtbl-mode TABLE to language."
19570     (orgtbl-to-generic
19571      table
19572      (org-combine-plists
19573       '(:tstart "!BTBL!" :tend "!ETBL!" :lstart "!BL!" :lend "!EL!" :sep "\t")
19574       params)))
19575 #+end_src
19577 #+texinfo: @noindent
19578 The documentation for the ~orgtbl-to-generic~ function shows
19579 a complete list of parameters, each of which can be passed through to
19580 ~orgtbl-to-latex~, ~orgtbl-to-texinfo~, and any other function using
19581 that generic function.
19583 For complicated translations the generic translator function could be
19584 replaced by a custom translator function.  Such a custom function must
19585 take two arguments and return a single string containing the formatted
19586 table.  The first argument is the table whose lines are a list of
19587 fields or the symbol ~hline~.  The second argument is the property
19588 list consisting of parameters specified in the =#+ORGTBL: SEND= line.
19589 Please share your translator functions by posting them to the Org
19590 users mailing list, at mailto:emacs-orgmode@gnu.org.
19592 ** Dynamic Blocks
19593 :PROPERTIES:
19594 :DESCRIPTION: Automatically filled blocks.
19595 :END:
19596 #+cindex: dynamic blocks
19598 Org supports /dynamic blocks/ in Org documents.  They are inserted
19599 with begin and end markers like any other code block, but the contents
19600 are updated automatically by a user function.  For example, {{{kbd(C-c
19601 C-x C-r)}}} inserts a dynamic table that updates the work time (see
19602 [[*Clocking Work Time]]).
19604 Dynamic blocks can have names and function parameters.  The syntax is
19605 similar to source code block specifications:
19607 #+begin_example
19608   ,#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
19609     ...
19610   ,#+END:
19611 #+end_example
19613 These commands update dynamic blocks:
19615 - {{{kbd(C-c C-x C-u)}}} (~org-dblock-update~) ::
19617      #+kindex: C-c C-x C-u
19618      #+findex: org-dblock-update
19619      Update dynamic block at point.
19621 - {{{kbd(C-u C-c C-x C-u)}}} ::
19623      #+kindex: C-u C-c C-x C-u
19624      Update all dynamic blocks in the current file.
19626 Before updating a dynamic block, Org removes content between the
19627 =BEGIN= and =END= markers.  Org then reads the parameters on the
19628 =BEGIN= line for passing to the writer function.  If the function
19629 expects to access the removed content, then Org expects an extra
19630 parameter, =:content=, on the =BEGIN= line.
19632 The syntax for naming a writer function with a dynamic block labelled
19633 =myblock= is: ~org-dblock-write:myblock~.  Parameters come from the
19634 =BEGIN= line.
19636 The following is an example of a dynamic block and a block writer function
19637 that updates the time when the function was last run:
19639 #+begin_example
19640   ,#+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
19641     ...
19642   ,#+END:
19643 #+end_example
19645 #+texinfo: @noindent
19646 The dynamic block's writer function:
19648 #+begin_src emacs-lisp
19649   (defun org-dblock-write:block-update-time (params)
19650     (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
19651       (insert "Last block update at: "
19652               (format-time-string fmt))))
19653 #+end_src
19655 To keep dynamic blocks up-to-date in an Org file, use the function,
19656 ~org-update-all-dblocks~ in hook, such as ~before-save-hook~.  The
19657 ~org-update-all-dblocks~ function does not run if the file is not in
19658 Org mode.
19660 #+findex: org-narrow-to-block
19661 Dynamic blocks, like any other block, can be narrowed with
19662 ~org-narrow-to-block~.
19664 ** Special Agenda Views
19665 :PROPERTIES:
19666 :DESCRIPTION: Customized views.
19667 :END:
19668 #+cindex: agenda views, user-defined
19670 #+vindex: org-agenda-skip-function
19671 #+vindex: org-agenda-skip-function-global
19672 Org provides a special hook to further limit items in agenda views:
19673 ~agenda~, ~agenda*~[fn:141], ~todo~, ~alltodo~, ~tags~, ~tags-todo~,
19674 ~tags-tree~.  Specify a custom function that tests inclusion of every
19675 matched item in the view.  This function can also skip as much as is
19676 needed.
19678 For a global condition applicable to agenda views, use the
19679 ~org-agenda-skip-function-global~ variable.  Org uses a global
19680 condition with ~org-agenda-skip-function~ for custom searching.
19682 This example defines a function for a custom view showing TODO items
19683 with =waiting= status.  Manually this is a multi-step search process,
19684 but with a custom view, this can be automated as follows:
19686 The custom function searches the subtree for the =waiting= tag and
19687 returns ~nil~ on match.  Otherwise it gives the location from where
19688 the search continues.
19690 #+begin_src emacs-lisp
19691   (defun my-skip-unless-waiting ()
19692     "Skip trees that are not waiting"
19693     (let ((subtree-end (save-excursion (org-end-of-subtree t))))
19694       (if (re-search-forward ":waiting:" subtree-end t)
19695           nil          ; tag found, do not skip
19696         subtree-end))) ; tag not found, continue after end of subtree
19697 #+end_src
19699 To use this custom function in a custom agenda command:
19701 #+begin_src emacs-lisp
19702   (org-add-agenda-custom-command
19703    '("b" todo "PROJECT"
19704      ((org-agenda-skip-function 'my-skip-unless-waiting)
19705       (org-agenda-overriding-header "Projects waiting for something: "))))
19706 #+end_src
19708 #+vindex: org-agenda-overriding-header
19709 Note that this also binds ~org-agenda-overriding-header~ to a more
19710 meaningful string suitable for the agenda view.
19712 #+vindex: org-odd-levels-only
19713 #+vindex: org-agenda-skip-function
19714 Search for entries with a limit set on levels for the custom search.
19715 This is a general approach to creating custom searches in Org.  To
19716 include all levels, use =LEVEL>0=[fn:142].  Then to selectively pick
19717 the matched entries, use ~org-agenda-skip-function~, which also
19718 accepts Lisp forms, such as ~org-agenda-skip-entry-if~ and
19719 ~org-agenda-skip-subtree-if~.  For example:
19721 - ~(org-agenda-skip-entry-if 'scheduled)~ ::
19723      Skip current entry if it has been scheduled.
19725 - ~(org-agenda-skip-entry-if 'notscheduled)~ ::
19727      Skip current entry if it has not been scheduled.
19729 - ~(org-agenda-skip-entry-if 'deadline)~ ::
19731      Skip current entry if it has a deadline.
19733 - ~(org-agenda-skip-entry-if 'scheduled 'deadline)~ ::
19735      Skip current entry if it has a deadline, or if it is scheduled.
19737 - ~(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))~ ::
19739      Skip current entry if the TODO keyword is TODO or WAITING.
19741 - ~(org-agenda-skip-entry-if 'todo 'done)~ ::
19743      Skip current entry if the TODO keyword marks a DONE state.
19745 - ~(org-agenda-skip-entry-if 'timestamp)~ ::
19747      Skip current entry if it has any timestamp, may also be deadline
19748      or scheduled.
19750 - ~(org-agenda-skip-entry-if 'regexp "regular expression")~ ::
19752      Skip current entry if the regular expression matches in the
19753      entry.
19755 - ~(org-agenda-skip-entry-if 'notregexp "regular expression")~ ::
19757      Skip current entry unless the regular expression matches.
19759 - ~(org-agenda-skip-subtree-if 'regexp "regular expression")~ ::
19761      Same as above, but check and skip the entire subtree.
19763 The following is an example of a search for =waiting= without the
19764 special function:
19766 #+begin_src emacs-lisp
19767   (org-add-agenda-custom-command
19768    '("b" todo "PROJECT"
19769      ((org-agenda-skip-function '(org-agenda-skip-subtree-if
19770                                   'regexp ":waiting:"))
19771       (org-agenda-overriding-header "Projects waiting for something: "))))
19772 #+end_src
19774 ** Speeding Up Your Agendas
19775 :PROPERTIES:
19776 :DESCRIPTION: Tips on how to speed up your agendas.
19777 :END:
19778 #+cindex: agenda views, optimization
19780 Some agenda commands slow down when the Org files grow in size or
19781 number.  Here are tips to speed up:
19783 - Reduce the number of Org agenda files to avoid slowdowns due to hard drive
19784   accesses.
19786 - Reduce the number of DONE and archived headlines so agenda
19787   operations that skip over these can finish faster.
19789 - Do not dim blocked tasks:
19790   #+vindex: org-agenda-dim-blocked-tasks
19792   #+begin_src emacs-lisp
19793     (setq org-agenda-dim-blocked-tasks nil)
19794   #+end_src
19796 - Stop preparing agenda buffers on startup:
19797   #+vindex: org-startup-folded
19798   #+vindex: org-agenda-inhibit-startup
19800   #+begin_src emacs-lisp
19801     (setq org-agenda-inhibit-startup nil)
19802   #+end_src
19804 - Disable tag inheritance for agendas:
19805   #+vindex: org-agenda-show-inherited-tags
19806   #+vindex: org-agenda-use-tag-inheritance
19808   #+begin_src emacs-lisp
19809     (setq org-agenda-use-tag-inheritance nil)
19810   #+end_src
19812 These options can be applied to selected agenda views.  For more
19813 details about generation of agenda views, see the docstrings for the
19814 relevant variables, and this [[https://orgmode.org/worg/agenda-optimization.html][dedicated Worg page]] for agenda
19815 optimization.
19817 ** Extracting Agenda Information
19818 :PROPERTIES:
19819 :DESCRIPTION: Post-processing agenda information.
19820 :END:
19821 #+cindex: agenda, pipe
19822 #+cindex: scripts, for agenda processing
19824 Org provides commands to access agendas through Emacs batch mode.
19825 Through this command-line interface, agendas are automated for further
19826 processing or printing.
19828 #+vindex: org-agenda-custom-commands
19829 #+findex: org-batch-agenda
19830 ~org-batch-agenda~ creates an agenda view in ASCII and outputs to
19831 standard output.  This command takes one string parameter.  When
19832 string consists of a single character, Org uses it as a key to
19833 ~org-agenda-custom-commands~.  These are the same ones available
19834 through {{{kbd(C-c a)}}}.
19836 This example command line directly prints the TODO list to the printer:
19838 : emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
19840 When the string parameter length is two or more characters, Org
19841 matches it with tags/TODO strings.  For example, this example command
19842 line prints items tagged with =shop=, but excludes items tagged with
19843 =NewYork=:
19845 #+begin_example
19846   emacs -batch -l ~/.emacs                                      \
19847         -eval '(org-batch-agenda "+shop-NewYork")' | lpr
19848 #+end_example
19850 #+texinfo: @noindent
19851 An example showing on-the-fly parameter modifications:
19853 #+begin_example
19854   emacs -batch -l ~/.emacs                                      \
19855      -eval '(org-batch-agenda "a"                               \
19856              org-agenda-span (quote month)                      \
19857              org-agenda-include-diary nil                       \
19858              org-agenda-files (quote ("~/org/project.org")))'   \
19859      | lpr
19860 #+end_example
19862 #+texinfo: @noindent
19863 which produces an agenda for the next 30 days from just the
19864 =~/org/projects.org= file.
19866 #+findex: org-batch-agenda-csv
19867 For structured processing of agenda output, use ~org-batch-agenda-csv~
19868 with the following fields:
19870 - category :: The category of the item
19871 - head :: The headline, without TODO keyword, TAGS and PRIORITY
19872 - type :: The type of the agenda entry, can be
19874      | ~todo~              | selected in TODO match              |
19875      | ~tagsmatch~         | selected in tags match              |
19876      | ~diary~             | imported from diary                 |
19877      | ~deadline~          | a deadline                          |
19878      | ~scheduled~         | scheduled                           |
19879      | ~timestamp~         | appointment, selected by timestamp  |
19880      | ~closed~            | entry was closed on date            |
19881      | ~upcoming-deadline~ | warning about nearing deadline      |
19882      | ~past-scheduled~    | forwarded scheduled item            |
19883      | ~block~             | entry has date block including date |
19885 - todo :: The TODO keyword, if any
19886 - tags :: All tags including inherited ones, separated by colons
19887 - date :: The relevant date, like =2007-2-14=
19888 - time :: The time, like =15:00-16:50=
19889 - extra :: String with extra planning info
19890 - priority-l :: The priority letter if any was given
19891 - priority-n :: The computed numerical priority
19893 #+texinfo: @noindent
19894 If the selection of the agenda item was based on a timestamp,
19895 including those items with =DEADLINE= and =SCHEDULED= keywords, then
19896 Org includes date and time in the output.
19898 If the selection of the agenda item was based on a timestamp  (or
19899 deadline/scheduled), then Org includes date and time in the output.
19901 Here is an example of a post-processing script in Perl.  It takes the
19902 CSV output from Emacs and prints with a checkbox:
19904 #+begin_src perl
19905   #!/usr/bin/perl
19907   # define the Emacs command to run
19908   $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
19910   # run it and capture the output
19911   $agenda = qx{$cmd 2>/dev/null};
19913   # loop over all lines
19914   foreach $line (split(/\n/,$agenda)) {
19915       # get the individual values
19916       ($category,$head,$type,$todo,$tags,$date,$time,$extra,
19917        $priority_l,$priority_n) = split(/,/,$line);
19918       # process and print
19919       print "[ ] $head\n";
19920   }
19921 #+end_src
19923 ** Using the Property API
19924 :PROPERTIES:
19925 :DESCRIPTION: Writing programs that use entry properties.
19926 :END:
19927 #+cindex: API, for properties
19928 #+cindex: properties, API
19930 Here is a description of the functions that can be used to work with
19931 properties.
19933 #+attr_texinfo: :options org-entry-properties &optional pom which
19934 #+begin_defun
19935 Get all properties of the entry at point-or-marker {{{var(POM)}}}.
19936 This includes the TODO keyword, the tags, time strings for deadline,
19937 scheduled, and clocking, and any additional properties defined in the
19938 entry.  The return value is an alist.  Keys may occur multiple times
19939 if the property key was used several times.  {{{var(POM)}}} may also
19940 be ~nil~, in which case the current entry is used.  If
19941 {{{var(WHICH)}}} is ~nil~ or ~all~, get all properties.  If
19942 {{{var(WHICH)}}} is ~special~ or ~standard~, only get that subclass.
19943 #+end_defun
19945 #+vindex: org-use-property-inheritance
19946 #+findex: org-insert-property-drawer
19947 #+attr_texinfo: :options org-entry-get pom property &optional inherit
19948 #+begin_defun
19949 Get value of {{{var(PROPERTY)}}} for entry at point-or-marker
19950 {{{var(POM)}}}.  By default, this only looks at properties defined
19951 locally in the entry.  If {{{var(INHERIT)}}} is non-~nil~ and the
19952 entry does not have the property, then also check higher levels of the
19953 hierarchy.  If {{{var(INHERIT)}}} is the symbol ~selective~, use
19954 inheritance if and only if the setting of
19955 ~org-use-property-inheritance~ selects {{{var(PROPERTY)}}} for
19956 inheritance.
19957 #+end_defun
19959 #+attr_texinfo: :options org-entry-delete pom property
19960 #+begin_defun
19961 Delete the property {{{var(PROPERTY)}}} from entry at point-or-marker
19962 {{{var(POM)}}}.
19963 #+end_defun
19965 #+attr_texinfo: :options org-entry-put pom property value
19966 #+begin_defun
19967 Set {{{var(PROPERTY)}}} to {{{var(VALUES)}}} for entry at
19968 point-or-marker POM.
19969 #+end_defun
19971 #+attr_texinfo: :options org-buffer-property-keys &optional include-specials
19972 #+begin_defun
19973 Get all property keys in the current buffer.
19974 #+end_defun
19976 #+attr_texinfo: :options org-insert-property-drawer
19977 #+begin_defun
19978 Insert a property drawer for the current entry.  Also
19979 #+end_defun
19981 #+attr_texinfo: :options org-entry-put-multivalued-property pom property &rest values
19982 #+begin_defun
19983 Set {{{var(PROPERTY)}}} at point-or-marker {{{var(POM)}}} to
19984 {{{var(VALUES)}}}.  {{{var(VALUES)}}} should be a list of strings.
19985 They are concatenated, with spaces as separators.
19986 #+end_defun
19988 #+attr_texinfo: :options org-entry-get-multivalued-property pom property
19989 #+begin_defun
19990 Treat the value of the property {{{var(PROPERTY)}}} as
19991 a whitespace-separated list of values and return the values as a list
19992 of strings.
19993 #+end_defun
19995 #+attr_texinfo: :options org-entry-add-to-multivalued-property pom property value
19996 #+begin_defun
19997 Treat the value of the property {{{var(PROPERTY)}}} as
19998 a whitespace-separated list of values and make sure that
19999 {{{var(VALUE)}}} is in this list.
20000 #+end_defun
20002 #+attr_texinfo: :options org-entry-remove-from-multivalued-property pom property value
20003 #+begin_defun
20004 Treat the value of the property {{{var(PROPERTY)}}} as
20005 a whitespace-separated list of values and make sure that
20006 {{{var(VALUE)}}} is /not/ in this list.
20007 #+end_defun
20009 #+attr_texinfo: :options org-entry-member-in-multivalued-property pom property value
20010 #+begin_defun
20011 Treat the value of the property {{{var(PROPERTY)}}} as
20012 a whitespace-separated list of values and check if {{{var(VALUE)}}} is
20013 in this list.
20014 #+end_defun
20016 #+attr_texinfo: :options org-property-allowed-value-functions
20017 #+begin_defopt
20018 Hook for functions supplying allowed values for a specific property.
20019 The functions must take a single argument, the name of the property,
20020 and return a flat list of allowed values.  If =:ETC= is one of the
20021 values, use the values as completion help, but allow also other values
20022 to be entered.  The functions must return ~nil~ if they are not
20023 responsible for this property.
20024 #+end_defopt
20026 ** Using the Mapping API
20027 :PROPERTIES:
20028 :DESCRIPTION: Mapping over all or selected entries.
20029 :END:
20030 #+cindex: API, for mapping
20031 #+cindex: mapping entries, API
20033 Org has sophisticated mapping capabilities to find all entries
20034 satisfying certain criteria.  Internally, this functionality is used
20035 to produce agenda views, but there is also an API that can be used to
20036 execute arbitrary functions for each or selected entries.  The main
20037 entry point for this API is:
20039 #+attr_texinfo: :options org-map-entries func &optional match scope &rest skip
20040 #+begin_defun
20041 Call {{{(var(FUNC))}}} at each headline selected by {{{var(MATCH)}}}
20042 in {{{var(SCOPE)}}}.
20044 {{{var(FUNC)}}} is a function or a Lisp form.  With the cursor
20045 positioned at the beginning of the headline, call the function without
20046 arguments.  Org returns an alist of return values of calls to the
20047 function.
20049 To avoid preserving point, Org wraps the call to {{{var(FUNC)}}} in
20050 save-excursion form.  After evaluation, Org moves the cursor to the
20051 end of the line that was just processed.  Search continues from that
20052 point forward.  This may not always work as expected under some
20053 conditions, such as if the current sub-tree was removed by a previous
20054 archiving operation.  In such rare circumstances, Org skips the next
20055 entry entirely when it should not.  To stop Org from such skips, make
20056 {{{var(FUNC)}}} set the variable ~org-map-continue-from~ to a specific
20057 buffer position.
20059 {{{var(MATCH)}}} is a tags/property/TODO match.  Org iterates only
20060 matched headlines.  Org iterates over all headlines when
20061 {{{var(MATCH)}}} is ~nil~ or ~t~.
20063 {{{var(SCOPE)}}} determines the scope of this command.  It can be any
20066 - ~nil~ ::
20068      The current buffer, respecting the restriction, if any.
20070 - ~tree~ ::
20072      The subtree started with the entry at point.
20074 - ~region~ ::
20076      The entries within the active region, if any.
20078 - ~file~ ::
20080      The current buffer, without restriction.
20082 - ~file-with-archives~ ::
20084      The current buffer, and any archives associated with it.
20086 - ~agenda~ ::
20088      All agenda files.
20090 - ~agenda-with-archives~ ::
20092      All agenda files with any archive files associated with them.
20094 - ~(file1 file2 ...)~ ::
20096      If this is a list, all files in the list are scanned.
20098 #+texinfo: @noindent
20099 The remaining arguments are treated as settings for the scanner's
20100 skipping facilities.  Valid arguments are:
20102 - ~archive~ ::
20104      Skip trees with the archive tag.
20106 - ~comment~ ::
20108      Skip trees with the COMMENT keyword.
20110 - function or Lisp form ::
20112      #+vindex: org-agenda-skip-function
20113      Used as value for ~org-agenda-skip-function~, so whenever the
20114      function returns ~t~, {{{var(FUNC)}}} is called for that entry
20115      and search continues from the point where the function leaves it.
20116 #+end_defun
20118 The mapping routine can call any arbitrary function, even functions
20119 that change meta data or query the property API (see [[*Using the
20120 Property API]]).  Here are some handy functions:
20122 #+attr_texinfo: :options org-todo &optional arg
20123 #+begin_defun
20124 Change the TODO state of the entry.  See the docstring of the
20125 functions for the many possible values for the argument
20126 {{{var(ARG)}}}.
20127 #+end_defun
20129 #+attr_texinfo: :options org-priority &optional action
20130 #+begin_defun
20131 Change the priority of the entry.  See the docstring of this function
20132 for the possible values for {{{var(ACTION)}}}.
20133 #+end_defun
20135 #+attr_texinfo: :options org-toggle-tag tag &optional onoff
20136 #+begin_defun
20137 Toggle the tag {{{var(TAG)}}} in the current entry.  Setting
20138 {{{var(ONOFF)}}} to either ~on~ or ~off~ does not toggle tag, but
20139 ensure that it is either on or off.
20140 #+end_defun
20142 #+attr_texinfo: :options org-promote
20143 #+begin_defun
20144 Promote the current entry.
20145 #+end_defun
20147 #+attr_texinfo: :options org-demote
20148 #+begin_defun
20149 Demote the current entry.
20150 #+end_defun
20152 This example turns all entries tagged with =TOMORROW= into TODO
20153 entries with keyword =UPCOMING=.  Org ignores entries in comment trees
20154 and archive trees.
20156 #+begin_src emacs-lisp
20157   (org-map-entries '(org-todo "UPCOMING")
20158                    "+TOMORROW" 'file 'archive 'comment)
20159 #+end_src
20161 The following example counts the number of entries with TODO keyword
20162 =WAITING=, in all agenda files.
20164 #+begin_src emacs-lisp
20165   (length (org-map-entries t "/+WAITING" 'agenda))
20166 #+end_src
20168 * MobileOrg
20169 :PROPERTIES:
20170 :DESCRIPTION: Viewing and capture on a mobile device.
20171 :APPENDIX: Appendix
20172 :END:
20173 #+cindex: iPhone
20174 #+cindex: smartphone
20175 #+cindex: android
20176 #+cindex: MobileOrg
20178 MobileOrg is a companion mobile app that runs on iOS and Android
20179 devices.  MobileOrg enables offline-views and capture support for an
20180 Org mode system that is rooted on a "real" computer.  MobileOrg can
20181 record changes to existing entries.
20183 The [[https://github.com/MobileOrg/][iOS implementation]] for the /iPhone/iPod Touch/iPad/ series of
20184 devices, was started by Richard Moreland and is now in the hands of
20185 Sean Escriva.  Android users should check out [[http://wiki.github.com/matburt/mobileorg-android/][MobileOrg Android]] by
20186 Matt Jones.  Though the two implementations are not identical, they
20187 offer similar features.
20189 This appendix describes Org's support for agenda view formats
20190 compatible with MobileOrg.  It also describes synchronizing changes,
20191 such as to notes, between MobileOrg and the computer.
20193 To change tags and TODO states in MobileOrg, first customize the
20194 variables ~org-todo-keywords~ and ~org-tag-alist~.  These should cover
20195 all the important tags and TODO keywords, even if Org files use only
20196 some of them.  Though MobileOrg has in-buffer settings, it understands
20197 TODO states /sets/ (see [[*Setting up keywords for individual files]]) and
20198 /mutually exclusive/ tags (see [[*Setting Tags]]) only for those set in
20199 these variables.
20201 ** Setting Up the Staging Area
20202 :PROPERTIES:
20203 :DESCRIPTION: For the mobile device.
20204 :END:
20206 MobileOrg needs access to a file directory on a server to interact
20207 with Emacs.  With a public server, consider encrypting the files.
20208 MobileOrg version 1.5 supports encryption for the iPhone.  Org also
20209 requires =openssl= installed on the local computer.  To turn on
20210 encryption, set the same password in MobileOrg and in Emacs.  Set the
20211 password in the variable ~org-mobile-use-encryption~[fn:143].  Note
20212 that even after MobileOrg encrypts the file contents, the file name
20213 remains visible on the file systems of the local computer, the server,
20214 and the mobile device.
20216 For a server to host files, consider options like [[http://dropbox.com][Dropbox.com]]
20217 account[fn:144].  On first connection, MobileOrg creates a directory
20218 =MobileOrg= on Dropbox.  Pass its location to Emacs through an
20219 initialisation file variable as follows:
20221 #+begin_src emacs-lisp
20222   (setq org-mobile-directory "~/Dropbox/MobileOrg")
20223 #+end_src
20225 Org copies files to the above directory for MobileOrg.  Org also uses
20226 the same directory for sharing notes between Org and MobileOrg.
20228 ** Pushing to MobileOrg
20229 :PROPERTIES:
20230 :DESCRIPTION: Uploading Org files and agendas.
20231 :END:
20233 #+vindex: org-mobile-files
20234 #+vindex: org-directory
20235 Org pushes files listed in ~org-mobile-files~ to
20236 ~org-mobile-directory~.  Files include agenda files (as listed in
20237 ~org-agenda-files~).  Customize ~org-mobile-files~ to add other files.
20238 File names are staged with paths relative to ~org-directory~, so all
20239 files should be inside this directory[fn:145].
20241 Push creates a special Org file =agendas.org= with custom agenda views
20242 defined by the user[fn:146].
20244 Finally, Org writes the file =index.org=, containing links to other
20245 files.  MobileOrg reads this file first from the server to determine
20246 what other files to download for agendas.  For faster downloads,
20247 MobileOrg only reads files whose checksums[fn:147] have changed.
20249 ** Pulling from MobileOrg
20250 :PROPERTIES:
20251 :DESCRIPTION: Integrating captured and flagged items.
20252 :END:
20254 When MobileOrg synchronizes with the server, it pulls the Org files
20255 for viewing.  It then appends to the file =mobileorg.org= on the
20256 server the captured entries, pointers to flagged and changed entries.
20257 Org integrates its data in an inbox file format.
20260    #+vindex: org-mobile-inbox-for-pull
20261    Org moves all entries found in =mobileorg.org=[fn:148] and appends
20262    them to the file pointed to by the variable
20263    ~org-mobile-inbox-for-pull~.  Each captured entry and each editing
20264    event is a top-level entry in the inbox file.
20266 2. After moving the entries, Org attempts changes to MobileOrg.  Some
20267    changes are applied directly and without user interaction.
20268    Examples include changes to tags, TODO state, headline and body
20269    text.  Entries for further action are tagged as =FLAGGED=.  Org
20270    marks entries with problems with an error message in the inbox.
20271    They have to be resolved manually.
20273 3. Org generates an agenda view for flagged entries for user
20274    intervention to clean up.  For notes stored in flagged entries,
20275    MobileOrg displays them in the echo area when the cursor is on the
20276    corresponding agenda item.
20278    - {{{kbd(?)}}} ::
20279         #+kindex: ?
20281         Pressing {{{kbd(?)}}} displays the entire flagged note in
20282         another window.  Org also pushes it to the kill ring.  To
20283         store flagged note as a normal note, use {{{kbd(? z C-y C-c
20284         C-c)}}}.  Pressing{{{kbd(?)}}} twice does these things: first
20285         it removes the =FLAGGED= tag; second, it removes the flagged
20286         note from the property drawer; third, it signals that manual
20287         editing of the flagged entry is now finished.
20289 #+kindex: C-c a ?
20290 {{{kbd(C-c a ?)}}} returns to the agenda view to finish processing
20291 flagged entries.  Note that these entries may not be the most recent
20292 since MobileOrg searches files that were last pulled.  To get an
20293 updated agenda view with changes since the last pull, pull 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 * GNU Free Documentation License
20660 :PROPERTIES:
20661 :APPENDIX: t
20662 :DESCRIPTION: The license for this documentation.
20663 :END:
20665 #+texinfo: @include ../doc/doclicense.texi
20667 * Main Index
20668 :PROPERTIES:
20669 :INDEX:    cp
20670 :DESCRIPTION: An index of Org's concepts and features.
20671 :END:
20673 * Key Index
20674 :PROPERTIES:
20675 :DESCRIPTION: Key bindings and where they are described.
20676 :INDEX:    ky
20677 :END:
20679 * Command and Function Index
20680 :PROPERTIES:
20681 :DESCRIPTION: Command names and some internal functions.
20682 :INDEX:    fn
20683 :END:
20685 * Variable Index
20686 :PROPERTIES:
20687 :DESCRIPTION: Variables mentioned in the manual.
20688 :INDEX:    vr
20689 :END:
20691 This is not a complete index of variables and faces, only the ones
20692 that are mentioned in the manual.  For a more complete list, use
20693 {{{kbd(M-x org-customize)}}} and then click yourself through the tree.
20695 * Copying
20696 :PROPERTIES:
20697 :copying:  t
20698 :END:
20700 This manual is for Org version {{{version}}}.
20702 Copyright \copy 2004--2018  Free Software Foundation, Inc.
20704 #+begin_quote
20705 Permission is granted to copy, distribute and/or modify this document
20706 under the terms of the GNU Free Documentation License, Version 1.3 or
20707 any later version published by the Free Software Foundation; with no
20708 Invariant Sections, with the Front-Cover texts being "A GNU Manual",
20709 and with the Back-Cover Texts as in (a) below.  A copy of the license
20710 is included in the section entitled "GNU Free Documentation License".
20712 (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
20713 modify this GNU manual."
20714 #+end_quote
20716 * Export Setup                                                          :noexport:
20718 #+subtitle:  Release {{{version}}}
20719 #+author:    by Carsten Dominik
20720 #+subauthor: with contributions by Bastien Guerry, Nicolas Goaziou, Eric Schulte, Jambunathan K, Dan Davison, Thomas Dye, David O'Toole, and Philip Rooke.
20721 #+date:      {{{modification-time}}}
20722 #+email:     tsd@tsdye.com
20723 #+language:  en
20725 # XXX: We cannot use TODO keyword as a node starts with "TODO".
20726 #+todo: REVIEW FIXME | DONE
20727 #+property: header-args :eval no
20728 #+startup: overview nologdone
20730 #+export_file_name: org.texi
20732 #+texinfo_dir_category: Emacs editing modes
20733 #+texinfo_dir_title: Org Mode: (org)
20734 #+texinfo_dir_desc: Outline-based notes management and organizer
20736 # Use proper quote and backtick for code sections in PDF output
20737 # Cf. Texinfo manual 14.2
20738 #+texinfo_header: @set txicodequoteundirected
20739 #+texinfo_header: @set txicodequotebacktick
20741 # Contact Info
20742 #+texinfo_header: @set MAINTAINERSITE @uref{https://orgmode.org,maintainers webpage}
20743 #+texinfo_header: @set MAINTAINER Carsten Dominik
20744 #+texinfo_header: @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
20745 #+texinfo_header: @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
20747 #+options: H:4 num:t toc:t author:t \n:nil ::t |:t ^:nil -:t f:t *:t <:t e:t ':t
20748 #+options: d:nil todo:nil pri:nil tags:not-in-toc stat:nil broken-links:mark
20749 #+select_tags: export
20750 #+exclude_tags: noexport
20752 #+macro: cite @@texinfo:@cite{@@$1@@texinfo:}@@
20753 #+macro: var @@texinfo:@var{@@$1@@texinfo:}@@
20755 # The "version" macro returns major.minor version number.  This is
20756 # sufficient since bugfix releases are not expected to add features
20757 # and therefore imply manual modifications.
20758 #+macro: version (eval (mapconcat #'identity (cl-subseq (split-string (org-version) "\\.") 0 -1) "."))
20760 # The "kbd" macro turns KBD into @kbd{KBD}.  Additionnally, it
20761 # encloses case-sensitive special keys (SPC, RET...) within @key{...}.
20762 #+macro: kbd (eval (let ((case-fold-search nil) (regexp (regexp-opt '("SPC" "RET" "LFD" "TAB" "BS" "ESC" "DELETE" "SHIFT" "CTRL" "META" "up" "left" "right" "down") 'words))) (format "@@texinfo:@kbd{@@%s@@texinfo:}@@" (replace-regexp-in-string regexp "@@texinfo:@key{@@\\&@@texinfo:}@@" $1 t))))
20764 * Footnotes
20766 [fn:1] If you do not use Font Lock globally turn it on in Org buffer
20767 with ~(add-hook 'org-mode-hook 'turn-on-font-lock)~.
20769 [fn:2] Please consider subscribing to the mailing list in order to
20770 minimize the work the mailing list moderators have to do.
20772 [fn:3] See the variables ~org-special-ctrl-a/e~, ~org-special-ctrl-k~,
20773 and ~org-ctrl-k-protect-subtree~ to configure special behavior of
20774 {{{kbd(C-a)}}}, {{{kbd(C-e)}}}, and {{{kbd(C-k)}}} in headlines.  Note
20775 also that clocking only works with headings indented less than 30
20776 stars.
20778 [fn:4] See, however, the option ~org-cycle-emulate-tab~.
20780 [fn:5] The indirect buffer contains the entire buffer, but is narrowed
20781 to the current tree.  Editing the indirect buffer also changes the
20782 original buffer, but without affecting visibility in that buffer.  For
20783 more information about indirect buffers, see [[info:emacs:Indirect%20Buffers][GNU Emacs Manual]].
20785 [fn:6] When ~org-agenda-inhibit-startup~ is non-~nil~, Org does not
20786 honor the default visibility state when first opening a file for the
20787 agenda (see [[*Speeding Up Your Agendas]]).
20789 [fn:7] See also the variable ~org-show-context-detail~ to decide how
20790 much context is shown around each match.
20792 [fn:8] This depends on the option ~org-remove-highlights-with-change~.
20794 [fn:9] When using =*= as a bullet, lines must be indented so that they
20795 are not interpreted as headlines.  Also, when you are hiding leading
20796 stars to get a clean outline view, plain list items starting with
20797 a star may be hard to distinguish from true headlines.  In short: even
20798 though =*= is supported, it may be better to not use it for plain list
20799 items.
20801 [fn:10] You can filter out any of them by configuring
20802 ~org-plain-list-ordered-item-terminator~.
20804 [fn:11] You can also get =a.=, =A.=, =a)= and =A)= by configuring
20805 ~org-list-allow-alphabetical~.  To minimize confusion with normal
20806 text, those are limited to one character only.  Beyond that limit,
20807 bullets automatically become numbers.
20809 [fn:12] If there's a checkbox in the item, the cookie must be put
20810 /before/ the checkbox.  If you have activated alphabetical lists, you
20811 can also use counters like =[@b]=.
20813 [fn:13] If you do not want the item to be split, customize the
20814 variable ~org-M-RET-may-split-line~.
20816 [fn:14] If you want to cycle around items that way, you may customize
20817 ~org-list-use-circular-motion~.
20819 [fn:15] See ~org-list-use-circular-motion~ for a cyclic behavior.
20821 [fn:16] Many desktops intercept {{{kbd(M-TAB)}}} to switch windows.
20822 Use {{{kbd(C-M-i)}}} or {{{kbd(ESC TAB)}}} instead.
20824 [fn:17] The corresponding in-buffer setting is: =#+STARTUP: fninline=
20825 or =#+STARTUP: nofninline=.
20827 [fn:18] The corresponding in-buffer options are =#+STARTUP: fnadjust=
20828 and =#+STARTUP: nofnadjust=.
20830 [fn:19] To insert a vertical bar into a table field, use =\vert= or,
20831 inside a word =abc\vert{}def=.
20833 [fn:20] Org understands references typed by the user as =B4=, but it
20834 does not use this syntax when offering a formula for editing.  You can
20835 customize this behavior using the variable
20836 ~org-table-use-standard-references~.
20838 [fn:21] The computation time scales as O(N^2) because table
20839 {{{var(FOO)}}} is parsed for each field to be copied.
20841 [fn:22] The file =constants.el= can supply the values of constants in
20842 two different unit systems, =SI= and =cgs=.  Which one is used depends
20843 on the value of the variable ~constants-unit-system~.  You can use the
20844 =STARTUP= options =constSI= and =constcgs= to set this value for the
20845 current buffer.
20847 [fn:23] The printf reformatting is limited in precision because the
20848 value passed to it is converted into an "integer" or "double".  The
20849 "integer" is limited in size by truncating the signed value to 32
20850 bits.  The "double" is limited in precision to 64 bits overall which
20851 leaves approximately 16 significant decimal digits.
20853 [fn:24] Such names must start with an alphabetic character and use
20854 only alphanumeric/underscore characters.
20856 [fn:25] To insert a link targeting a headline, in-buffer completion
20857 can be used.  Just type a star followed by a few optional letters into
20858 the buffer and press {{{kbd(M-TAB)}}}.  All headlines in the current
20859 buffer are offered as completions.
20861 [fn:26] When targeting a =NAME= keyword, =CAPTION= keyword is
20862 mandatory in order to get proper numbering (see [[*Images and Tables]]).
20864 [fn:27] The actual behavior of the search depends on the value of the
20865 variable ~org-link-search-must-match-exact-headline~.  If its value is
20866 ~nil~, then a fuzzy text search is done.  If it is ~t~, then only the
20867 exact headline is matched, ignoring spaces and statistic cookies.  If
20868 the value is ~query-to-create~, then an exact headline is searched; if
20869 it is not found, then the user is queried to create it.
20871 [fn:28] If the headline contains a timestamp, it is removed from the
20872 link, which results in a wrong link---you should avoid putting
20873 a timestamp in the headline.
20875 [fn:29] The Org Id library must first be loaded, either through
20876 ~org-customize~, by enabling ~id~ in ~org-modules~, or by adding
20877 ~(require 'org-id)~ in your Emacs init file.
20879 [fn:30] Note that you do not have to use this command to insert
20880 a link.  Links in Org are plain text, and you can type or paste them
20881 straight into the buffer.  By using this command, the links are
20882 automatically enclosed in double brackets, and you will be asked for
20883 the optional descriptive text.
20885 [fn:31] After insertion of a stored link, the link will be removed
20886 from the list of stored links.  To keep it in the list later use, use
20887 a triple {{{kbd(C-u)}}} prefix argument to {{{kbd(C-c C-l)}}}, or
20888 configure the option ~org-keep-stored-link-after-insertion~.
20890 [fn:32] This works if a function has been defined in the ~:complete~
20891 property of a link in ~org-link-parameters~.
20893 [fn:33] See the variable ~org-display-internal-link-with-indirect-buffer~.
20895 [fn:34] The variable ~org-startup-with-inline-images~ can be set
20896 within a buffer with the =STARTUP= options =inlineimages= and
20897 =noinlineimages=.
20899 [fn:35] For backward compatibility, line numbers can also follow a
20900 single colon.
20902 [fn:36] Of course, you can make a document that contains only long
20903 lists of TODO items, but this is not required.
20905 [fn:37] Changing the variable ~org-todo-keywords~ only becomes
20906 effective after restarting Org mode in a buffer.
20908 [fn:38] This is also true for the {{{kbd(t)}}} command in the timeline
20909 and agenda buffers.
20911 [fn:39] All characters are allowed except =@=, =^= and =!=, which have
20912 a special meaning here.
20914 [fn:40] Check also the variable ~org-fast-tag-selection-include-todo~,
20915 it allows you to change the TODO state through the tags interface
20916 ([[*Setting Tags]]), in case you like to mingle the two concepts.  Note
20917 that this means you need to come up with unique keys across both sets
20918 of keywords.
20920 [fn:41] Org mode parses these lines only when Org mode is activated
20921 after visiting a file.  {{{kbd(C-c C-c)}}} with the cursor in a line
20922 starting with =#+= is simply restarting Org mode for the current
20923 buffer.
20925 [fn:42] The corresponding in-buffer setting is: =#+STARTUP: logdone=.
20927 [fn:43] The corresponding in-buffer setting is: =#+STARTUP:
20928 lognotedone=.
20930 [fn:44] See the variable ~org-log-states-order-reversed~.
20932 [fn:45] Note that the =LOGBOOK= drawer is unfolded when pressing
20933 {{{kbd(SPC)}}} in the agenda to show an entry---use {{{kbd(C-u
20934 SPC)}}} to keep it folded here.
20936 [fn:46] It is possible that Org mode records two timestamps when you
20937 are using both ~org-log-done~ and state change logging.  However, it
20938 never prompts for two notes: if you have configured both, the state
20939 change recording note takes precedence and cancel the closing note.
20941 [fn:47] See also the option ~org-priority-start-cycle-with-default~.
20943 [fn:48] To keep subtasks out of the global TODO list, see the
20944 ~org-agenda-todo-list-sublevels~.
20946 [fn:49] With the exception of description lists.  But you can allow it
20947 by modifying ~org-list-automatic-rules~ accordingly.
20949 [fn:50] Set the variable ~org-hierarchical-checkbox-statistics~ if you
20950 want such cookies to count all checkboxes below the cookie, not just
20951 those belonging to direct children.
20953 [fn:51] {{{kbd(C-u C-c C-c)}}} on the /first/ item of a list with no
20954 checkbox adds checkboxes to the rest of the list.
20956 [fn:52] As with all these in-buffer settings, pressing {{{kbd(C-c
20957 C-c)}}} activates any changes in the line.
20959 [fn:53] This is only true if the search does not involve more complex
20960 tests including properties (see [[*Property Searches]]).
20962 [fn:54] Keys are automatically assigned to tags that have no
20963 configured keys.
20965 [fn:55] If more than one summary type applies to the same property,
20966 the parent values are computed according to the first of them.
20968 [fn:56] An age is defined as a duration, using effort modifiers
20969 defined in ~org-effort-durations~, e.g., =3d 1h=.  If any value in the
20970 column is as such, the summary is also an effort duration.
20972 [fn:57] Please note that the =COLUMNS= definition must be on a single
20973 line; it is wrapped here only because of formatting constraints.
20975 [fn:58] Contributed packages are not part of Emacs, but are
20976 distributed with the main distribution of Org---visit
20977 [[https://orgmode.org]].
20979 [fn:59] The Org date format is inspired by the standard ISO 8601
20980 date/time format.  To use an alternative format, see [[*Custom time
20981 format]].  The day name is optional when you type the date yourself.
20982 However, any date inserted or modified by Org adds that day name, for
20983 reading convenience.
20985 [fn:60] When working with the standard diary sexp functions, you need
20986 to be very careful with the order of the arguments.  That order
20987 depends evilly on the variable ~calendar-date-style~.  For example, to
20988 specify a date December 12, 2005, the call might look like
20989 =(diary-date 12 1 2005)= or =(diary-date 1 12 2005)= or =(diary-date
20990 2005 12 1)=, depending on the settings.  This has been the source of
20991 much confusion.  Org mode users can resort to special versions of
20992 these functions like ~org-date~ or ~org-anniversary~.  These work just
20993 like the corresponding ~diary-~ functions, but with stable ISO order
20994 of arguments (year, month, day) wherever applicable, independent of
20995 the value of ~calendar-date-style~.
20997 [fn:61] See the variable ~org-read-date-prefer-future~.  You may set
20998 that variable to the symbol ~time~ to even make a time before now
20999 shift the date to tomorrow.
21001 [fn:62] If you do not need/want the calendar, configure the variable
21002 ~org-popup-calendar-for-date-prompt~.
21004 [fn:63] If you find this distracting, turn off the display with
21005 ~org-read-date-display-live~.
21007 [fn:64] It will still be listed on that date after it has been marked
21008 DONE.  If you do not like this, set the variable
21009 ~org-agenda-skip-scheduled-if-done~.
21011 [fn:65] The =SCHEDULED= and =DEADLINE= dates are inserted on the line
21012 right below the headline.  Do not put any text between this line and
21013 the headline.
21015 [fn:66] Note the corresponding =STARTUP= options =logredeadline=,
21016 =lognoteredeadline=, and =nologredeadline=.
21018 [fn:67] Note the corresponding =STARTUP= options =logreschedule=,
21019 =lognotereschedule=, and =nologreschedule=.
21021 [fn:68] In fact, the target state is taken from, in this sequence, the
21022 =REPEAT_TO_STATE= property, the variable ~org-todo-repeat-to-state~ if
21023 it is a string, the previous TODO state if ~org-todo-repeat-to-state~
21024 is ~t~, or the first state of the TODO state sequence.
21026 [fn:69] You can change this using the option ~org-log-repeat~, or the
21027 =STARTUP= options =logrepeat=, =lognoterepeat=, and =nologrepeat=.
21028 With =lognoterepeat=, you will also be prompted for a note.
21030 [fn:70] Clocking only works if all headings are indented with less
21031 than 30 stars.  This is a hard-coded limitation of ~lmax~ in
21032 ~org-clock-sum~.
21034 [fn:71] To resume the clock under the assumption that you have worked
21035 on this task while outside Emacs, use ~(setq org-clock-persist t)~.
21037 [fn:72] To add an effort estimate "on the fly", hook a function doing
21038 this to ~org-clock-in-prepare-hook~.
21040 [fn:73] The last reset of the task is recorded by the =LAST_REPEAT=
21041 property.
21043 [fn:74] See also the variable ~org-clock-modeline-total~.
21045 [fn:75] The corresponding in-buffer setting is: =#+STARTUP:
21046 lognoteclock-out=.
21048 [fn:76] Language terms can be set through the variable
21049 ~org-clock-clocktable-language-setup~.
21051 [fn:77] Note that all parameters must be specified in a single
21052 line---the line is broken here only to fit it into the manual.
21054 [fn:78] On computers using Mac OS X, idleness is based on actual user
21055 idleness, not just Emacs' idle time.  For X11, you can install
21056 a utility program =x11idle.c=, available in the =contrib/scripts/=
21057 directory of the Org Git distribution, or install the xprintidle
21058 package and set it to the variable ~org-clock-x11idle-program-name~ if
21059 you are running Debian, to get the same general treatment of idleness.
21060 On other systems, idle time refers to Emacs idle time only.
21062 [fn:79] Please note the pitfalls of summing hierarchical data in
21063 a flat list ([[*Using Column View in the Agenda]]).
21065 [fn:80] Please select your own key, {{{kbd(C-c c)}}} is only
21066 a suggestion.
21068 [fn:81] Org used to offer four different targets for date/week tree
21069 capture.  Now, Org automatically translates these to use
21070 ~file+olp+datetree~, applying the ~:time-prompt~ and ~:tree-type~
21071 properties.  Please rewrite your date/week-tree targets using
21072 ~file+olp+datetree~ since the older targets are now deprecated.
21074 [fn:82] A date tree is an outline structure with years on the highest
21075 level, months or ISO weeks as sublevels and then dates on the lowest
21076 level.  Tags are allowed in the tree structure.
21078 [fn:83] If you need one of these sequences literally, escape the =%=
21079 with a backslash.
21081 [fn:84] If you define your own link types (see [[*Adding Hyperlink
21082 Types]]), any property you store with ~org-store-link-props~ can be
21083 accessed in capture templates in a similar way.
21085 [fn:85] This is always the other, not the user.  See the variable
21086 ~org-from-is-user-regexp~.
21088 [fn:86] If you move entries or Org files from one directory to
21089 another, you may want to configure ~org-attach-directory~ to contain
21090 an absolute path.
21092 [fn:87] Note the corresponding =STARTUP= options =logrefile=,
21093 =lognoterefile=, and =nologrefile=.
21095 [fn:88] If the value of that variable is not a list, but a single file
21096 name, then the list of agenda files in maintained in that external
21097 file.
21099 [fn:89] When using the dispatcher, pressing {{{kbd(<)}}} before
21100 selecting a command actually limits the command to the current file,
21101 and ignores ~org-agenda-files~ until the next dispatcher command.
21103 [fn:90] For backward compatibility, you can also press {{{kbd(1)}}} to
21104 restrict to the current buffer.
21106 [fn:91] For backward compatibility, you can also press {{{kbd(0)}}} to
21107 restrict to the current region/subtree.
21109 [fn:92] For backward compatibility, the universal prefix
21110 {{{kbd(C-u)}}} causes all TODO entries to be listed before the agenda.
21111 This feature is deprecated, use the dedicated TODO list, or a block
21112 agenda instead (see [[*Block agenda]]).
21114 [fn:93] The variable ~org-anniversary~ used in the example is just
21115 like ~diary-anniversary~, but the argument order is always according
21116 to ISO and therefore independent of the value of
21117 ~calendar-date-style~.
21119 [fn:94] Custom commands can preset a filter by binding the variable
21120 ~org-agenda-tag-filter-preset~ as an option.  This filter is then
21121 applied to the view and persists as a basic filter through refreshes
21122 and more secondary filtering.  The filter is a global property of the
21123 entire agenda view---in a block agenda, you should only set this in
21124 the global options section, not in the section of an individual block.
21126 [fn:95] Only tags filtering is respected here, effort filtering is
21127 ignored.
21129 [fn:96] You can also create persistent custom functions through
21130 ~org-agenda-bulk-custom-functions~.
21132 [fn:97] This file is parsed for the agenda when
21133 ~org-agenda-include-diary~ is set.
21135 [fn:98] You can provide a description for a prefix key by inserting
21136 a cons cell with the prefix and the description.
21138 [fn:99] /Planned/ means here that these entries have some planning
21139 information attached to them, like a time-stamp, a scheduled or
21140 a deadline string.  See ~org-agenda-entry-types~ on how to set what
21141 planning information is taken into account.
21143 [fn:100] For HTML you need to install Hrvoje Niksic's =htmlize.el=
21144 from [[https://github.com/hniksic/emacs-htmlize][Hrvoje Niksic's repository]].
21146 [fn:101] To create PDF output, the Ghostscript ps2pdf utility must be
21147 installed on the system.  Selecting a PDF file also creates the
21148 postscript file.
21150 [fn:102] If you want to store standard views like the weekly agenda or
21151 the global TODO list as well, you need to define custom commands for
21152 them in order to be able to specify file names.
21154 [fn:103] Quoting depends on the system you use, please check the FAQ
21155 for examples.
21157 [fn:104] This works automatically for the HTML backend (it requires
21158 version 1.34 of the =htmlize.el= package, which you need to install).
21159 Fontified code chunks in LaTeX can be achieved using either the
21160 listings package or the [[https://github.com/gpoore/minted][minted]] package.  Refer to
21161 ~org-export-latex-listings~ for details.
21163 [fn:105] Source code in code blocks may also be evaluated either
21164 interactively or on export.  See [[*Working with Source Code]] for more
21165 information on evaluating code blocks.
21167 [fn:106] Adding =-k= to =-n -r= /keeps/ the labels in the source code
21168 while using line numbers for the links, which might be useful to
21169 explain those in an Org mode example code.
21171 [fn:107] Upon exit, lines starting with =*=, =,*=, =#+= and =,#+= get
21172 a comma prepended, to keep them from being interpreted by Org as
21173 outline nodes or special syntax.  These commas are stripped when
21174 editing with {{{kbd(C-c ')}}}, and also before export.
21176 [fn:108] You may select a different-mode with the variable
21177 ~org-edit-fixed-width-region-mode~.
21179 [fn:109] You can turn this on by default by setting the variable
21180 ~org-pretty-entities~, or on a per-file base with the =STARTUP= option
21181 =entitiespretty=.
21183 [fn:110] This behaviour can be disabled with =-= export setting (see
21184 [[*Export Settings]]).
21186 [fn:111] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
21187 system.  Many of the features described here as "LaTeX" are really
21188 from TeX, but for simplicity I am blurring this distinction.
21190 [fn:112] When MathJax is used, only the environments recognized by
21191 MathJax are processed.  When dvipng, dvisvgm, or ImageMagick suite is
21192 used to create images, any LaTeX environment is handled.
21194 [fn:113] These are respectively available at
21195 [[http://sourceforge.net/projects/dvipng/]], [[http://dvisvgm.bplaced.net/]]
21196 and from the ImageMagick suite.  Choose the converter by setting the
21197 variable ~org-preview-latex-default-process~ accordingly.
21199 [fn:114] Org mode has a method to test if the cursor is inside such
21200 a fragment, see the documentation of the function
21201 ~org-inside-LaTeX-fragment-p~.
21203 [fn:115] The variable ~org-export-date-timestamp-format~ defines how
21204 this timestamp are exported.
21206 [fn:116] At the moment, some export back-ends do not obey this
21207 specification.  For example, LaTeX export excludes every unnumbered
21208 headline from the table of contents.
21210 [fn:117] Since commas separate the arguments, commas within arguments
21211 have to be escaped with the backslash character.  So only those
21212 backslash characters before a comma need escaping with another
21213 backslash character.
21215 [fn:118] For a less drastic behavior, consider using a select tag (see
21216 [[*Export Settings]]) instead.
21218 [fn:119] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
21219 to make it visible.  The tag serves as a visual aid and has no
21220 semantic relevance.
21222 [fn:120] By default Org loads MathJax from [[https://cdnjs.com][cdnjs.com]] as recommended by
21223 [[http://www.mathjax.org][MathJax]].
21225 [fn:121] See [[http://docs.mathjax.org/en/latest/tex.html#tex-extensions][TeX and LaTeX extensions]] in the [[http://docs.mathjax.org][MathJax manual]] to learn
21226 about extensions.
21228 [fn:122] If the classes on TODO keywords and tags lead to conflicts,
21229 use the variables ~org-html-todo-kwd-class-prefix~ and
21230 ~org-html-tag-class-prefix~ to make them unique.
21232 [fn:123] This does not allow setting different bibliography compilers
21233 for different files.  However, "smart" LaTeX compilation systems, such
21234 as latexmk, can select the correct bibliography compiler.
21236 [fn:124] See [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][Open Document Format for Office Applications
21237 (OpenDocument) Version 1.2]].
21239 [fn:125] See [[http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl][MathToWeb]].
21241 [fn:126] See [[http://dlmf.nist.gov/LaTeXML/]].
21243 [fn:127] [[http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html][OpenDocument-v1.2 Specification]]
21245 [fn:128] See the =<table:table-template>= element of the
21246 OpenDocument-v1.2 specification.
21248 [fn:129] See the attributes =table:template-name=,
21249 =table:use-first-row-styles=, =table:use-last-row-styles=,
21250 =table:use-first-column-styles=, =table:use-last-column-styles=,
21251 =table:use-banding-rows-styles=, and =table:use-banding-column-styles=
21252 of the =<table:table>= element in the OpenDocument-v1.2 specification.
21254 [fn:130] If the publishing directory is the same as the source
21255 directory, =file.org= is exported as =file.org.org=, so you probably
21256 do not want to do this.
21258 [fn:131] The option ~org-babel-no-eval-on-ctrl-c-ctrl-c~ can be used
21259 to remove code evaluation from the {{{kbd(C-c C-c)}}} key binding.
21261 [fn:132] Actually, the constructs =call_<name>()= and =src_<lang>{}=
21262 are not evaluated when they appear in a keyword line---i.e. lines
21263 starting with =#+KEYWORD:=, see [[*Summary of In-Buffer Settings]].
21265 [fn:133] For Noweb literate programming details, see
21266 http://www.cs.tufts.edu/~nr/noweb/.
21268 [fn:134] For more information, please refer to the commentary section
21269 in =org-tempo.el=.
21271 [fn:135] Note that ~org-indent-mode~ also sets the ~wrap-prefix~
21272 property, such that ~visual-line-mode~ (or purely setting ~word-wrap~)
21273 wraps long lines (including headlines) correctly indented.
21275 [fn:136] The ~org-indent-mode~ also sets the ~wrap-prefix~ correctly
21276 for indenting and wrapping long lines of headlines or text.  This
21277 minor mode handles ~visual-line-mode~ and directly applied settings
21278 through ~word-wrap~.
21280 [fn:137] Also see the variable ~org-adapt-indentation~.
21282 [fn:138] Because =LEVEL=2= has 3 stars, =LEVEL=3= has 4 stars, and so
21285 [fn:139] https://ctan.org/tex-archive/macros/latex/contrib/comment?lang=en
21287 [fn:140] If the =TBLFM= keyword contains an odd number of dollar
21288 characters, this may cause problems with Font Lock in LaTeX mode.  As
21289 shown in the example you can fix this by adding an extra line inside
21290 the =comment= environment that is used to balance the dollar
21291 expressions.  If you are using AUCTeX with the font-latex library,
21292 a much better solution is to add the =comment= environment to the
21293 variable ~LaTeX-verbatim-environments~.
21295 [fn:141] The ~agenda*~ view is the same as ~agenda~ except that it
21296 only considers /appointments/, i.e., scheduled and deadline items that
21297 have a time specification =[h]h:mm= in their time-stamps.
21299 [fn:142] Note that, for ~org-odd-levels-only~, a level number
21300 corresponds to order in the hierarchy, not to the number of stars.
21302 [fn:143] If Emacs is configured for safe storing of passwords, then
21303 configure the variable, ~org-mobile-encryption-password~; please read
21304 the docstring of that variable.
21306 [fn:144] An alternative is to use a WebDAV server.  MobileOrg
21307 documentation has details of WebDAV server configuration.  Additional
21308 help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
21310 [fn:145] Symbolic links in ~org-directory~ need to have the same name
21311 as their targets.
21313 [fn:146] While creating the agendas, Org mode forces ID properties on
21314 all referenced entries, so that these entries can be uniquely
21315 identified if MobileOrg flags them for further action.  To avoid
21316 setting properties configure the variable
21317 ~org-mobile-force-id-on-agenda-items~ to ~nil~.  Org mode then relies
21318 on outline paths, assuming they are unique.
21320 [fn:147] Checksums are stored automatically in the file
21321 =checksums.dat=.
21323 [fn:148] The file will be empty after this operation.