orgguide.texi 97 KB

  1. \input texinfo
  2. @c %**start of header
  3. @setfilename ../../info/orgguide
  4. @settitle The compact Org-mode Guide
  5. @set VERSION 0.92
  6. @set DATE April 2010
  7. @c Use proper quote and backtick for code sections in PDF output
  8. @c Cf. Texinfo manual 14.2
  9. @set txicodequoteundirected
  10. @set txicodequotebacktick
  11. @c Version and Contact Info
  12. @set MAINTAINERSITE @uref{,maintainers webpage}
  13. @set AUTHOR Carsten Dominik
  14. @set MAINTAINER Carsten Dominik
  15. @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
  16. @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
  17. @c %**end of header
  18. @finalout
  19. @c Macro definitions
  20. @iftex
  21. @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
  22. @end iftex
  23. @macro Ie {}
  24. I.e.,
  25. @end macro
  26. @macro ie {}
  27. i.e.,
  28. @end macro
  29. @macro Eg {}
  30. E.g.,
  31. @end macro
  32. @macro eg {}
  33. e.g.,
  34. @end macro
  35. @c Subheadings inside a table.
  36. @macro tsubheading{text}
  37. @ifinfo
  38. @subsubheading \text\
  39. @end ifinfo
  40. @ifnotinfo
  41. @item @b{\text\}
  42. @end ifnotinfo
  43. @end macro
  44. @macro seealso{text}
  45. @noindent @b{Further reading}@*@noindent \text\
  46. @end macro
  47. @copying
  48. Copyright @copyright{} 2010 Free Software Foundation
  49. @quotation
  50. Permission is granted to copy, distribute and/or modify this document
  51. under the terms of the GNU Free Documentation License, Version 1.3 or
  52. any later version published by the Free Software Foundation; with no
  53. Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
  54. and with the Back-Cover Texts as in (a) below. A copy of the license
  55. is included in the section entitled ``GNU Free Documentation License.''
  56. (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
  57. modify this GNU manual. Buying copies from the FSF supports it in
  58. developing GNU and promoting software freedom.''
  59. This document is part of a collection distributed under the GNU Free
  60. Documentation License. If you want to distribute this document
  61. separately from the collection, you can do so by adding a copy of the
  62. license to the document, as described in section 6 of the license.
  63. @end quotation
  64. @end copying
  65. @dircategory Emacs
  66. @direntry
  67. * Org Mode Guide: (orgguide). Abbreviated Org-mode Manual
  68. @end direntry
  69. @titlepage
  70. @title The compact Org-mode Guide
  71. @subtitle Release @value{VERSION}
  72. @author by Carsten Dominik
  73. @c The following two commands start the copyright page.
  74. @page
  75. @vskip 0pt plus 1filll
  76. @insertcopying
  77. @end titlepage
  78. @c Output the table of contents at the beginning.
  79. @shortcontents
  80. @ifnottex
  81. @node Top, Introduction, (dir), (dir)
  82. @top Org Mode Manual
  83. @insertcopying
  84. @end ifnottex
  85. @menu
  86. * Introduction:: Getting started
  87. * Document Structure:: A tree works like your brain
  88. * Tables:: Pure magic for quick formatting
  89. * Hyperlinks:: Notes in context
  90. * TODO Items:: Every tree branch can be a TODO item
  91. * Tags:: Tagging headlines and matching sets of tags
  92. * Properties:: Properties
  93. * Dates and Times:: Making items useful for planning
  94. * Capture - Refile - Archive:: The ins and outs for projects
  95. * Agenda Views:: Collecting information into views
  96. * Markup:: Prepare text for rich export
  97. * Exporting:: Sharing and publishing of notes
  98. * Publishing:: Create a web site of linked Org files
  99. * Working With Source Code:: Source code snippets embedded in Org
  100. * Miscellaneous:: All the rest which did not fit elsewhere
  101. @detailmenu
  102. --- The Detailed Node Listing ---
  103. Introduction
  104. * Preface:: Welcome
  105. * Installation:: How to install a downloaded version of Org
  106. * Activation:: How to activate Org for certain buffers
  107. * Feedback:: Bug reports, ideas, patches etc.
  108. Document Structure
  109. * Outlines:: Org is based on Outline mode
  110. * Headlines:: How to typeset Org tree headlines
  111. * Visibility cycling:: Show and hide, much simplified
  112. * Motion:: Jumping to other headlines
  113. * Structure editing:: Changing sequence and level of headlines
  114. * Sparse trees:: Matches embedded in context
  115. * Plain lists:: Additional structure within an entry
  116. * Footnotes:: How footnotes are defined in Org's syntax
  117. Hyperlinks
  118. * Link format:: How links in Org are formatted
  119. * Internal links:: Links to other places in the current file
  120. * External links:: URL-like links to the world
  121. * Handling links:: Creating, inserting and following
  122. * Targeted links:: Point at a location in a file
  123. TODO Items
  124. * Using TODO states:: Setting and switching states
  125. * Multi-state workflows:: More than just on/off
  126. * Progress logging:: Dates and notes for progress
  127. * Priorities:: Some things are more important than others
  128. * Breaking down tasks:: Splitting a task into manageable pieces
  129. * Checkboxes:: Tick-off lists
  130. Progress logging
  131. * Closing items:: When was this entry marked DONE?
  132. * Tracking TODO state changes:: When did the status change?
  133. Tags
  134. * Tag inheritance:: Tags use the tree structure of the outline
  135. * Setting tags:: How to assign tags to a headline
  136. * Tag searches:: Searching for combinations of tags
  137. Dates and Times
  138. * Timestamps:: Assigning a time to a tree entry
  139. * Creating timestamps:: Commands which insert timestamps
  140. * Deadlines and scheduling:: Planning your work
  141. * Clocking work time:: Tracking how long you spend on a task
  142. Capture - Refile - Archive
  143. * Capture::
  144. * Refiling notes:: Moving a tree from one place to another
  145. * Archiving:: What to do with finished projects
  146. Capture
  147. * Setting up a capture location:: Where notes will be stored
  148. * Using capture:: Commands to invoke and terminate capture
  149. * Capture templates:: Define the outline of different note types
  150. Agenda Views
  151. * Agenda files:: Files being searched for agenda information
  152. * Agenda dispatcher:: Keyboard access to agenda views
  153. * Built-in agenda views:: What is available out of the box?
  154. * Agenda commands:: Remote editing of Org trees
  155. * Custom agenda views:: Defining special searches and views
  156. The built-in agenda views
  157. * Weekly/daily agenda:: The calendar page with current tasks
  158. * Global TODO list:: All unfinished action items
  159. * Matching tags and properties:: Structured information with fine-tuned search
  160. * Timeline:: Time-sorted view for single file
  161. * Search view:: Find entries by searching for text
  162. Markup for rich export
  163. * Structural markup elements:: The basic structure as seen by the exporter
  164. * Images and tables:: Tables and Images will be included
  165. * Literal examples:: Source code examples with special formatting
  166. * Include files:: Include additional files into a document
  167. * Embedded LaTeX:: LaTeX can be freely used inside Org documents
  168. Structural markup elements
  169. * Document title:: Where the title is taken from
  170. * Headings and sections:: The document structure as seen by the exporter
  171. * Table of contents:: The if and where of the table of contents
  172. * Paragraphs:: Paragraphs
  173. * Emphasis and monospace:: Bold, italic, etc.
  174. * Comment lines:: What will *not* be exported
  175. Exporting
  176. * Export options:: Per-file export settings
  177. * The export dispatcher:: How to access exporter commands
  178. * ASCII/Latin-1/UTF-8 export:: Exporting to flat files with encoding
  179. * HTML export:: Exporting to HTML
  180. * LaTeX and PDF export:: Exporting to La@TeX{}, and processing to PDF
  181. * DocBook export:: Exporting to DocBook
  182. * iCalendar export::
  183. Miscellaneous
  184. * Completion:: M-TAB knows what you need
  185. * Clean view:: Getting rid of leading stars in the outline
  186. * MobileOrg:: Org-mode on the iPhone
  187. @end detailmenu
  188. @end menu
  189. @node Introduction, Document Structure, Top, Top
  190. @chapter Introduction
  191. @menu
  192. * Preface:: Welcome
  193. * Installation:: How to install a downloaded version of Org
  194. * Activation:: How to activate Org for certain buffers
  195. * Feedback:: Bug reports, ideas, patches etc.
  196. @end menu
  197. @node Preface, Installation, Introduction, Introduction
  198. @section Preface
  199. Org is a mode for keeping notes, maintaining TODO lists, and doing project
  200. planning with a fast and effective plain-text system. It is also an
  201. authoring and publishing system.
  202. @i{This document is a much compressed derivative of the
  203. @uref{, comprehensive Org-mode manual}.
  204. It contains all basic features and commands, along with important hints for
  205. customization. It is intended for beginners who would shy back from a 200
  206. page manual because of sheer size.}
  207. @node Installation, Activation, Preface, Introduction
  208. @section Installation
  209. @b{Important:} @i{If you are using a version of Org that is part of the Emacs
  210. distribution or an XEmacs package, please skip this section and go directly
  211. to @ref{Activation}.}
  212. If you have downloaded Org from the Web, either as a distribution @file{.zip}
  213. or @file{.tar} file, or as a Git archive, it is best to run it directly from
  214. the distribution directory. You need to add the @file{lisp} subdirectories
  215. to the Emacs load path. To do this, add the following line to @file{.emacs}:
  216. @smallexample
  217. (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
  218. (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
  219. @end smallexample
  220. @noindent For speed you should byte-compile the Lisp files with the shell
  221. command:
  222. @smallexample
  223. make
  224. @end smallexample
  225. Then add the following line to @file{.emacs}. It is needed so that
  226. Emacs can autoload functions that are located in files not immediately loaded
  227. when Org-mode starts.
  228. @smalllisp
  229. (require 'org-install)
  230. @end smalllisp
  231. @node Activation, Feedback, Installation, Introduction
  232. @section Activation
  233. Add the following lines to your @file{.emacs} file. The last three lines
  234. define @emph{global} keys for some commands --- please choose suitable keys
  235. yourself.
  236. @smalllisp
  237. ;; The following lines are always needed. Choose your own keys.
  238. (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
  239. (add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
  240. (global-set-key "\C-cl" 'org-store-link)
  241. (global-set-key "\C-ca" 'org-agenda)
  242. (global-set-key "\C-cb" 'org-iswitchb)
  243. @end smalllisp
  244. With this setup, all files with extension @samp{.org} will be put
  245. into Org mode.
  246. @node Feedback, , Activation, Introduction
  247. @section Feedback
  248. If you find problems with Org, or if you have questions, remarks, or ideas
  249. about it, please mail to the Org mailing list @email{}.
  250. For information on how to submit bug reports, see the main manual.
  251. @node Document Structure, Tables, Introduction, Top
  252. @chapter Document Structure
  253. Org is based on Outline mode and provides flexible commands to
  254. edit the structure of the document.
  255. @menu
  256. * Outlines:: Org is based on Outline mode
  257. * Headlines:: How to typeset Org tree headlines
  258. * Visibility cycling:: Show and hide, much simplified
  259. * Motion:: Jumping to other headlines
  260. * Structure editing:: Changing sequence and level of headlines
  261. * Sparse trees:: Matches embedded in context
  262. * Plain lists:: Additional structure within an entry
  263. * Footnotes:: How footnotes are defined in Org's syntax
  264. @end menu
  265. @node Outlines, Headlines, Document Structure, Document Structure
  266. @section Outlines
  267. Org is implemented on top of Outline mode. Outlines allow a
  268. document to be organized in a hierarchical structure, which (at least
  269. for me) is the best representation of notes and thoughts. An overview
  270. of this structure is achieved by folding (hiding) large parts of the
  271. document to show only the general document structure and the parts
  272. currently being worked on. Org greatly simplifies the use of
  273. outlines by compressing the entire show/hide functionality into a single
  274. command, @command{org-cycle}, which is bound to the @key{TAB} key.
  275. @node Headlines, Visibility cycling, Outlines, Document Structure
  276. @section Headlines
  277. Headlines define the structure of an outline tree. The headlines in
  278. Org start with one or more stars, on the left margin@footnote{See
  279. the variable @code{org-special-ctrl-a/e} to configure special behavior
  280. of @kbd{C-a} and @kbd{C-e} in headlines.}. For example:
  281. @smallexample
  282. * Top level headline
  283. ** Second level
  284. *** 3rd level
  285. some text
  286. *** 3rd level
  287. more text
  288. * Another top level headline
  289. @end smallexample
  290. @noindent Some people find the many stars too noisy and would prefer an
  291. outline that has whitespace followed by a single star as headline
  292. starters. @ref{Clean view}, describes a setup to realize this.
  293. @node Visibility cycling, Motion, Headlines, Document Structure
  294. @section Visibility cycling
  295. Outlines make it possible to hide parts of the text in the buffer.
  296. Org uses just two commands, bound to @key{TAB} and
  297. @kbd{S-@key{TAB}} to change the visibility in the buffer.
  298. @table @kbd
  299. @item @key{TAB}
  300. @emph{Subtree cycling}: Rotate current subtree among the states
  301. @smallexample
  302. ,-> FOLDED -> CHILDREN -> SUBTREE --.
  303. '-----------------------------------'
  304. @end smallexample
  305. When called with a prefix argument (@kbd{C-u @key{TAB}}) or with the shift
  306. key, global cycling is invoked.
  307. @item S-@key{TAB} @r{and} C-u @key{TAB}
  308. @emph{Global cycling}: Rotate the entire buffer among the states
  309. @smallexample
  310. ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
  311. '--------------------------------------'
  312. @end smallexample
  313. @item C-u C-u C-u @key{TAB}
  314. Show all, including drawers.
  315. @end table
  316. When Emacs first visits an Org file, the global state is set to
  317. OVERVIEW, i.e. only the top level headlines are visible. This can be
  318. configured through the variable @code{org-startup-folded}, or on a
  319. per-file basis by adding a startup keyword @code{overview}, @code{content},
  320. @code{showall}, like this:
  321. @smallexample
  322. #+STARTUP: content
  323. @end smallexample
  324. @node Motion, Structure editing, Visibility cycling, Document Structure
  325. @section Motion
  326. The following commands jump to other headlines in the buffer.
  327. @table @kbd
  328. @item C-c C-n
  329. Next heading.
  330. @item C-c C-p
  331. Previous heading.
  332. @item C-c C-f
  333. Next heading same level.
  334. @item C-c C-b
  335. Previous heading same level.
  336. @item C-c C-u
  337. Backward to higher level heading.
  338. @end table
  339. @node Structure editing, Sparse trees, Motion, Document Structure
  340. @section Structure editing
  341. @table @kbd
  342. @item M-@key{RET}
  343. Insert new heading with same level as current. If the cursor is in a plain
  344. list item, a new item is created (@pxref{Plain lists}). When this command is
  345. used in the middle of a line, the line is split and the rest of the line
  346. becomes the new headline@footnote{If you do not want the line to be split,
  347. customize the variable @code{org-M-RET-may-split-line}.}.
  348. @item M-S-@key{RET}
  349. Insert new TODO entry with same level as current heading.
  350. @item @key{TAB} @r{in new, empty entry}
  351. In a new entry with no text yet, @key{TAB} will cycle through reasonable
  352. levels.
  353. @item M-@key{left}@r{/}@key{right}
  354. Promote/demote current heading by one level.
  355. @item M-S-@key{left}@r{/}@key{right}
  356. Promote/demote the current subtree by one level.
  357. @item M-S-@key{up}@r{/}@key{down}
  358. Move subtree up/down (swap with previous/next subtree of same
  359. level).
  360. @item C-c C-w
  361. Refile entry or region to a different location. @xref{Refiling notes}.
  362. @item C-x n s/w
  363. Narrow buffer to current subtree / widen it again
  364. @end table
  365. When there is an active region (Transient Mark mode), promotion and
  366. demotion work on all headlines in the region.
  367. @node Sparse trees, Plain lists, Structure editing, Document Structure
  368. @section Sparse trees
  369. An important feature of Org mode is the ability to construct @emph{sparse
  370. trees} for selected information in an outline tree, so that the entire
  371. document is folded as much as possible, but the selected information is made
  372. visible along with the headline structure above it@footnote{See also the
  373. variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
  374. @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
  375. control on how much context is shown around each match.}. Just try it out
  376. and you will see immediately how it works.
  377. Org mode contains several commands creating such trees, all these
  378. commands can be accessed through a dispatcher:
  379. @table @kbd
  380. @item C-c /
  381. This prompts for an extra key to select a sparse-tree creating command.
  382. @item C-c / r
  383. Occur. Prompts for a regexp and shows a sparse tree with all matches. Each
  384. match is also highlighted; the highlights disappear by pressing @kbd{C-c C-c}.
  385. @end table
  386. The other sparse tree commands select headings based on TODO keywords,
  387. tags, or properties and will be discussed later in this manual.
  388. @node Plain lists, Footnotes, Sparse trees, Document Structure
  389. @section Plain lists
  390. Within an entry of the outline tree, hand-formatted lists can provide
  391. additional structure. They also provide a way to create lists of
  392. checkboxes (@pxref{Checkboxes}). Org supports editing such lists,
  393. and the HTML exporter (@pxref{Exporting}) parses and formats them.
  394. Org knows ordered lists, unordered lists, and description lists.
  395. @itemize @bullet
  396. @item
  397. @emph{Unordered} list items start with @samp{-}, @samp{+}, or
  398. @samp{*} as bullets.
  399. @item
  400. @emph{Ordered} list items start with @samp{1.} or @samp{1)}.
  401. @item
  402. @emph{Description} list use @samp{ :: } to separate the @emph{term} from the
  403. description.
  404. @end itemize
  405. Items belonging to the same list must have the same indentation on the first
  406. line. A list ends before the next line that is indented like the
  407. bullet/number, or less. An example:
  408. @smallexample
  409. @group
  410. ** Lord of the Rings
  411. My favorite scenes are (in this order)
  412. 1. The attack of the Rohirrim
  413. 2. Eowyn's fight with the witch king
  414. + this was already my favorite scene in the book
  415. + I really like Miranda Otto.
  416. Important actors in this film are:
  417. - @b{Elijah Wood} :: He plays Frodo
  418. - @b{Sean Austin} :: He plays Sam, Frodo's friend.
  419. @end group
  420. @end smallexample
  421. The following commands act on items when the cursor is in the first line of
  422. an item (the line with the bullet or number).
  423. @table @kbd
  424. @item @key{TAB}
  425. Items can be folded just like headline levels.
  426. @item M-@key{RET}
  427. Insert new item at current level. With a prefix argument, force a new
  428. heading (@pxref{Structure editing}).
  429. @item M-S-@key{RET}
  430. Insert a new item with a checkbox (@pxref{Checkboxes}).
  431. @item M-S-@key{up}@r{/}@key{down}
  432. Move the item including subitems up/down (swap with previous/next item
  433. of same indentation). If the list is ordered, renumbering is
  434. automatic.
  435. @item M-@key{left}@r{/}M-@key{right}
  436. Decrease/increase the indentation of an item, leaving children alone.
  437. @item M-S-@key{left}@r{/}@key{right}
  438. Decrease/increase the indentation of the item, including subitems.
  439. @item C-c C-c
  440. If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
  441. state of the checkbox. If not, make sure all items have the same bullet type
  442. and renumber ordered lists.
  443. @item C-c -
  444. Cycle the entire list level through the different itemize/enumerate bullets
  445. (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).
  446. @end table
  447. @node Footnotes, , Plain lists, Document Structure
  448. @section Footnotes
  449. A footnote is defined in a paragraph that is started by a footnote marker in
  450. square brackets in column 0, no indentation allowed. The footnote reference
  451. is simply the marker in square brackets, inside text. For example:
  452. @smallexample
  453. The Org homepage[fn:1] now looks a lot better than it used to.
  454. ...
  455. [fn:1] The link is:
  456. @end smallexample
  457. @noindent The following commands handle footnotes:
  458. @table @kbd
  459. @item C-c C-x f
  460. The footnote action command. When the cursor is on a footnote reference,
  461. jump to the definition. When it is at a definition, jump to the (first)
  462. reference. Otherwise, create a new footnote. When this command is called
  463. with a prefix argument, a menu of additional options including renumbering is
  464. offered.
  465. @item C-c C-c
  466. Jump between definition and reference.
  467. @end table
  468. @seealso{
  469. @uref{,
  470. Chapter 2 of the manual}@*
  471. @uref{,
  472. Sacha Chua's tutorial}}
  473. @node Tables, Hyperlinks, Document Structure, Top
  474. @chapter Tables
  475. Org comes with a fast and intuitive table editor. Spreadsheet-like
  476. calculations are supported in connection with the Emacs @file{calc}
  477. package
  478. @ifinfo
  479. (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
  480. @end ifinfo
  481. @ifnotinfo
  482. (see the Emacs Calculator manual for more information about the Emacs
  483. calculator).
  484. @end ifnotinfo
  485. Org makes it easy to format tables in plain ASCII. Any line with
  486. @samp{|} as the first non-whitespace character is considered part of a
  487. table. @samp{|} is also the column separator. A table might look like
  488. this:
  489. @smallexample
  490. | Name | Phone | Age |
  491. |-------+-------+-----|
  492. | Peter | 1234 | 17 |
  493. | Anna | 4321 | 25 |
  494. @end smallexample
  495. A table is re-aligned automatically each time you press @key{TAB} or
  496. @key{RET} or @kbd{C-c C-c} inside the table. @key{TAB} also moves to
  497. the next field (@key{RET} to the next row) and creates new table rows
  498. at the end of the table or before horizontal lines. The indentation
  499. of the table is set by the first line. Any line starting with
  500. @samp{|-} is considered as a horizontal separator line and will be
  501. expanded on the next re-align to span the whole table width. So, to
  502. create the above table, you would only type
  503. @smallexample
  504. |Name|Phone|Age|
  505. |-
  506. @end smallexample
  507. @noindent and then press @key{TAB} to align the table and start filling in
  508. fields. Even faster would be to type @code{|Name|Phone|Age} followed by
  509. @kbd{C-c @key{RET}}.
  510. When typing text into a field, Org treats @key{DEL},
  511. @key{Backspace}, and all character keys in a special way, so that
  512. inserting and deleting avoids shifting other fields. Also, when
  513. typing @emph{immediately after the cursor was moved into a new field
  514. with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
  515. field is automatically made blank.
  516. @table @kbd
  517. @tsubheading{Creation and conversion}
  518. @item C-c |
  519. Convert the active region to table. If every line contains at least one
  520. TAB character, the function assumes that the material is tab separated.
  521. If every line contains a comma, comma-separated values (CSV) are assumed.
  522. If not, lines are split at whitespace into fields.
  523. @*
  524. If there is no active region, this command creates an empty Org
  525. table. But it's easier just to start typing, like
  526. @kbd{|Name|Phone|Age C-c @key{RET}}.
  527. @tsubheading{Re-aligning and field motion}
  528. @item C-c C-c
  529. Re-align the table without moving the cursor.
  530. @c
  531. @item @key{TAB}
  532. Re-align the table, move to the next field. Creates a new row if
  533. necessary.
  534. @c
  535. @item S-@key{TAB}
  536. Re-align, move to previous field.
  537. @c
  538. @item @key{RET}
  539. Re-align the table and move down to next row. Creates a new row if
  540. necessary.
  541. @tsubheading{Column and row editing}
  542. @item M-@key{left}
  543. @itemx M-@key{right}
  544. Move the current column left/right.
  545. @c
  546. @item M-S-@key{left}
  547. Kill the current column.
  548. @c
  549. @item M-S-@key{right}
  550. Insert a new column to the left of the cursor position.
  551. @c
  552. @item M-@key{up}
  553. @itemx M-@key{down}
  554. Move the current row up/down.
  555. @c
  556. @item M-S-@key{up}
  557. Kill the current row or horizontal line.
  558. @c
  559. @item M-S-@key{down}
  560. Insert a new row above the current row. With a prefix argument, the line is
  561. created below the current one.
  562. @c
  563. @item C-c -
  564. Insert a horizontal line below current row. With a prefix argument, the line
  565. is created above the current line.
  566. @c
  567. @item C-c @key{RET}
  568. Insert a horizontal line below current row, and move the cursor into the row
  569. below that line.
  570. @c
  571. @item C-c ^
  572. Sort the table lines in the region. The position of point indicates the
  573. column to be used for sorting, and the range of lines is the range
  574. between the nearest horizontal separator lines, or the entire table.
  575. @end table
  576. @seealso{
  577. @uref{, Chapter 3 of the
  578. manual}@*
  579. @uref{, Bastien's
  580. table tutorial}@*
  581. @uref{,
  582. Bastien's spreadsheet tutorial}@*
  583. @uref{, Eric's plotting tutorial}}
  584. @node Hyperlinks, TODO Items, Tables, Top
  585. @chapter Hyperlinks
  586. Like HTML, Org provides links inside a file, external links to
  587. other files, Usenet articles, emails, and much more.
  588. @menu
  589. * Link format:: How links in Org are formatted
  590. * Internal links:: Links to other places in the current file
  591. * External links:: URL-like links to the world
  592. * Handling links:: Creating, inserting and following
  593. * Targeted links:: Point at a location in a file
  594. @end menu
  595. @node Link format, Internal links, Hyperlinks, Hyperlinks
  596. @section Link format
  597. Org will recognize plain URL-like links and activate them as
  598. clickable links. The general link format, however, looks like this:
  599. @smallexample
  600. [[link][description]] @r{or alternatively} [[link]]
  601. @end smallexample
  602. @noindent
  603. Once a link in the buffer is complete (all brackets present), Org will change
  604. the display so that @samp{description} is displayed instead of
  605. @samp{[[link][description]]} and @samp{link} is displayed instead of
  606. @samp{[[link]]}. To edit the invisible @samp{link} part, use @kbd{C-c
  607. C-l} with the cursor on the link.
  608. @node Internal links, External links, Link format, Hyperlinks
  609. @section Internal links
  610. If the link does not look like a URL, it is considered to be internal in the
  611. current file. The most important case is a link like
  612. @samp{[[#my-custom-id]]} which will link to the entry with the
  613. @code{CUSTOM_ID} property @samp{my-custom-id}.
  614. Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
  615. lead to a text search in the current file for the corresponding target which
  616. looks like @samp{<<My Target>>}.
  617. @node External links, Handling links, Internal links, Hyperlinks
  618. @section External links
  619. Org supports links to files, websites, Usenet and email messages,
  620. BBDB database entries and links to both IRC conversations and their
  621. logs. External links are URL-like locators. They start with a short
  622. identifying string followed by a colon. There can be no space after
  623. the colon. Here are some examples:
  624. @smallexample
  625. @r{on the web}
  626. file:/home/dominik/images/jupiter.jpg @r{file, absolute path}
  627. /home/dominik/images/jupiter.jpg @r{same as above}
  628. file:papers/last.pdf @r{file, relative path}
  629. @r{another Org file}
  630. docview:papers/last.pdf::NNN @r{open file in doc-view mode at page NNN}
  631. id:B7423F4D-2E8A-471B-8810-C40F074717E9 @r{Link to heading by ID}
  632. news:comp.emacs @r{Usenet link}
  633. @r{Mail link}
  634. vm:folder @r{VM folder link}
  635. vm:folder#id @r{VM message link}
  636. wl:folder#id @r{WANDERLUST message link}
  637. mhe:folder#id @r{MH-E message link}
  638. rmail:folder#id @r{RMAIL message link}
  639. gnus:group#id @r{Gnus article link}
  640. bbdb:R.*Stallman @r{BBDB link (with regexp)}
  641. irc:/ @r{IRC link}
  642. info:org:External%20links @r{Info node link (with encoded space)}
  643. @end smallexample
  644. A link should be enclosed in double brackets and may contain a
  645. descriptive text to be displayed instead of the URL (@pxref{Link
  646. format}), for example:
  647. @smallexample
  648. [[][GNU Emacs]]
  649. @end smallexample
  650. @noindent
  651. If the description is a file name or URL that points to an image, HTML export
  652. (@pxref{HTML export}) will inline the image as a clickable button. If there
  653. is no description at all and the link points to an image, that image will be
  654. inlined into the exported HTML file.
  655. @node Handling links, Targeted links, External links, Hyperlinks
  656. @section Handling links
  657. Org provides methods to create a link in the correct syntax, to
  658. insert it into an Org file, and to follow the link.
  659. @table @kbd
  660. @item C-c l
  661. Store a link to the current location. This is a @emph{global} command (you
  662. must create the key binding yourself) which can be used in any buffer to
  663. create a link. The link will be stored for later insertion into an Org
  664. buffer (see below).
  665. @c
  666. @item C-c C-l
  667. Insert a link. This prompts for a link to be inserted into the buffer. You
  668. can just type a link, or use history keys @key{up} and @key{down} to access
  669. stored links. You will be prompted for the description part of the link.
  670. When called with a @kbd{C-u} prefix argument, file name completion is used to
  671. link to a file.
  672. @c
  673. @item C-c C-l @r{(with cursor on existing link)}
  674. When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
  675. link and description parts of the link.
  676. @c
  677. @item C-c C-o @r{or} mouse-1 @r{or} mouse-2
  678. Open link at point.
  679. @item C-c &
  680. Jump back to a recorded position. A position is recorded by the
  681. commands following internal links, and by @kbd{C-c %}. Using this
  682. command several times in direct succession moves through a ring of
  683. previously recorded positions.
  684. @c
  685. @end table
  686. @node Targeted links, , Handling links, Hyperlinks
  687. @section Targeted links
  688. File links can contain additional information to make Emacs jump to a
  689. particular location in the file when following a link. This can be a
  690. line number or a search option after a double colon.
  691. Here is the syntax of the different ways to attach a search to a file
  692. link, together with an explanation:
  693. @smallexample
  694. [[file:~/code/main.c::255]] @r{Find line 255}
  695. [[file:~/ Target]] @r{Find @samp{<<My Target>>}}
  696. [[file:~/]] @r{Find entry with custom id}
  697. @end smallexample
  698. @seealso{
  699. @uref{, Chapter 4 of the
  700. manual}}
  701. @node TODO Items, Tags, Hyperlinks, Top
  702. @chapter TODO Items
  703. Org mode does not maintain TODO lists as separate documents@footnote{Of
  704. course, you can make a document that contains only long lists of TODO items,
  705. but this is not required.}. Instead, TODO items are an integral part of the
  706. notes file, because TODO items usually come up while taking notes! With Org
  707. mode, simply mark any entry in a tree as being a TODO item. In this way,
  708. information is not duplicated, and the entire context from which the TODO
  709. item emerged is always present.
  710. Of course, this technique for managing TODO items scatters them
  711. throughout your notes file. Org mode compensates for this by providing
  712. methods to give you an overview of all the things that you have to do.
  713. @menu
  714. * Using TODO states:: Setting and switching states
  715. * Multi-state workflows:: More than just on/off
  716. * Progress logging:: Dates and notes for progress
  717. * Priorities:: Some things are more important than others
  718. * Breaking down tasks:: Splitting a task into manageable pieces
  719. * Checkboxes:: Tick-off lists
  720. @end menu
  721. @node Using TODO states, Multi-state workflows, TODO Items, TODO Items
  722. @section Using TODO states
  723. Any headline becomes a TODO item when it starts with the word
  724. @samp{TODO}, for example:
  725. @smallexample
  726. *** TODO Write letter to Sam Fortune
  727. @end smallexample
  728. @noindent
  729. The most important commands to work with TODO entries are:
  730. @table @kbd
  731. @item C-c C-t
  732. Rotate the TODO state of the current item among
  733. @smallexample
  734. ,-> (unmarked) -> TODO -> DONE --.
  735. '--------------------------------'
  736. @end smallexample
  737. The same rotation can also be done ``remotely'' from the timeline and
  738. agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
  739. @item S-@key{right}@r{/}@key{left}
  740. Select the following/preceding TODO state, similar to cycling.
  741. @item C-c / t
  742. View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}). Folds the
  743. buffer, but shows all TODO items and the headings hierarchy above
  744. them.
  745. @item C-c a t
  746. Show the global TODO list. Collects the TODO items from all agenda files
  747. (@pxref{Agenda Views}) into a single buffer. @xref{Global TODO list}, for
  748. more information.
  749. @item S-M-@key{RET}
  750. Insert a new TODO entry below the current one.
  751. @end table
  752. @noindent
  753. Changing a TODO state can also trigger tag changes. See the docstring of the
  754. option @code{org-todo-state-tags-triggers} for details.
  755. @node Multi-state workflows, Progress logging, Using TODO states, TODO Items
  756. @section Multi-state workflows
  757. You can use TODO keywords to indicate different @emph{sequential} states
  758. in the process of working on an item, for example:
  759. @smalllisp
  760. (setq org-todo-keywords
  761. '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
  762. @end smalllisp
  763. The vertical bar separates the TODO keywords (states that @emph{need
  764. action}) from the DONE states (which need @emph{no further action}). If
  765. you don't provide the separator bar, the last state is used as the DONE
  766. state.
  767. With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
  768. to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.
  769. Sometimes you may want to use different sets of TODO keywords in
  770. parallel. For example, you may want to have the basic
  771. @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
  772. separate state indicating that an item has been canceled (so it is not
  773. DONE, but also does not require action). Your setup would then look
  774. like this:
  775. @smalllisp
  776. (setq org-todo-keywords
  777. '((sequence "TODO(t)" "|" "DONE(d)")
  778. (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
  779. (sequence "|" "CANCELED(c)")))
  780. @end smalllisp
  781. The keywords should all be different, this helps Org mode to keep track of
  782. which subsequence should be used for a given entry. The example also shows
  783. how to define keys for fast access of a particular state, by adding a letter
  784. in parenthesis after each keyword - you will be prompted for the key after
  785. @kbd{C-c C-t}.
  786. To define TODO keywords that are valid only in a single file, use the
  787. following text anywhere in the file.
  788. @smallexample
  789. #+TODO: TODO(t) | DONE(d)
  790. #+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
  791. #+TODO: | CANCELED(c)
  792. @end smallexample
  793. After changing one of these lines, use @kbd{C-c C-c} with the cursor still in
  794. the line to make the changes known to Org mode.
  795. @node Progress logging, Priorities, Multi-state workflows, TODO Items
  796. @section Progress logging
  797. Org mode can automatically record a timestamp and possibly a note when
  798. you mark a TODO item as DONE, or even each time you change the state of
  799. a TODO item. This system is highly configurable, settings can be on a
  800. per-keyword basis and can be localized to a file or even a subtree. For
  801. information on how to clock working time for a task, see @ref{Clocking
  802. work time}.
  803. @menu
  804. * Closing items:: When was this entry marked DONE?
  805. * Tracking TODO state changes:: When did the status change?
  806. @end menu
  807. @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
  808. @unnumberedsubsec Closing items
  809. The most basic logging is to keep track of @emph{when} a certain TODO
  810. item was finished. This is achieved with@footnote{The corresponding
  811. in-buffer setting is: @code{#+STARTUP: logdone}}.
  812. @smalllisp
  813. (setq org-log-done 'time)
  814. @end smalllisp
  815. @noindent
  816. Then each time you turn an entry from a TODO (not-done) state into any of the
  817. DONE states, a line @samp{CLOSED: [timestamp]} will be inserted just after
  818. the headline. If you want to record a note along with the timestamp,
  819. use@footnote{The corresponding in-buffer setting is: @code{#+STARTUP:
  820. lognotedone}}
  821. @smalllisp
  822. (setq org-log-done 'note)
  823. @end smalllisp
  824. @noindent
  825. You will then be prompted for a note, and that note will be stored below
  826. the entry with a @samp{Closing Note} heading.
  827. @node Tracking TODO state changes, , Closing items, Progress logging
  828. @unnumberedsubsec Tracking TODO state changes
  829. You might want to keep track of TODO state changes. You can either record
  830. just a timestamp, or a time-stamped note for a change. These records will be
  831. inserted after the headline as an itemized list. When taking a lot of notes,
  832. you might want to get the notes out of the way into a drawer. Customize the
  833. variable @code{org-log-into-drawer} to get this behavior.
  834. For state logging, Org mode expects configuration on a per-keyword basis.
  835. This is achieved by adding special markers @samp{!} (for a timestamp) and
  836. @samp{@@} (for a note) in parentheses after each keyword. For example:
  837. @smallexample
  838. #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
  839. @end smallexample
  840. @noindent
  841. will define TODO keywords and fast access keys, and also request that a time
  842. is recorded when the entry is set to DONE, and that a note is recorded when
  843. switching to WAIT or CANCELED. The same syntax works also when setting
  844. @code{org-todo-keywords}.
  845. @node Priorities, Breaking down tasks, Progress logging, TODO Items
  846. @section Priorities
  847. If you use Org mode extensively, you may end up with enough TODO items that
  848. it starts to make sense to prioritize them. Prioritizing can be done by
  849. placing a @emph{priority cookie} into the headline of a TODO item, like this
  850. @smallexample
  851. *** TODO [#A] Write letter to Sam Fortune
  852. @end smallexample
  853. @noindent
  854. Org mode supports three priorities: @samp{A}, @samp{B}, and @samp{C}.
  855. @samp{A} is the highest, @samp{B} the default if none is given. Priorities
  856. make a difference only in the agenda.
  857. @table @kbd
  858. @item @kbd{C-c ,}
  859. Set the priority of the current headline. Press @samp{A}, @samp{B} or
  860. @samp{C} to select a priority, or @key{SPC} to remove the cookie.
  861. @c
  862. @item S-@key{up}
  863. @itemx S-@key{down}
  864. Increase/decrease priority of current headline
  865. @end table
  866. @node Breaking down tasks, Checkboxes, Priorities, TODO Items
  867. @section Breaking tasks down into subtasks
  868. It is often advisable to break down large tasks into smaller, manageable
  869. subtasks. You can do this by creating an outline tree below a TODO item,
  870. with detailed subtasks on the tree. To keep the overview over the fraction
  871. of subtasks that are already completed, insert either @samp{[/]} or
  872. @samp{[%]} anywhere in the headline. These cookies will be updated each time
  873. the TODO status of a child changes, or when pressing @kbd{C-c C-c} on the
  874. cookie. For example:
  875. @smallexample
  876. * Organize Party [33%]
  877. ** TODO Call people [1/2]
  878. *** TODO Peter
  879. *** DONE Sarah
  880. ** TODO Buy food
  881. ** DONE Talk to neighbor
  882. @end smallexample
  883. @node Checkboxes, , Breaking down tasks, TODO Items
  884. @section Checkboxes
  885. Every item in a plain list (@pxref{Plain lists}) can be made into a checkbox
  886. by starting it with the string @samp{[ ]}. Checkboxes are not included into
  887. the global TODO list, so they are often great to split a task into a number
  888. of simple steps.
  889. Here is an example of a checkbox list.
  890. @smallexample
  891. * TODO Organize party [1/3]
  892. - [-] call people [1/2]
  893. - [ ] Peter
  894. - [X] Sarah
  895. - [X] order food
  896. - [ ] think about what music to play
  897. @end smallexample
  898. Checkboxes work hierarchically, so if a checkbox item has children that
  899. are checkboxes, toggling one of the children checkboxes will make the
  900. parent checkbox reflect if none, some, or all of the children are
  901. checked.
  902. @noindent The following commands work with checkboxes:
  903. @table @kbd
  904. @item C-c C-c
  905. Toggle checkbox status or (with prefix arg) checkbox presence at point.
  906. @item M-S-@key{RET}
  907. Insert a new item with a checkbox.
  908. This works only if the cursor is already in a plain list item
  909. (@pxref{Plain lists}).
  910. @end table
  911. @seealso{
  912. @uref{, Chapter 5 of the manual}@*
  913. @uref{, David
  914. O'Toole's introductory tutorial}@*
  915. @uref{,
  916. Charles Cave's GTD setup}}
  917. @node Tags, Properties, TODO Items, Top
  918. @chapter Tags
  919. An excellent way to implement labels and contexts for cross-correlating
  920. information is to assign @i{tags} to headlines. Org mode has extensive
  921. support for tags.
  922. Every headline can contain a list of tags; they occur at the end of the
  923. headline. Tags are normal words containing letters, numbers, @samp{_}, and
  924. @samp{@@}. Tags must be preceded and followed by a single colon, e.g.,
  925. @samp{:work:}. Several tags can be specified, as in @samp{:work:urgent:}.
  926. Tags will by default be in bold face with the same color as the headline.
  927. @menu
  928. * Tag inheritance:: Tags use the tree structure of the outline
  929. * Setting tags:: How to assign tags to a headline
  930. * Tag searches:: Searching for combinations of tags
  931. @end menu
  932. @node Tag inheritance, Setting tags, Tags, Tags
  933. @section Tag inheritance
  934. @i{Tags} make use of the hierarchical structure of outline trees. If a
  935. heading has a certain tag, all subheadings will inherit the tag as
  936. well. For example, in the list
  937. @smallexample
  938. * Meeting with the French group :work:
  939. ** Summary by Frank :boss:notes:
  940. *** TODO Prepare slides for him :action:
  941. @end smallexample
  942. @noindent
  943. the final heading will have the tags @samp{:work:}, @samp{:boss:},
  944. @samp{:notes:}, and @samp{:action:} even though the final heading is not
  945. explicitly marked with those tags. You can also set tags that all entries in
  946. a file should inherit just as if these tags were defined in a hypothetical
  947. level zero that surrounds the entire file. Use a line like this@footnote{As
  948. with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
  949. changes in the line.}:
  950. @smallexample
  951. #+FILETAGS: :Peter:Boss:Secret:
  952. @end smallexample
  953. @node Setting tags, Tag searches, Tag inheritance, Tags
  954. @section Setting tags
  955. Tags can simply be typed into the buffer at the end of a headline.
  956. After a colon, @kbd{M-@key{TAB}} offers completion on tags. There is
  957. also a special command for inserting tags:
  958. @table @kbd
  959. @item C-c C-q
  960. Enter new tags for the current headline. Org mode will either offer
  961. completion or a special single-key interface for setting tags, see
  962. below. After pressing @key{RET}, the tags will be inserted and aligned
  963. to @code{org-tags-column}. When called with a @kbd{C-u} prefix, all
  964. tags in the current buffer will be aligned to that column, just to make
  965. things look nice.
  966. @item C-c C-c
  967. When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
  968. @end table
  969. Org will support tag insertion based on a @emph{list of tags}. By
  970. default this list is constructed dynamically, containing all tags
  971. currently used in the buffer. You may also globally specify a hard list
  972. of tags with the variable @code{org-tag-alist}. Finally you can set
  973. the default tags for a given file with lines like
  974. @smallexample
  975. #+TAGS: @@work @@home @@tennisclub
  976. #+TAGS: laptop car pc sailboat
  977. @end smallexample
  978. By default Org mode uses the standard minibuffer completion facilities for
  979. entering tags. However, it also implements another, quicker, tag selection
  980. method called @emph{fast tag selection}. This allows you to select and
  981. deselect tags with just a single key press. For this to work well you should
  982. assign unique letters to most of your commonly used tags. You can do this
  983. globally by configuring the variable @code{org-tag-alist} in your
  984. @file{.emacs} file. For example, you may find the need to tag many items in
  985. different files with @samp{:@@home:}. In this case you can set something
  986. like:
  987. @smalllisp
  988. (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
  989. @end smalllisp
  990. @noindent If the tag is only relevant to the file you are working on, then you
  991. can instead set the TAGS option line as:
  992. @smallexample
  993. #+TAGS: @@work(w) @@home(h) @@tennisclub(t) laptop(l) pc(p)
  994. @end smallexample
  995. @node Tag searches, , Setting tags, Tags
  996. @section Tag searches
  997. Once a system of tags has been set up, it can be used to collect related
  998. information into special lists.
  999. @table @kbd
  1000. @item C-c \
  1001. @itemx C-c / m
  1002. Create a sparse tree with all headlines matching a tags search. With a
  1003. @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
  1004. @item C-c a m
  1005. Create a global list of tag matches from all agenda files.
  1006. @xref{Matching tags and properties}.
  1007. @item C-c a M
  1008. Create a global list of tag matches from all agenda files, but check
  1009. only TODO items and force checking subitems (see variable
  1010. @code{org-tags-match-list-sublevels}).
  1011. @end table
  1012. These commands all prompt for a match string which allows basic Boolean logic
  1013. like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
  1014. @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
  1015. which are tagged, like @samp{Kathy} or @samp{Sally}. The full syntax of the
  1016. search string is rich and allows also matching against TODO keywords, entry
  1017. levels and properties. For a complete description with many examples, see
  1018. @ref{Matching tags and properties}.
  1019. @seealso{
  1020. @uref{, Chapter 6 of the manual}@*
  1021. @uref{,
  1022. Sacha Chua's article about tagging in Org-mode}}
  1023. @node Properties, Dates and Times, Tags, Top
  1024. @chapter Properties
  1025. Properties are key-value pairs associates with and entry. They live in a
  1026. special drawer with the name @code{PROPERTIES}. Each
  1027. property is specified on a single line, with the key (surrounded by colons)
  1028. first, and the value after it:
  1029. @smallexample
  1030. * CD collection
  1031. ** Classic
  1032. *** Goldberg Variations
  1033. :PROPERTIES:
  1034. :Title: Goldberg Variations
  1035. :Composer: J.S. Bach
  1036. :Publisher: Deutsche Grammophon
  1037. :NDisks: 1
  1038. :END:
  1039. @end smallexample
  1040. You may define the allowed values for a particular property @samp{:Xyz:}
  1041. by setting a property @samp{:Xyz_ALL:}. This special property is
  1042. @emph{inherited}, so if you set it in a level 1 entry, it will apply to
  1043. the entire tree. When allowed values are defined, setting the
  1044. corresponding property becomes easier and is less prone to typing
  1045. errors. For the example with the CD collection, we can predefine
  1046. publishers and the number of disks in a box like this:
  1047. @smallexample
  1048. * CD collection
  1049. :PROPERTIES:
  1050. :NDisks_ALL: 1 2 3 4
  1051. :Publisher_ALL: "Deutsche Grammophon" Philips EMI
  1052. :END:
  1053. @end smallexample
  1054. or globally using @code{org-global-properties}, or file-wide like this:
  1055. @smallexample
  1056. #+PROPERTY: NDisks_ALL 1 2 3 4
  1057. @end smallexample
  1058. @table @kbd
  1059. @item C-c C-x p
  1060. Set a property. This prompts for a property name and a value.
  1061. @item C-c C-c d
  1062. Remove a property from the current entry.
  1063. @end table
  1064. To create sparse trees and special lists with selection based on properties,
  1065. the same commands are used as for tag searches (@pxref{Tag searches}). The
  1066. syntax for the search string is described in @ref{Matching tags and
  1067. properties}.
  1068. @table @kbd
  1069. @end table
  1070. @seealso{
  1071. @uref{,
  1072. Chapter 7 of the manual}@*
  1073. @uref{,Bastien
  1074. Guerry's column view tutorial}}
  1075. @node Dates and Times, Capture - Refile - Archive, Properties, Top
  1076. @chapter Dates and Times
  1077. To assist project planning, TODO items can be labeled with a date and/or
  1078. a time. The specially formatted string carrying the date and time
  1079. information is called a @emph{timestamp} in Org mode.
  1080. @menu
  1081. * Timestamps:: Assigning a time to a tree entry
  1082. * Creating timestamps:: Commands which insert timestamps
  1083. * Deadlines and scheduling:: Planning your work
  1084. * Clocking work time:: Tracking how long you spend on a task
  1085. @end menu
  1086. @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
  1087. @section Timestamps
  1088. A timestamp is a specification of a date (possibly with a time or a range of
  1089. times) in a special format, either @samp{<2003-09-16 Tue>} or
  1090. @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue 12:00-12:30>}. A
  1091. timestamp can appear anywhere in the headline or body of an Org tree entry.
  1092. Its presence causes entries to be shown on specific dates in the agenda
  1093. (@pxref{Weekly/daily agenda}). We distinguish:
  1094. @noindent @b{Plain timestamp; Event; Appointment}@*
  1095. A simple timestamp just assigns a date/time to an item. This is just
  1096. like writing down an appointment or event in a paper agenda.
  1097. @smallexample
  1098. * Meet Peter at the movies <2006-11-01 Wed 19:15>
  1099. * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
  1100. @end smallexample
  1101. @noindent @b{Timestamp with repeater interval}@*
  1102. A timestamp may contain a @emph{repeater interval}, indicating that it
  1103. applies not only on the given date, but again and again after a certain
  1104. interval of N days (d), weeks (w), months (m), or years (y). The
  1105. following will show up in the agenda every Wednesday:
  1106. @smallexample
  1107. * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
  1108. @end smallexample
  1109. @noindent @b{Diary-style sexp entries}@*
  1110. For more complex date specifications, Org mode supports using the
  1111. special sexp diary entries implemented in the Emacs calendar/diary
  1112. package. For example
  1113. @smallexample
  1114. * The nerd meeting on every 2nd Thursday of the month
  1115. <%%(diary-float t 4 2)>
  1116. @end smallexample
  1117. @noindent @b{Time/Date range}@*
  1118. Two timestamps connected by @samp{--} denote a range.
  1119. @smallexample
  1120. ** Meeting in Amsterdam
  1121. <2004-08-23 Mon>--<2004-08-26 Thu>
  1122. @end smallexample
  1123. @noindent @b{Inactive timestamp}@*
  1124. Just like a plain timestamp, but with square brackets instead of
  1125. angular ones. These timestamps are inactive in the sense that they do
  1126. @emph{not} trigger an entry to show up in the agenda.
  1127. @smallexample
  1128. * Gillian comes late for the fifth time [2006-11-01 Wed]
  1129. @end smallexample
  1130. @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
  1131. @section Creating timestamps
  1132. For Org mode to recognize timestamps, they need to be in the specific
  1133. format. All commands listed below produce timestamps in the correct
  1134. format.
  1135. @table @kbd
  1136. @item C-c .
  1137. Prompt for a date and insert a corresponding timestamp. When the cursor is
  1138. at an existing timestamp in the buffer, the command is used to modify this
  1139. timestamp instead of inserting a new one. When this command is used twice in
  1140. succession, a time range is inserted. With a prefix, also add the current
  1141. time.
  1142. @c
  1143. @item C-c !
  1144. Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
  1145. an agenda entry.
  1146. @c
  1147. @item S-@key{left}@r{/}@key{right}
  1148. Change date at cursor by one day.
  1149. @c
  1150. @item S-@key{up}@r{/}@key{down}
  1151. Change the item under the cursor in a timestamp. The cursor can be on a
  1152. year, month, day, hour or minute. When the timestamp contains a time range
  1153. like @samp{15:30-16:30}, modifying the first time will also shift the second,
  1154. shifting the time block with constant length. To change the length, modify
  1155. the second time.
  1156. @end table
  1157. When Org mode prompts for a date/time, it will accept any string containing
  1158. some date and/or time information, and intelligently interpret the string,
  1159. deriving defaults for unspecified information from the current date and time.
  1160. You can also select a date in the pop-up calendar. See the manual for more
  1161. information on how exactly the date/time prompt works.
  1162. @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
  1163. @section Deadlines and scheduling
  1164. A timestamp may be preceded by special keywords to facilitate planning:
  1165. @noindent @b{DEADLINE}@*
  1166. Meaning: the task (most likely a TODO item, though not necessarily) is supposed
  1167. to be finished on that date.
  1168. @table @kbd
  1169. @item C-c C-d
  1170. Insert @samp{DEADLINE} keyword along with a stamp, in the line following the
  1171. headline.
  1172. @end table
  1173. On the deadline date, the task will be listed in the agenda. In
  1174. addition, the agenda for @emph{today} will carry a warning about the
  1175. approaching or missed deadline, starting
  1176. @code{org-deadline-warning-days} before the due date, and continuing
  1177. until the entry is marked DONE. An example:
  1178. @smallexample
  1179. *** TODO write article about the Earth for the Guide
  1180. The editor in charge is [[bbdb:Ford Prefect]]
  1181. DEADLINE: <2004-02-29 Sun>
  1182. @end smallexample
  1183. @noindent @b{SCHEDULED}@*
  1184. Meaning: you are @i{planning to start working} on that task on the given
  1185. date@footnote{This is quite different from what is normally understood by
  1186. @i{scheduling a meeting}, which is done in Org-mode by just inserting a time
  1187. stamp without keyword.}.
  1188. @table @kbd
  1189. @item C-c C-s
  1190. Insert @samp{SCHEDULED} keyword along with a stamp, in the line following the
  1191. headline.
  1192. @end table
  1193. The headline will be listed under the given date@footnote{It will still
  1194. be listed on that date after it has been marked DONE. If you don't like
  1195. this, set the variable @code{org-agenda-skip-scheduled-if-done}.}. In
  1196. addition, a reminder that the scheduled date has passed will be present
  1197. in the compilation for @emph{today}, until the entry is marked DONE.
  1198. I.e. the task will automatically be forwarded until completed.
  1199. @smallexample
  1200. *** TODO Call Trillian for a date on New Years Eve.
  1201. SCHEDULED: <2004-12-25 Sat>
  1202. @end smallexample
  1203. Some tasks need to be repeated again and again. Org mode helps to
  1204. organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
  1205. or plain timestamp. In the following example
  1206. @smallexample
  1207. ** TODO Pay the rent
  1208. DEADLINE: <2005-10-01 Sat +1m>
  1209. @end smallexample
  1210. @noindent
  1211. the @code{+1m} is a repeater; the intended interpretation is that the task
  1212. has a deadline on <2005-10-01> and repeats itself every (one) month starting
  1213. from that time.
  1214. @node Clocking work time, , Deadlines and scheduling, Dates and Times
  1215. @section Clocking work time
  1216. Org mode allows you to clock the time you spend on specific tasks in a
  1217. project.
  1218. @table @kbd
  1219. @item C-c C-x C-i
  1220. Start the clock on the current item (clock-in). This inserts the CLOCK
  1221. keyword together with a timestamp. When called with a @kbd{C-u} prefix
  1222. argument, select the task from a list of recently clocked tasks.
  1223. @c
  1224. @item C-c C-x C-o
  1225. Stop the clock (clock-out). This inserts another timestamp at the same
  1226. location where the clock was last started. It also directly computes
  1227. the resulting time in inserts it after the time range as @samp{=>
  1228. HH:MM}.
  1229. @item C-c C-x C-e
  1230. Update the effort estimate for the current clock task.
  1231. @item C-c C-x C-x
  1232. Cancel the current clock. This is useful if a clock was started by
  1233. mistake, or if you ended up working on something else.
  1234. @item C-c C-x C-j
  1235. Jump to the entry that contains the currently running clock. With a
  1236. @kbd{C-u} prefix arg, select the target task from a list of recently clocked
  1237. tasks.
  1238. @item C-c C-x C-r
  1239. Insert a dynamic block containing a clock
  1240. report as an Org-mode table into the current file. When the cursor is
  1241. at an existing clock table, just update it.
  1242. @smallexample
  1243. #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
  1244. #+END: clocktable
  1245. @end smallexample
  1246. @noindent
  1247. For details about how to customize this view, see @uref{,the manual}.
  1248. @item C-c C-c
  1249. Update dynamic block at point. The cursor needs to be in the
  1250. @code{#+BEGIN} line of the dynamic block.
  1251. @end table
  1252. The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
  1253. the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
  1254. worked on or closed during a day.
  1255. @seealso{
  1256. @uref{,
  1257. Chapter 8 of the manual}@*
  1258. @uref{, Charles
  1259. Cave's Date and Time tutorial}@*
  1260. @uref{, Bernt Hansen's clocking workflow}}
  1261. @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
  1262. @chapter Capture - Refile - Archive
  1263. An important part of any organization system is the ability to quickly
  1264. capture new ideas and tasks, and to associate reference material with them.
  1265. Org defines a capture process to create tasks. It stores files related to a
  1266. task (@i{attachments}) in a special directory. Once in the system, tasks and
  1267. projects need to be moved around. Moving completed project trees to an
  1268. archive file keeps the system compact and fast.
  1269. @menu
  1270. * Capture::
  1271. * Refiling notes:: Moving a tree from one place to another
  1272. * Archiving:: What to do with finished projects
  1273. @end menu
  1274. @node Capture, Refiling notes, Capture - Refile - Archive, Capture - Refile - Archive
  1275. @section Capture
  1276. Org's method for capturing new items is heavily inspired by John Wiegley
  1277. excellent remember package. It lets you store quick notes with little
  1278. interruption of your work flow. Org lets you define templates for new
  1279. entries and associate them with different targets for storing notes.
  1280. @menu
  1281. * Setting up a capture location:: Where notes will be stored
  1282. * Using capture:: Commands to invoke and terminate capture
  1283. * Capture templates:: Define the outline of different note types
  1284. @end menu
  1285. @node Setting up a capture location, Using capture, Capture, Capture
  1286. @unnumberedsubsec Setting up a capture location
  1287. The following customization sets a default target@footnote{Using capture
  1288. templates, you can define more fine-grained capture locations, see
  1289. @ref{Capture templates}.} file for notes, and defines a global
  1290. key@footnote{Please select your own key, @kbd{C-c c} is only a suggestion.}
  1291. for capturing new stuff.
  1292. @example
  1293. (setq org-default-notes-file (concat org-directory "/"))
  1294. (define-key global-map "\C-cc" 'org-capture)
  1295. @end example
  1296. @node Using capture, Capture templates, Setting up a capture location, Capture
  1297. @unnumberedsubsec Using capture
  1298. @table @kbd
  1299. @item C-c c
  1300. Start a capture process. You will be placed into a narrowed indirect buffer
  1301. to edit the item.
  1302. @item C-c C-c
  1303. Once you are done entering information into the capture buffer,
  1304. @kbd{C-c C-c} will return you to the window configuration before the capture
  1305. process, so that you can resume your work without further distraction.
  1306. @item C-c C-w
  1307. Finalize by moving the entry to a refile location (@pxref{Refiling notes}).
  1308. @item C-c C-k
  1309. Abort the capture process and return to the previous state.
  1310. @end table
  1311. @node Capture templates, , Using capture, Capture
  1312. @unnumberedsubsec Capture templates
  1313. You can use templates to generate different types of capture notes, and to
  1314. store them in different places. For example, if you would like
  1315. to store new tasks under a heading @samp{Tasks} in file @file{}, and
  1316. journal entries in a date tree in @file{} you could
  1317. use:
  1318. @smallexample
  1319. (setq org-capture-templates
  1320. '(("t" "Todo" entry (file+headline "~/org/" "Tasks")
  1321. "* TODO %?\n %i\n %a")
  1322. ("j" "Journal" entry (file+datetree "~/org/")
  1323. "* %?\nEntered on %U\n %i\n %a")))
  1324. @end smallexample
  1325. @noindent In these entries, the first string is the key to reach the
  1326. template, the second is a short description. Then follows the type of the
  1327. entry and a definition of the target location for storing the note. Finally,
  1328. the template itself, a string with %-escapes to fill in information based on
  1329. time and context.
  1330. When you call @kbd{M-x org-capture}, Org will prompt for a key to select the
  1331. template (if you have more than one template) and then prepare the buffer like
  1332. @smallexample
  1333. * TODO
  1334. [[file:@var{link to where you were when initiating capture}]]
  1335. @end smallexample
  1336. @noindent
  1337. During expansion of the template, special @kbd{%}-escapes@footnote{If you
  1338. need one of these sequences literally, escape the @kbd{%} with a backslash.}
  1339. allow dynamic insertion of content. Here is a small selection of the
  1340. possibilities, consult the manual for more.
  1341. @smallexample
  1342. %a @r{annotation, normally the link created with @code{org-store-link}}
  1343. %i @r{initial content, the region when remember is called with C-u.}
  1344. %t @r{timestamp, date only}
  1345. %T @r{timestamp with date and time}
  1346. %u, %U @r{like the above, but inactive timestamps}
  1347. @end smallexample
  1348. @node Refiling notes, Archiving, Capture, Capture - Refile - Archive
  1349. @section Refiling notes
  1350. When reviewing the captured data, you may want to refile some of the entries
  1351. into a different list, for example into a project. Cutting, finding the
  1352. right location, and then pasting the note is cumbersome. To simplify this
  1353. process, you can use the following special command:
  1354. @table @kbd
  1355. @item C-c C-w
  1356. Refile the entry or region at point. This command offers possible locations
  1357. for refiling the entry and lets you select one with completion. The item (or
  1358. all items in the region) is filed below the target heading as a subitem.@*
  1359. By default, all level 1 headlines in the current buffer are considered to be
  1360. targets, but you can have more complex definitions across a number of files.
  1361. See the variable @code{org-refile-targets} for details.
  1362. @item C-u C-c C-w
  1363. Use the refile interface to jump to a heading.
  1364. @item C-u C-u C-c C-w
  1365. Jump to the location where @code{org-refile} last moved a tree to.
  1366. @end table
  1367. @node Archiving, , Refiling notes, Capture - Refile - Archive
  1368. @section Archiving
  1369. When a project represented by a (sub)tree is finished, you may want
  1370. to move the tree out of the way and to stop it from contributing to the
  1371. agenda. Archiving is important to keep your working files compact and global
  1372. searches like the construction of agenda views fast.
  1373. The most common archiving action is to move a project tree to another file,
  1374. the archive file.
  1375. @table @kbd
  1376. @item C-c C-x C-a
  1377. Archive the current entry using the command specified in the variable
  1378. @code{org-archive-default-command}.
  1379. @item C-c C-x C-s@ @r{or short} @ C-c $
  1380. Archive the subtree starting at the cursor position to the location
  1381. given by @code{org-archive-location}.
  1382. @end table
  1383. The default archive location is a file in the same directory as the
  1384. current file, with the name derived by appending @file{_archive} to the
  1385. current file name. For information and examples on how to change this,
  1386. see the documentation string of the variable
  1387. @code{org-archive-location}. There is also an in-buffer option for
  1388. setting this variable, for example
  1389. @smallexample
  1390. #+ARCHIVE: %s_done::
  1391. @end smallexample
  1392. @seealso{
  1393. @uref{,
  1394. Chapter 9 of the manual}@*
  1395. @uref{, Charles
  1396. Cave's remember tutorial}@*
  1397. @uref{,
  1398. Sebastian Rose's tutorial for capturing from a web browser}}@uref{}@*
  1399. @node Agenda Views, Markup, Capture - Refile - Archive, Top
  1400. @chapter Agenda Views
  1401. Due to the way Org works, TODO items, time-stamped items, and tagged
  1402. headlines can be scattered throughout a file or even a number of files. To
  1403. get an overview of open action items, or of events that are important for a
  1404. particular date, this information must be collected, sorted and displayed in
  1405. an organized way. There are several different views, see below.
  1406. The extracted information is displayed in a special @emph{agenda buffer}.
  1407. This buffer is read-only, but provides commands to visit the corresponding
  1408. locations in the original Org files, and even to edit these files remotely.
  1409. Remote editing from the agenda buffer means, for example, that you can
  1410. change the dates of deadlines and appointments from the agenda buffer.
  1411. The commands available in the Agenda buffer are listed in @ref{Agenda
  1412. commands}.
  1413. @menu
  1414. * Agenda files:: Files being searched for agenda information
  1415. * Agenda dispatcher:: Keyboard access to agenda views
  1416. * Built-in agenda views:: What is available out of the box?
  1417. * Agenda commands:: Remote editing of Org trees
  1418. * Custom agenda views:: Defining special searches and views
  1419. @end menu
  1420. @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
  1421. @section Agenda files
  1422. The information to be shown is normally collected from all @emph{agenda
  1423. files}, the files listed in the variable
  1424. @code{org-agenda-files}.
  1425. @table @kbd
  1426. @item C-c [
  1427. Add current file to the list of agenda files. The file is added to
  1428. the front of the list. If it was already in the list, it is moved to
  1429. the front. With a prefix argument, file is added/moved to the end.
  1430. @item C-c ]
  1431. Remove current file from the list of agenda files.
  1432. @item C-,
  1433. Cycle through agenda file list, visiting one file after the other.
  1434. @end table
  1435. @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
  1436. @section The agenda dispatcher
  1437. The views are created through a dispatcher, which should be bound to a
  1438. global key---for example @kbd{C-c a} (@pxref{Installation}). After
  1439. pressing @kbd{C-c a}, an additional letter is required to execute a
  1440. command:
  1441. @table @kbd
  1442. @item a
  1443. The calendar-like agenda (@pxref{Weekly/daily agenda}).
  1444. @item t @r{/} T
  1445. A list of all TODO items (@pxref{Global TODO list}).
  1446. @item m @r{/} M
  1447. A list of headlines matching a TAGS expression (@pxref{Matching
  1448. tags and properties}).
  1449. @item L
  1450. The timeline view for the current buffer (@pxref{Timeline}).
  1451. @item s
  1452. A list of entries selected by a boolean expression of keywords
  1453. and/or regular expressions that must or must not occur in the entry.
  1454. @end table
  1455. @node Built-in agenda views, Agenda commands, Agenda dispatcher, Agenda Views
  1456. @section The built-in agenda views
  1457. @menu
  1458. * Weekly/daily agenda:: The calendar page with current tasks
  1459. * Global TODO list:: All unfinished action items
  1460. * Matching tags and properties:: Structured information with fine-tuned search
  1461. * Timeline:: Time-sorted view for single file
  1462. * Search view:: Find entries by searching for text
  1463. @end menu
  1464. @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
  1465. @subsection The weekly/daily agenda
  1466. The purpose of the weekly/daily @emph{agenda} is to act like a page of a
  1467. paper agenda, showing all the tasks for the current week or day.
  1468. @table @kbd
  1469. @item C-c a a
  1470. Compile an agenda for the current week from a list of Org files. The agenda
  1471. shows the entries for each day.
  1472. @end table
  1473. Emacs contains the calendar and diary by Edward M. Reingold. Org-mode
  1474. understands the syntax of the diary and allows you to use diary sexp entries
  1475. directly in Org files:
  1476. @smallexample
  1477. * Birthdays and similar stuff
  1478. #+CATEGORY: Holiday
  1479. %%(org-calendar-holiday) ; special function for holiday names
  1480. #+CATEGORY: Ann
  1481. %%(diary-anniversary 5 14 1956)@footnote{Note that the order of the arguments (month, day, year) depends on the setting of @code{calendar-date-style}.} Arthur Dent is %d years old
  1482. %%(diary-anniversary 10 2 1869) Mahatma Gandhi would be %d years old
  1483. @end smallexample
  1484. Org can interact with Emacs appointments notification facility. To add all
  1485. the appointments of your agenda files, use the command
  1486. @code{org-agenda-to-appt}. See the docstring for details.
  1487. @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
  1488. @subsection The global TODO list
  1489. The global TODO list contains all unfinished TODO items formatted and
  1490. collected into a single place. Remote editing of TODO items lets you
  1491. can change the state of a TODO entry with a single key press. The commands
  1492. available in the TODO list are described in @ref{Agenda commands}.
  1493. @table @kbd
  1494. @item C-c a t
  1495. Show the global TODO list. This collects the TODO items from all
  1496. agenda files (@pxref{Agenda Views}) into a single buffer.
  1497. @item C-c a T
  1498. Like the above, but allows selection of a specific TODO keyword.
  1499. @end table
  1500. @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
  1501. @subsection Matching tags and properties
  1502. If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
  1503. or have properties (@pxref{Properties}), you can select headlines
  1504. based on this metadata and collect them into an agenda buffer. The match
  1505. syntax described here also applies when creating sparse trees with @kbd{C-c /
  1506. m}. The commands available in the tags list are described in @ref{Agenda
  1507. commands}.
  1508. @table @kbd
  1509. @item C-c a m
  1510. Produce a list of all headlines that match a given set of tags. The
  1511. command prompts for a selection criterion, which is a boolean logic
  1512. expression with tags, like @samp{+work+urgent-withboss} or
  1513. @samp{work|home} (@pxref{Tags}). If you often need a specific search,
  1514. define a custom command for it (@pxref{Agenda dispatcher}).
  1515. @item C-c a M
  1516. Like @kbd{C-c a m}, but only select headlines that are also TODO items.
  1517. @end table
  1518. @subsubheading Match syntax
  1519. A search string can use Boolean operators @samp{&} for AND and @samp{|} for
  1520. OR. @samp{&} binds more strongly than @samp{|}. Parentheses are currently
  1521. not implemented. Each element in the search is either a tag, a regular
  1522. expression matching tags, or an expression like @code{PROPERTY OPERATOR
  1523. VALUE} with a comparison operator, accessing a property value. Each element
  1524. may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
  1525. sugar for positive selection. The AND operator @samp{&} is optional when
  1526. @samp{+} or @samp{-} is present. Here are some examples, using only tags.
  1527. @table @samp
  1528. @item +work-boss
  1529. Select headlines tagged @samp{:work:}, but discard those also tagged
  1530. @samp{:boss:}.
  1531. @item work|laptop
  1532. Selects lines tagged @samp{:work:} or @samp{:laptop:}.
  1533. @item work|laptop+night
  1534. Like before, but require the @samp{:laptop:} lines to be tagged also
  1535. @samp{:night:}.
  1536. @end table
  1537. You may also test for properties at the same
  1538. time as matching tags, see the manual for more information.
  1539. @node Timeline, Search view, Matching tags and properties, Built-in agenda views
  1540. @subsection Timeline for a single file
  1541. The timeline summarizes all time-stamped items from a single Org mode
  1542. file in a @emph{time-sorted view}. The main purpose of this command is
  1543. to give an overview over events in a project.
  1544. @table @kbd
  1545. @item C-c a L
  1546. Show a time-sorted view of the Org file, with all time-stamped items.
  1547. When called with a @kbd{C-u} prefix, all unfinished TODO entries
  1548. (scheduled or not) are also listed under the current date.
  1549. @end table
  1550. @node Search view, , Timeline, Built-in agenda views
  1551. @subsection Search view
  1552. This agenda view is a general text search facility for Org mode entries.
  1553. It is particularly useful to find notes.
  1554. @table @kbd
  1555. @item C-c a s
  1556. This is a special search that lets you select entries by matching a substring
  1557. or specific words using a boolean logic.
  1558. @end table
  1559. For example, the search string @samp{computer equipment} will find entries
  1560. that contain @samp{computer equipment} as a substring.
  1561. Search view can also search for specific keywords in the entry, using Boolean
  1562. logic. The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
  1563. will search for note entries that contain the keywords @code{computer}
  1564. and @code{wifi}, but not the keyword @code{ethernet}, and which are also
  1565. not matched by the regular expression @code{8\.11[bg]}, meaning to
  1566. exclude both 8.11b and 8.11g.
  1567. Note that in addition to the agenda files, this command will also search
  1568. the files listed in @code{org-agenda-text-search-extra-files}.
  1569. @node Agenda commands, Custom agenda views, Built-in agenda views, Agenda Views
  1570. @section Commands in the agenda buffer
  1571. Entries in the agenda buffer are linked back to the Org file or diary
  1572. file where they originate. Commands are provided to show and jump to the
  1573. original entry location, and to edit the Org files ``remotely'' from
  1574. the agenda buffer. This is just a selection of the many commands, explore
  1575. the @code{Agenda} menu and the manual for a complete list.
  1576. @table @kbd
  1577. @tsubheading{Motion}
  1578. @item n
  1579. Next line (same as @key{up} and @kbd{C-p}).
  1580. @item p
  1581. Previous line (same as @key{down} and @kbd{C-n}).
  1582. @tsubheading{View/Go to Org file}
  1583. @item mouse-3
  1584. @itemx @key{SPC}
  1585. Display the original location of the item in another window.
  1586. With prefix arg, make sure that the entire entry is made visible in the
  1587. outline, not only the heading.
  1588. @c
  1589. @itemx @key{TAB}
  1590. Go to the original location of the item in another window. Under Emacs
  1591. 22, @kbd{mouse-1} will also works for this.
  1592. @c
  1593. @itemx @key{RET}
  1594. Go to the original location of the item and delete other windows.
  1595. @c
  1596. @tsubheading{Change display}
  1597. @item o
  1598. Delete other windows.
  1599. @c
  1600. @item d @r{/} w
  1601. Switch to day/week view.
  1602. @c
  1603. @item f @r{and} b
  1604. Go forward/backward in time to display the following @code{org-agenda-ndays}
  1605. days. For example, if the display covers a week, switch to the
  1606. following/previous week.
  1607. @c
  1608. @item .
  1609. Go to today.
  1610. @c
  1611. @item j
  1612. Prompt for a date and go there.
  1613. @c
  1614. @item v l @ @r{or short} @ l
  1615. Toggle Logbook mode. In Logbook mode, entries that were marked DONE while
  1616. logging was on (variable @code{org-log-done}) are shown in the agenda, as are
  1617. entries that have been clocked on that day. When called with a @kbd{C-u}
  1618. prefix, show all possible logbook entries, including state changes.
  1619. @c
  1620. @item r @r{or} g
  1621. Recreate the agenda buffer, to reflect the changes.
  1622. @item s
  1623. Save all Org buffers in the current Emacs session, and also the locations of
  1624. IDs.
  1625. @tsubheading{Secondary filtering and query editing}
  1626. @item /
  1627. Filter the current agenda view with respect to a tag. You are prompted for a
  1628. letter to select a tag. Press @samp{-} first to select against the tag.
  1629. @item \
  1630. Narrow the current agenda filter by an additional condition.
  1631. @tsubheading{Remote editing (see the manual for many more commands)}
  1632. @item 0-9
  1633. Digit argument.
  1634. @c
  1635. @item t
  1636. Change the TODO state of the item, in the agenda and in the
  1637. org file.
  1638. @c
  1639. @item C-k
  1640. Delete the current agenda item along with the entire subtree belonging
  1641. to it in the original Org file.
  1642. @c
  1643. @item C-c C-w
  1644. Refile the entry at point.
  1645. @c
  1646. @item C-c C-x C-a @ @r{or short} @ a
  1647. Archive the subtree corresponding to the entry at point using the default
  1648. archiving command set in @code{org-archive-default-command}.
  1649. @c
  1650. @item C-c C-x C-s @ @r{or short} @ $
  1651. Archive the subtree corresponding to the current headline.
  1652. @c
  1653. @item C-c C-s
  1654. Schedule this item, with prefix arg remove the scheduling timestamp
  1655. @c
  1656. @item C-c C-d
  1657. Set a deadline for this item, with prefix arg remove the deadline.
  1658. @c
  1659. @item S-@key{right} @r{and} S-@key{left}
  1660. Change the timestamp associated with the current line by one day.
  1661. @c
  1662. @item I
  1663. Start the clock on the current item.
  1664. @c
  1665. @item O / X
  1666. Stop/cancel the previously started clock.
  1667. @item J
  1668. Jump to the running clock in another window.
  1669. @end table
  1670. @node Custom agenda views, , Agenda commands, Agenda Views
  1671. @section Custom agenda views
  1672. The main application of custom searches is the definition of keyboard
  1673. shortcuts for frequently used searches, either creating an agenda
  1674. buffer, or a sparse tree (the latter covering of course only the current
  1675. buffer).
  1676. Custom commands are configured in the variable
  1677. @code{org-agenda-custom-commands}. You can customize this variable, for
  1678. example by pressing @kbd{C-c a C}. You can also directly set it with
  1679. Emacs Lisp in @file{.emacs}. The following example contains all valid
  1680. search types:
  1681. @smalllisp
  1682. @group
  1683. (setq org-agenda-custom-commands
  1684. '(("w" todo "WAITING")
  1685. ("u" tags "+boss-urgent")
  1686. ("v" tags-todo "+boss-urgent")))
  1687. @end group
  1688. @end smalllisp
  1689. @noindent
  1690. The initial string in each entry defines the keys you have to press after the
  1691. dispatcher command @kbd{C-c a} in order to access the command. Usually this
  1692. will be just a single character. The second parameter is the search type,
  1693. followed by the string or regular expression to be used for the matching.
  1694. The example above will therefore define:
  1695. @table @kbd
  1696. @item C-c a w
  1697. as a global search for TODO entries with @samp{WAITING} as the TODO
  1698. keyword
  1699. @item C-c a u
  1700. as a global tags search for headlines marked @samp{:boss:} but not
  1701. @samp{:urgent:}
  1702. @item C-c a v
  1703. as the same search as @kbd{C-c a u}, but limiting the search to
  1704. headlines that are also TODO items
  1705. @end table
  1706. @seealso{
  1707. @uref{, Chapter 10 of
  1708. the manual}@*
  1709. @uref{,
  1710. Mat Lundin's tutorial about custom agenda commands}@*
  1711. @uref{,
  1712. John Wiegley's setup}}
  1713. @node Markup, Exporting, Agenda Views, Top
  1714. @chapter Markup for rich export
  1715. When exporting Org-mode documents, the exporter tries to reflect the
  1716. structure of the document as accurately as possible in the backend. Since
  1717. export targets like HTML, La@TeX{}, or DocBook allow much richer formatting,
  1718. Org mode has rules on how to prepare text for rich export. This section
  1719. summarizes the markup rules used in an Org-mode buffer.
  1720. @menu
  1721. * Structural markup elements:: The basic structure as seen by the exporter
  1722. * Images and tables:: Tables and Images will be included
  1723. * Literal examples:: Source code examples with special formatting
  1724. * Include files:: Include additional files into a document
  1725. * Embedded LaTeX:: LaTeX can be freely used inside Org documents
  1726. @end menu
  1727. @node Structural markup elements, Images and tables, Markup, Markup
  1728. @section Structural markup elements
  1729. @menu
  1730. * Document title:: Where the title is taken from
  1731. * Headings and sections:: The document structure as seen by the exporter
  1732. * Table of contents:: The if and where of the table of contents
  1733. * Paragraphs:: Paragraphs
  1734. * Emphasis and monospace:: Bold, italic, etc.
  1735. * Comment lines:: What will *not* be exported
  1736. @end menu
  1737. @node Document title, Headings and sections, Structural markup elements, Structural markup elements
  1738. @subheading Document title
  1739. @noindent
  1740. The title of the exported document is taken from the special line
  1741. @smallexample
  1742. #+TITLE: This is the title of the document
  1743. @end smallexample
  1744. @node Headings and sections, Table of contents, Document title, Structural markup elements
  1745. @subheading Headings and sections
  1746. The outline structure of the document as described in @ref{Document
  1747. Structure}, forms the basis for defining sections of the exported document.
  1748. However, since the outline structure is also used for (for example) lists of
  1749. tasks, only the first three outline levels will be used as headings. Deeper
  1750. levels will become itemized lists. You can change the location of this
  1751. switch globally by setting the variable @code{org-export-headline-levels}, or on a
  1752. per-file basis with a line
  1753. @smallexample
  1754. #+OPTIONS: H:4
  1755. @end smallexample
  1756. @node Table of contents, Paragraphs, Headings and sections, Structural markup elements
  1757. @subheading Table of contents
  1758. The table of contents is normally inserted directly before the first headline
  1759. of the file.
  1760. @smallexample
  1761. #+OPTIONS: toc:2 (only to two levels in TOC)
  1762. #+OPTIONS: toc:nil (no TOC at all)
  1763. @end smallexample
  1764. @node Paragraphs, Emphasis and monospace, Table of contents, Structural markup elements
  1765. @subheading Paragraphs, line breaks, and quoting
  1766. Paragraphs are separated by at least one empty line. If you need to enforce
  1767. a line break within a paragraph, use @samp{\\} at the end of a line.
  1768. To keep the line breaks in a region, but otherwise use normal formatting, you
  1769. can use this construct, which can also be used to format poetry.
  1770. @smallexample
  1771. #+BEGIN_VERSE
  1772. Great clouds overhead
  1773. Tiny black birds rise and fall
  1774. Snow covers Emacs
  1775. -- AlexSchroeder
  1776. #+END_VERSE
  1777. @end smallexample
  1778. When quoting a passage from another document, it is customary to format this
  1779. as a paragraph that is indented on both the left and the right margin. You
  1780. can include quotations in Org-mode documents like this:
  1781. @smallexample
  1782. #+BEGIN_QUOTE
  1783. Everything should be made as simple as possible,
  1784. but not any simpler -- Albert Einstein
  1785. #+END_QUOTE
  1786. @end smallexample
  1787. If you would like to center some text, do it like this:
  1788. @smallexample
  1789. #+BEGIN_CENTER
  1790. Everything should be made as simple as possible, \\
  1791. but not any simpler
  1792. #+END_CENTER
  1793. @end smallexample
  1794. @node Emphasis and monospace, Comment lines, Paragraphs, Structural markup elements
  1795. @subheading Emphasis and monospace
  1796. You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
  1797. and @code{~verbatim~}, and, if you must, @samp{+strike-through+}. Text
  1798. in the code and verbatim string is not processed for Org-mode specific
  1799. syntax, it is exported verbatim. To insert a horizontal rules, use a line
  1800. consisting of only dashes, and at least 5 of them.
  1801. @node Comment lines, , Emphasis and monospace, Structural markup elements
  1802. @subheading Comment lines
  1803. Lines starting with @samp{#} in column zero are treated as comments and will
  1804. never be exported. If you want an indented line to be treated as a comment,
  1805. start it with @samp{#+ }. Also entire subtrees starting with the word
  1806. @samp{COMMENT} will never be exported. Finally, regions surrounded by
  1807. @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
  1808. @table @kbd
  1809. @item C-c ;
  1810. Toggle the COMMENT keyword at the beginning of an entry.
  1811. @end table
  1812. @node Images and tables, Literal examples, Structural markup elements, Markup
  1813. @section Images and Tables
  1814. For Org mode tables, the lines before the first horizontal separator line
  1815. will become table header lines. You can use the following lines somewhere
  1816. before the table to assign a caption and a label for cross references, and in
  1817. the text you can refer to the object with @code{\ref@{tab:basic-data@}}:
  1818. @smallexample
  1819. #+CAPTION: This is the caption for the next table (or link)
  1820. #+LABEL: tbl:basic-data
  1821. | ... | ...|
  1822. |-----|----|
  1823. @end smallexample
  1824. Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include
  1825. images into the exported document. Org does this, if a link to an image
  1826. files does not have a description part, for example @code{[[./img/a.jpg]]}.
  1827. If you wish to define a caption for the image and maybe a label for internal
  1828. cross references, you sure that the link is on a line by itself precede it
  1829. with:
  1830. @smallexample
  1831. #+CAPTION: This is the caption for the next figure link (or table)
  1832. #+LABEL: fig:SED-HR4049
  1833. [[./img/a.jpg]]
  1834. @end smallexample
  1835. You may also define additional attributes for the figure. As this is
  1836. backend-specific, see the sections about the individual backends for more
  1837. information.
  1838. @node Literal examples, Include files, Images and tables, Markup
  1839. @section Literal examples
  1840. You can include literal examples that should not be subjected to
  1841. markup. Such examples will be typeset in monospace, so this is well suited
  1842. for source code and similar examples.
  1843. @smallexample
  1845. Some example from a text file.
  1846. #+END_EXAMPLE
  1847. @end smallexample
  1848. For simplicity when using small examples, you can also start the example
  1849. lines with a colon followed by a space. There may also be additional
  1850. whitespace before the colon:
  1851. @smallexample
  1852. Here is an example
  1853. : Some example from a text file.
  1854. @end smallexample
  1855. For source code from a programming language, or any other text
  1856. that can be marked up by font-lock in Emacs, you can ask for it to
  1857. look like the fontified Emacs buffer
  1858. @smallexample
  1859. #+BEGIN_SRC emacs-lisp
  1860. (defun org-xor (a b)
  1861. "Exclusive or."
  1862. (if a (not b) b))
  1863. #+END_SRC
  1864. @end smallexample
  1865. To edit the example in a special buffer supporting this language, use
  1866. @kbd{C-c '} to both enter and leave the editing buffer.
  1867. @node Include files, Embedded LaTeX, Literal examples, Markup
  1868. @section Include files
  1869. During export, you can include the content of another file. For example, to
  1870. include your @file{.emacs} file, you could use:
  1871. @smallexample
  1872. #+INCLUDE: "~/.emacs" src emacs-lisp
  1873. @end smallexample
  1874. @noindent
  1875. The optional second and third parameter are the markup (e.g. @samp{quote},
  1876. @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
  1877. language for formatting the contents. The markup is optional, if it is not
  1878. given, the text will be assumed to be in Org mode format and will be
  1879. processed normally. @kbd{C-c '} will visit the included file.
  1880. @node Embedded LaTeX, , Include files, Markup
  1881. @section Embedded La@TeX{}
  1882. For scientific notes which need to be able to contain mathematical symbols
  1883. and the occasional formula, Org-mode supports embedding La@TeX{} code into
  1884. its files. You can directly use TeX-like macros for special symbols, enter
  1885. formulas and entire LaTeX environments.
  1886. @smallexample
  1887. Angles are written as Greek letters \alpha, \beta and \gamma. The mass if
  1888. the sun is M_sun = 1.989 x 10^30 kg. The radius of the sun is R_@{sun@} =
  1889. 6.96 x 10^8 m. If $a^2=b$ and $b=2$, then the solution must be either
  1890. $a=+\sqrt@{2@}$ or $a=-\sqrt@{2@}$.
  1891. \begin@{equation@}
  1892. x=\sqrt@{b@}
  1893. \end@{equation@}
  1894. @end smallexample
  1895. @noindent With
  1896. @uref{,special
  1897. setup}, LaTeX snippets will be included as images when exporting to HTML.
  1898. @seealso{
  1899. @uref{, Chapter 11 of the manual}}
  1900. @node Exporting, Publishing, Markup, Top
  1901. @chapter Exporting
  1902. Org-mode documents can be exported into a variety of other formats: ASCII
  1903. export for inclusion into emails, HTML to publish on the web, La@TeX{}/PDF
  1904. for beautiful printed documents and DocBook to enter the world of many other
  1905. formats using DocBook tools. There is also export to iCalendar format so
  1906. that planning information can be incorporated into desktop calendars.
  1907. @menu
  1908. * Export options:: Per-file export settings
  1909. * The export dispatcher:: How to access exporter commands
  1910. * ASCII/Latin-1/UTF-8 export:: Exporting to flat files with encoding
  1911. * HTML export:: Exporting to HTML
  1912. * LaTeX and PDF export:: Exporting to La@TeX{}, and processing to PDF
  1913. * DocBook export:: Exporting to DocBook
  1914. * iCalendar export::
  1915. @end menu
  1916. @node Export options, The export dispatcher, Exporting, Exporting
  1917. @section Export options
  1918. The exporter recognizes special lines in the buffer which provide
  1919. additional information. These lines may be put anywhere in the file.
  1920. The whole set of lines can be inserted into the buffer with @kbd{C-c
  1921. C-e t}.
  1922. @table @kbd
  1923. @item C-c C-e t
  1924. Insert template with export options, see example below.
  1925. @end table
  1926. @smallexample
  1927. #+TITLE: the title to be shown (default is the buffer name)
  1928. #+AUTHOR: the author (default taken from @code{user-full-name})
  1929. #+DATE: a date, fixed, of a format string for @code{format-time-string}
  1930. #+EMAIL: his/her email address (default from @code{user-mail-address})
  1931. #+DESCRIPTION: the page description, e.g. for the XHTML meta tag
  1932. #+KEYWORDS: the page keywords, e.g. for the XHTML meta tag
  1933. #+LANGUAGE: language for HTML, e.g. @samp{en} (@code{org-export-default-language})
  1934. #+TEXT: Some descriptive text to be inserted at the beginning.
  1935. #+TEXT: Several lines may be given.
  1936. #+OPTIONS: H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
  1937. #+LINK_UP: the ``up'' link of an exported page
  1938. #+LINK_HOME: the ``home'' link of an exported page
  1939. #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
  1940. @end smallexample
  1941. @node The export dispatcher, ASCII/Latin-1/UTF-8 export, Export options, Exporting
  1942. @section The export dispatcher
  1943. All export commands can be reached using the export dispatcher, which is a
  1944. prefix key that prompts for an additional key specifying the command.
  1945. Normally the entire file is exported, but if there is an active region that
  1946. contains one outline tree, the first heading is used as document title and
  1947. the subtrees are exported.
  1948. @table @kbd
  1949. @item C-c C-e
  1950. Dispatcher for export and publishing commands.
  1951. @end table
  1952. @node ASCII/Latin-1/UTF-8 export, HTML export, The export dispatcher, Exporting
  1953. @section ASCII/Latin-1/UTF-8 export
  1954. ASCII export produces a simple and very readable version of an Org-mode
  1955. file, containing only plain ASCII. Latin-1 and UTF-8 export augment the file
  1956. with special characters and symbols available in these encodings.
  1957. @table @kbd
  1958. @item C-c C-e a
  1959. Export as ASCII file.
  1960. @item C-c C-e n @ @ @r{and} @ @ C-c C-e N
  1961. Like the above commands, but use Latin-1 encoding.
  1962. @item C-c C-e u @ @ @r{and} @ @ C-c C-e U
  1963. Like the above commands, but use UTF-8 encoding.
  1964. @end table
  1965. @node HTML export, LaTeX and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
  1966. @section HTML export
  1967. @table @kbd
  1968. @item C-c C-e h
  1969. Export as HTML file @file{myfile.html}.
  1970. @item C-c C-e b
  1971. Export as HTML file and immediately open it with a browser.
  1972. @end table
  1973. To insert HTML that should be copied verbatim to
  1974. the exported file use either
  1975. @smallexample
  1976. #+HTML: Literal HTML code for export
  1977. @end smallexample
  1978. @noindent or
  1979. @smallexample
  1980. #+BEGIN_HTML
  1981. All lines between these markers are exported literally
  1982. #+END_HTML
  1983. @end smallexample
  1984. @node LaTeX and PDF export, DocBook export, HTML export, Exporting
  1985. @section La@TeX{} and PDF export
  1986. @table @kbd
  1987. @item C-c C-e l
  1988. Export as La@TeX{} file @file{myfile.tex}.
  1989. @item C-c C-e p
  1990. Export as La@TeX{} and then process to PDF.
  1991. @item C-c C-e d
  1992. Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
  1993. @end table
  1994. By default, the La@TeX{} output uses the class @code{article}. You can
  1995. change this by adding an option like @code{#+LaTeX_CLASS: myclass} in your
  1996. file. The class must be listed in @code{org-export-latex-classes}.
  1997. Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
  1998. inserted into the La@TeX{} file. Similarly to the HTML exporter, you can use
  1999. @code{#+LaTeX:} and @code{#+BEGIN_LaTeX ... #+END_LaTeX} construct to add
  2000. verbatim LaTeX code.
  2001. @node DocBook export, iCalendar export, LaTeX and PDF export, Exporting
  2002. @section DocBook export
  2003. @table @kbd
  2004. @item C-c C-e D
  2005. Export as DocBook file.
  2006. @end table
  2007. Similarly to the HTML exporter, you can use @code{#+DocBook:} and
  2008. @code{#+BEGIN_DocBook ... #+END_DocBook} construct to add verbatim LaTeX
  2009. code.
  2010. @node iCalendar export, , DocBook export, Exporting
  2011. @section iCalendar export
  2012. @table @kbd
  2013. @item C-c C-e i
  2014. Create iCalendar entries for the current file in a @file{.ics} file.
  2015. @item C-c C-e c
  2016. Create a single large iCalendar file from all files in
  2017. @code{org-agenda-files} and write it to the file given by
  2018. @code{org-combined-agenda-icalendar-file}.
  2019. @end table
  2020. @seealso{
  2021. @uref{, Chapter 12 of the manual}@*
  2022. @uref{,
  2023. Sebastian Rose's image handling tutorial}@*
  2024. @uref{, Thomas
  2025. Dye's LaTeX export tutorial}
  2026. @uref{, Eric
  2027. Fraga's BEAMER presentation tutorial}}
  2028. @node Publishing, Working With Source Code, Exporting, Top
  2029. @chapter Publishing
  2030. Org includes a publishing management system that allows you to configure
  2031. automatic HTML conversion of @emph{projects} composed of interlinked org
  2032. files. You can also configure Org to automatically upload your exported HTML
  2033. pages and related attachments, such as images and source code files, to a web
  2034. server. For detailed instructions about setup, see the manual.
  2035. Here is an example:
  2036. @smalllisp
  2037. (setq org-publish-project-alist
  2038. '(("org"
  2039. :base-directory "~/org/"
  2040. :publishing-directory "~/public_html"
  2041. :section-numbers nil
  2042. :table-of-contents nil
  2043. :style "<link rel=\"stylesheet\"
  2044. href=\"../other/mystyle.css\"
  2045. type=\"text/css\"/>")))
  2046. @end smalllisp
  2047. @table @kbd
  2048. @item C-c C-e C
  2049. Prompt for a specific project and publish all files that belong to it.
  2050. @item C-c C-e P
  2051. Publish the project containing the current file.
  2052. @item C-c C-e F
  2053. Publish only the current file.
  2054. @item C-c C-e E
  2055. Publish every project.
  2056. @end table
  2057. Org uses timestamps to track when a file has changed. The above functions
  2058. normally only publish changed files. You can override this and force
  2059. publishing of all files by giving a prefix argument to any of the commands
  2060. above.
  2061. @seealso{
  2062. @uref{, Chapter 13 of the
  2063. manual}@*
  2064. @uref{,
  2065. Sebastian Rose's publishing tutorial}@*
  2066. @uref{, Ian Barton's
  2067. Jekyll/blogging setup}}
  2068. @node Working With Source Code, Miscellaneous, Publishing, Top
  2069. @chapter Working with source code
  2070. Org-mode provides a number of features for working with source code,
  2071. including editing of code blocks in their native major-mode, evaluation of
  2072. code blocks, tangling of code blocks, and exporting code blocks and their
  2073. results in several formats.
  2074. @subheading Structure of Code Blocks
  2075. The structure of code blocks is as follows:
  2076. @example
  2077. #+srcname: <name>
  2078. #+begin_src <language> <switches> <header arguments>
  2079. <body>
  2080. #+end_src
  2081. @end example
  2082. Where @code{<name>} is a string used to name the code block,
  2083. @code{<language>} specifies the language of the code block
  2084. (e.g. @code{emacs-lisp}, @code{shell}, @code{R}, @code{python}, etc...),
  2085. @code{<switches>} can be used to control export of the code block,
  2086. @code{<header arguments>} can be used to control many aspects of code block
  2087. behavior as demonstrated below, and @code{<body>} contains the actual source
  2088. code.
  2089. @subheading Editing source code
  2090. Use @kbd{C-c '} to edit the current code block. This brings up a language
  2091. major-mode edit buffer containing the body of the code block. Saving this
  2092. buffer will write the new contents back to the Org buffer. Use @kbd{C-c '}
  2093. again to exit the edit buffer.
  2094. @subheading Evaluating code blocks
  2095. Use @kbd{C-c C-c} to evaluate the current code block and insert its results
  2096. in the Org-mode buffer. By default, evaluation is only turned on for
  2097. @code{emacs-lisp} code blocks, however support exists for evaluating blocks
  2098. in many languages. For a complete list of supported languages see the
  2099. manual. The following shows a code block and its results.
  2100. @example
  2101. #+begin_src emacs-lisp
  2102. (+ 1 2 3 4)
  2103. #+end_src
  2104. #+results:
  2105. : 10
  2106. @end example
  2107. @subheading Extracting source code
  2108. Use @kbd{C-c C-v t} to create pure source code files by extracting code from
  2109. source blocks in the current buffer. This is referred to as ``tangling''---a
  2110. term adopted from the literate programming community. During ``tangling'' of
  2111. code blocks their bodies are expanded using @code{org-babel-expand-src-block}
  2112. which can expand both variable and ``noweb'' style references. In order to
  2113. tangle a code block it must have a @code{:tangle} header argument, see the
  2114. manual for details.
  2115. @subheading Header Arguments
  2116. Many aspects of the evaluation and export of code blocks are controlled
  2117. through header arguments. These can be specified globally, at the file
  2118. level, at the outline subtree level, and at the individual code block level.
  2119. The following describes some of the header arguments.
  2120. @table @code
  2121. @item :var
  2122. The @code{:var} header argument is used to pass arguments to code blocks.
  2123. The values passed to arguments can be literal values, values from org-mode
  2124. tables and literal example blocks, or the results of other named code blocks.
  2125. @item :results
  2126. The @code{:results} header argument controls the @emph{collection},
  2127. @emph{type}, and @emph{handling} of code block results. Values of
  2128. @code{output} or @code{value} (the default) specify how results are collected
  2129. from a code block's evaluation. Values of @code{vector}, @code{scalar}
  2130. @code{file} @code{raw} @code{html} @code{latex} and @code{code} specify the
  2131. type of the results of the code block which dictates how they will be
  2132. incorporated into the Org-mode buffer. Values of @code{silent},
  2133. @code{replace}, @code{prepend}, and @code{append} specify handling of code
  2134. block results, specifically if and how the results should be inserted into
  2135. the Org-mode buffer.
  2136. @item :session
  2137. A header argument of @code{:session} will cause the code block to be
  2138. evaluated in a persistent interactive inferior process in Emacs. This allows
  2139. for persisting state between code block evaluations, and for manual
  2140. inspection of the results of evaluation.
  2141. @item :exports
  2142. Any combination of the @emph{code} or the @emph{results} of a block can be
  2143. retained on export, this is specified by setting the @code{:results} header
  2144. argument to @code{code} @code{results} @code{none} or @code{both}.
  2145. @item :tangle
  2146. A header argument of @code{:tangle yes} will cause a code block's contents to
  2147. be tangled to a file named after the filename of the Org-mode buffer. An
  2148. alternate file name can be specified with @code{:tangle filename}.
  2149. @item :cache
  2150. A header argument of @code{:cache yes} will cause associate a hash of the
  2151. expanded code block with the results, ensuring that code blocks are only
  2152. re-run when their inputs have changed.
  2153. @item :noweb
  2154. A header argument of @code{:noweb yes} will expand ``noweb'' style references
  2155. on evaluation and tangling.
  2156. @item :file
  2157. Code blocks which output results to files (e.g. graphs, diagrams and figures)
  2158. can accept a @code{:file filename} header argument in which case the results
  2159. are saved to the named file, and a link to the file is inserted into the
  2160. Org-mode buffer.
  2161. @end table
  2162. @subheading Library of Babel
  2163. Use @kbd{C-c C-v l} to load the code blocks from an Org-mode files into the
  2164. ``Library of Babel'', these blocks can then be evaluated from any Org-mode
  2165. buffer. A collection of generally useful code blocks is distributed with
  2166. Org-mode in @code{contrib/}.
  2167. @seealso{
  2168. @uref{,Chapter 14 of the manual}@*
  2169. @uref{,
  2170. The Babel site on Worg}}
  2171. @node Miscellaneous, , Working With Source Code, Top
  2172. @chapter Miscellaneous
  2173. @menu
  2174. * Completion:: M-TAB knows what you need
  2175. * Clean view:: Getting rid of leading stars in the outline
  2176. * MobileOrg:: Org-mode on the iPhone
  2177. @end menu
  2178. @node Completion, Clean view, Miscellaneous, Miscellaneous
  2179. @section Completion
  2180. Org supports in-buffer completion with @kbd{M-@key{TAB}}. This type of
  2181. completion does not make use of the minibuffer. You simply type a few
  2182. letters into the buffer and use the key to complete text right there. For
  2183. example, this command will complete @TeX{} symbols after @samp{\}, TODO
  2184. keywords at the beginning of a headline, and tags after @samp{:} in a
  2185. headline.
  2186. @node Clean view, MobileOrg, Completion, Miscellaneous
  2187. @section A cleaner outline view
  2188. Some people find it noisy and distracting that the Org headlines start with a
  2189. potentially large number of stars, and that text below the headlines is not
  2190. indented. While this is no problem when writing a @emph{book-like} document
  2191. where the outline headings are really section headings, in a more
  2192. @emph{list-oriented} outline, indented structure is a lot cleaner:
  2193. @smallexample
  2194. @group
  2195. * Top level headline | * Top level headline
  2196. ** Second level | * Second level
  2197. *** 3rd level | * 3rd level
  2198. some text | some text
  2199. *** 3rd level | * 3rd level
  2200. more text | more text
  2201. * Another top level headline | * Another top level headline
  2202. @end group
  2203. @end smallexample
  2204. @noindent
  2205. If you are using at least Emacs and version 6.29 of Org, this kind
  2206. of view can be achieved dynamically at display time using
  2207. @code{org-indent-mode}, which will prepend intangible space to each line.
  2208. You can turn on @code{org-indent-mode} for all files by customizing the
  2209. variable @code{org-startup-indented}, or you can turn it on for individual
  2210. files using
  2211. @smallexample
  2212. #+STARTUP: indent
  2213. @end smallexample
  2214. If you want a similar effect in earlier version of Emacs and/or Org, or if
  2215. you want the indentation to be hard space characters so that the plain text
  2216. file looks as similar as possible to the Emacs display, Org supports you by
  2217. helping to indent (with @key{TAB}) text below each headline, by hiding
  2218. leading stars, and by only using levels 1, 3, etc to get two characters
  2219. indentation for each level. To get this support in a file, use
  2220. @smallexample
  2221. #+STARTUP: hidestars odd
  2222. @end smallexample
  2223. @node MobileOrg, , Clean view, Miscellaneous
  2224. @section MobileOrg
  2225. @i{MobileOrg} is an application for the @i{iPhone/iPod Touch} series of
  2226. devices, developed by Richard Moreland. For details, see the Org-mode
  2227. manual.
  2228. @seealso{
  2229. @uref{, Chapter 15
  2230. of the manual}@*
  2231. @uref{, Appendix B of the
  2232. manual}@*
  2233. @uref{,Key reference card}}
  2234. @bye
  2235. @ignore
  2236. arch-tag: 8f0a8557-0acc-4436-b2b2-0197699e1452
  2237. @end ignore
  2238. @c Local variables:
  2239. @c fill-column: 77
  2240. @c End:
  2241. @c LocalWords: webdavhost pre