changeset 96044:c1ef445563bb

2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-colview.el (org-columns-next-allowed-value): Bug fix. * org-colview-xemacs.el (org-columns-next-allowed-value): Bug fix. * org-agenda.el (org-agenda-get-closed): Get the end time into the agenda prefix as well. * org-publish.el (org-publish-org-index): Make a properly indented list. * org.el (org-calendar-agenda-action-key): New option. (org-get-cursor-date): New function. (org-mark-entry-for-agenda-action): New command. (org-overriding-default-time): New variable. (org-read-date): Respect `org-overriding-default-time'. * org-remember.el (org-remember-apply-template): Respect the ovverriding default time. * org-agenda.el (org-agenda-action-marker): New variable. (org-agenda-action): New command. (org-agenda-do-action): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-schedule, org-deadline): Protect scheduled and deadline tasks against changes that accidently remove the repeater. Also show a message with the new date when done. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-beginning-of-line): Cater for the case when there are tags but no headline text. (org-align-tags-here): Convert to tabs only when indent-tabs-mode it set. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-mhe.el (org-mhe-get-message-folder-from-index): Make sure the return value is nil instead of "nil" when there is no match. * org-exp.el (org-insert-centered): Use fill-column instead of 80. (org-export-as-ascii): Use string-width to measure the width of the heading. * org.el (org-diary-to-ical-string): No longer kill buffer FROMBUF, this is now done by the caller. * org-exp.el (org-print-icalendar-entries): Move the call to `org-diary-to-ical-string' out of the loop, and kill the buffer afterwords. * org-remember.el (org-remember-visit-immediately): Position cursor after moving to the note. (org-remember-apply-template): Use a text property to record the cursor position. (org-remember-handler): Align tags after pasting the note. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-bbdb.el (org-bbdb-follow-anniversary-link): New function. * org-agenda.el (org-agenda-open-link): If there is an org-bbdb-name property in the current line, jump to that bbdb entry. * org-bbdb.el (org-bbdb-anniversaries): Add the bbdb-name as a text property, so that the agenda knows where this entry comes from. * org-agenda.el (org-agenda-clock-in): Fixed bug in the interaction between clocking-in from the agenda, and automatic task state switching. * org-macs.el (org-with-point-at): Bug fix in macro defintion. * org.el (org-beginning-of-line, org-end-of-line): Make sure the zmacs-region stays after this command in XEmacs. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-scan-tags): Allow new values for ACTION parameter. * org-remember.el (org-remember-templates): Fix bug in customization type definition. * org.el (org-map-entries): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-skip-comment-trees): New option. (org-agenda-skip): Respect `org-agenda-skip-comment-trees'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-remember.el (org-jump-to-target-location): New variable. (org-remember-apply-template): Set `org-remember-apply-template' if requested by template. (org-remember-handler): Start an idle timer to jump to remember location. * org-exp.el (org-get-current-options): Add the FILETAGS setting. * org.el (org-set-regexps-and-options): Fix bug with parsing of file tags. (org-get-tags-at): Add the content of `org-file-tags'. * org-exp.el (org-export-handle-comments): Fix bug with several comment lines after each other. (org-number-to-roman, org-number-to-counter): New functions. (org-export-section-number-format): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-protect-examples): Catch the case of a missing end_example line. * org.el (org-set-regexps-and-options): Set `org-file-properties' and `org-file-tags' to nil. * org-colview.el (org-columns-next-allowed-value): Handle next argument NTH to directly select a value. * org-colview-xemacs.el (org-columns-next-allowed-value): Handle next argument NTH to directly select a value. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-scheduled-leaders): Fix docstring. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-columns-ellipses): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-colview.el (org-columns-add-ellipses): New function. (org-columns-compact-links): New function. (org-columns-cleanup-item): Call `org-columns-compact-links'. (org-columns-display-here): Call `org-agenda-columns-cleanup-item' when in agenda. (org-columns-edit-value): Fixed bug with editing values from agenda column view. (org-columns-redo): Also redo the agenda itself. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-columns-remove-prefix-from-item): New option. * org-colview.el (org-agenda-columns-cleanup-item): New function. * org-exp.el (org-export-ascii-preprocess): Renamed from `org-export-ascii-clean-string'. (org-export-kill-licensed-text) (org-export-define-heading-targets) (org-export-handle-invisible-targets) (org-export-target-internal-links) (org-export-remove-or-extract-drawers) (org-export-remove-archived-trees) (org-export-protect-quoted-subtrees) (org-export-protect-verbatim, org-export-protect-examples) (org-export-select-backend-specific-text) (org-export-mark-blockquote-and-verse) (org-export-remove-comment-blocks-and-subtrees) (org-export-handle-comments, org-export-mark-radio-links) (org-export-remove-special-table-lines) (org-export-normalize-links) (org-export-concatenate-multiline-links) (org-export-concatenate-multiline-emphasis): New functions, obtained from spliiting the export preprocessor. * org-table.el (org-table-recalculate): Improve error message if the row number is invalid. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-archive.el (org-archive-save-context-info): Fix bugs in customization setup and docstring. * org-exp.el (org-export-html-style): Changed the size of in the <pre> element to 90%. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-find-src-example-start): Function removed. (org-edit-src-find-region-and-lang): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-edit-src-exit): New function. (org-exit-edit-mode): New minor mode. * org-exp.el (org-export-preprocess-string): Fix bug with removing comment-like lines from protected examples. * org.el (org-edit-src-example, org-find-src-example-start) (org-protect-source-example, org-edit-special): New functions. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-publish.el (org-publish-project-alist): Fix typo in docstring. (org-publish-project-alist): Handle :index-title property. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-export-latex.el (org-export-as-latex): Make sure region bounds are correct. Parse subtree properties relating to export. * org-exp.el (org-export-add-options-to-plist): New function. (org-infile-export-plist): Use `org-export-add-options-to-plist'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-default-properties): Add EXPORT_FILE_NAME and EXPORT_TITLE. * org-exp.el (org-export-get-title-from-subtree) (org-export-as-ascii, org-export-as-html): Make sure the original region-beginning and region-end are used, even after moving point. (org-export-get-title-from-subtree): Also try the EXPORT_TITLE property. * org-remember.el (org-remember-last-stored-marker): New variable. (org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'. (org-remember-handler): Also use marker to remember last-stored position. * org.el (org-goto-marker-or-bmk): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-file-properties): Renamed from `org-local-properties'. (org-scan-tags): Take file tags into account. (org-tags-match-list-sublevels): Default changed to t. * org-exp.el (org-export-as-html): Close paragraph after a footnote. * org.el (org-update-parent-todo-statistics): New function. * org-exp.el (org-icalendar-store-UID): New option. (org-icalendar-force-UID): Option removed. (org-print-icalendar-entries): IMplement UIDs. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-mhe.el (org-mhe-follow-link): Fix bug in mhe searches. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-faces.el (org-column): Document how this face is being used and why sometimes the background faces shine through. * org-mhe.el (org-mhe-follow-link): Improve handling of searches. * org-publish.el (org-publish-attachment): Create publishing directory if it does not yet exist. * org-table.el (org-calc-default-modes): Change default number format to (float 8). * org.el (org-olpath-completing-read): New function. (org-time-clocksum-format): New option. (org-minutes-to-hh:mm-string): Use `org-time-clocksum-format'. * org-clock.el (org-clock-display, org-clock-out) (org-update-mode-line): Use `org-time-clocksum-format'. * org-colview-xemacs.el (org-columns-number-to-string): Use `org-time-clocksum-format'. * org-colview.el (org-columns-number-to-string): Use `org-time-clocksum-format'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-id.el: New file, move from contrib to core. * org-exp.el (org-icalendar-force-UID): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-print-icalendar-entries): Make sure DTEND is shifted by one day if theere is a date range without an end time. * org.el (org-try-structure-completion): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-font-lock-defaults): Improve fontification of description lists. (org-insert-item): Handle description lists. (org-adaptive-fill-function): Improve auto indentation in description lists. * org-exp.el (org-export-as-html, org-export-preprocess-string): Implement VERSE environment. (org-export-preprocess-string): Implement the COMMENT environment. * org-export-latex.el (org-export-latex-preprocess): Implement VERSE environment. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-jsinfo.el (org-infojs-opts-table): Add entry for FIXED_TOC option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-table.el (orgtbl-to-tsv, orgtbl-to-csv): New functions. * org.el (org-quote-csv-field): New functions. * org-table.el (org-table-export-default-format): Remove :splice from default format, we get the same effect by not specifying :tstart and :tend. (org-table-export): Improve setup, distinguish better between interactive and non-interactive use, allow specifying the format on the fly, better protection against wrong file names. (orgtbl-to-generic): Fix documentation. Do not require :tstart and :tend when :splice is omitted. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-select-task): Make sure the selection letters are 1-9 and A-Z, no special characters. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-htmlize): New group. (org-export-htmlize-output-type) (org-export-htmlize-css-font-prefix): New options. (org-export-htmlize-region-for-paste): New function. (org-export-htmlize-generate-css): New command. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-visibility-according-to-property): New function. (org-ctrl-c-ctrl-c): Do not restart org-mode, just get the options and compute the regular expressions, and update font-lock. (org-property-re): Allow a dash in property names. * org-archive.el (org-extract-archive-file): Insert the file name without the path into the format, to allow the location format to contain a subdirectory. * org-agenda.el (org-agenda-post-command-hook): If point is at end of buffer, and the `org-agenda-type' property undefined, use the value from the character before. * org.el (org-add-planning-info): Don't let indentation for would-be timestamp become extra whitespace at the end of headline. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-remove-double-quotes, org-file-contents): New functions. * org-exp.el (org-infile-export-plist): Also parse the contents of #+SETUPFILE files, recursively. * org.el (org-set-regexps-and-options): Also parse the contents of #+SETUPFILE files, recursively. * org-exp.el (org-export-handle-include-files): New function. (org-export-preprocess-string): Call `org-export-handle-include-files'. * org.el (org-delete-property-globally) (org-delete-property, org-set-property): Ignore case during completion. (org-set-property): Use `org-completing-read' instead of `completing-read'. * org.el (org-complete-expand-structure-template): New, experimental function. (org-structure-template-alist): New, experimental option. (org-complete): Call `org-complete-expand-structure-template'. 2008-06-17 Bastien Guerry <bzg@altern.org> * org-export-latex.el (org-export-latex-preprocess): Added support for blockquotes. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-read-date-analyze): Catch the case where only a weekday is given. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-font-lock-defaults): Make the description tag bold. * org-exp.el (org-export-as-html, org-close-li): Implement description lists. 2008-06-17 Jason Riedy <jason@acm.org> * org-table.el (*orgtbl-default-fmt*): New variable. (orgtbl-format-line): Use the value of *orgtbl-default-fmt* when there is no other fmt available. (orgtbl-to-generic): Allow an explicitly nil :tstart or :tend to suppress the appropriate string. (orgtbl-to-orgtbl): New function for translating to another orgtbl table. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-read-date-analyze): "." as an alias for "+0" in read date. * org-clock.el (org-clock-save-markers-for-cut-and-paste): New function. * org-agenda.el (org-agenda-save-markers-for-cut-and-paste): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-find-position): Don't include notes into clock drawer. * org-archive.el (org-archive-subtree): No longer remove an extra line after cutting the subtree. `org-cut-subtree' already takes care of this. * org-remember.el (org-remember-handler): Only kill the target buffer if it does not contain the running clock. * org.el (org-markers-to-move): New variable. (org-save-markers-in-region, org-check-and-save-marker) (org-reinstall-markers-in-region): New function. (org-move-subtree-down, org-copy-subtree): Remember relative marker positions before cutting. (org-move-subtree-down, org-paste-subtree): Restore relative marker positions after pasting. * org-remember.el (org-remember-clock-out-on-exit): New option. (org-remember-finalize): Clock out only if the setting in `org-remember-clock-out-on-exit' requires it. (org-remember-handler): Do the cleanup in the buffer, to make sure that the clock marker remains in tact. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-goto): Widen buffer if necessary. (org-clock-in): Make sure that also tasks outside the narrowed region will be clocked in correctly. (org-clock-insert-selection-line): Widen the buffer so that we can find the correct task heading. * org.el (org-base-buffer): New function. * org-exp.el (org-icalendar-cleanup-string): Make sure '," and ";" are escaped. (org-print-icalendar-entries): Also apply `org-icalendar-cleanup-string' to the headline, not only to the summary property. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-preprocess-hook): New hook. (org-export-preprocess-string): Call `org-export-preprocess-hook'. * org.el (org-font-lock-hook): New variable. (org-font-lock-hook): New function. (org-set-font-lock-defaults): Call `org-font-lock-hook'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.texi: Modify license to no longer include back- and front cover matters. (Using the mapping API): New section. (Agenda column view): New section. (Moving subtrees): Document archiving to the archive sibling. (Agenda commands): Document columns view in the agenda. (Using the property API): Document the API for multi-valued properties.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 17 Jun 2008 15:22:00 +0000
parents a678c02d0c40
children 19a1d523548c
files doc/misc/ChangeLog doc/misc/org.texi etc/refcards/orgcard.tex lisp/org/ChangeLog lisp/org/org-agenda.el lisp/org/org-archive.el lisp/org/org-bbdb.el lisp/org/org-bibtex.el lisp/org/org-clock.el lisp/org/org-colview.el lisp/org/org-compat.el lisp/org/org-exp.el lisp/org/org-export-latex.el lisp/org/org-faces.el lisp/org/org-gnus.el lisp/org/org-info.el lisp/org/org-irc.el lisp/org/org-jsinfo.el lisp/org/org-mac-message.el lisp/org/org-macs.el lisp/org/org-mew.el lisp/org/org-mhe.el lisp/org/org-mouse.el lisp/org/org-publish.el lisp/org/org-remember.el lisp/org/org-rmail.el lisp/org/org-table.el lisp/org/org-vm.el lisp/org/org-wl.el lisp/org/org.el
diffstat 30 files changed, 4261 insertions(+), 1436 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/ChangeLog	Tue Jun 17 11:28:06 2008 +0000
+++ b/doc/misc/ChangeLog	Tue Jun 17 15:22:00 2008 +0000
@@ -1,3 +1,21 @@
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.texi: Modify license to no longer include back- and front
+	cover matters.
+	(Using the mapping API): New section.
+	(Agenda column view): New section.
+	(Moving subtrees): Document archiving to the archive
+	sibling.
+	(Agenda commands): Document columns view in the agenda.
+	(Using the property API): Document the API for
+	multi-valued properties.
+
+2008-06-17  Jason Riedy  <jason@acm.org>
+
+	* org.texi (A LaTeX example): Note that fmt may be a one-argument
+	function, and efmt may be a two-argument function.
+	(Radio tables): Document multiple destinations.
+
 2008-06-16  Glenn Morris  <rgm@gnu.org>
 
 	* epa.texi, erc.texi, pgg.texi, remember.texi, sasl.texi, url.texi:
--- a/doc/misc/org.texi	Tue Jun 17 11:28:06 2008 +0000
+++ b/doc/misc/org.texi	Tue Jun 17 15:22:00 2008 +0000
@@ -3,8 +3,8 @@
 @setfilename ../../info/org
 @settitle The Org Manual
 
-@set VERSION 6.02b
-@set DATE April 2008
+@set VERSION 6.05a
+@set DATE June 2008
 
 @dircategory Emacs
 @direntry
@@ -42,9 +42,9 @@
 under the terms of the GNU Free Documentation License, Version 1.2 or
 any later version published by the Free Software Foundation; with no
 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
-and with the Back-Cover Texts as in (a) below.  A copy of the
-license is included in the section entitled ``GNU Free Documentation
-License'' in the Emacs manual.
+and with the Back-Cover Texts as in (a) below.    A copy of the
+ license is included in the section entitled ``GNU Free Documentation
+-License.''
 
 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
 modify this GNU manual.  Buying copies from the FSF supports it in
@@ -94,7 +94,8 @@
 * Exporting::                   Sharing and publishing of notes
 * Publishing::                  Create a web site of linked Org files
 * Miscellaneous::               All the rest which did not fit elsewhere
-* Extensions and Hacking::      It is possible to write add-on code
+* Extensions::                 
+* Hacking::                     
 * History and Acknowledgments::  How Org came into being
 * Main Index::                  An index of Org's concepts and features
 * Key Index::                   Key bindings and where they are described
@@ -279,16 +280,35 @@
 
 Exporting
 
+* Markup rules::                Which structures are recognized?
+* Export options::              Per-file export settings
+* The export dispatcher::       How to access exporter commands
 * ASCII export::                Exporting to plain ASCII
 * HTML export::                 Exporting to HTML
 * LaTeX export::                Exporting to LaTeX
 * XOXO export::                 Exporting to XOXO
 * iCalendar export::            Exporting in iCalendar format
-* Text interpretation::         How the exporter looks at the file
+
+Markup rules
+
+* Document title::              How the document title is determined
+* Headings and sections::       The main structure of the exported document
+* Table of contents::           If, where, how to create a table of contents
+* Initial text::                Text before the first headline
+* Lists::                       Plain lists are exported
+* Paragraphs::                  What determines beginning and ending
+* Literal examples::            Source code and other examples
+* Include files::               Include the contents of a file during export
+* Tables exported::             Tables are exported richly
+* Footnotes::                   Numbers like [1]
+* Emphasis and monospace::      To bold or not to bold
+* TeX macros and LaTeX fragments::  Create special, rich export.
+* Horizontal rules::            A line across the page
+* Comment lines::               Some lines will not be exported
 
 HTML export
 
-* HTML Export commands::        How to invoke LaTeX export
+* HTML Export commands::        How to invoke HTML export
 * Quoting HTML tags::           Using direct HTML in Org mode
 * Links::                       Transformation of links for HTML
 * Images::                      How to include images
@@ -301,15 +321,6 @@
 * Quoting LaTeX code::          Incorporating literal LaTeX code
 * Sectioning structure::        Changing sectioning in LaTeX output
 
-Text interpretation by the exporter
-
-* Comment lines::               Some lines will not be exported
-* Initial text::                Text before the first headline
-* Footnotes::                   Numbers like [1]
-* Quoted examples::             Inserting quoted chunks of text
-* Enhancing text::              Subscripts, symbols and more
-* Export options::              How to influence the export settings
-
 Publishing
 
 * Configuration::               Defining projects
@@ -347,14 +358,19 @@
 * Cooperation::                 Packages Org cooperates with
 * Conflicts::                   Packages that lead to conflicts
 
-Extensions, Hooks and Hacking
-
-* Extensions::                  Existing 3rd-party extensions
+Extensions
+
+* Extensions in the contrib directory::  These come with the Org distro
+* Other extensions::            These you have to find on the web.
+
+Hacking
+
 * Adding hyperlink types::      New custom link types
 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
 * Dynamic blocks::              Automatically filled blocks
 * Special agenda views::        Customized views
 * Using the property API::      Writing programs that use entry properties
+* Using the mapping API::       Mapping over all or selected entries
 
 Tables and lists in arbitrary syntax
 
@@ -561,9 +577,10 @@
 @cindex maintainer
 @cindex author
 
-If you find problems with Org, or if you have questions, remarks,
-or ideas about it, please contact the maintainer @value{MAINTAINER} at
-@value{MAINTAINEREMAIL}.
+If you find problems with Org, or if you have questions, remarks, or ideas
+about it, please mail to the Org mailing list @code{emacs-orgmode@@gnu.org}.
+If you are not a member of the mailing list, your mail will be reviewed by a
+moderator and then passed through to the list.
 
 For bug reports, please provide as much information as possible,
 including the version information of Emacs (@kbd{C-h v emacs-version
@@ -792,6 +809,19 @@
 #+STARTUP: showall
 @end example
 
+@noindent
+Forthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
+and Columns}) will get their visibility adapted accordingly.  Allowed values
+for this property are @code{folded}, @code{children}, @code{content}, and
+@code{all}.
+@table @kbd
+@kindex C-u C-u @key{TAB}
+@item C-u C-u @key{TAB}
+Switch back to the startup visibility of the buffer, i.e. whatever is
+requested by startup options and @samp{VISIBILITY} properties in individual
+entries.
+@end table
+
 @node Motion, Structure editing, Visibility cycling, Document Structure
 @section Motion
 @cindex motion, between headlines
@@ -915,6 +945,12 @@
 also supply your own function to extract the sorting key.  With a @kbd{C-u}
 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
 duplicate entries will also be removed.
+@kindex C-x n s
+@item C-x n s
+Narrow buffer to current subtree.
+@kindex C-x n w
+@item C-x n w
+Widen buffer to remove a narrowing.
 @kindex C-c *
 @item C-c *
 Turn a normal line or plain list item into a headline (so that it
@@ -1064,14 +1100,14 @@
 @cindex folding, sparse trees
 @cindex occur, command
 
-An important feature of Org mode is the ability to construct
-@emph{sparse trees} for selected information in an outline tree, so that
-the entire document is folded as much as possible, but the selected
-information is made visible along with the headline structure above
-it@footnote{See also the variables @code{org-show-hierarchy-above},
-@code{org-show-following-heading}, and @code{org-show-siblings} for
-detailed control on how much context is shown around each match.}.  Just
-try it out and you will see immediately how it works.
+An important feature of Org mode is the ability to construct @emph{sparse
+trees} for selected information in an outline tree, so that the entire
+document is folded as much as possible, but the selected information is made
+visible along with the headline structure above it@footnote{See also the
+variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
+@code{org-show-siblings}, and @code{org-show-entry-below} for detailed
+control on how much context is shown around each match.}.  Just try it out
+and you will see immediately how it works.
 
 Org mode contains several commands creating such trees, all these
 commands can be accessed through a dispatcher:
@@ -1082,15 +1118,16 @@
 This prompts for an extra key to select a sparse-tree creating command.
 @kindex C-c / r
 @item C-c / r
-Occur.  Prompts for a regexp and shows a sparse tree with all matches.
-If the match is in a headline, the headline is made visible.  If the
-match is in the body of an entry, headline and body are made visible.
-In order to provide minimal context, also the full hierarchy of
-headlines above the match is shown, as well as the headline following
-the match.  Each match is also highlighted; the highlights disappear
-when the buffer is changed by an editing command, or by pressing
-@kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
-highlights are kept, so several calls to this command can be stacked.
+Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
+the match is in a headline, the headline is made visible.  If the match is in
+the body of an entry, headline and body are made visible.  In order to
+provide minimal context, also the full hierarchy of headlines above the match
+is shown, as well as the headline following the match.  Each match is also
+highlighted; the highlights disappear when the buffer is changed by an
+editing command@footnote{depending on the option
+@code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
+When called with a @kbd{C-u} prefix argument, previous highlights are kept,
+so several calls to this command can be stacked.
 @end table
 
 @noindent
@@ -1133,24 +1170,34 @@
 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
 and the HTML exporter (@pxref{Exporting}) parses and formats them.
 
-Org knows ordered and unordered lists.  Unordered list items start
-with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
-bullet, lines must be indented or they will be seen as top-level
-headlines.  Also, when you are hiding leading stars to get a clean
-outline view, plain list items starting with a star are visually
-indistinguishable from true headlines.  In short: even though @samp{*}
-is supported, it may be better to not use it for plain list items.} as
-bullets.  Ordered list items start with a numeral followed by either a
-period or a right parenthesis, such as @samp{1.} or @samp{1)}.  Items
-belonging to the same list must have the same indentation on the first
-line.  In particular, if an ordered list reaches number @samp{10.}, then
-the 2--digit numbers must be written left-aligned with the other numbers
-in the list.  Indentation also determines the end of a list item.  It
-ends before the next line that is indented like the bullet/number, or
-less.  Empty lines are part of the previous item, so you can have
-several paragraphs in one item.  If you would like an empty line to
-terminate all currently open plain lists, configure the variable
-@code{org-empty-line-terminates-plain-lists}.  Here is an example:
+Org knows ordered lists, unordered lists, and description lists.
+@itemize @bullet
+@item
+@emph{Unordered} list items start with @samp{-}, @samp{+}, or
+@samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
+they will be seen as top-level headlines.  Also, when you are hiding leading
+stars to get a clean outline view, plain list items starting with a star are
+visually indistinguishable from true headlines.  In short: even though
+@samp{*} is supported, it may be better to not use it for plain list items.}
+as bullets.
+@item
+@emph{Ordered} list items start with a numeral followed by either a period or
+a right parenthesis, such as @samp{1.} or @samp{1)}.
+@item
+@emph{Description} list items are like unordered list items, but contain the
+separator @samp{ :: } to separate the description @emph{term} from the
+desciption.
+@end itemize
+
+Items belonging to the same list must have the same indentation on the first
+line.  In particular, if an ordered list reaches number @samp{10.}, then the
+2--digit numbers must be written left-aligned with the other numbers in the
+list.  Indentation also determines the end of a list item.  It ends before
+the next line that is indented like the bullet/number, or less.  Empty lines
+are part of the previous item, so you can have several paragraphs in one
+item.  If you would like an empty line to terminate all currently open plain
+lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
+Here is an example:
 
 @example
 @group
@@ -1164,6 +1211,10 @@
        - on DVD only
       He makes a really funny face when it happens.
    But in the end, not individual scenes matter but the film as a whole.
+   Important actors in this film are:
+   - @b{Elijah Wood} :: He plays the Frodo
+   - @b{Sean Austin} :: He plays the Sam, Frodos friend.  I still remember
+     him very well from his role as Mikey Walsh a in the Goonies.
 @end group
 @end example
 
@@ -1171,7 +1222,8 @@
 deal with them correctly@footnote{Org only changes the filling
 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
-@code{(require 'filladapt)}}.
+@code{(require 'filladapt)}}, and by exporting them properly
+(@pxref{Exporting}).
 
 The following commands act on items when the cursor is in the first line
 of an item (the line with the bullet or number).
@@ -1265,7 +1317,8 @@
 hide and show the entry, but keep the drawer collapsed to a single line.
 In order to look inside the drawer, you need to move the cursor to the
 drawer line and press @key{TAB} there.  Org mode uses a drawer for
-storing properties (@pxref{Properties and Columns}).
+storing properties (@pxref{Properties and Columns}), and another one for
+storing clock times (@pxref{Clocking work time}).
 
 @node Orgstruct mode,  , Drawers, Document Structure
 @section The Orgstruct minor mode
@@ -1520,7 +1573,10 @@
 used to export the file can be configured in the variable
 @code{org-table-export-default-format}.  You may also use properties
 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
-name and the format for table export in a subtree.
+name and the format for table export in a subtree.  Org supports quite
+general formats for exported tables.  The exporter format is the same as the
+format used by Orgtbl radio tables, see @ref{Translator functions} for a
+detailed description.
 @end table
 
 If you don't like the automatic table editor because it gets in your
@@ -2656,8 +2712,6 @@
 an implementation example.  Search for @samp{BibTeX links} in the source
 file.
 
-
-
 @node TODO Items, Tags, Hyperlinks, Top
 @chapter TODO Items
 @cindex TODO items
@@ -3136,12 +3190,37 @@
 @cindex tasks, breaking down
 
 It is often advisable to break down large tasks into smaller, manageable
-subtasks.  You can do this by creating an outline tree below a TODO
-item, with detailed subtasks on the tree@footnote{To keep subtasks out
-of the global TODO list, see the
-@code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
-of checkboxes to identify (a hierarchy of) a large number of subtasks
-(@pxref{Checkboxes}).
+subtasks.  You can do this by creating an outline tree below a TODO item,
+with detailed subtasks on the tree@footnote{To keep subtasks out of the
+global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
+the overview over the fraction of subtasks that are already completed, insert
+either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
+be updates each time the todo status of a child changes.  For example:
+
+@example
+* Organize Party [33%]
+** TODO Call people [1/2]
+*** TODO Peter
+*** DONE Sarah
+** TODO Buy food
+** DONE Talk to neighbor
+@end example
+
+If you would like a TODO entry to automatically change to DONE when all
+chilrden are done, you can use the following setup:
+
+@example
+(defun org-summary-todo (n-done n-not-done)
+  "Switch entry to DONE when all subentries are done, to TODO otherwise."
+  (let (org-log-done org-log-states)   ; turn off logging
+    (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
+
+(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
+@end example
+
+
+Another possibility is the use of checkboxes to identify (a hierarchy of) a
+large number of subtasks (@pxref{Checkboxes}).
 
 
 @node Checkboxes,  , Breaking down tasks, TODO Items
@@ -3268,14 +3347,24 @@
 @noindent
 the final heading will have the tags @samp{:work:}, @samp{:boss:},
 @samp{:notes:}, and @samp{:action:} even though the final heading is not
-explicitly marked with those tags.  When executing tag searches and
-Org mode finds that a certain headline matches the search criterion, it
-will not check any sublevel headline, assuming that these also match and
-that the list of matches could become very long because of that.  If you
-do want the sublevels be tested and listed as well, you may set the
-variable @code{org-tags-match-list-sublevels}.  To limit tag inheritance
-to specific tags, or to turn it off entirely, use the variable
-@code{org-use-tag-inheritance}.
+explicitly marked with those tags.  You can also set tags that all entries in
+a file should inherit as if these tags would be defined in a hypothetical
+level zero that surounds the entire file.
+
+@example
+#+FILETAGS: :Peter:Boss:Secret:
+@end example
+
+@noindent
+To limit tag inheritance to specific tags, or to turn it off entirely, use
+the variable @code{org-use-tag-inheritance}.
+
+When a headline matches during a tags search while tag inheritance is turned
+on, all the sublevels in the same tree will match as well@footnote{This is
+only true if the the search does not involve more complex tests including
+properties (@pxref{Property searches}).}.  The list of matches may then
+become very long.  If you only want to see the first tags match in a subtree,
+configure the variable @code{org-tags-match-list-sublevels}.
 
 @node Setting tags, Tag searches, Tag inheritance, Tags
 @section Setting tags
@@ -3886,6 +3975,8 @@
 @item  S-@key{left}/@key{right}
 Switch to the next/previous allowed value of the field.  For this, you
 have to have specified allowed values for a property.
+@item 1..9,0
+Directly select the nth allowed value, @kbd{0} selects the 10th value.
 @kindex n
 @kindex p
 @itemx  n / p
@@ -3930,6 +4021,7 @@
 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
 of this block looks like this:
 
+@cindex #+BEGIN: columnview
 @example
 * The column view
 #+BEGIN: columnview :hlines 1 :id "label"
@@ -3948,8 +4040,10 @@
 @example
 local     @r{use the tree in which the capture block is located}
 global    @r{make a global view, including all headings in the file}
-"label"   @r{call column view in the tree that has and @code{:ID:}}
-          @r{property with the value @i{label}}
+"label"   @r{call column view in the tree that has an @code{:ID:}}
+          @r{property with the value @i{label}.  You can use}
+          @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
+          @r{the current entry and copy it to the kill-ring.}
 @end example
 @item :hlines
 When @code{t}, insert a hline after every line.  When a number N, insert
@@ -4215,6 +4309,8 @@
 the nth such day.  E.g.
 
 @example
++0            --> today
+.             --> today
 +4d           --> four days from today
 +4            --> same as above
 +2w           --> two weeks from today
@@ -4411,6 +4507,15 @@
 happen in the line directly following the headline.  Any CLOSED
 timestamp will be removed.  When called with a prefix argument, remove
 the scheduling date from the entry.
+@c
+@kindex C-c C-x C-k
+@kindex k a
+@kindex k s
+@item C-c C-x C-k
+Mark the current entry for agenda action.  After you have marked the entry
+like this, you can open the agenda or the calendar to find an appropriate
+date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
+schedule the marked item.
 @end table
 
 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
@@ -4545,6 +4650,7 @@
 at an existing clock table, just update it.  When called with a prefix
 argument, jump to the first clock report in the current document and
 update it.
+@cindex #+BEGIN: clocktable
 @example
 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
 #+END: clocktable
@@ -4620,7 +4726,7 @@
 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
 worked on or closed during a day.
 
-@node Effort estimates
+@node Effort estimates,  , Clocking work time, Dates and Times
 @section Effort estimates
 @cindex Effort estimates
 
@@ -4655,7 +4761,7 @@
 If you switch to column view in the daily/weekly agenda, the effort column
 will summarize the estimated work effort for each day@footnote{Please note
 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
-column view}.}, and you can use this to find space in your schedule.  To get
+column view}).}, and you can use this to find space in your schedule.  To get
 an overview of the entire part of the day that is committed, you can set the
 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
 appointments on a day that take place over a specified time interval will
@@ -4705,6 +4811,11 @@
 use two prefix arguments, Org jumps to the location where the last
 remember note was stored.
 
+You can also call @code{org-remember} in a special way from the agenda,
+using the @kbd{k r} key combination.  With this access, any time stamps
+inserted by the selected remember template (see below) will default to
+the cursor date in the agenda, rather than to the current date.
+
 @node Remember templates, Storing notes, Setting up Remember, Remember
 @section Remember templates
 @cindex templates, for remember
@@ -4724,26 +4835,29 @@
 
 @noindent In these entries, the first string is just a name, and the
 character specifies how to select the template.  It is useful if the
-character is also the first letter of the name.  The next string
-specifies the template.  Two more (optional) strings give the file in
-which, and the headline under which the new note should be stored.  The
-file (if not present or @code{nil}) defaults to
-@code{org-default-notes-file}, the heading to
-@code{org-remember-default-headline}.  If the file name is not an
-absolute path, it will be interpreted relative to @code{org-directory}.
-
-An optional sixth element specifies the contexts in which the user can
-select the template.  This element can be either a list of major modes
-or a function.  @code{org-remember} will first check whether the function
-returns @code{t} or if we are in any of the listed major mode, and select
-the template accordingly.
+character is also the first letter of the name.  The next string specifies
+the template.  Two more (optional) strings give the file in which, and the
+headline under which the new note should be stored.  The file (if not present
+or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
+@code{org-remember-default-headline}.  If the file name is not an absolute
+path, it will be interpreted relative to @code{org-directory}.  The heading
+can also be the symbols @code{top} or @code{bottom} to send note as level 1
+entries to the beginning or end of the file, respectively.
+
+An optional sixth element specifies the contexts in which the user can select
+the template.  This element can be a list of major modes or a function.
+@code{org-remember} will first check whether the function returns @code{t} or
+if we are in any of the listed major mode, and exclude templates fo which
+this condition is not fulfilled.  Templates that do not specify this element
+at all, or that use @code{nil} or @code{t} as a value will always be
+selectable.
 
 So for example:
 
 @example
 (setq org-remember-templates
  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
-   ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" my-check)
+   ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
 @end example
 
@@ -4752,8 +4866,8 @@
 available when the function @code{my-check} returns @code{t}.  The third
 template will be proposed in any context.
 
-When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
-something, org will prompt for a key to select the template (if you have
+When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
+something, Org will prompt for a key to select the template (if you have
 more than one template) and then prepare the buffer like
 @example
 * TODO
@@ -4768,16 +4882,16 @@
             @r{You may specify a default value and a completion table with}
             @r{%^@{prompt|default|completion2|completion3...@}}
             @r{The arrow keys access a prompt-specific history.}
+%a          @r{annotation, normally the link created with @code{org-store-link}}
+%A          @r{like @code{%a}, but prompt for the description part}
+%i          @r{initial content, the region when remember is called with C-u.}
+            @r{The entire text will be indented like @code{%i} itself.}
 %t          @r{time stamp, date only}
 %T          @r{time stamp with date and time}
 %u, %U      @r{like the above, but inactive time stamps}
 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
             @r{You may define a prompt like @code{%^@{Birthday@}t}}
 %n          @r{user name (taken from @code{user-full-name})}
-%a          @r{annotation, normally the link created with @code{org-store-link}}
-%A          @r{like @code{%a}, but prompt for the description part}
-%i          @r{initial content, the region when remember is called with C-u.}
-            @r{The entire text will be indented like @code{%i} itself.}
 %c          @r{Current kill ring head.}
 %x          @r{Content of the X clipboard.}
 %^C         @r{Interactive selection of which kill or clip to use.}
@@ -4789,6 +4903,7 @@
 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
 %!          @r{immediately store note after completing the template}
             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
+%&          @r{jump to target location immediately after storing note}
 @end example
 
 @noindent
@@ -4828,14 +4943,20 @@
 @node Storing notes, Refiling notes, Remember templates, Remember
 @section Storing notes
 
-When you are finished preparing a note with @i{remember}, you have to
-press @kbd{C-c C-c} to file the note away.  The handler will store the
-note in the file and under the headline specified in the template, or it
-will use the default file and headlines.  The window configuration will
-be restored, sending you back to the working context before the call to
-@code{remember}.  To re-use the location found during the last call to
-@code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c},
-i.e. specify a double prefix argument to @kbd{C-c C-c}.
+When you are finished preparing a note with @i{remember}, you have to press
+@kbd{C-c C-c} to file the note away.  If you have started the clock in the
+remember buffer, you will first be asked if you want to clock out
+now@footnote{To avoid this query, configure the variable
+@code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
+will continue to run after the note is filed away.
+
+The handler will then store the note in the file and under the headline
+specified in the template, or it will use the default file and headlines.
+The window configuration will be restored, sending you back to the working
+context before the call to @code{remember}.  To re-use the location found
+during the last call to @code{remember}, exit the remember buffer with
+@kbd{C-u C-u C-c C-c}, i.e. specify a double prefix argument to @kbd{C-c
+C-c}.
 
 If you want to store the note directly to a different place, use
 @kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
@@ -4898,7 +5019,9 @@
 subitem.@* By default, all level 1 headlines in the current buffer are
 considered to be targets, but you can have more complex definitions
 across a number of files.  See the variable @code{org-refile-targets}
-for details.
+for details.  If you would like to select a location via a file-pathlike
+completion along the outline path, see the variable
+@code{org-refile-use-outline-path}.
 @kindex C-u C-c C-w
 @item C-u C-c C-w
 Use the refile interface to jump to a heading.
@@ -5696,13 +5819,13 @@
 @c
 @kindex A
 @item A
-Move the subtree correspoding to the current entry to its @emph{Archive
+Move the subtree corresponding to the current entry to its @emph{Archive
 Sibling}.
 @c
 @kindex $
 @item $
 Archive the subtree corresponding to the current headline.  This means the
-entry will be moved to the configured archive locatin, most likely a
+entry will be moved to the configured archive location, most likely a
 different file.
 @c
 @kindex T
@@ -5747,6 +5870,21 @@
 @item C-c C-d
 Set a deadline for this item.
 @c
+@kindex k
+@item k
+Agenda actions, to set dates for selected items to the cursor date.
+This command also works in the calendar!  The command prompts for an
+additonal key:
+@example
+m   @r{Mark the entry at point for action.  You can also make entries}
+    @r{in Org files with @kbd{C-c C-x C-k}.}
+d   @r{Set the deadline of the marked entry to the date at point.}
+s   @r{Schedule the marked entry at the date at point.}
+r   @r{Call @code{org-remember} with the cursor date as default date.}
+@end example
+Press @kbd{r} afterwards to refresh the agenda and see the effect of the
+command.
+@c
 @kindex S-@key{right}
 @item S-@key{right}
 Change the time stamp associated with the current line by one day into the
@@ -6554,8 +6692,425 @@
 Org mode can also produce extracts in the iCalendar format.  Currently
 Org mode only supports export, not import of these different formats.
 
-When exporting, Org mode uses special conventions to enrich the output
-produced.  @xref{Text interpretation}, for more details.
+@menu
+* Markup rules::                Which structures are recognized?
+* Export options::              Per-file export settings
+* The export dispatcher::       How to access exporter commands
+* ASCII export::                Exporting to plain ASCII
+* HTML export::                 Exporting to HTML
+* LaTeX export::                Exporting to LaTeX
+* XOXO export::                 Exporting to XOXO
+* iCalendar export::            Exporting in iCalendar format
+@end menu
+
+@node Markup rules, Export options, Exporting, Exporting
+@section Markup rules
+
+When exporting Org mode documents,  the exporter tries to reflect the
+structure of the document as accurately as possible in the back-end.  Since
+export targets like HTML or La@TeX{} allow much richer formatting, Org mode
+has rules how to prepare text for rich export.  This section summarizes the
+markup rule used in an Org mode buffer.
+
+@menu
+* Document title::              How the document title is determined
+* Headings and sections::       The main structure of the exported document
+* Table of contents::           If, where, how to create a table of contents
+* Initial text::                Text before the first headline
+* Lists::                       Plain lists are exported
+* Paragraphs::                  What determines beginning and ending
+* Literal examples::            Source code and other examples
+* Include files::               Include the contents of a file during export
+* Tables exported::             Tables are exported richly
+* Footnotes::                   Numbers like [1]
+* Emphasis and monospace::      To bold or not to bold
+* TeX macros and LaTeX fragments::  Create special, rich export.
+* Horizontal rules::            A line across the page
+* Comment lines::               Some lines will not be exported
+@end menu
+
+@node Document title, Headings and sections, Markup rules, Markup rules
+@subheading Document title
+@cindex document title, markup rules
+
+@noindent
+The title of the exported document is taken from the special line
+
+@example
+#+TITLE: This is the title of the document
+@end example
+
+@noindent
+If this line does not exist, the title is derived from the first non-empty,
+non-comment line in the buffer.  If no such line exists, or if you have
+turned off exporting of the text before the first headline (see below), the
+title will be the file name without extension.
+
+If you are exporting only a subtree by marking is as the region, the heading
+of the subtree will become the title of the document.  If the subtree has a
+property @code{EXPORT_TITLE}, that will take precedence.
+
+@node Headings and sections, Table of contents, Document title, Markup rules
+@subheading Headings and sections
+@cindex headings and sections, markup rules
+
+The outline structure of the document as described in @ref{Document
+Structure} forms the basis for defining sections of the exported document.
+However, since the outline structure is also used for (for example) lists of
+tasks, only the first three outline levels will be used as headings.  Deeper
+levels will become itemized lists.  You can change the location of this
+switch, globally by setting the variable @code{org-headline-levels}, or on a
+per file basis with a line
+
+@example
+#+OPTIONS: H:4
+@end example
+
+@node Table of contents, Initial text, Headings and sections, Markup rules
+@subheading Table of contents
+@cindex table of contents, markup rules
+
+The table of contents is normally inserted directly before the first headline
+of the file.  If you would like to get it to a different location, insert the
+string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
+location.  The depth of the table of contents is by default the same as the
+number of headline levels, but you can choose a smaller number or turn off
+the table of contents entirely by configuring the variable
+@code{org-export-with-toc}, or on a per-file basis with a line like
+
+@example
+#+OPTIONS: toc:2          (only to two levels in TOC)
+#+OPTIONS: toc:nil        (no TOC at all)
+@end example
+
+@node Initial text, Lists, Table of contents, Markup rules
+@subheading Text before the first headline
+@cindex text before first headline, markup rules
+@cindex #+TEXT
+
+Org mode normally exports the text before the first headline, and even uses
+the first line as the document title.  The text will be fully marked up.  If
+you need to include literal HTML or La@TeX{} code, use the special constructs
+described below in the sections for the individual exporters.
+
+Some people like to use the space before the first headline for setup and
+internal links and therefore would like to control the exported text before
+the first headline in a different way.  You can do so by setting the variable
+@code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
+basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
+
+@noindent
+If you still want to have some text before the first headline, use the
+@code{#+TEXT} construct:
+
+@example
+#+OPTIONS: skip:t
+#+TEXT: This text will go before the *first* headline.
+#+TEXT: [TABLE-OF-CONTENTS]
+#+TEXT: This goes between the table of contents and the first headline
+@end example
+
+@node Lists, Paragraphs, Initial text, Markup rules
+@subheading Lists
+@cindex lists, markup rules
+
+Plain lists as described in @ref{Plain lists} are translated to the back-ends
+syntax for such lists.  Most back-ends support unordered, ordered, and
+description lists.
+
+@node Paragraphs, Literal examples, Lists, Markup rules
+@subheading Paragraphs, line breaks, and quoting
+@cindex paragraphs, markup rules
+
+Paragraphs are separated by at least one empty line.  If you need to enforce
+a line break within a paragraph, use @samp{\\} at the end of a line.
+
+To keep the line breaks in a region, but otherwise use normal formatting, you
+can use this construct, which can also be used to format poetry.
+
+@example
+#+BEGIN_VERSE
+Everything should be made as simple as possible,
+but not any simpler -- Albert Einstein
+#+END_VERSE
+@end example
+
+When quoting a passage from another document, it is customary to format this
+as a paragraph that is indented on both the left and the right margin.  You
+can include quotations in Org mode documents like this:
+
+@example
+#+BEGIN_QUOTE
+Everything should be made as simple as possible,
+but not any simpler -- Albert Einstein
+#+END_QUOTE
+@end example
+
+
+@node Literal examples, Include files, Paragraphs, Markup rules
+@subheading Literal examples
+@cindex literal examples, markup rules
+
+You can include literal examples that should not be subjected to
+markup.  Such examples will be typeset in monospace, so this is well suited
+for source code and similar examples.
+@cindex #+BEGIN_EXAMPLE
+
+@example
+#+BEGIN_EXAMPLE
+Some example from a text file.
+#+END_EXAMPLE
+@end example
+
+For simplicity when using small examples, you can also start the example
+lines with a colon:
+
+@example
+: Some example from a text file.
+@end example
+
+@cindex formatting source code, markup rules
+If the example is source code from a programming language, or any other text
+that can be marked up by font-lock in Emacs, you can ask for the example to
+look like the fontified Emacs buffer@footnote{Currently this works only for
+the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
+later.}.  This is done with the @samp{src} block, where you also need to
+specify the name of the major mode that should be used to fontify the
+example:
+@cindex #+BEGIN_SRC
+
+@example
+#+BEGIN_SRC emacs-lisp
+(defun org-xor (a b)
+   "Exclusive or."
+   (if a (not b) b))
+#+END_SRC
+@end example
+
+@table @kbd
+@kindex C-c '
+@item C-c '
+Edit the source code example at point in its native mode.  This works by
+switching to an indirect buffer, narrowing the buffer and switching to the
+other mode.  You need to exit by pressing @kbd{C-c '} again.
+@end table
+
+
+@node Include files, Tables exported, Literal examples, Markup rules
+@subheading Include files
+@cindex include files, markup rules
+
+During export, you can include the content of another file.  For example, to
+include your .emacs file, you could use:
+@cindex #+INCLUDE
+
+@example
+#+INCLUDE: "~/.emacs" src emacs-lisp
+@end example
+
+The optional second and third parameter are the markup (@samp{quote},
+@samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
+language for formatting the contents.  The markup is optional, if it is not
+given, the text will be assumed to be in Org mode format and will be
+processed normally.
+
+@table @kbd
+@kindex C-c '
+@item C-c '
+Visit the include file at point.
+@end table
+
+@node Tables exported, Footnotes, Include files, Markup rules
+@subheading Tables
+@cindex tables, markup rules
+
+Both the native Org mode tables (@pxref{Tables}) and tables formatted with
+the @file{table.el} package will be exported properly.  For Org mode tables,
+the lines before the first horizontal separator line will become table header
+lines.
+
+@node Footnotes, Emphasis and monospace, Tables exported, Markup rules
+@subheading Footnotes
+@cindex footnotes, markup rules
+@cindex @file{footnote.el}
+
+@kindex C-c !
+Numbers in square brackets are treated as footnote markers, and lines
+starting with such a marker are interpreted as the footnote itself.  You can
+use the Emacs package @file{footnote.el} to create footnotes@footnote{The
+@file{footnote} package uses @kbd{C-c !} to invoke its commands.  This
+binding conflicts with the Org mode command for inserting inactive time
+stamps.  You could use the variable @code{footnote-prefix} to switch
+footnotes commands to another key.  Or, if you are too used to this binding,
+you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
+to change the settings in Org.}.  For example:
+
+@example
+The Org homepage[1] now looks a lot better than it used to.
+
+[1] The link is: http://orgmode.org
+@end example
+
+@node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
+@subheading Emphasis and monospace
+
+@cindex underlined text, markup rules
+@cindex bold text, markup rules
+@cindex italic text, markup rules
+@cindex verbatim text, markup rules
+@cindex code text, markup rules
+@cindex strike-through text, markup rules
+You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
+and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
+in the code and verbatim string is not processed for Org mode specific
+syntax, it is exported verbatim.
+
+@node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
+@subheading @TeX{} macros and La@TeX{} fragments
+@cindex LaTeX fragments, markup rules
+@cindex TeX macros, markup rules
+@cindex HTML entities
+@cindex LaTeX entities
+
+A @TeX{}-like syntax is used to specify special characters.  Where possible,
+these will be transformed into the native format of the exporter back-end.
+Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
+output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
+@code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
+This applies for a large number of entities, with names taken from both HTML
+and La@TeX{}, see the variable @code{org-html-entities} for the complete
+list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
+after having types the backslash and maybe a few characters
+(@pxref{Completion}).
+
+La@TeX{} fragments are converted into images for HTML export, and they are
+written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
+
+Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
+@samp{...} are all converted into special commands creating hyphens of
+different lengths or a compact set of dots.
+
+@node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
+@subheading  Horizontal rules
+@cindex horizontal rules, markup rules
+A line consisting of only dashes, and at least 5 of them, will be
+exported as a horizontal line (@samp{<hr/>} in HTML).
+
+@node Comment lines,  , Horizontal rules, Markup rules
+@subheading Comment lines
+@cindex comment lines
+@cindex exporting, not
+
+Lines starting with @samp{#} in column zero are treated as comments and will
+never be exported.  Also entire subtrees starting with the word
+@samp{COMMENT} will never be exported.  Finally, regions surrounded by
+@samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
+
+@table @kbd
+@kindex C-c ;
+@item C-c ;
+Toggle the COMMENT keyword at the beginning of an entry.
+@end table
+
+@node Export options, The export dispatcher, Markup rules, Exporting
+@section Export options
+@cindex options, for export
+
+@cindex completion, of option keywords
+The exporter recognizes special lines in the buffer which provide
+additional information.  These lines may be put anywhere in the file.
+The whole set of lines can be inserted into the buffer with @kbd{C-c
+C-e t}.  For individual lines, a good way to make sure the keyword is
+correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
+(@pxref{Completion}).
+
+@table @kbd
+@kindex C-c C-e t
+@item C-c C-e t
+Insert template with export options, see example below.
+@end table
+
+@cindex #+TITLE:
+@cindex #+AUTHOR:
+@cindex #+DATE:
+@cindex #+EMAIL:
+@cindex #+LANGUAGE:
+@cindex #+TEXT:
+@cindex #+OPTIONS:
+@cindex #+LINK_UP:
+@cindex #+LINK_HOME:
+@example
+#+TITLE:     the title to be shown (default is the buffer name)
+#+AUTHOR:    the author (default taken from @code{user-full-name})
+#+DATE:      A date, fixed, of a format string for @code{format-time-string}
+#+EMAIL:     his/her email address (default from @code{user-mail-address})
+#+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
+#+TEXT:      Some descriptive text to be inserted at the beginning.
+#+TEXT:      Several lines may be given.
+#+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
+#+LINK_UP:   the ``up'' link of an exported page
+#+LINK_HOME: the ``home'' link of an exported page
+@end example
+
+@noindent
+The OPTIONS line is a compact@footnote{If you want to configure many options
+this way, you can use several OPTIONS lines.} form to specify export settings.  Here
+you can:
+@cindex headline levels
+@cindex section-numbers
+@cindex table of contents
+@cindex line-break preservation
+@cindex quoted HTML tags
+@cindex fixed-width sections
+@cindex tables
+@cindex @TeX{}-like syntax for sub- and superscripts
+@cindex footnotes
+@cindex special strings
+@cindex emphasized text
+@cindex @TeX{} macros
+@cindex La@TeX{} fragments
+@cindex author info, in export
+@cindex time info, in export
+@example
+H:         @r{set the number of headline levels for export}
+num:       @r{turn on/off section-numbers}
+toc:       @r{turn on/off table of contents, or set level limit (integer)}
+\n:        @r{turn on/off line-break-preservation}
+@@:         @r{turn on/off quoted HTML tags}
+::         @r{turn on/off fixed-width sections}
+|:         @r{turn on/off tables}
+^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
+           @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
+           @r{the simple @code{a_b} will be left as it is.}
+-:         @r{turn on/off conversion of special strings.}
+f:         @r{turn on/off footnotes like this[1].}
+*:         @r{turn on/off emphasized text (bold, italic, underlined)}
+TeX:       @r{turn on/off simple @TeX{} macros in plain text}
+LaTeX:     @r{turn on/off La@TeX{} fragments}
+skip:      @r{turn on/off skipping the text before the first heading}
+author:    @r{turn on/off inclusion of author name/email into exported file}
+timestamp: @r{turn on/off inclusion creation time into exported file}
+d:         @r{turn on/off inclusion of drawers}
+@end example
+
+These options take effect in both the HTML and La@TeX{} export, except
+for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
+@code{nil} for the La@TeX{} export.
+
+When exporting only a single subtree by selecting it with @kbd{C-c @@} before
+calling an export command, the subtree can overrule some of the file's export
+settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
+@code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
+
+@node The export dispatcher, ASCII export, Export options, Exporting
+@section The export dispatcher
+@cindex dispatcher, for export commands
+
+All export commands can be reached using the export dispatcher, which is a
+prefix key that prompts for an additional key specifying the command.
+Normally the entire file is exported, but if there is an active region that
+contains one outline tree, the first heading is used as document title and
+the subtrees are exported.
 
 @table @kbd
 @kindex C-c C-e
@@ -6566,6 +7121,10 @@
 @code{org-export-run-in-background} is set, Org will run the command in the
 background if that seems useful for the specific command (i.e. commands that
 write to a file).
+@kindex C-c C-e v
+@item C-c C-e v
+Like @kbd{C-c C-e}, but only export the text that is currently visible
+(i.e. not hidden by outline visibility).
 @kindex C-u C-u C-c C-e
 @item C-u C-u C-c C-e
 Call an the exporter, but reverse the setting of
@@ -6573,16 +7132,7 @@
 not set, or force processing in the current Emacs process if st.
 @end table
 
-@menu
-* ASCII export::                Exporting to plain ASCII
-* HTML export::                 Exporting to HTML
-* LaTeX export::                Exporting to LaTeX
-* XOXO export::                 Exporting to XOXO
-* iCalendar export::            Exporting in iCalendar format
-* Text interpretation::         How the exporter looks at the file
-@end menu
-
-@node ASCII export, HTML export, Exporting, Exporting
+@node ASCII export, HTML export, The export dispatcher, Exporting
 @section ASCII export
 @cindex ASCII export
 
@@ -6598,9 +7148,10 @@
 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
 will be @file{myfile.txt}.  The file will be overwritten without
 warning.  If there is an active region, only the region will be
-exported. If the selected region is a single tree, the tree head will
+exported. If the selected region is a single tree@footnote{To select the
+current subtree, use @kbd{C-c @@}.}, the tree head will
 become the document title.  If the tree head entry has or inherits an
-@code{:EXPORT_FILE_NAME:} property, that name will be used for the
+@code{EXPORT_FILE_NAME} property, that name will be used for the
 export.
 @kindex C-c C-e v a
 @item C-c C-e v a
@@ -6635,7 +7186,7 @@
 language, but with additional support for tables.
 
 @menu
-* HTML Export commands::        How to invoke LaTeX export
+* HTML Export commands::        How to invoke HTML export
 * Quoting HTML tags::           Using direct HTML in Org mode
 * Links::                       Transformation of links for HTML
 * Images::                      How to include images
@@ -6652,13 +7203,13 @@
 @table @kbd
 @kindex C-c C-e h
 @item C-c C-e h
-Export as HTML file @file{myfile.html}.  For an org file
-@file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
-will be overwritten without warning.  If there is an active region, only
-the region will be exported. If the selected region is a single tree,
-the tree head will become the document title.  If the tree head entry
-has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
-used for the export.
+Export as HTML file @file{myfile.html}.  For an org file @file{myfile.org},
+the ASCII file will be @file{myfile.html}.  The file will be overwritten
+without warning.  If there is an active region, only the region will be
+exported. If the selected region is a single tree@footnote{To select the
+current subtree, use @kbd{C-c @@}.}, the tree head will become the document
+title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
+property, that name will be used for the export.
 @kindex C-c C-e b
 @item C-c C-e b
 Export as HTML file and immediately open it with a browser.
@@ -6716,6 +7267,7 @@
 @end example
 
 @noindent or
+@cindex #+BEGIN_HTML
 
 @example
 #+BEGIN_HTML
@@ -6818,19 +7370,20 @@
 as well, press @kbd{?} for an overview of the available keys).  The second
 view type is a @emph{folding} view much like Org provides it inside Emacs.
 The script is available at @url{http://orgmode.org/org-info.js} and you can
-find the documentation for it at @url{http://orgmode.org/org-infojs.html}.
-We are serving the script from our site, but if you use it a lot, you might
-not want to be dependent on @url{orgmode.org} and prefer to install a local
-copy on your own web server.
-
-To use the script, you need to make sure that the @file{org-infojs.el} module
+find the documentation for it at
+@url{http://orgmode.org/worg/code/org-info-js/org-info.js.html}.  We are
+serving the script from our site, but if you use it a lot, you might not want
+to be dependent on @url{orgmode.org} and prefer to install a local copy on
+your own web server.
+
+To use the script, you need to make sure that the @file{org-jsinfo.el} module
 gets loaded.  It should be loaded by default, try @kbd{M-x customize-variable
 @key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
 case.  All it then takes to make use of the program is adding a single line
 to the Org file:
 
 @example
-#+INFOSJ_OPT: view:info toc:nil
+#+INFOJS_OPT: view:info toc:nil
 @end example
 
 @noindent
@@ -6842,7 +7395,7 @@
 path:    @r{The path to the script.  The default is to grab the script from}
          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
-view:    @r{Initial view when website is first shown.  Possible values are}
+view:    @r{Initial view when website is first shown.  Possible values are:}
          info      @r{Info-like interface with one section per page.}
          overview  @r{Folding interface, initially showing only top-level.}
          content   @r{Folding interface, starting with all headlines visible.}
@@ -6856,6 +7409,8 @@
          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
+ftoc:    @r{Does the css of the page specify a fixed position for the toc?}
+         @r{If yes, the toc will never be displayed as a section.}
 ltoc:    @r{Should there be short contents (children) in each section?}
 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
@@ -6885,7 +7440,13 @@
 @table @kbd
 @kindex C-c C-e l
 @item C-c C-e l
-Export as La@TeX{} file @file{myfile.tex}.
+Export as La@TeX{} file @file{myfile.tex}.  For an org file
+@file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
+be overwritten without warning.  If there is an active region, only the
+region will be exported. If the selected region is a single tree@footnote{To
+select the current subtree, use @kbd{C-c @@}.}, the tree head will become the
+document title.  If the tree head entry has or inherits an
+@code{EXPORT_FILE_NAME} property, that name will be used for the export.
 @kindex C-c C-e L
 @item C-c C-e L
 Export to a temporary buffer, do not create a file.
@@ -6933,6 +7494,7 @@
 @end example
 
 @noindent or
+@cindex #+BEGIN_LaTeX
 
 @example
 #+BEGIN_LaTeX
@@ -6940,8 +7502,6 @@
 #+END_LaTeX
 @end example
 
-
-
 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
 @subsection Sectioning structure
 @cindex LaTeX class
@@ -6973,7 +7533,7 @@
 Export only the visible part of the document.
 @end table
 
-@node iCalendar export, Text interpretation, XOXO export, Exporting
+@node iCalendar export,  , XOXO export, Exporting
 @section iCalendar export
 @cindex iCalendar export
 
@@ -6985,6 +7545,16 @@
 iCalendar format.  If you also want to have TODO entries included in the
 export, configure the variable @code{org-icalendar-include-todo}.
 
+The iCalendar standard requires each entry to have a globally unique
+identifier (UID).  Org creates these identifiers during export.  If you set
+the variable @code{org-icalendar-store-UID}, the UID will be stored in the
+@code{:ID:} property of the entry and re-used next time you report this
+entry.  Since a single entry can give rise to multiple iCalendar entries (as
+a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
+prefixes to the UID, depending on what triggered the inclusion of the entry.
+In this way the UID remains unique, but a synchronization program can still
+figure out from which entry all the different instances originate.
+
 @table @kbd
 @kindex C-c C-e i
 @item C-c C-e i
@@ -7010,294 +7580,6 @@
 How this calendar is best read and updated, depends on the application
 you are using.  The FAQ covers this issue.
 
-
-@node Text interpretation,  , iCalendar export, Exporting
-@section Text interpretation by the exporter
-
-The exporter backends interpret additional structure in the Org file
-in order to produce better output.
-
-@menu
-* Comment lines::               Some lines will not be exported
-* Initial text::                Text before the first headline
-* Footnotes::                   Numbers like [1]
-* Quoted examples::             Inserting quoted chunks of text
-* Enhancing text::              Subscripts, symbols and more
-* Export options::              How to influence the export settings
-@end menu
-
-@node Comment lines, Initial text, Text interpretation, Text interpretation
-@subsection Comment lines
-@cindex comment lines
-@cindex exporting, not
-
-Lines starting with @samp{#} in column zero are treated as comments
-and will never be exported.  Also entire subtrees starting with the
-word @samp{COMMENT} will never be exported.
-
-@table @kbd
-@kindex C-c ;
-@item C-c ;
-Toggle the COMMENT keyword at the beginning of an entry.
-@end table
-
-@node Initial text, Footnotes, Comment lines, Text interpretation
-@subsection Text before the first headline
-
-Org mode normally ignores any text before the first headline when
-exporting, leaving this region for internal links to speed up navigation
-etc.  However, in publishing-oriented files, you might want to have some
-text before the first headline, like a small introduction, special HTML
-code with a navigation bar, etc.  You can ask to have this part of the
-file exported as well by setting the variable
-@code{org-export-skip-text-before-1st-heading} to @code{nil}.  On a
-per-file basis, you can get the same effect with
-
-@example
-#+OPTIONS: skip:nil
-@end example
-
-The text before the first headline will be fully processed
-(@pxref{Enhancing text}), and the first non-comment line becomes the
-title of the exported document.  If you need to include literal HTML,
-use the special constructs described in @ref{Quoting HTML tags}.  The
-table of contents is normally inserted directly before the first
-headline of the file.  If you would like to get it to a different
-location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
-itself at the desired location.
-
-Finally, if you want to use the space before the first headline for
-internal purposes, but @emph{still} want to place something before the
-first headline when exporting the file, you can use the @code{#+TEXT}
-construct:
-
-@example
-#+OPTIONS: skip:t
-#+TEXT: This text will go before the *first* headline.
-#+TEXT: We place the table of contents here:
-#+TEXT: [TABLE-OF-CONTENTS]
-#+TEXT: This goes between the table of contents and the first headline
-@end example
-
-@node Footnotes, Quoted examples, Initial text, Text interpretation
-@subsection Footnotes
-@cindex footnotes
-@cindex @file{footnote.el}
-
-Numbers in square brackets are treated as footnotes, so that you can use
-the Emacs package @file{footnote.el} to create footnotes.  For example:
-
-@example
-The Org homepage[1] clearly needs help from
-a good web designer.
-
-[1] The link is: http://orgmode.org
-@end example
-
-@noindent
-@kindex C-c !
-Note that the @file{footnote} package uses @kbd{C-c !} to invoke its
-commands.  This binding conflicts with the Org mode command for
-inserting inactive time stamps.  You could use the variable
-@code{footnote-prefix} to switch footnotes commands to another key.  Or,
-if you are too used to this binding, you could use
-@code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
-the settings in Org.
-
-@node Quoted examples, Enhancing text, Footnotes, Text interpretation
-@subsection Quoted examples
-@cindex quoted examples
-@cindex examples, quoted
-@cindex text, fixed width
-@cindex fixed width text
-
-When writing technical documents, you often need to insert examples that
-are not further interpreted by Org mode.  For historical reasons, there
-are several ways to do this:
-
-@itemize @bullet
-@item
-If a headline starts with the word @samp{QUOTE}, the text below the
-headline will be typeset as fixed-width, to allow quoting of computer
-codes etc.
-@item
-Lines starting with @samp{:} are also typeset in fixed-width font.
-@table @kbd
-@kindex C-c :
-@item C-c :
-Toggle fixed-width for entry (QUOTE) or region, see below.
-@end table
-@item
-Finally, text between
-@example
-#+BEGIN_EXAMPLE
-quoted text
-#+END_EXAMPLE
-@end example
-will also be exported in this way.
-@end itemize
-
-
-@node Enhancing text, Export options, Quoted examples, Text interpretation
-@subsection Enhancing text for export
-@cindex enhancing text
-@cindex richer text
-
-Some of the export backends of Org mode allow for sophisticated text
-formatting, this is true in particular for the HTML and La@TeX{}
-backends.  Org mode has a number of typing conventions that allow to
-produce a richly formatted output.
-
-@itemize @bullet
-
-@cindex hand-formatted lists
-@cindex lists, hand-formatted
-@item
-Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
-or @samp{2)} as enumerator will be recognized and transformed if the
-backend supports lists.  See @xref{Plain lists}.
-
-@cindex underlined text
-@cindex bold text
-@cindex italic text
-@cindex verbatim text
-@item
-You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
-and @code{~verbatim~}, and, if you must, @samp{+strikethrough+}.  Text
-in the code and verbatim string is not processed for Org mode specific
-syntax, it is exported verbatim.
-
-@cindex horizontal rules, in exported files
-@item
-A line consisting of only dashes, and at least 5 of them, will be
-exported as a horizontal line (@samp{<hr/>} in HTML).
-
-@cindex LaTeX fragments, export
-@cindex TeX macros, export
-@item
-Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
-entities or images (@pxref{Embedded LaTeX}).
-
-@cindex tables, export
-@item
-Tables are transformed into native tables under the exporter, if the
-export backend supports this. Data fields before the first horizontal
-separator line will be formatted as table header fields.
-
-@cindex fixed width
-@item
-If a headline starts with the word @samp{QUOTE}, the text below the
-headline will be typeset as fixed-width, to allow quoting of computer
-codes etc.  Lines starting with @samp{:} are also typeset in fixed-width
-font.
-@table @kbd
-@kindex C-c :
-@item C-c :
-Toggle fixed-width for entry (QUOTE) or region, see below.
-@end table
-Finally, text between
-@example
-#+BEGIN_EXAMPLE
-quoted text
-#+END_EXAMPLE
-@end example
-will also be exported in this way.
-
-@cindex linebreak, forced
-@item
-A double backslash @emph{at the end of a line} enforces a line break at
-this position.
-
-@cindex HTML entities, LaTeX entities
-@item
-Strings like @code{\alpha} will be exported as @code{&alpha;}, in the
-HTML output.  These strings are exported as @code{$\alpha$} in the
-La@TeX{} output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in
-HTML and in La@TeX{}.  This applies for a long list of entities, see
-the variable @code{org-html-entities} for the complete list.
-@c FIXME
-@end itemize
-
-If these conversions conflict with your habits of typing ASCII text,
-they can all be turned off with corresponding variables.  See the
-customization group @code{org-export-general}, and the following section
-which explains how to set export options with special lines in a
-buffer.
-
-
-@node Export options,  , Enhancing text, Text interpretation
-@subsection Export options
-@cindex options, for export
-
-@cindex completion, of option keywords
-The exporter recognizes special lines in the buffer which provide
-additional information.  These lines may be put anywhere in the file.
-The whole set of lines can be inserted into the buffer with @kbd{C-c
-C-e t}.  For individual lines, a good way to make sure the keyword is
-correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
-(@pxref{Completion}).
-
-@table @kbd
-@kindex C-c C-e t
-@item C-c C-e t
-Insert template with export options, see example below.
-@end table
-
-@example
-#+TITLE:     the title to be shown (default is the buffer name)
-#+AUTHOR:    the author (default taken from @code{user-full-name})
-#+DATE:      A date, fixed, of a format string for @code{format-time-string}
-#+EMAIL:     his/her email address (default from @code{user-mail-address})
-#+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
-#+TEXT:      Some descriptive text to be inserted at the beginning.
-#+TEXT:      Several lines may be given.
-#+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
-@end example
-
-@noindent
-The OPTIONS line is a compact form to specify export settings.  Here
-you can:
-@cindex headline levels
-@cindex section-numbers
-@cindex table of contents
-@cindex linebreak preservation
-@cindex quoted HTML tags
-@cindex fixed-width sections
-@cindex tables
-@cindex @TeX{}-like syntax for sub- and superscripts
-@cindex footnotes
-@cindex special strings
-@cindex emphasized text
-@cindex @TeX{} macros
-@cindex La@TeX{} fragments
-@cindex author info, in export
-@cindex time info, in export
-@example
-H:         @r{set the number of headline levels for export}
-num:       @r{turn on/off section-numbers}
-toc:       @r{turn on/off table of contents, or set level limit (integer)}
-\n:        @r{turn on/off linebreak-preservation}
-@@:         @r{turn on/off quoted HTML tags}
-::         @r{turn on/off fixed-width sections}
-|:         @r{turn on/off tables}
-^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
-           @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
-           @r{the simple @code{a_b} will be left as it is.}
--:         @r{turn on/off conversion of special strings.}
-f:         @r{turn on/off foototes like this[1].}
-*:         @r{turn on/off emphasized text (bold, italic, underlined)}
-TeX:       @r{turn on/off simple @TeX{} macros in plain text}
-LaTeX:     @r{turn on/off La@TeX{} fragments}
-skip:      @r{turn on/off skipping the text before the first heading}
-author:    @r{turn on/off inclusion of author name/email into exported file}
-timestamp: @r{turn on/off inclusion creation time into exported file}
-d:         @r{turn on/off inclusion of drawers}
-@end example
-
-These options take effect in both the HTML and La@TeX{} export, except
-for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
-@code{nil} for the La@TeX{} export.
-
 @node Publishing, Miscellaneous, Exporting, Top
 @chapter Publishing
 @cindex publishing
@@ -7383,8 +7665,11 @@
 @item @code{:publishing-directory}
 @tab Directory (possibly remote) where output files will be published.
 @item @code{:preparation-function}
-@tab Function called before starting publishing process, for example to
+@tab Function called before starting the publishing process, for example to
 run @code{make} for updating files to be published.
+@item @code{:completion-function}
+@tab Function called after finishing the publishing process, for example to
+change permissions of the resulting files.
 @end multitable
 @noindent
 
@@ -7651,7 +7936,7 @@
 functions normally only publish changed files. You can override this and
 force publishing of all files by giving a prefix argument.
 
-@node Miscellaneous, Extensions and Hacking, Publishing, Top
+@node Miscellaneous, Extensions, Publishing, Top
 @chapter Miscellaneous
 
 @menu
@@ -7769,6 +8054,9 @@
 line set the local variable @code{org-table-formula-constants-local}.
 The global version of this variable is
 @code{org-table-formula-constants}.
+@item #+FILETAGS: :tag1:tag2:tag3:
+Set tags that can be inherited by any entry in the file, including the
+top-level entries.
 @item #+DRAWERS: NAME1 .....
 Set the file-local set of drawers.  The corresponding global variable is
 @code{org-drawers}.
@@ -7783,6 +8071,14 @@
 @item #+PROPERTY: Property_Name Value
 This line sets a default inheritance value for entries in the current
 buffer, most useful for specifying the allowed values of a property.
+@item #+SETUPFILE: file
+This line defines a file that holds more in-buffer setup.  Normally this is
+entirely ignored.  Only when the buffer is parsed for option-setting lines
+(i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
+settings line, or when exporting), then the contents of this file are parsed
+as if they had been included in the buffer.  In particlar, the file can be
+any other Org mode file with internal setup.  You can visit the file the
+cursor is in the line with @kbd{C-c '}.
 @item #+STARTUP:
 This line sets options to be used at startup of Org mode, when an
 Org file is being visited.  The first set of options deals with the
@@ -7828,10 +8124,10 @@
 lognoteclock-out   @r{record a note when clocking out}
 nolognoteclock-out @r{don't record a note when clocking out}
 @end example
-Here are the options for hiding leading stars in outline headings.  The
-corresponding variables are @code{org-hide-leading-stars} and
-@code{org-odd-levels-only}, both with a default setting @code{nil}
-(meaning @code{showstars} and @code{oddeven}).
+Here are the options for hiding leading stars in outline headings, and for
+indenting outlines.  The corresponding variables are
+@code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
+default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
 @cindex @code{hidestars}, STARTUP keyword
 @cindex @code{showstars}, STARTUP keyword
 @cindex @code{odd}, STARTUP keyword
@@ -7839,6 +8135,8 @@
 @example
 hidestars  @r{make all but one of the stars starting a headline invisible.}
 showstars  @r{show all stars starting a headline}
+indent     @r{virtual indentation according to outline level}
+noindent   @r{no virtual indentation according to outline level}
 odd        @r{allow only odd outline levels (1,3,...)}
 oddeven    @r{allow all outline levels}
 @end example
@@ -7925,56 +8223,73 @@
 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
 @section A cleaner outline view
 @cindex hiding leading stars
+@cindex dynamic indentation
+@cindex odd-levels-only outlines
 @cindex clean outline view
 
-Some people find it noisy and distracting that the Org headlines
-are starting with a potentially large number of stars.  For example
-the tree from @ref{Headlines}:
-
-@example
-* Top level headline
-** Second level
-*** 3rd level
-    some text
-*** 3rd level
-    more text
-* Another top level headline
+Some people find it noisy and distracting that the Org headlines are starting
+with a potentially large number of stars, and that text below the headlines
+is not indented.  This is not really a problem when you are writing a book
+where the outline headings are really section headlines.  However, in a more
+list-oriented outline, it is clear that an indented structure is a lot
+cleaner, as can be seen by comparing the two columns in the following
+example: 
+
+@example
+@group
+* Top level headline             |    * Top level headline
+** Second level                  |      * Second level
+*** 3rd level                    |        * 3rd level
+some text                        |          some text
+*** 3rd level                    |        * 3rd level
+more text                        |          more text
+* Another top level headline     |    * Another top level headline
+@end group
 @end example
 
 @noindent
-Unfortunately this is deeply ingrained into the code of Org and
-cannot be easily changed.  You can, however, modify the display in such
-a way that all leading stars become invisible and the outline more easy
-to read.  To do this, customize the variable
-@code{org-hide-leading-stars} like this:
-
-@lisp
-(setq org-hide-leading-stars t)
-@end lisp
-
-@noindent
-or change this on a per-file basis with one of the lines (anywhere in
-the buffer)
+It is non-trivial to make such a look work in Emacs, but Org contains three
+separate features that, combined, achieve just that.
+
+@enumerate
+@item 
+@emph{Indentation of text below headlines}@*
+You may indent text below each headline to make the left boundary line up
+with the headline, like
+
+@example
+*** 3rd level
+    more text, now indented
+@end example
+
+A good way to get this indentation is by hand, and Org supports this with
+paragraph filling, line wrapping, and structure editing@footnote{See also the
+variable @code{org-adapt-indentation}.} preserving or adapting the
+indentation appropriate.  A different approach would be to have a way to
+automatically indent lines according to outline structure by adding overlays
+or text properties.  But I have not yet found a robust and efficient way to
+do this in large files.
+
+@item
+@emph{Hiding leading stars}@* You can modify the display in such a way that
+all leading stars become invisible.  To do this in a global way, configure
+the variable @code{org-hide-leading-stars} or change this on a per-file basis
+with
 
 @example
 #+STARTUP: showstars
 #+STARTUP: hidestars
 @end example
 
-@noindent
-Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
-the modifications.
-
-With stars hidden, the tree becomes:
-
-@example
+With hidden stars, the tree becomes:
+
+@example
+@group
 * Top level headline
  * Second level
   * 3rd level
-    some text
-  * 3rd level
-    more text
-* Another top level headline
+  ...
+@end group
 @end example
 
 @noindent
@@ -7986,32 +8301,14 @@
 stars are @i{almost} invisible, for example using the color
 @code{grey90} on a white background.
 
-Things become cleaner still if you skip all the even levels and use only
-odd levels 1, 3, 5..., effectively adding two stars to go from one
-outline level to the next:
-
-@example
-* Top level headline
-  * Second level
-    * 3rd level
-      some text
-    * 3rd level
-      more text
-* Another top level headline
-@end example
-
-@noindent
-In order to make the structure editing and export commands handle this
-convention correctly, use
-
-@lisp
-(setq org-odd-levels-only t)
-@end lisp
-
-@noindent
-or set this on a per-file basis with one of the following lines (don't
-forget to press @kbd{C-c C-c} with the cursor in the startup line to
-activate changes immediately).
+@item
+Things become cleaner still if you skip all the even levels and use only odd
+levels 1, 3, 5..., effectively adding two stars to go from one outline level
+to the next.  In this way we get the outline view shown at the beginning of
+this section.  In order to make the structure editing and export commands
+handle this convention correctly, configure the variable
+@code{org-odd-levels-only}, or set this on a per-file basis with one of the
+following lines:
 
 @example
 #+STARTUP: odd
@@ -8022,6 +8319,7 @@
 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
 RET} in that file.  The reverse operation is @kbd{M-x
 org-convert-to-oddeven-levels}.
+@end enumerate
 
 @node TTY keys, Interaction, Clean view, Miscellaneous
 @section Using Org on a tty
@@ -8240,39 +8538,108 @@
 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
 recalculate until convergence.
 @item
-A single letter cannot be made bold, for example @samp{*a*}.
-@item
 The exporters work well, but could be made more efficient.
 @end itemize
 
 
-@node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
-@appendix Extensions, Hooks and Hacking
-
-This appendix lists extensions for Org written by other authors.
-It also covers some aspects where users can extend the functionality of
+@node Extensions, Hacking, Miscellaneous, Top
+@appendix Extensions
+
+This appendix lists the extension modules that have been written for Org.
+Many of these extensions live in the @file{contrib} directory of the Org
+distribution, others are available somewhere on the web.
+
+@menu
+* Extensions in the contrib directory::  These come with the Org distro
+* Other extensions::            These you have to find on the web.
+@end menu
+
+@node Extensions in the contrib directory, Other extensions, Extensions, Extensions
+@section Extensions in the @file{contrib} directory
+
+@table @asis
+@item @file{org-annotate-file.el} by @i{Philip Jackson}
+      Annotate a file with org syntax, in a separate file, with links back to
+      the annotated file.
+@item @file{org-annotation-helper.el} by @i{Bastien Guerry and Daniel E. German} 
+      Call @i{remember} directly from Firefox/Opera, or from Adobe Reader.
+      When activating a special link or bookmark, Emacs receives a trigger to
+      create a note with a link back to the website.  Requires some setup, a
+      detailes description is in
+      @file{contrib/packages/org-annotation-helper}.
+@item @file{org-bookmark.el} by @i{Tokuya Kameshima}
+      Support for links to Emacs bookmarks.
+@item @file{org-depend.el} by @i{Carsten Dominik}
+      TODO dependencies for Org-mode.  Make TODO state changes in one entry
+      trigger changes in another, or be blocked by the state of another
+      entry.  Also, easily create chains of TODO items with exactly one
+      active item at any time.
+@item @file{org-elisp-symbol.el} by @i{Bastien Guerry}
+      Org links to emacs-lisp symbols.  This can create annotated links that
+      exactly point to the definition location of a variable of function.
+@item @file{org-eval.el} by @i{Carsten Dominik}
+      The @code{<lisp>} tag, adapted from Emacs Wiki and Emacs Muse, allows
+      to include text in a document that is the result of evaluating some
+      code.  Other scripting languages like @code{perl} can be supported with
+      this package as well.
+@item @file{org-expiry.el} by @i{Bastien Guerry}
+      Expiry mechanism for Org entries.
+@item @file{org-indent.el} by @i{Carsten Dominik}
+      Dynamic indentation of Org outlines.  The plan is to indent an outline
+      according to level, but so far this is too hard for a proper and stable
+      implementation.  Still, it works somewhat.
+@item @file{org-interactive-query.el} by @i{Christopher League}
+      Interactive modification of tags queries.  After running a general
+      query in Org, this package allows to narrow down the results by adding
+      more tags or keywords.
+@item @file{org-mairix.el} by @i{Georg C. F. Greve}
+      Hook mairix search into Org for different MUAs.
+@item @file{org-man.el} by @i{Carsten Dominik}
+      Support for links to manpages in Org-mode.
+@item @file{org-mtags.el} by @i{Carsten Dominik}
+      Support for some Muse-like tags in Org-mode.  This package allows you
+      to write @code{<example>} and @code{<src>} and other syntax copied from
+      Emacs Muse, right inside an Org file.  The goal here is to make it easy
+      to publish the same file using either org-publish or Muse.
+@item @file{org-panel.el} by @i{Lennard Borgman}
+      Simplified and display-aided access to some Org commands.
+@item @file{org-registry.el} by @i{Bastien Guerry}
+      A registry for Org links, to find out from where links point to a given
+      file or location.
+@item @file{org2rem.el} by @i{Bastien Guerry}
+      Convert org appointments into reminders for the @file{remind} program.
+@item @file{org-screen.el} by @i{Andrew Hyatt}
+      Visit screen sessions through Org-mode links.
+@item @file{org-toc.el} by @i{Bastien Guerry}
+      Table of contents in a separate buffer, with fast access to sections
+      and easy visibility cycling.
+@item @file{orgtbl-sqlinsert.el} by @i{Jason Riedy}
+      Convert Org-mode tables to SQL insertions.  Documentation for this can
+      be found on the Worg pages.
+@end table
+
+
+@node Other extensions,  , Extensions in the contrib directory, Extensions
+@section Other extensions
+
+@i{TO BE DONE}
+
+@node Hacking, History and Acknowledgments, Extensions, Top
+@appendix Hacking
+
+This appendix covers some aspects where users can extend the functionality of
 Org.
 
 @menu
-* Extensions::                  Existing 3rd-party extensions
 * Adding hyperlink types::      New custom link types
 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
 * Dynamic blocks::              Automatically filled blocks
 * Special agenda views::        Customized views
 * Using the property API::      Writing programs that use entry properties
+* Using the mapping API::       Mapping over all or selected entries
 @end menu
 
-@node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
-@section Third-party extensions for Org
-@cindex extension, third-party
-
-There are lots of extensions that have been written by other people.  Most of
-them have either been integrated into Org by now, or they can be found in the
-Org distribution, in the @file{contrib} directory.  The list has gotten too
-long to cover in any detail here, but there is a seaparate manual for these
-extensions.
-
-@node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
+@node Adding hyperlink types, Tables in arbitrary syntax, Hacking, Hacking
 @section Adding hyperlink types
 @cindex hyperlinks, adding new types
 
@@ -8369,7 +8736,7 @@
 the link description when the link is later inserted into an Org
 buffer with @kbd{C-c C-l}.
 
-@node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
+@node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Hacking
 @section Tables and lists in arbitrary syntax
 @cindex tables, in other modes
 @cindex lists, in other modes
@@ -8436,7 +8803,9 @@
 
 @table @code
 @item :skip N
-Skip the first N lines of the table. Hlines do count!
+Skip the first N lines of the table.  Hlines do count as separate lines for
+this parameter!
+
 @item :skipcols (n1 n2 ...)
 List of columns that should be skipped.  If the table has a column with
 calculation marks, that column is automatically discarded as well.
@@ -8482,6 +8851,7 @@
 be prompted for a table name, lets say we use @samp{salesfigures}.  You
 will then get the following template:
 
+@cindex #+ORGTBL: SEND
 @example
 % BEGIN RECEIVE ORGTBL salesfigures
 % END RECEIVE ORGTBL salesfigures
@@ -8550,7 +8920,7 @@
 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
 and marks horizontal lines with @code{\hline}.  Furthermore, it
-interprets the following parameters:
+interprets the following parameters (see also @ref{Translator functions}):
 
 @table @code
 @item :splice nil/t
@@ -8581,15 +8951,15 @@
 @cindex HTML, and Orgtbl mode
 @cindex translator function
 
-Orgtbl mode has several translator functions built-in:
-@code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
-@code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
-HTML translator uses the same code that produces tables during HTML
-export.}, these all use a generic translator, @code{orgtbl-to-generic}.
-For example, @code{orgtbl-to-latex} itself is a very short function that
-computes the column definitions for the @code{tabular} environment,
-defines a few field and line separators and then hands over to the
-generic translator.  Here is the entire code:
+Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
+(comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
+@code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
+Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
+code that produces tables during HTML export.}, these all use a generic
+translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
+itself is a very short function that computes the column definitions for the
+@code{tabular} environment, defines a few field and line separators and then
+hands over to the generic translator.  Here is the entire code:
 
 @lisp
 @group
@@ -8692,7 +9062,7 @@
 Pressing `C-c C-c' on @code{a new house} and will insert the converted
 La@TeX{} list between the two marker lines.
 
-@node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
+@node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
 @section Dynamic blocks
 @cindex dynamic blocks
 
@@ -8705,6 +9075,7 @@
 to the block and can also specify parameters for the function producing
 the content of the block.
 
+#+BEGIN:dynamic block
 @example
 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
 
@@ -8756,7 +9127,7 @@
 written in a way that is does nothing in buffers that are not in
 @code{org-mode}.
 
-@node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
+@node Special agenda views, Using the property API, Dynamic blocks, Hacking
 @section Special agenda views
 @cindex agenda views, user-defined
 
@@ -8838,7 +9209,7 @@
     (org-agenda-overriding-header "Projects waiting for something: "))))
 @end lisp
 
-@node Using the property API,  , Special agenda views, Extensions and Hacking
+@node Using the property API, Using the mapping API, Special agenda views, Hacking
 @section Using the property API
 @cindex API, for properties
 @cindex properties, API
@@ -8896,7 +9267,105 @@
 values and check if VALUE is in this list.
 @end defun
 
-@node History and Acknowledgments, Main Index, Extensions and Hacking, Top
+@node Using the mapping API,  , Using the property API, Hacking
+@section Using the mapping API
+@cindex API, for mapping
+@cindex mapping entries, API
+
+Org has sophisticated mapping capabilities to find all entries satisfying
+certain criteria.  Internally, this functionality is used to produce agenda
+views, but there is also an API that can be used to execute arbitrary
+functions for each or selected entries.  The main entry point for this API
+is: 
+
+@defun org-map-entries func &optional match scope &rest skip
+Call FUNC at each headline selected by MATCH in SCOPE.
+
+FUNC is a function or a lisp form.  The function will be called without
+arguments, with the cursor positioned at the beginning of the headline.
+The return values of all calls to the function will be collected and
+returned as a list.
+
+MATCH is a tags/property/todo match as it is used in the agenda tags view.
+Only headlines that are matched by this query will be considered during
+the iteration.  When MATCH is nil or t, all headlines will be
+visited by the iteration.
+
+SCOPE determines the scope of this command.  It can be any of:
+
+@example
+nil     @r{the current buffer, respecting the restriction if any}
+tree    @r{the subtree started with the entry at point}
+file    @r{the current buffer, without restriction}
+file-with-archives
+        @r{the current buffer, and any archives associated with it}
+agenda  @r{all agenda files}
+agenda-with-archives
+        @r{all agenda files with any archive files associated with them}
+(file1 file2 ...)
+        @r{if this is a list, all files in the list will be scanned}
+@end example
+
+The remaining args are treated as settings for the skipping facilities of
+the scanner.  The following items can be given here:
+
+@example
+archive   @r{skip trees with the archive tag}
+comment   @r{skip trees with the COMMENT keyword}
+function or Lisp form
+          @r{will be used as value for @code{org-agenda-skip-function},}
+          @r{so whenever the the function returns t, FUNC}
+          @r{will not be called for that entry and search will}
+          @r{continue from the point where the function leaves it}
+@end example
+@end defun
+
+The function given to that mapping routine can really do anything you like.
+It can uce the property API (@pxref{Using the property API}) to gather more
+information about the entry, or in order to change metadate in the entry.
+Here are a couple of functions that might be handy:
+ 
+@defun org-todo &optional arg
+Change the TODO state of the entry, see the docstring of the functions for
+the many possible values for the argument ARG.
+@end defun
+
+@defun org-priority &optional action
+Change the priority of the entry, see the docstring of this function for the
+possible values for ACTION.
+@end defun
+
+@defun org-toggle-tag tag &optional onoff
+Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
+or @code{off} will not toggle tag, but ensure that it is either on or off.
+@end defun
+
+@defun org-promote
+Promote the current entry.
+@end defun
+
+@defun org-demote
+Demote the current entry.
+@end defun
+
+Here is a simple example that will turn all entries in the current file with
+a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
+Entries in comment trees and in archive trees will be ignored.
+
+@lisp
+(org-map-entries
+   '(org-todo "UPCOMING")
+   "+TOMORROW" 'file 'archive 'comment)
+@end lisp
+
+The following example counts the number of entries with TODO keyword
+@code{WAITING}, in all agenda files.
+
+@lisp
+(length (org-map-entries t "/+WAITING" nil 'agenda))
+@end lisp
+
+@node History and Acknowledgments, Main Index, Hacking, Top
 @appendix History and Acknowledgments
 @cindex acknowledgments
 @cindex history
@@ -8940,6 +9409,9 @@
 @item
 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
 @item
+@i{Christophe Bataillon} created the great unicorn logo that we use on the
+Org-mode website.
+@item
 @i{Alex Bochannek} provided a patch for rounding time stamps.
 @item
 @i{Charles Cave}'s suggestion sparked the implementation of templates
@@ -9039,15 +9511,16 @@
 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
 conflict with @file{allout.el}.
 @item
-@i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords.
-@item
-@i{Philip Rooke} created the Org reference card and provided lots
-of feedback.
+@i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
+extensive patches.
+@item
+@i{Philip Rooke} created the Org reference card, provided lots
+of feedback, developed and applied standards to the Org documentation.
 @item
 @i{Christian Schlauer} proposed angular brackets around links, among
 other things.
 @item
-Linking to VM/BBDB/Gnus was inspired by @i{Tom Shannon}'s
+Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
 @file{organizer-mode.el}.
 @item
 @i{Ilya Shlyakhter} proposed the Archive Sibling.
@@ -9057,8 +9530,8 @@
 @item
 @i{Dale Smith} proposed link abbreviations.
 @item
-@i{Adam Spiers} asked for global linking commands and inspired the link
-extension system.  support mairix.
+@i{Adam Spiers} asked for global linking commands, inspired the link
+extension system, added support for mairix, and proposed the mapping API.
 @item
 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
 chapter about publishing.
@@ -9072,12 +9545,11 @@
 @i{David Wainberg} suggested archiving, and improvements to the linking
 system.
 @item
-@i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
-development of Org was fully independent, and both systems are really
-different beasts in their basic ideas and implementation details.  I later
-looked at John's code, however, and learned from his implementation of (i)
-links where the link itself is hidden and only a description is shown, and
-(ii) popping up a calendar to select a date.  John has also contributed a
+@i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
+@file{muse.el}, which have similar goals as Org.  Initially the
+development of Org was fully independent because I was not aware of the
+existence of these packages.  But with time I have accasionally looked
+at John's code and learned a lot from it.  John has also contributed a
 number of great ideas and patches directly to Org, including the file
 @code{org-mac-message.el}'
 @item
--- a/etc/refcards/orgcard.tex	Tue Jun 17 11:28:06 2008 +0000
+++ b/etc/refcards/orgcard.tex	Tue Jun 17 15:22:00 2008 +0000
@@ -1,5 +1,5 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{6.02b}
+\def\orgversionnumber{6.05a}
 \def\versionyear{2008}          % latest update
 \def\year{2008}                 % latest copyright year
 
@@ -309,10 +309,8 @@
 \key{insert new heading after subtree}{C-RET}
 \key{insert new TODO entry/checkbox item}{M-S-RET}
 
-\key{promote current heading up one level}{M-LEFT}
-\key{demote current heading down one level}{M-RIGHT}
-\key{promote current subtree up one level}{M-S-LEFT}
-\key{demote current subtree down one level}{M-S-RIGHT}
+\key{promote/demote heading}{M-LEFT/RIGHT}
+\metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
 
 \key{move subtree/list item up/down}{M-S-UP/DOWN}
 \key{refile subtree}{C-c C-w}
@@ -320,6 +318,7 @@
 \key{copy subtree}{C-c C-x M-w}
 \key{yank subtree}{C-c C-x C-y}
 \key{narrow buffer to current subtree}{C-x n s}
+\key{widen restriction to full buffer}{C-x n w}
 
 \section{Archiving}
 
@@ -452,7 +451,7 @@
 \key{jump back to last followed link(s)}{C-c \&}
 \key{Find next link}{C-c C-x C-n}
 \key{Find previous link}{C-c C-x C-p}
-
+\key{Edit code snippet of file at point}{C-c '}
 {\bf Internal Links}
 
 \key{\kbd{<<My Target>>}}{\rm target}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/org/ChangeLog	Tue Jun 17 15:22:00 2008 +0000
@@ -0,0 +1,480 @@
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-colview.el (org-columns-next-allowed-value): Bug fix.
+
+	* org-colview-xemacs.el (org-columns-next-allowed-value): Bug fix.
+
+	* org-agenda.el (org-agenda-get-closed): Get the end time into the
+	agenda prefix as well.
+
+	* org-publish.el (org-publish-org-index): Make a properly indented
+	list.
+
+	* org.el (org-calendar-agenda-action-key): New option.
+	(org-get-cursor-date): New function.
+	(org-mark-entry-for-agenda-action): New command.
+	(org-overriding-default-time): New variable.
+	(org-read-date): Respect `org-overriding-default-time'.
+
+	* org-remember.el (org-remember-apply-template): Respect the
+	ovverriding default time.
+
+	* org-agenda.el (org-agenda-action-marker): New variable.
+	(org-agenda-action): New command.
+	(org-agenda-do-action): New function.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-schedule, org-deadline): Protect scheduled and
+	deadline tasks against changes that accidently remove the
+	repeater.  Also show a message with the new date when done.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-beginning-of-line): Cater for the case when there
+	are tags but no headline text.
+	(org-align-tags-here): Convert to tabs only when indent-tabs-mode
+	it set.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-mhe.el (org-mhe-get-message-folder-from-index): Make sure
+	the return value is nil instead of "nil" when there is no match.
+
+	* org-exp.el (org-insert-centered): Use fill-column instead of
+	80.
+	(org-export-as-ascii): Use string-width to measure the width of
+	the heading.
+
+	* org.el (org-diary-to-ical-string): No longer kill buffer
+	FROMBUF, this is now done by the caller.
+
+	* org-exp.el (org-print-icalendar-entries): Move the call to
+	`org-diary-to-ical-string' out of the loop, and kill the buffer
+	afterwords.
+
+	* org-remember.el (org-remember-visit-immediately): Position
+	cursor after moving to the note.
+	(org-remember-apply-template): Use a text property to record the
+	cursor position.
+	(org-remember-handler): Align tags after pasting the note.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-bbdb.el (org-bbdb-follow-anniversary-link): New function.
+
+	* org-agenda.el (org-agenda-open-link): If there is an
+	org-bbdb-name property in the current line, jump to that bbdb
+	entry.
+
+	* org-bbdb.el (org-bbdb-anniversaries): Add the bbdb-name as a
+	text property, so that the agenda knows where this entry comes
+	from.
+
+	* org-agenda.el (org-agenda-clock-in): Fixed bug in the
+	interaction between clocking-in from the agenda, and  automatic
+	task state switching.
+
+	* org-macs.el (org-with-point-at): Bug fix in macro defintion.
+
+	* org.el (org-beginning-of-line, org-end-of-line): Make sure the
+	zmacs-region stays after this command in XEmacs.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-scan-tags): Allow new values for ACTION parameter.
+
+	* org-remember.el (org-remember-templates): Fix bug in
+	customization type definition.
+
+	* org.el (org-map-entries): New function.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-agenda.el (org-agenda-skip-comment-trees): New option.
+	(org-agenda-skip): Respect `org-agenda-skip-comment-trees'.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-remember.el (org-jump-to-target-location): New variable.
+	(org-remember-apply-template): Set
+	`org-remember-apply-template' if requested by template.
+	(org-remember-handler): Start an idle timer to jump to
+	remember location.
+
+	* org-exp.el (org-get-current-options): Add the FILETAGS setting.
+
+	* org.el (org-set-regexps-and-options): Fix bug with parsing of
+	file tags.
+	(org-get-tags-at): Add the content of `org-file-tags'.
+
+	* org-exp.el (org-export-handle-comments): Fix bug with several
+	comment lines after each other.
+	(org-number-to-roman, org-number-to-counter): New functions.
+	(org-export-section-number-format): New option.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-exp.el (org-export-protect-examples): Catch the case of a
+	missing end_example line.
+
+	* org.el (org-set-regexps-and-options): Set `org-file-properties' and
+	`org-file-tags' to nil.
+
+	* org-colview.el (org-columns-next-allowed-value): Handle next
+	argument NTH to directly select a value.
+
+	* org-colview-xemacs.el (org-columns-next-allowed-value): Handle next
+	argument NTH to directly select a value.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-agenda.el (org-agenda-scheduled-leaders): Fix docstring.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-columns-ellipses): New option.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-colview.el (org-columns-add-ellipses): New function.
+	(org-columns-compact-links): New function.
+	(org-columns-cleanup-item): Call `org-columns-compact-links'.
+	(org-columns-display-here): Call `org-agenda-columns-cleanup-item'
+	when in agenda.
+	(org-columns-edit-value): Fixed bug with editing values from
+	agenda column view.
+	(org-columns-redo): Also redo the agenda itself.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-agenda.el (org-agenda-columns-remove-prefix-from-item): New
+	option.
+
+	* org-colview.el (org-agenda-columns-cleanup-item): New function.
+
+	* org-exp.el (org-export-ascii-preprocess): Renamed from
+	`org-export-ascii-clean-string'.
+	(org-export-kill-licensed-text)
+	(org-export-define-heading-targets)
+	(org-export-handle-invisible-targets)
+	(org-export-target-internal-links)
+	(org-export-remove-or-extract-drawers)
+	(org-export-remove-archived-trees)
+	(org-export-protect-quoted-subtrees)
+	(org-export-protect-verbatim, org-export-protect-examples)
+	(org-export-select-backend-specific-text)
+	(org-export-mark-blockquote-and-verse)
+	(org-export-remove-comment-blocks-and-subtrees)
+	(org-export-handle-comments, org-export-mark-radio-links)
+	(org-export-remove-special-table-lines)
+	(org-export-normalize-links)
+	(org-export-concatenate-multiline-links)
+	(org-export-concatenate-multiline-emphasis): New functions,
+	obtained from spliiting the export preprocessor.
+
+	* org-table.el (org-table-recalculate): Improve error message if
+	the row number is invalid.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-archive.el (org-archive-save-context-info): Fix bugs in
+	customization setup and docstring.
+
+	* org-exp.el (org-export-html-style): Changed the size of in the
+	<pre> element to 90%.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-find-src-example-start): Function removed.
+	(org-edit-src-find-region-and-lang): New function.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-edit-src-exit): New function.
+	(org-exit-edit-mode): New minor mode.
+
+	* org-exp.el (org-export-preprocess-string): Fix bug with removing
+	comment-like lines from protected examples.
+
+	* org.el (org-edit-src-example, org-find-src-example-start)
+	(org-protect-source-example, org-edit-special): New functions.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-publish.el (org-publish-project-alist): Fix typo in
+	docstring.
+	(org-publish-project-alist): Handle :index-title property.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-export-latex.el (org-export-as-latex): Make sure region
+	bounds are correct.  Parse subtree properties relating to export.
+
+	* org-exp.el (org-export-add-options-to-plist): New function.
+	(org-infile-export-plist): Use `org-export-add-options-to-plist'.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-default-properties): Add EXPORT_FILE_NAME and
+	EXPORT_TITLE.
+
+	* org-exp.el (org-export-get-title-from-subtree)
+	(org-export-as-ascii, org-export-as-html): Make sure the original
+	region-beginning and region-end are used, even after moving
+	point.
+	(org-export-get-title-from-subtree): Also try the EXPORT_TITLE
+	property.
+
+	* org-remember.el (org-remember-last-stored-marker): New variable.
+	(org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'.
+	(org-remember-handler): Also use marker to remember
+	last-stored position.
+
+	* org.el (org-goto-marker-or-bmk): New function.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-file-properties): Renamed from `org-local-properties'.
+	(org-scan-tags): Take file tags into account.
+	(org-tags-match-list-sublevels): Default changed to t.
+
+	* org-exp.el (org-export-as-html): Close paragraph after a
+	footnote.
+
+	* org.el (org-update-parent-todo-statistics): New function.
+
+	* org-exp.el (org-icalendar-store-UID): New option.
+	(org-icalendar-force-UID): Option removed.
+	(org-print-icalendar-entries): IMplement UIDs.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-mhe.el (org-mhe-follow-link): Fix bug in mhe searches.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-faces.el (org-column): Document how this face is being used
+	and why sometimes the background faces shine through.
+
+	* org-mhe.el (org-mhe-follow-link): Improve handling of searches.
+
+	* org-publish.el (org-publish-attachment): Create publishing
+	directory if it does not yet exist.
+
+	* org-table.el (org-calc-default-modes): Change default number
+	format to (float 8).
+
+	* org.el (org-olpath-completing-read): New function.
+	(org-time-clocksum-format): New option.
+	(org-minutes-to-hh:mm-string): Use `org-time-clocksum-format'.
+
+	* org-clock.el (org-clock-display, org-clock-out)
+	(org-update-mode-line): Use `org-time-clocksum-format'.
+
+	* org-colview-xemacs.el (org-columns-number-to-string): Use
+	`org-time-clocksum-format'.
+
+	* org-colview.el (org-columns-number-to-string): Use
+	`org-time-clocksum-format'.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-id.el: New file, move from contrib to core.
+
+	* org-exp.el (org-icalendar-force-UID): New option.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-exp.el (org-print-icalendar-entries): Make sure DTEND is
+	shifted by one day if theere is a date range without an end
+	time.
+
+	* org.el (org-try-structure-completion): New function.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-set-font-lock-defaults): Improve fontification of
+	description lists.
+	(org-insert-item): Handle description lists.
+	(org-adaptive-fill-function): Improve auto indentation in
+	description lists.
+
+	* org-exp.el (org-export-as-html, org-export-preprocess-string):
+	Implement VERSE environment.
+	(org-export-preprocess-string): Implement the COMMENT
+	environment.
+
+	* org-export-latex.el (org-export-latex-preprocess): Implement
+	VERSE environment.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-jsinfo.el (org-infojs-opts-table): Add entry for FIXED_TOC
+	option.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-table.el (orgtbl-to-tsv, orgtbl-to-csv): New functions.
+
+	* org.el (org-quote-csv-field): New functions.
+
+	* org-table.el (org-table-export-default-format): Remove :splice
+	from default format, we get the same effect by not specifying
+	:tstart and :tend.
+	(org-table-export): Improve setup, distinguish better between
+	interactive and non-interactive use, allow specifying the format
+	on the fly, better protection against wrong file names.
+	(orgtbl-to-generic): Fix documentation.  Do not require :tstart
+	and :tend when :splice is omitted.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-clock.el (org-clock-select-task): Make sure the selection
+	letters are 1-9 and A-Z, no special characters.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-exp.el (org-export-htmlize): New group.
+	(org-export-htmlize-output-type)
+	(org-export-htmlize-css-font-prefix): New options.
+	(org-export-htmlize-region-for-paste): New function.
+	(org-export-htmlize-generate-css): New command.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-set-visibility-according-to-property): New function.
+	(org-ctrl-c-ctrl-c): Do not restart org-mode, just get the options
+	and compute the regular expressions, and update font-lock.
+	(org-property-re): Allow a dash in property names.
+
+	* org-archive.el (org-extract-archive-file): Insert the file name
+	without the path into the format, to allow the location format to
+	contain a subdirectory.
+
+	* org-agenda.el (org-agenda-post-command-hook): If point is at end
+	of buffer, and the `org-agenda-type' property undefined, use the
+	value from the character before.
+
+	* org.el (org-add-planning-info): Don't let indentation for
+	would-be timestamp become extra whitespace at the end of headline.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-remove-double-quotes, org-file-contents): New
+	functions.
+
+	* org-exp.el (org-infile-export-plist): Also parse the
+	contents of #+SETUPFILE files, recursively.
+
+	* org.el (org-set-regexps-and-options): Also parse the
+	contents of #+SETUPFILE files, recursively.
+
+	* org-exp.el (org-export-handle-include-files): New function.
+	(org-export-preprocess-string): Call
+	`org-export-handle-include-files'.
+
+	* org.el (org-delete-property-globally)
+	(org-delete-property, org-set-property): Ignore case during
+	completion.
+	(org-set-property): Use `org-completing-read' instead of
+	`completing-read'.
+
+	* org.el (org-complete-expand-structure-template): New,
+	experimental function.
+	(org-structure-template-alist): New, experimental option.
+	(org-complete): Call `org-complete-expand-structure-template'.
+
+2008-06-17 Bastien Guerry  <bzg@altern.org>
+
+	* org-export-latex.el (org-export-latex-preprocess): Added
+	support for blockquotes.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-read-date-analyze): Catch the case where only a
+	weekday is given.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-set-font-lock-defaults): Make the description
+	tag bold.
+
+	* org-exp.el (org-export-as-html, org-close-li): Implement
+	description lists.
+
+2008-06-17 Jason Riedy  <jason@acm.org>
+
+	* org-table.el (*orgtbl-default-fmt*): New variable.
+	(orgtbl-format-line): Use the value of *orgtbl-default-fmt*
+	when there is no other fmt available.
+
+	(orgtbl-to-generic): Allow an explicitly nil :tstart or
+	:tend to suppress the appropriate string.
+
+	(orgtbl-to-orgtbl): New function for translating to another orgtbl
+	table.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-read-date-analyze): "." as an alias for "+0" in
+	read date.
+
+	* org-clock.el (org-clock-save-markers-for-cut-and-paste):
+	New function.
+
+	* org-agenda.el (org-agenda-save-markers-for-cut-and-paste):
+	New function.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-clock.el (org-clock-find-position): Don't include notes
+	into clock drawer.
+
+	* org-archive.el (org-archive-subtree): No longer remove an
+	extra line after cutting the subtree.  `org-cut-subtree' already
+	takes care of this.
+
+	* org-remember.el (org-remember-handler): Only kill the target
+	buffer if it does not contain the running clock.
+
+	* org.el (org-markers-to-move): New variable.
+	(org-save-markers-in-region, org-check-and-save-marker)
+	(org-reinstall-markers-in-region): New function.
+	(org-move-subtree-down, org-copy-subtree): Remember relative
+	marker positions before cutting.
+	(org-move-subtree-down, org-paste-subtree): Restore relative
+	marker positions after pasting.
+
+	* org-remember.el (org-remember-clock-out-on-exit): New option.
+	(org-remember-finalize): Clock out only if the setting in
+	`org-remember-clock-out-on-exit' requires it.
+	(org-remember-handler): Do the cleanup in the buffer, to make sure
+	that the clock marker remains in tact.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-clock.el (org-clock-goto): Widen buffer if necessary.
+	(org-clock-in): Make sure that also tasks outside the narrowed
+	region will be clocked in correctly.
+	(org-clock-insert-selection-line): Widen the buffer so that we can
+	find the correct task heading.
+
+	* org.el (org-base-buffer): New function.
+
+	* org-exp.el (org-icalendar-cleanup-string): Make sure ',"
+	and ";" are escaped.
+	(org-print-icalendar-entries): Also apply
+	`org-icalendar-cleanup-string' to the headline, not only to the
+	summary property.
+
+2008-06-17  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-exp.el (org-export-preprocess-hook): New hook.
+	(org-export-preprocess-string): Call
+	`org-export-preprocess-hook'.
+
+	* org.el (org-font-lock-hook): New variable.
+	(org-font-lock-hook): New function.
+	(org-set-font-lock-defaults): Call `org-font-lock-hook'.
+
--- a/lisp/org/org-agenda.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-agenda.el	Tue Jun 17 15:22:00 2008 +0000
@@ -1,4 +1,4 @@
-;;; org-agenda.el --- The table editor for Org-mode
+;;; org-agenda.el --- Dynamic task and appointment lists for Org
 
 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008
 ;;   Free Software Foundation, Inc.
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -34,7 +34,7 @@
 (eval-when-compile
   (require 'calendar))
 
-(declare-function add-to-diary-list "diary-lib"
+(declare-function diary-add-to-list "diary-lib"
                   (date string specifier &optional marker globcolor literal))
 (declare-function calendar-absolute-from-iso    "cal-iso"    (date))
 (declare-function calendar-astro-date-string    "cal-julian" (&optional date))
@@ -392,6 +392,12 @@
  :tag "Org Agenda Skip"
  :group 'org-agenda)
 
+(defcustom org-agenda-skip-comment-trees t
+  "Non-nil means, skip trees that start with teh COMMENT keyword.
+When nil, these trees are also scand by agenda commands."
+  :group 'org-agenda-skip
+  :type 'boolean)
+
 (defcustom org-agenda-todo-list-sublevels t
   "Non-nil means, check also the sublevels of a TODO entry for TODO entries.
 When nil, the sublevels of a TODO entry are not checked, resulting in
@@ -464,7 +470,6 @@
 	  (const :tag "All" t)
 	  (number :tag "at most")))
 
-
 (defgroup org-agenda-startup nil
   "Options concerning initial settings in the Agenda in Org Mode."
   :tag "Org Agenda Startup"
@@ -676,7 +681,7 @@
  today         show grid on current date, independent of daily/weekly display
  require-timed show grid only if at least one item has a time specification
 
-The second item is a string which will be places behing the grid time.
+The second item is a string which will be placed behind the grid time.
 
 The third item is a list of integers, indicating the times that should have
 a grid line."
@@ -849,8 +854,10 @@
   "Text preceeding scheduled items in the agenda view.
 This is a list with two strings.  The first applies when the item is
 scheduled on the current day.  The second applies when it has been scheduled
-previously, it may contain a %d to capture how many days ago the item was
-scheduled."
+previously, it may contain a %d indicating that this is the nth time that
+this item is scheduled, due to automatic rescheduling of unfinished items
+for the following day.  So this number is one larger than the number of days
+that passed since this item was scheduled first."
   :group 'org-agenda-line-format
   :type '(list
 	  (string :tag "Scheduled today     ")
@@ -946,6 +953,16 @@
   :group 'org-agenda-column-view
   :type 'boolean)
 
+(defcustom org-agenda-columns-remove-prefix-from-item t
+  "Non-nil means, remove the prefix from a headline for agenda column view.
+The special ITEM field in the columns format contains the current line, with
+all information shown in other columns (like the TODO state or a tag).
+When this variable is non-nil, also the agenda prefix will be removed from
+the content of the ITEM field, to make sure as much as possible of the
+headline can be shown in the limited width of the field."
+  :group 'org-agenda
+  :type 'boolean)
+
 (defcustom org-agenda-columns-compute-summary-properties t
   "Non-nil means, recompute all summary properties before column view.
 When column view in the agenda is listing properties that have a summary
@@ -1071,6 +1088,8 @@
 (org-defkey org-agenda-mode-map "y"        'org-agenda-year-view)
 (org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
 (org-defkey org-agenda-mode-map "z"        'org-agenda-add-note)
+(org-defkey org-agenda-mode-map "k"        'org-agenda-action)
+(org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
 (org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
 (org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later)
@@ -1177,6 +1196,11 @@
      ["Schedule" org-agenda-schedule t]
      ["Set Deadline" org-agenda-deadline t]
      "--"
+     ["Mark item" org-agenda-action :active t :keys "k m"]
+     ["Show mark item" org-agenda-action :active t :keys "k v"]
+     ["Schedule marked item" org-agenda-action :active t :keys "k s"]
+     ["Set Deadline for marked item" org-agenda-action :active t :keys "k d"]
+     "--"
      ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
@@ -2012,7 +2036,8 @@
 	 (get-text-property p :org-archived)
 	 (org-end-of-subtree t)
 	 (throw :skip t))
-    (and (get-text-property p :org-comment)
+    (and org-agenda-skip-comment-trees
+	 (get-text-property p :org-comment)
 	 (org-end-of-subtree t)
 	 (throw :skip t))
     (if (equal (char-after p) ?#) (throw :skip t))
@@ -2045,6 +2070,11 @@
   (while org-agenda-markers
     (move-marker (pop org-agenda-markers) nil)))
 
+(defun org-agenda-save-markers-for-cut-and-paste (beg end)
+  "Save relative positions of markers in region."
+  (mapc (lambda (m) (org-check-and-save-marker m beg end))
+	org-agenda-markers))
+
 ;;; Agenda timeline
 
 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
@@ -2425,6 +2455,7 @@
 		      'done-face 'org-done
 		      'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'mouse-face 'highlight
 		      'keymap org-agenda-keymap
 		      'help-echo (format "mouse-2 or RET jump to location")))
@@ -2539,6 +2570,7 @@
 		      (org-add-props txt props
 			'org-marker marker 'org-hd-marker marker
 			'org-todo-regexp org-todo-regexp
+			'org-complex-heading-regexp org-complex-heading-regexp
 			'priority 1000 'org-category category
 			'type "search")
 		      (push txt ee)
@@ -3065,6 +3097,7 @@
 		      'done-face 'org-done
 		      'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'mouse-face 'highlight
 		      'keymap org-agenda-keymap
 		      'help-echo
@@ -3123,6 +3156,7 @@
   (let* ((props (list 'face nil
 		      'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'mouse-face 'highlight
 		      'keymap org-agenda-keymap
 		      'help-echo
@@ -3255,6 +3289,7 @@
   (let* ((props (list 'mouse-face 'highlight
 		      'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'keymap org-agenda-keymap
 		      'help-echo
 		      (format "mouse-2 or RET jump to org file %s"
@@ -3269,7 +3304,7 @@
 			    (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
 		    1 11))))
 	 marker hdmarker priority category tags closedp
-	 ee txt timestr)
+	 ee txt timestr rest)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -3280,9 +3315,15 @@
 	      timestr (buffer-substring (match-beginning 0) (point-at-eol))
 	      ;; donep (org-entry-is-done-p)
 	      )
-	(if (string-match "\\]" timestr)
-	    ;; substring should only run to end of time stamp
-	    (setq timestr (substring timestr 0 (match-end 0))))
+	(when (string-match "\\]" timestr)
+	  ;; substring should only run to end of time stamp
+	  (setq rest (substring timestr (match-end 0))
+		timestr (substring timestr 0 (match-end 0)))
+	  (if (and (not closedp)
+		   (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\]" rest))
+	      (setq timestr (concat (substring timestr 0 -1)
+				    "-" (match-string 1 rest) "]"))))
+		
 	(save-excursion
 	  (if (re-search-backward "^\\*+ " nil t)
 	      (progn
@@ -3309,6 +3350,7 @@
   (let* ((props (list 'mouse-face 'highlight
 		      'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'keymap org-agenda-keymap
 		      'help-echo
 		      (format "mouse-2 or RET jump to org file %s"
@@ -3394,6 +3436,7 @@
   "Return the scheduled information for agenda display."
   (let* ((props (list 'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'done-face 'org-done
 		      'mouse-face 'highlight
 		      'keymap org-agenda-keymap
@@ -3469,6 +3512,7 @@
   (let* ((props (list 'face nil
 		      'org-not-done-regexp org-not-done-regexp
 		      'org-todo-regexp org-todo-regexp
+		      'org-complex-heading-regexp org-complex-heading-regexp
 		      'mouse-face 'highlight
 		      'keymap org-agenda-keymap
 		      'help-echo
@@ -4137,12 +4181,12 @@
   (setq org-agenda-ndays 7)
   (org-agenda-change-time-span 'week iso-week))
 (defun org-agenda-month-view (&optional month)
-  "Switch to daily view for agenda.
+  "Switch to monthly view for agenda.
 With argument MONTH, switch to that month."
   (interactive "P")
   (org-agenda-change-time-span 'month month))
 (defun org-agenda-year-view (&optional year)
-  "Switch to daily view for agenda.
+  "Switch to yearly view for agenda.
 With argument YEAR, switch to that year.
 If MONTH has more then 2 digits, only the last two encode the
 month.  Any digits before this encode a year.  So 200712 means
@@ -4331,7 +4375,10 @@
 
 (defun org-agenda-post-command-hook ()
   (and (eolp) (not (bolp)) (backward-char 1))
-  (setq org-agenda-type (get-text-property (point) 'org-agenda-type))
+  (setq org-agenda-type
+	(or (get-text-property (point) 'org-agenda-type)
+	    (get-text-property (max (point-min) (1- (point)))
+			       'org-agenda-type)))
   (if (and org-agenda-follow-mode
 	   (get-text-property (point) 'org-marker))
       (org-agenda-show)))
@@ -4890,6 +4937,69 @@
       (org-agenda-show-new-time marker ts "S"))
 	(message "Deadline for this item set to %s" ts)))
 
+(defun org-agenda-action ()
+  "Select entry for agenda action, or execute an agenda action.
+This command prompts for another letter.  Valid inputs are:
+
+m     Mark the entry at point for an agenda action
+s     Schedule the marked entry to the date at the cursor
+d     Set the deadline of the marked entry to the date at the cursor
+r     Call `org-remember' with cursor date as the default date
+SPC   Show marked entry in other window
+TAB   Visit marked entry in other window
+
+The cursor may be at a date in the calendar, or in the Org agenda."
+  (interactive)
+  (let (pos ans)
+    (message "Select action: [m]ark | [s]chedule [d]eadline [r]emember [ ]show")
+    (setq ans (read-char-exclusive))
+    (cond
+     ((equal ans ?m)
+      ;; Mark this entry
+      (if (eq major-mode 'org-agenda-mode)
+	  (let ((m (or (get-text-property (point) 'org-hd-marker)
+		       (get-text-property (point) 'org-marker))))
+	    (if m
+		(progn
+		  (move-marker org-agenda-action-marker
+			       (marker-position m) (marker-buffer m))
+		  (message "Entry marked for action; press `k' at desired date in agenda or calendar"))
+	      (error "Don't know which entry to mark")))
+	(error "This command works only in the agenda")))
+     ((equal ans ?s)
+      (org-agenda-do-action '(org-schedule nil org-overriding-default-time)))
+     ((equal ans ?d)
+      (org-agenda-do-action '(org-deadline nil org-overriding-default-time)))
+     ((equal ans ?r)
+      (org-agenda-do-action '(org-remember) t))
+     ((equal ans ?\ )
+      (let ((cw (selected-window)))
+	(org-switch-to-buffer-other-window
+	 (marker-buffer org-agenda-action-marker))
+	(goto-char org-agenda-action-marker)
+	(org-show-context 'agenda)
+	(select-window cw)))
+     ((equal ans ?\C-i)
+      (org-switch-to-buffer-other-window
+       (marker-buffer org-agenda-action-marker))
+      (goto-char org-agenda-action-marker)
+      (org-show-context 'agenda))
+     (t (error "Invalid agenda action %c" ans)))))
+
+(defun org-agenda-do-action (form &optional current-buffer)
+  "Evaluate FORM at the entry pointed to by `org-agenda-action-marker'."
+  (let ((org-overriding-default-time (org-get-cursor-date)))
+    (if current-buffer
+	(eval form)
+      (if (not (marker-buffer org-agenda-action-marker))
+	  (error "No entry has bee selected for agenda action")
+	(with-current-buffer (marker-buffer org-agenda-action-marker)
+	  (save-excursion
+	    (save-restriction
+	      (widen)
+	      (goto-char org-agenda-action-marker)
+	      (eval form))))))))
+  
 (defun org-agenda-clock-in (&optional arg)
   "Start the clock on the currently selected item."
   (interactive "P")
@@ -4898,12 +5008,20 @@
       (org-clock-in arg)
     (let* ((marker (or (get-text-property (point) 'org-marker)
 		       (org-agenda-error)))
-	   (pos (marker-position marker)))
+	   (hdmarker (or (get-text-property (point) 'org-hd-marker)
+			 marker))
+	   (pos (marker-position marker))
+	   newhead)
       (org-with-remote-undo (marker-buffer marker)
         (with-current-buffer (marker-buffer marker)
 	  (widen)
 	  (goto-char pos)
-	  (org-clock-in arg))))))
+	  (org-show-context 'agenda)
+	  (org-show-entry)
+	  (org-cycle-hide-drawers 'children)
+	  (org-clock-in arg)
+	  (setq newhead (org-get-heading)))
+	(org-agenda-change-all-lines newhead hdmarker t)))))
 
 (defun org-agenda-clock-out (&optional arg)
   "Stop the currently running clock."
@@ -5141,6 +5259,8 @@
 
 (provide 'org-agenda)
 
+;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1
+
 ;;; org-agenda.el ends here
 
-;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1
+
--- a/lisp/org/org-archive.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-archive.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -64,8 +64,8 @@
 
 time       The time of archiving.
 file       The file where the entry originates.
-itags      The local tags, in the headline of the subtree.
-ltags      The tags the subtree inherits from further up the hierarchy.
+ltags      The local tags, in the headline of the subtree.
+itags      The tags the subtree inherits from further up the hierarchy.
 todo       The pre-archive TODO state.
 category   The category, taken from file name or #+CATEGORY lines.
 olpath     The outline path to the item.  These are all headlines above
@@ -80,7 +80,7 @@
 	  (const :tag "File" file)
 	  (const :tag "Category" category)
 	  (const :tag "TODO state" todo)
-	  (const :tag "TODO state" priority)
+	  (const :tag "Priority" priority)
 	  (const :tag "Inherited tags" itags)
 	  (const :tag "Outline path" olpath)
 	  (const :tag "Local tags" ltags)))
@@ -135,14 +135,19 @@
     files))
 
 (defun org-extract-archive-file (&optional location)
+  "Extract and expand the file name from archive LOCATION.
+if LOCATION is not given, the value of `org-archive-location' is used."
   (setq location (or location org-archive-location))
   (if (string-match "\\(.*\\)::\\(.*\\)" location)
       (if (= (match-beginning 1) (match-end 1))
 	  (buffer-file-name)
 	(expand-file-name
-	 (format (match-string 1 location) buffer-file-name)))))
+	 (format (match-string 1 location)
+		 (file-name-nondirectory buffer-file-name))))))
 
 (defun org-extract-archive-heading (&optional location)
+  "Extract the heading from archive LOCATION.
+if LOCATION is not given, the value of `org-archive-location' is used."
   (setq location (or location org-archive-location))
   (if (string-match "\\(.*\\)::\\(.*\\)" location)
       (match-string 2 location)))
@@ -180,7 +185,7 @@
 		 (current-time)))
 	  category todo priority ltags itags
           ;; end of variables that will be used for saving context
-	  location afile heading buffer level newfile-p)
+	  location afile heading buffer level newfile-p visiting)
 
       ;; Find the local archive location
       (setq location (org-get-local-archive-location)
@@ -191,7 +196,8 @@
 
       (if (> (length afile) 0)
 	  (setq newfile-p (not (file-exists-p afile))
-		buffer (find-file-noselect afile))
+		visiting (find-buffer-visiting afile)
+		buffer (or visiting (find-file-noselect afile)))
 	(setq buffer (current-buffer)))
       (unless buffer
 	(error "Cannot access file \"%s\"" afile))
@@ -213,9 +219,9 @@
 	(setq ltags (mapconcat 'identity ltags " ")
 	      itags (mapconcat 'identity itags " "))
 	;; We first only copy, in case something goes wrong
-	;; we need to protect this-command, to avoid kill-region sets it,
+	;; we need to protect `this-command', to avoid kill-region sets it,
 	;; which would lead to duplication of subtrees
-	(let (this-command) (org-copy-subtree))
+	(let (this-command) (org-copy-subtree 1 nil t))
 	(set-buffer buffer)
 	;; Enforce org-mode for the archive buffer
 	(if (not (org-mode-p))
@@ -283,12 +289,18 @@
 		  (org-entry-put (point) n v)))))
 
 	  ;; Save and kill the buffer, if it is not the same buffer.
-	  (if (not (eq this-buffer buffer))
-	      (progn (save-buffer) (kill-buffer buffer)))))
+	  (when (not (eq this-buffer buffer))
+	    (save-buffer)
+	    ;; Check if it is OK to kill the buffer
+	    (unless
+		(or visiting
+		    (equal (marker-buffer org-clock-marker) (current-buffer)))
+	      (kill-buffer buffer)))
+	  ))
       ;; Here we are back in the original buffer.  Everything seems to have
       ;; worked.  So now cut the tree and finish up.
       (let (this-command) (org-cut-subtree))
-      (if (and (not (eobp)) (looking-at "[ \t]*$")) (kill-line))
+      (setq org-markers-to-move nil)
       (message "Subtree archived %s"
 	       (if (eq this-buffer buffer)
 		   (concat "under heading: " heading)
@@ -404,4 +416,5 @@
 (provide 'org-archive)
 
 ;; arch-tag: 0837f601-9699-43c3-8b90-631572ae6c85
+
 ;;; org-archive.el ends here
--- a/lisp/org/org-bbdb.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-bbdb.el	Tue Jun 17 15:22:00 2008 +0000
@@ -6,7 +6,7 @@
 ;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -30,7 +30,6 @@
 ;; Org-mode loads this module by default - if this is not what you want,
 ;; configure the variable `org-modules'.
 
-
 ;; It also implements an interface (based on Ivar Rummelhoff's
 ;; bbdb-anniv.el) for those org-mode users, who do not use the diary
 ;; but who do want to include the anniversaries stored in the BBDB
@@ -77,7 +76,10 @@
 ;;       1973-06-22
 ;;       20??-??-?? wedding
 ;;       1998-03-12 %s created bbdb-anniv.el %d years ago
-
+;;
+;; From Org's agenda, you can use `C-c C-o' to jump to the BBDB
+;; link from which the entry at point originates.
+;;
 ;;; Code:
 
 (require 'org)
@@ -100,7 +102,7 @@
 (declare-function calendar-leap-year-p "calendar" (year))
 (declare-function diary-ordinal-suffix "diary-lib" (n))
 
-(defvar date)
+(defvar date)   ;; dynamically scoped from Org
 
 ;; Customization
 
@@ -115,8 +117,16 @@
   :require 'bbdb)
 
 (defcustom org-bbdb-anniversary-format-alist
-  '( ("birthday" . "Birthday: %s (%d%s)")
-     ("wedding"  . "%s's %d%s wedding anniversary") )
+  '(("birthday" lambda
+     (name years suffix)
+     (concat "Birthday: [[bbdb:" name "][" name " ("
+	     (number-to-string years)
+	     suffix ")]]"))
+    ("wedding" lambda
+     (name years suffix)
+     (concat "[[bbdb:" name "][" name "'s "
+	     (number-to-string years)
+	     suffix " wedding anniversary]]")))
   "How different types of anniversaries should be formatted.
 An alist of elements (STRING . FORMAT) where STRING is the name of an
 anniversary class and format is either:
@@ -227,17 +237,19 @@
 		  (bbdb-string-trim (substring str pos)))
       (list str nil))))
 
+(defvar org-bbdb-anniv-hash nil
+  "A hash holding anniversaries extracted from BBDB.
+The hash table is created on first use.")
 
-;;;###autoload
-(defun org-bbdb-anniversaries ()
-  "Extract anniversaries from BBDB for display in the agenda."
-  (require 'diary-lib)
-  (let ((dates (list (cons (cons (car date)    ; month
-                                 (nth 1 date)) ; day
-                           (nth 2 date))))     ; year
-        (text ())
-        annivs date years
-        split class form)
+(defvar org-bbdb-updated-p t
+  "This is non-nil if BBDB has been updated since we last built the hash.")
+
+(defun org-bbdb-make-anniv-hash ()
+  "Create a hash with anniversaries extracted from BBDB, for fast access.
+The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
+
+  (let (split tmp annivs)
+    (clrhash org-bbdb-anniv-hash)
     (dolist (rec (bbdb-records))
       (when (setq annivs (bbdb-record-getprop
                           rec org-bbdb-anniversary-field))
@@ -246,33 +258,70 @@
           (setq split (org-bbdb-anniv-split (pop annivs)))
           (multiple-value-bind (m d y)
               (funcall org-bbdb-extract-date-fun (car split))
+            (setq tmp (gethash (list m d) org-bbdb-anniv-hash))
+            (puthash (list m d) (cons (list y 
+                                            (bbdb-record-name rec) 
+                                            (cadr split))
+                                      tmp)
+                     org-bbdb-anniv-hash))))))
+  (setq org-bbdb-updated-p nil))
 
-            (when (and (or (setq date (assoc (cons m d) dates))
-                           (and (= d 29)
-                                (= m 2)
-                                (setq date (assoc '(3 . 1) dates))
-                                (not (calendar-leap-year-p (cdr date)))))
-                       (< 0 (setq years (-  (cdr date) y))))
-              (let* ((class (or (cadr split)
-                                org-bbdb-default-anniversary-format))
-                     (form (or (cdr (assoc class
-                                           org-bbdb-anniversary-format-alist))
-                               class))	; (as format string)
-                     (name (bbdb-record-name rec))
-                     (suffix (diary-ordinal-suffix years))
-                     (tmp (cond
-                           ((functionp form)
-                            (funcall form name years suffix))
-                           ((listp form) (eval form))
-                           (t (format form name years suffix)))))
-                (if text
-                    (setq text (append text (list tmp)))
-                  (setq text (list tmp))))
-              )))))
+(defun org-bbdb-updated (rec)
+  "Record the fact that BBDB has been updated.
+This is used by Org to re-create the anniversary hash table."
+  (setq org-bbdb-updated-p t))
+
+(add-hook 'bbdb-after-change-hook 'org-bbdb-updated)
+
+;;;###autoload
+(defun org-bbdb-anniversaries()
+  "Extract anniversaries from BBDB for display in the agenda."
+  (require 'diary-lib)
+  (unless (hash-table-p org-bbdb-anniv-hash)
+    (setq org-bbdb-anniv-hash
+	  (make-hash-table :test 'equal :size 366)))
+
+  (when (or org-bbdb-updated-p
+            (= 0 (hash-table-count org-bbdb-anniv-hash)))
+    (org-bbdb-make-anniv-hash))
+
+  (let* ((m (car date))    ; month
+         (d (nth 1 date))  ; day
+         (y (nth 2 date))  ; year
+         (annivs (gethash (list m d) org-bbdb-anniv-hash))
+         (text ())
+         split class form rec)
+    
+    ;; we don't want to miss people born on Feb. 29th
+    (when (and (= m 3) (= d 1) (not (calendar-leap-year-p y)))
+      (setq annivs (cons annivs (gethash (list 2 29) org-bbdb-anniv-hash))))
+
+    (when annivs
+      (while (setq rec (pop annivs))
+        (when rec 
+          (let* ((class (or (nth 2 rec)
+                            org-bbdb-default-anniversary-format))
+                 (form (or (cdr (assoc class
+                                       org-bbdb-anniversary-format-alist))
+                           class))	; (as format string)
+                 (name (nth 1 rec))
+                 (years (- y (car rec)))
+                 (suffix (diary-ordinal-suffix years))
+                 (tmp (cond
+                       ((functionp form)
+                        (funcall form name years suffix))
+                       ((listp form) (eval form))
+                       (t (format form name years suffix)))))
+	    (org-add-props tmp nil 'org-bbdb-name name)
+            (if text
+                (setq text (append text (list tmp)))
+              (setq text (list tmp)))))
+        ))
     (when text
       (mapconcat 'identity text "; "))))
 
 (provide 'org-bbdb)
 
 ;; arch-tag: 9e4f275d-d080-48c1-b040-62247f66b5c2
+
 ;;; org-bbdb.el ends here
--- a/lisp/org/org-bibtex.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-bibtex.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Bastien Guerry <bzg at altern dot org>
 ;;         Carsten Dominik <carsten dot dominik at gmail dot com>
 ;; Keywords: org, wp, remember
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -200,4 +200,5 @@
 (provide 'org-bibtex)
 
 ;; arch-tag: 83987d5a-01b8-41c7-85bc-77700f1285f5
+
 ;;; org-bibtex.el ends here
--- a/lisp/org/org-clock.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-clock.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -97,11 +97,7 @@
 (defvar org-clock-start-time "")
 
 (defvar org-clock-history nil
-  "Marker pointing to the previous task teking clock time.
-This is used to find back to the previous task after interrupting work.
-When clocking into a task and the clock is currently running, this marker
-is moved to the position of the currently running task and continues
-to point there even after the task is clocked out.")
+  "List of marker pointing to recent clocked tasks.")
 
 (defvar org-clock-default-task (make-marker)
   "Marker pointing to the default task that should clock time.
@@ -109,12 +105,11 @@
 of a different task.")
 
 (defvar org-clock-interrupted-task (make-marker)
-  "Marker pointing to the default task that should clock time.
-The clock can be made to switch to this task after clocking out
-of a different task.")
+  "Marker pointing to the task that has been interrupted by the current clock.")
 
 (defun org-clock-history-push (&optional pos buffer)
   "Push a marker to the clock history."
+  (setq org-clock-history-length (max 1 (min 35 org-clock-history-length)))
   (let ((m (move-marker (make-marker) (or pos (point)) buffer)) n l)
     (while (setq n (member m org-clock-history))
       (move-marker (car n) nil))
@@ -129,6 +124,14 @@
 		     (nreverse org-clock-history)))))
     (push m org-clock-history)))
 
+(defun org-clock-save-markers-for-cut-and-paste (beg end)
+  "Save relative positions of markers in region."
+  (org-check-and-save-marker org-clock-marker beg end)
+  (org-check-and-save-marker org-clock-default-task beg end)
+  (org-check-and-save-marker org-clock-interrupted-task beg end)
+  (mapc (lambda (m) (org-check-and-save-marker m beg end))
+	org-clock-history))
+
 (defun org-clock-select-task (&optional prompt)
   "Select a task that recently was associated with clocking."
   (interactive)
@@ -155,10 +158,14 @@
 	 (when (marker-buffer m)
 	   (setq i (1+ i)
 		 s (org-clock-insert-selection-line
-		    (string-to-char (number-to-string i)) m))
+		    (if (< i 10)
+			(+ i ?0)
+		      (+ i (- ?A 10))) m))
 	   (push s sel-list)))
        org-clock-history)
-      (shrink-window-if-larger-than-buffer)
+      (if (fboundp 'fit-window-to-buffer)
+	  (fit-window-to-buffer)
+	(shrink-window-if-larger-than-buffer))
       (message (or prompt "Select task for clocking:"))
       (setq rpl (read-char-exclusive))
       (cond
@@ -170,14 +177,16 @@
 (defun org-clock-insert-selection-line (i marker)
   (when (marker-buffer marker)
     (let (file cat task)
-      (with-current-buffer (marker-buffer marker)
+      (with-current-buffer (org-base-buffer (marker-buffer marker))
 	(save-excursion
-	  (goto-char marker)
-	  (setq file (buffer-file-name (marker-buffer marker))
-		cat (or (org-get-category)
-			(progn (org-refresh-category-properties)
-			       (org-get-category)))
-		task (org-get-heading 'notags))))
+	  (save-restriction
+	    (widen)
+	    (goto-char marker)
+	    (setq file (buffer-file-name (marker-buffer marker))
+		  cat (or (org-get-category)
+			  (progn (org-refresh-category-properties)
+				 (org-get-category)))
+		  task (org-get-heading 'notags)))))
       (when (and cat task)
 	(insert (format "[%c] %-15s %s\n" i cat task))
 	(cons i marker)))))
@@ -188,7 +197,7 @@
 	 (h (floor delta 3600))
 	 (m (floor (- delta (* 3600 h)) 60)))
     (setq org-mode-line-string
-	  (propertize (format "-[%d:%02d (%s)]" h m org-clock-heading)
+	  (propertize (format (concat "-[" org-time-clocksum-format " (%s)]") h m org-clock-heading)
 		      'help-echo "Org-mode clock is running"))
     (force-mode-line-update)))
 
@@ -204,60 +213,69 @@
 the clocking selection, associated with the letter `d'."
   (interactive "P")
   (let ((interrupting (marker-buffer org-clock-marker))
-	ts selected-task)
+	ts selected-task target-pos)
     (when (equal select '(4))
       (setq selected-task (org-clock-select-task "Clock-in on task: "))
       (if selected-task
 	  (setq selected-task (copy-marker selected-task))
 	(error "Abort")))
-    ;; Are we interrupting the clocking of a differnt task?
-    (if interrupting
-	(progn
-	  (move-marker org-clock-interrupted-task
-		       (marker-position org-clock-marker)
-		       (marker-buffer org-clock-marker))
-	  (org-clock-out t)))
+    (when interrupting
+      ;; We are interrupting the clocking of a differnt task.
+      ;; Save a marker to this task, so that we can go back.
+      (move-marker org-clock-interrupted-task
+		   (marker-position org-clock-marker)
+		   (marker-buffer org-clock-marker))
+      (org-clock-out t))
     
     (when (equal select '(16))
+      ;; Mark as default clocking task
       (save-excursion
 	(org-back-to-heading t)
 	(move-marker org-clock-default-task (point))))
     
+    (setq target-pos (point))  ;; we want to clock in at this location
     (save-excursion
-      (org-back-to-heading t)
       (when (and selected-task (marker-buffer selected-task))
-	(set-buffer (marker-buffer selected-task))
-	(goto-char selected-task)
+	;; There is a selected task, move to the correct buffer
+	;; and set the new target position.
+	(set-buffer (org-base-buffer (marker-buffer selected-task)))
+	(setq target-pos (marker-position selected-task))
 	(move-marker selected-task nil))
-      (or interrupting (move-marker org-clock-interrupted-task nil))
-      (org-clock-history-push)
-      (when (and org-clock-in-switch-to-state
-		 (not (looking-at (concat outline-regexp "[ \t]*"
-					  org-clock-in-switch-to-state
-					  "\\>"))))
-	(org-todo org-clock-in-switch-to-state))
-      (if (and org-clock-heading-function
-	       (functionp org-clock-heading-function))
-	  (setq org-clock-heading (funcall org-clock-heading-function))
-	(if (looking-at org-complex-heading-regexp)
-	    (setq org-clock-heading (match-string 4))
-	  (setq org-clock-heading "???")))
-      (setq org-clock-heading (propertize org-clock-heading 'face nil))
-      (org-clock-find-position)
-      
-      (insert "\n") (backward-char 1)
-      (indent-relative)
-      (insert org-clock-string " ")
-      (setq org-clock-start-time (current-time))
-      (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
-      (move-marker org-clock-marker (point) (buffer-base-buffer))
-      (or global-mode-string (setq global-mode-string '("")))
-      (or (memq 'org-mode-line-string global-mode-string)
-	  (setq global-mode-string
-		(append global-mode-string '(org-mode-line-string))))
-      (org-update-mode-line)
-      (setq org-mode-line-timer (run-with-timer 60 60 'org-update-mode-line))
-      (message "Clock started at %s" ts))))
+      (save-excursion
+	(save-restriction
+	  (widen)
+	  (goto-char target-pos)
+	  (org-back-to-heading t)
+	  (or interrupting (move-marker org-clock-interrupted-task nil))
+	  (org-clock-history-push)
+	  (when (and org-clock-in-switch-to-state
+		     (not (looking-at (concat outline-regexp "[ \t]*"
+					      org-clock-in-switch-to-state
+					      "\\>"))))
+	    (org-todo org-clock-in-switch-to-state))
+	  (if (and org-clock-heading-function
+		   (functionp org-clock-heading-function))
+	      (setq org-clock-heading (funcall org-clock-heading-function))
+	    (if (looking-at org-complex-heading-regexp)
+		(setq org-clock-heading (match-string 4))
+	      (setq org-clock-heading "???")))
+	  (setq org-clock-heading (propertize org-clock-heading 'face nil))
+	  (org-clock-find-position)
+	  
+	  (insert "\n") (backward-char 1)
+	  (indent-relative)
+	  (insert org-clock-string " ")
+	  (setq org-clock-start-time (current-time))
+	  (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
+	  (move-marker org-clock-marker (point) (buffer-base-buffer))
+	  (or global-mode-string (setq global-mode-string '("")))
+	  (or (memq 'org-mode-line-string global-mode-string)
+	      (setq global-mode-string
+		    (append global-mode-string '(org-mode-line-string))))
+	  (org-update-mode-line)
+	  (setq org-mode-line-timer
+		(run-with-timer 60 60 'org-update-mode-line))
+	  (message "Clock started at %s" ts))))))
 
 (defun org-clock-find-position ()
   "Find the location where the next clock line should be inserted."
@@ -288,7 +306,6 @@
 	;; Wrap current entries into a new drawer
 	(goto-char last)
 	(beginning-of-line 2)
-	(if (org-at-item-p) (org-end-of-item))
 	(insert ":END:\n")
 	(beginning-of-line 0)
 	(org-indent-line-function)
@@ -358,7 +375,7 @@
 	(setq global-mode-string
 	      (delq 'org-mode-line-string global-mode-string))
 	(force-mode-line-update)
-	(message "Clock stopped at %s after HH:MM = %d:%02d%s" te h m
+	(message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
 		 (if remove " => LINE REMOVED" "")))))))
 
 (defun org-clock-cancel ()
@@ -387,6 +404,7 @@
 	    (error "No task selected")
 	  (error "No active clock")))
     (switch-to-buffer (marker-buffer m))
+    (if (or (< m (point-min)) (> m (point-max))) (widen))
     (goto-char m)
     (org-show-entry)
     (org-back-to-heading)
@@ -469,7 +487,7 @@
 	(when org-remove-highlights-with-change
 	  (org-add-hook 'before-change-functions 'org-remove-clock-overlays
 			nil 'local))))
-    (message "Total file time: %d:%02d (%d hours and %d minutes)" h m h m)))
+    (message (concat "Total file time: " org-time-clocksum-format " (%d hours and %d minutes)") h m h m)))
 
 (defvar org-clock-overlays nil)
 (make-variable-buffer-local 'org-clock-overlays)
@@ -481,6 +499,7 @@
 will be easy to remove."
   (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h)))
 	 (l (if level (org-get-valid-level level 0) 0))
+	 (fmt (concat "%s " org-time-clocksum-format "%s"))
 	 (off 0)
 	 ov tx)
     (org-move-to-column c)
@@ -489,7 +508,7 @@
     (setq ov (org-make-overlay (1- (point)) (point-at-eol))
 	  tx (concat (buffer-substring (1- (point)) (point))
 		     (make-string (+ off (max 0 (- c (current-column)))) ?.)
-		     (org-add-props (format "%s %2d:%02d%s"
+		     (org-add-props (format fmt
 					    (make-string l ?*) h m
 					    (make-string (- 16 l) ?\ ))
 			 '(face secondary-selection))
@@ -920,7 +939,6 @@
 
 (provide 'org-clock)
 
-;;; org-clock.el ends here
+;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
 
-
-;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
+;;; org-clock.el ends here
--- a/lisp/org/org-colview.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-colview.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -32,6 +32,8 @@
 (eval-when-compile (require 'cl))
 (require 'org)
 
+(declare-function org-agenda-redo "org-agenda" ())
+
 ;;; Column View
 
 (defvar org-columns-overlays nil
@@ -90,6 +92,10 @@
 (org-defkey org-columns-map [(meta left)] 'org-columns-move-left)
 (org-defkey org-columns-map [(shift meta right)] 'org-columns-new)
 (org-defkey org-columns-map [(shift meta left)] 'org-columns-delete)
+(dotimes (i 10)
+  (org-defkey org-columns-map (number-to-string i)
+              `(lambda () (interactive)
+                 (org-columns-next-allowed-value nil ,i))))
 
 (easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
   '("Column"
@@ -137,12 +143,11 @@
 		       (and (eq major-mode 'org-agenda-mode)
 			    (get-text-property (point-at-bol) 'face))
 		       'default))
-	 (color (list :foreground
-		      (face-attribute ref-face :foreground)
-		      :weight 'normal :strike-through nil
-		      :underline nil))
-	 (face (list color 'org-column level-face))
-	 pom property ass width f string ov column val modval)
+	 (color (list :foreground (face-attribute ref-face :foreground)))
+	 (face (list color 'org-column ref-face))
+	 (pl (or (get-text-property (point-at-bol) 'prefix-length) 0))
+	 (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp))
+	 pom property ass width f string ov column val modval s1 s2)
     ;; Check if the entry is in another buffer.
     (unless props
       (if (eq major-mode 'org-agenda-mode)
@@ -167,8 +172,13 @@
 	    f (format "%%-%d.%ds | " width width)
 	    val (or (cdr ass) "")
 	    modval (if (equal property "ITEM")
-		       (org-columns-cleanup-item val org-columns-current-fmt-compiled))
-	    string (format f (or modval val)))
+		       (if (org-mode-p)
+			   (org-columns-cleanup-item
+			    val org-columns-current-fmt-compiled)
+			 (org-agenda-columns-cleanup-item
+			  val pl cphr org-columns-current-fmt-compiled))))
+      (setq s2 (org-columns-add-ellipses (or modval val) width))
+      (setq string (format f s2))
       ;; Create the overlay
       (org-unmodified
        (setq ov (org-columns-new-overlay
@@ -200,6 +210,15 @@
 			  (min (point-max) (1+ (point-at-eol)))
 			  'read-only "Type `e' to edit property")))))
 
+(defun org-columns-add-ellipses (string width)
+  "Truncate STRING with WIDTH characters, with ellipses."
+  (cond 
+   ((<= (length string) width) string)
+   ((<= width (length org-columns-ellipses))
+    (substring org-columns-ellipses 0 width))
+   (t (concat (substring string 0 (- width (length org-columns-ellipses)))
+	      org-columns-ellipses))))
+
 (defvar org-columns-full-header-line-format nil
   "Fthe full header line format, will be shifted by horizontal scrolling." )
 (defvar org-previous-header-line-format nil
@@ -275,13 +294,40 @@
   (if (not org-complex-heading-regexp)
       item
     (when (string-match org-complex-heading-regexp item)
-      (concat
-       (org-add-props (concat (match-string 1 item) " ") nil
-	 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
-       (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item)))
-       (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item)))
-       " " (match-string 4 item)
-       (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item)))))))
+      (setq item
+	    (concat
+	     (org-add-props (match-string 1 item) nil
+	       'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
+	     (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item)))
+	     (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item)))
+	     " " (save-match-data (org-columns-compact-links (match-string 4 item)))
+	     (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item)))))
+      (add-text-properties
+       0 (1+ (match-end 1))
+       (list 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
+       item)
+      item)))
+
+(defun org-columns-compact-links (s)
+  "Replace [[link][desc]] with [desc] or [link]."
+  (while (string-match org-bracket-link-regexp s)
+    (setq s (replace-match
+	     (concat "[" (match-string (if (match-end 3) 3 1) s) "]")
+	     t t s)))
+  s)
+
+(defvar org-agenda-columns-remove-prefix-from-item)
+(defun org-agenda-columns-cleanup-item (item pl cphr fmt)
+  "Cleanup the tiem property for agenda column view.
+See also the variable `org-agenda-columns-remove-prefix-from-item'."
+  (let* ((org-complex-heading-regexp cphr)
+	 (prefix (substring item 0 pl))
+	 (rest (substring item pl))
+	 (fake (concat "* " rest))
+	 (cleaned (org-trim (substring (org-columns-cleanup-item fake fmt) 1))))
+    (if org-agenda-columns-remove-prefix-from-item
+	cleaned
+      (concat prefix cleaned))))
 
 (defun org-columns-show-value ()
   "Show the full value of the property."
@@ -381,7 +427,7 @@
 
       (cond
        ((equal major-mode 'org-agenda-mode)
-	(org-columns-eval '(org-entry-put pom key nval))
+	(org-columns-eval eval)
 	;; The following let preserves the current format, and makes sure
 	;; that in only a single file things need to be upated.
 	(let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
@@ -411,7 +457,8 @@
   "Edit the current headline, the part without TODO keyword, TAGS."
   (org-back-to-heading)
   (when (looking-at org-todo-line-regexp)
-    (let ((pre (buffer-substring (match-beginning 0) (match-beginning 3)))
+    (let ((pos (point))
+	  (pre (buffer-substring (match-beginning 0) (match-beginning 3)))
 	  (txt (match-string 3))
 	  (post "")
 	  txt2)
@@ -420,7 +467,7 @@
 		txt (substring txt 0 (match-beginning 0))))
       (setq txt2 (read-string "Edit: " txt))
       (when (not (equal txt txt2))
-	(beginning-of-line 1)
+	(goto-char pos)
 	(insert pre txt2 post)
 	(delete-region (point) (point-at-eol))
 	(org-set-tags nil t)))))
@@ -461,8 +508,10 @@
   (interactive)
   (org-columns-next-allowed-value t))
 
-(defun org-columns-next-allowed-value (&optional previous)
-  "Switch to the next allowed value for this column."
+(defun org-columns-next-allowed-value (&optional previous nth)
+  "Switch to the next allowed value for this column.
+When PREVIOUS is set, go to the previous value.  When NTH is
+an integer, select that value."
   (interactive)
   (org-columns-check-computed)
   (let* ((col (current-column))
@@ -484,6 +533,9 @@
 			    '(checkbox checkbox-n-of-m checkbox-percent))
 			   '("[ ]" "[X]"))))
 	 nval)
+    (when (integerp nth)
+      (setq nth (1- nth))
+      (if (= nth -1) (setq nth 9)))
     (when (equal key "ITEM")
       (error "Cannot edit item headline from here"))
     (unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
@@ -491,11 +543,18 @@
     (if (member key '("SCHEDULED" "DEADLINE"))
 	(setq nval (if previous 'earlier 'later))
       (if previous (setq allowed (reverse allowed)))
-      (if (member value allowed)
-	  (setq nval (car (cdr (member value allowed)))))
-      (setq nval (or nval (car allowed)))
-      (if (equal nval value)
-	  (error "Only one allowed value for this property")))
+      (cond
+       (nth
+	(setq nval (nth nth allowed))
+	(if (not nval)
+	    (error "There are only %d allowed values for property `%s'"
+		   (length allowed) key)))
+       ((member value allowed)
+	(setq nval (or (car (cdr (member value allowed)))
+		       (car allowed)))
+	(if (equal nval value)
+	    (error "Only one allowed value for this property")))
+       (t (setq nval (car allowed)))))
     (cond
      ((equal major-mode 'org-agenda-mode)
       (org-columns-eval '(org-entry-put pom key nval))
@@ -812,13 +871,18 @@
   "Construct the column display again."
   (interactive)
   (message "Recomputing columns...")
-  (save-excursion
-    (if (marker-position org-columns-begin-marker)
-	(goto-char org-columns-begin-marker))
-    (org-columns-remove-overlays)
-    (if (org-mode-p)
-	(call-interactively 'org-columns)
-      (call-interactively 'org-agenda-columns)))
+  (let ((line (org-current-line))
+	(col (current-column)))
+    (save-excursion
+      (if (marker-position org-columns-begin-marker)
+	  (goto-char org-columns-begin-marker))
+      (org-columns-remove-overlays)
+      (if (org-mode-p)
+	  (call-interactively 'org-columns)
+	(org-agenda-redo)
+	(call-interactively 'org-agenda-columns)))
+    (goto-line line)
+    (move-to-column col))
   (message "Recomputing columns...done"))
 
 (defun org-columns-not-in-agenda ()
@@ -840,7 +904,7 @@
   (cond
    ((eq fmt 'add_times)
     (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
-      (format "%d:%02d" h m)))
+      (format org-time-clocksum-format h m)))
    ((eq fmt 'checkbox)
     (cond ((= n (floor n)) "[X]")
 	  ((> n 1.) "[-]")
@@ -1212,6 +1276,6 @@
 
 (provide 'org-colview)
 
-;;; org-colview.el ends here
+;; arch-tag: 61f5128d-747c-4983-9479-e3871fa3d73c
 
-;; arch-tag: 61f5128d-747c-4983-9479-e3871fa3d73c
+;;; org-colview.el ends here
--- a/lisp/org/org-compat.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-compat.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -246,8 +246,8 @@
 			      (cadr ext-inv-spec))))
    (move-to-column column force)))
  
-
 (provide 'org-compat)
 
 ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
+
 ;;; org-compat.el ends here
--- a/lisp/org/org-exp.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-exp.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -33,6 +33,8 @@
 (declare-function org-export-latex-preprocess "org-export-latex" ())
 (declare-function org-agenda-skip "org-agenda" ())
 (declare-function org-infojs-options-inbuffer-template "org-jsinfo" ())
+(declare-function htmlize-region "ext:htmlize" (beg end))
+(defvar htmlize-buffer-places)  ; from htmlize.el
 
 (defgroup org-export nil
   "Options for exporting org-listings."
@@ -86,7 +88,9 @@
     ("fr"  "Auteur"          "Date"  "Table des mati\xe8res")
     ("it"  "Autore"          "Data"  "Indice")
     ("nl"  "Auteur"          "Datum" "Inhoudsopgave")
-    ("nn"  "Forfattar"       "Dato"  "Innhold")  ;; nn = Norsk (nynorsk)
+    ("no"  "Forfatter"       "Dato"  "Innhold")
+    ("nb"  "Forfatter"       "Dato"  "Innhold")  ;; nb = Norsk (bokm.l)
+    ("nn"  "Forfattar"       "Dato"  "Innhald")  ;; nn = Norsk (nynorsk)
     ("sv"  "F\xf6rfattarens" "Datum" "Inneh\xe5ll"))
   "Terms used in export text, translated to different languages.
 Use the variable `org-export-default-language' to set the language,
@@ -105,7 +109,7 @@
   :group 'org-export-general
   :type 'string)
 
-(defcustom org-export-skip-text-before-1st-heading t
+(defcustom org-export-skip-text-before-1st-heading nil
   "Non-nil means, skip all text before the first headline when exporting.
 When nil, that text is exported as well."
   :group 'org-export-general
@@ -128,6 +132,26 @@
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-section-number-format '((("1" ".")) . "")
+  "Format of section numbers for export.
+The variable has two components.
+1. A list of lists, each indicating a counter type and a separator.
+   The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"a\".
+   It causes causes numeric, alphabetic, or roman counters, respectively.
+   The separator is only used if another counter for a subsection is being
+   added.
+   If there are more numbered section levels than entries in this lists,
+   then the last entry will be reused.
+2. A terminator string that will be added after the entire
+   section number."
+  :group 'org-export-general
+  :type '(cons
+	  (repeat
+	   (list
+	    (string :tag "Counter Type")
+	    (string :tag "Separator   ")))
+	  (string :tag "Terminator")))
+
 (defcustom org-export-with-toc t
   "Non-nil means, create a table of contents in exported files.
 The TOC contains headlines with levels up to`org-export-headline-levels'.
@@ -227,6 +251,10 @@
 	  (repeat :tag "Selected drawers"
 		  (string :tag "Drawer name"))))
 
+(defvar org-export-preprocess-hook nil
+  "Hook for preprocessing an export buffer.
+Pretty much the first thing when exporting is running this hook.")
+
 (defgroup org-export-translation nil
   "Options for translating special ascii sequences for the export backends."
   :tag "Org Export Translation"
@@ -456,12 +484,14 @@
 	background-color: #F3F5F7;
 	padding: 5pt;
 	font-family: courier, monospace;
+        font-size: 90%;
   }
   table { border-collapse: collapse; }
   td, th {
 	vertical-align: top;
 	<!--border: 1pt solid #ADB9CC;-->
   }
+  dt { font-weight: bold; }
 </style>"
   "The default style specification for exported HTML files.
 Since there are different ways of setting style information, this variable
@@ -564,6 +594,25 @@
   :group 'org-export-html
   :type 'string)
 
+(defgroup org-export-htmlize nil
+  "Options for processing examples with htmlize.el."
+  :tag "Org Export Htmlize"
+  :group 'org-export-html)
+
+(defcustom org-export-htmlize-output-type 'inline-css
+  "Output type to be used by htmlize when formatting code snippets.
+Normally this is `inline-css', but if you have defined to appropriate
+classes in your css style file, setting this to `css' means that the
+fontification will use the class names.
+See also the function `org-export-htmlize-generate-css'."
+  :group 'org-export-htmlize
+  :type '(choice (const css) (const inline-css)))
+
+(defcustom org-export-htmlize-css-font-prefix "org-"
+  "The prefix for CSS class names for htmlize font specifications."
+  :group 'org-export-htmlize
+  :type 'string)
+
 (defgroup org-export-icalendar nil
   "Options specific for iCalendar export of Org-mode files."
   :tag "Org Export iCalendar"
@@ -606,6 +655,20 @@
   :group 'org-export-icalendar
   :type 'string)
 
+(defcustom org-icalendar-store-UID nil
+  "Non-nil means, store any created UIDs in properties.
+The iCalendar standard requires that all entries have a unique identifyer.
+Org will create these identifiers as needed.  When this variable is non-nil,
+the created UIDs will be stored in the ID property of the entry.  Then the
+next time this entry is exported, it will be exported with the same UID,
+superceeding the previous form of it.  This is essential for
+synchronization services.
+This variable is not turned on by default because we want to avoid creating
+a property drawer in every entry if people are only playing with this feature,
+or if they are only using it locally."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
 ;;;; Exporting
 
 ;;; Variables, constants, and parameter plists
@@ -630,6 +693,7 @@
     (:customtime           . org-display-custom-times)
     (:headline-levels      . org-export-headline-levels)
     (:section-numbers      . org-export-with-section-numbers)
+    (:section-number-format . org-export-section-number-format)
     (:table-of-contents    . org-export-with-toc)
     (:preserve-breaks      . org-export-preserve-breaks)
     (:archived-trees       . org-export-with-archived-trees)
@@ -694,16 +758,21 @@
   (save-excursion
     (save-restriction
       (widen)
-      (goto-char 0)
+      (goto-char (point-min))
       (let ((re (org-make-options-regexp
 		 (append
 		  '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
-		    "LINK_UP" "LINK_HOME")
+		    "LINK_UP" "LINK_HOME" "SETUPFILE")
 		  (mapcar 'car org-export-inbuffer-options-extra))))
-	    p key val text options js-up js-main js-css js-opt a pr)
-	(while (re-search-forward re nil t)
-	  (setq key (org-match-string-no-properties 1)
-		val (org-match-string-no-properties 2))
+	    p key val text options js-up js-main js-css js-opt a pr
+	    ext-setup-or-nil setup-contents (start 0))
+	(while (or (and ext-setup-or-nil
+			(string-match re ext-setup-or-nil start)
+			(setq start (match-end 0)))
+		   (and (setq ext-setup-or-nil nil start 0)
+			(re-search-forward re nil t)))
+	  (setq key (upcase (org-match-string-no-properties 1 ext-setup-or-nil))
+		val (org-match-string-no-properties 2 ext-setup-or-nil))
 	  (cond
 	   ((setq a (assoc key org-export-inbuffer-options-extra))
 	    (setq pr (nth 1 a))
@@ -716,41 +785,75 @@
 	   ((string-equal key "TEXT")
 	    (setq text (if text (concat text "\n" val) val)))
 	   ((string-equal key "OPTIONS")
-	    (setq options (concat options " " val)))
+	    (setq options (concat val " " options)))
 	   ((string-equal key "LINK_UP")
 	    (setq p (plist-put p :link-up val)))
 	   ((string-equal key "LINK_HOME")
-	    (setq p (plist-put p :link-home val)))))
+	    (setq p (plist-put p :link-home val)))
+	   ((equal key "SETUPFILE")
+	    (setq setup-contents (org-file-contents
+				  (expand-file-name
+				   (org-remove-double-quotes
+				    (org-trim val)))
+				  'noerror))
+	    (if (not ext-setup-or-nil)
+		(setq ext-setup-or-nil setup-contents start 0)
+	      (setq ext-setup-or-nil
+		    (concat (substring ext-setup-or-nil 0 start)
+			    "\n" setup-contents "\n"
+			    (substring ext-setup-or-nil start)))))))
 	(setq p (plist-put p :text text))
 	(when options
-	  (let ((op '(("H"     . :headline-levels)
-		      ("num"   . :section-numbers)
-		      ("toc"   . :table-of-contents)
-		      ("\\n"   . :preserve-breaks)
-		      ("@"     . :expand-quoted-html)
-		      (":"     . :fixed-width)
-		      ("|"     . :tables)
-		      ("^"     . :sub-superscript)
-		      ("-"     . :special-strings)
-		      ("f"     . :footnotes)
-		      ("d"     . :drawers)
-		      ("tags"  . :tags)
-		      ("*"     . :emphasize)
-		      ("TeX"   . :TeX-macros)
-		      ("LaTeX" . :LaTeX-fragments)
-		      ("skip"  . :skip-before-1st-heading)
-		      ("author" . :author-info)
-		      ("timestamp" . :time-stamp-file)))
-		o)
-	    (while (setq o (pop op))
-	      (if (string-match (concat (regexp-quote (car o))
-					":\\([^ \t\n\r;,.]*\\)")
-				options)
-		  (setq p (plist-put p (cdr o)
-				     (car (read-from-string
-					   (match-string 1 options)))))))))
+	  (setq p (org-export-add-options-to-plist p options)))
 	p))))
 
+(defun org-export-add-options-to-plist (p options)
+  "Parse an OPTONS line and set values in the property list P."
+  (let (o)
+    (when options
+      (let ((op '(("H"     . :headline-levels)
+		  ("num"   . :section-numbers)
+		  ("toc"   . :table-of-contents)
+		  ("\\n"   . :preserve-breaks)
+		  ("@"     . :expand-quoted-html)
+		  (":"     . :fixed-width)
+		  ("|"     . :tables)
+		  ("^"     . :sub-superscript)
+		  ("-"     . :special-strings)
+		  ("f"     . :footnotes)
+		  ("d"     . :drawers)
+		  ("tags"  . :tags)
+		  ("*"     . :emphasize)
+		  ("TeX"   . :TeX-macros)
+		  ("LaTeX" . :LaTeX-fragments)
+		  ("skip"  . :skip-before-1st-heading)
+		  ("author" . :author-info)
+		  ("timestamp" . :time-stamp-file)))
+	    o)
+	(while (setq o (pop op))
+	  (if (string-match (concat (regexp-quote (car o))
+				    ":\\([^ \t\n\r;,.]*\\)")
+			    options)
+	      (setq p (plist-put p (cdr o)
+				 (car (read-from-string
+				       (match-string 1 options))))))))))
+  p)
+  
+(defun org-export-add-subtree-options (p pos)
+  "Add options in subtree at position POS to property list P."
+  (save-excursion
+    (goto-char pos)
+    (when (org-at-heading-p)
+      (let (a)
+	;; This is actually read in `org-export-get-title-from-subtree'
+	;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
+	;;   (setq p (plist-put p :title a)))
+	(when (setq a (org-entry-get pos "EXPORT_TEXT"))
+	  (setq p (plist-put p :text a)))
+	(when (setq a (org-entry-get pos "EXPORT_OPTIONS"))
+	  (setq p (org-export-add-options-to-plist p a)))))
+    p))
+
 (defun org-export-directory (type plist)
   (let* ((val (plist-get plist :publishing-directory))
 	 (dir (if (listp val)
@@ -758,6 +861,12 @@
 		val)))
     dir))
 
+(defun org-export-process-option-filters (plist)
+  (let ((functions org-export-options-filters) f)
+    (while (setq f (pop functions))
+      (setq plist (funcall f plist))))
+  plist)
+
 ;;;###autoload
 (defun org-export (&optional arg)
   "Export dispatcher for Org-mode.
@@ -1151,51 +1260,41 @@
 The result is then again returned as a string, and the exporter works
 on this string to produce the exported version."
   (interactive)
-  (let* ((re-radio (and org-target-link-regexp
-			(concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")))
-	 (re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
-	 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re))
-	 (re-archive (concat ":" org-archive-tag ":"))
-	 (re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))
-	 (re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
-	 (htmlp (plist-get parameters :for-html))
+  (let* ((htmlp (plist-get parameters :for-html))
 	 (asciip (plist-get parameters :for-ascii))
 	 (latexp (plist-get parameters :for-LaTeX))
-	 (commentsp (plist-get parameters :comments))
 	 (archived-trees (plist-get parameters :archived-trees))
 	 (inhibit-read-only t)
 	 (drawers org-drawers)
-	 (exp-drawers (plist-get parameters :drawers))
 	 (outline-regexp "\\*+ ")
-	 target-alist tmp target level
-	 a b xx rtn p)
+	 target-alist rtn)
 
     (with-current-buffer (get-buffer-create " org-mode-tmp")
       (erase-buffer)
       (insert string)
+      (setq case-fold-search t)
+      ;; Call the hook
+      (run-hooks 'org-export-preprocess-hook)
+
       ;; Remove license-to-kill stuff
       ;; The caller markes some stuff fo killing, stuff that has been
       ;; used to create the page title, for example.
-      (while (setq p (text-property-any (point-min) (point-max)
-					:org-license-to-kill t))
-	(delete-region p (next-single-property-change p :org-license-to-kill)))
-
+      (org-export-kill-licensed-text)
+      
       (let ((org-inhibit-startup t)) (org-mode))
+      (setq case-fold-search t)
       (untabify (point-min) (point-max))
-
+      
+      ;; Handle incude files
+      (org-export-handle-include-files)
+      
+      ;; Handle source code snippets
+      (org-export-replace-src-segments)
+      
       ;; Get rid of drawers
-      (unless (eq t exp-drawers)
-	(goto-char (point-min))
-	(let ((re (concat "^[ \t]*:\\("
-			  (mapconcat
-			   'identity
-			   (org-delete-all exp-drawers
-					   (copy-sequence drawers))
-			   "\\|")
-			  "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
-	  (while (re-search-forward re nil t)
-	    (replace-match ""))))
-
+      (org-export-remove-or-extract-drawers drawers
+					    (plist-get parameters :drawers))
+      
       ;; Get the correct stuff before the first headline
       (when (plist-get parameters :skip-before-1st-heading)
 	(goto-char (point-min))
@@ -1206,247 +1305,390 @@
       (when (plist-get parameters :add-text)
 	(goto-char (point-min))
 	(insert (plist-get parameters :add-text) "\n"))
-
+      
       ;; Get rid of archived trees
-      (when (not (eq archived-trees t))
-	(goto-char (point-min))
-	(while (re-search-forward re-archive nil t)
-	  (if (not (org-on-heading-p t))
-	      (org-end-of-subtree t)
-	    (beginning-of-line 1)
-	    (setq a (if archived-trees
-			(1+ (point-at-eol)) (point))
-		  b (org-end-of-subtree t))
-	    (if (> b a) (delete-region a b)))))
-
+      (org-export-remove-archived-trees archived-trees)
+      
       ;; Find all headings and compute the targets for them
-      (goto-char (point-min))
-      (org-init-section-numbers)
-      (let ((re (concat "^" org-outline-regexp)))
-	(while (re-search-forward re nil t)
-	  (setq level (org-reduced-level
-		       (save-excursion (goto-char (point-at-bol))
-				       (org-outline-level))))
-	  (setq target (org-solidify-link-text
-			(format "sec-%s" (org-section-number level))))
-	  (push (cons target target) target-alist)
-	  (add-text-properties
-	   (point-at-bol) (point-at-eol)
-	   (list 'target target))))
+      (setq target-alist (org-export-define-heading-targets target-alist))
 
       ;; Find targets in comments and move them out of comments,
       ;; but mark them as targets that should be invisible
-      (goto-char (point-min))
-      (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t)
-	;; Check if the line before or after is a headline with a target
-	(if (setq target (or (get-text-property (point-at-bol 0) 'target)
-			     (get-text-property (point-at-bol 2) 'target)))
-	    (progn
-	      ;; use the existing target in a neighboring line
-	      (setq tmp (match-string 2))
-	      (replace-match "")
-	      (and (looking-at "\n") (delete-char 1))
-	      (push (cons (org-solidify-link-text tmp) target)
-		    target-alist))
-	  ;; Make an invisible target
-	  (replace-match "\\1(INVISIBLE)")))
+      (setq target-alist (org-export-handle-invisible-targets target-alist))
+
+      ;; Protect examples
+      (org-export-protect-examples)
 
       ;; Protect backend specific stuff, throw away the others.
-      (let ((formatters
-	     `((,htmlp "HTML" "BEGIN_HTML" "END_HTML")
-	       (,asciip "ASCII" "BEGIN_ASCII" "END_ASCII")
-	       (,latexp "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
-	    fmt)
-	(goto-char (point-min))
-	(while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
-	  (goto-char (match-end 0))
-	  (while (not (looking-at "#\\+END_EXAMPLE"))
-	    (insert ": ")
-	    (beginning-of-line 2)))
-	(goto-char (point-min))
-	(while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
-	  (add-text-properties (match-beginning 0) (match-end 0)
-			       '(org-protected t)))
-	(while formatters
-	  (setq fmt (pop formatters))
-	  (when (car fmt)
-	    (goto-char (point-min))
-	    (while (re-search-forward (concat "^#\\+" (cadr fmt)
-					      ":[ \t]*\\(.*\\)") nil t)
-	      (replace-match "\\1" t)
-	      (add-text-properties
-	       (point-at-bol) (min (1+ (point-at-eol)) (point-max))
-	       '(org-protected t))))
-	  (goto-char (point-min))
-	  (while (re-search-forward
-		  (concat "^#\\+"
-			  (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+"
-			  (cadddr fmt) "\\>.*\n?") nil t)
-	    (if (car fmt)
-		(add-text-properties (match-beginning 1) (1+ (match-end 1))
-				     '(org-protected t))
-	      (delete-region (match-beginning 0) (match-end 0))))))
+      (org-export-select-backend-specific-text
+       (cond (htmlp 'html) (latexp 'latex) (asciip 'ascii)))
 
       ;; Protect quoted subtrees
-      (goto-char (point-min))
-      (while (re-search-forward re-quote nil t)
-	(goto-char (match-beginning 0))
-	(end-of-line 1)
-	(add-text-properties (point) (org-end-of-subtree t)
-			     '(org-protected t)))
+      (org-export-protect-quoted-subtrees)
 
       ;; Protect verbatim elements
-      (goto-char (point-min))
-      (while (re-search-forward org-verbatim-re nil t)
-	(add-text-properties (match-beginning 4) (match-end 4)
-			     '(org-protected t))
-	(goto-char (1+ (match-end 4))))
-
-      ;; Remove subtrees that are commented
-      (goto-char (point-min))
-      (while (re-search-forward re-commented nil t)
-	(goto-char (match-beginning 0))
-	(delete-region (point) (org-end-of-subtree t)))
+      (org-export-protect-verbatim)
+
+      ;; Blockquotes and verse
+      (org-export-mark-blockquote-and-verse)
+
+      ;; Remove comment environment and comment subtrees
+      (org-export-remove-comment-blocks-and-subtrees)
 
       ;; Remove special table lines
       (when org-export-table-remove-special-lines
-	(goto-char (point-min))
-	(while (re-search-forward "^[ \t]*|" nil t)
-	  (beginning-of-line 1)
-	  (if (or (looking-at "[ \t]*| *[!_^] *|")
-		  (and (looking-at ".*?| *<[0-9]+> *|")
-		       (not (looking-at ".*?| *[^ <|]"))))
-	      (delete-region (max (point-min) (1- (point-at-bol)))
-			     (point-at-eol))
-	    (end-of-line 1))))
+	(org-export-remove-special-table-lines))
 
       ;; Specific LaTeX stuff
       (when latexp
 	(require 'org-export-latex nil)
 	(org-export-latex-preprocess))
 
+      ;; Specific ASCII stuff
       (when asciip
-	(org-export-ascii-clean-string))
+	(org-export-ascii-preprocess))
 
       ;; Specific HTML stuff
       (when htmlp
-	;; Convert LaTeX fragments to images
-	(when (plist-get parameters :LaTeX-fragments)
-	  (org-format-latex
-	   (concat "ltxpng/" (file-name-sans-extension
-			      (file-name-nondirectory
-			       org-current-export-file)))
-	   org-current-export-dir nil "Creating LaTeX image %s"))
-	(message "Exporting..."))
+	(org-export-html-preprocess parameters))
 
       ;; Remove or replace comments
-      (goto-char (point-min))
-      (while (re-search-forward "^#\\(.*\n?\\)" nil t)
-	(if commentsp
-	    (progn (add-text-properties
-		    (match-beginning 0) (match-end 0) '(org-protected t))
-		   (replace-match (format commentsp (match-string 1)) t t))
-	  (replace-match "")))
+      (org-export-handle-comments (plist-get parameters :comments))
 
       ;; Find matches for radio targets and turn them into internal links
-      (goto-char (point-min))
-      (when re-radio
-	(while (re-search-forward re-radio nil t)
-	  (org-if-unprotected
-	   (replace-match "\\1[[\\2]]"))))
+      (org-export-mark-radio-links)
 
       ;; Find all links that contain a newline and put them into a single line
-      (goto-char (point-min))
-      (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t)
-	(org-if-unprotected
-	 (replace-match "\\1 \\3")
-	 (goto-char (match-beginning 0))))
+      (org-export-concatenate-multiline-links)
 
       ;; Find all internal links.  If they have a fuzzy match (i.e. not
       ;; a *dedicated* target match, let the link  point to the
-      ;; correspinding section.
-
-      (goto-char (point-min))
-      (while (re-search-forward org-bracket-link-regexp nil t)
-	(org-if-unprotected
-	 (let* ((md (match-data))
-		(desc (match-end 2))
-		(link (org-link-unescape (match-string 1)))
-		(slink (org-solidify-link-text link))
-		found props pos
-		(target
-		 (or (cdr (assoc slink target-alist))
-		     (save-excursion
-		       (unless (string-match org-link-types-re link)
-			 (setq found (condition-case nil (org-link-search link)
-				       (error nil)))
-			 (when (and found
-				    (or (org-on-heading-p)
-					(not (eq found 'dedicated))))
-			   (or (get-text-property (point) 'target)
-			       (get-text-property
-				(max (point-min)
-				     (1- (previous-single-property-change
-					  (point) 'target)))
-				'target))))))))
-	   (when target
-	     (set-match-data md)
-	     (goto-char (match-beginning 1))
-	     (setq props (text-properties-at (point)))
-	     (delete-region (match-beginning 1) (match-end 1))
-	     (setq pos (point))
-	     (insert target)
-	     (unless desc (insert "][" link))
-	     (add-text-properties pos (point) props)))))
+      ;; corresponding section.
+      (org-export-target-internal-links target-alist)
 
       ;; Normalize links: Convert angle and plain links into bracket links
-      ;; Expand link abbreviations
-      (goto-char (point-min))
-      (while (re-search-forward re-plain-link nil t)
-	(goto-char (1- (match-end 0)))
-	(org-if-unprotected
-	 (let* ((s (concat (match-string 1) "[[" (match-string 2)
-			   ":" (match-string 3) "]]")))
-	   ;; added 'org-link face to links
-	   (put-text-property 0 (length s) 'face 'org-link s)
-	   (replace-match s t t))))
-      (goto-char (point-min))
-      (while (re-search-forward re-angle-link nil t)
-	(goto-char (1- (match-end 0)))
-	(org-if-unprotected
-	 (let* ((s (concat (match-string 1) "[[" (match-string 2)
-			   ":" (match-string 3) "]]")))
-	   (put-text-property 0 (length s) 'face 'org-link s)
-	   (replace-match s t t))))
-      (goto-char (point-min))
-      (while (re-search-forward org-bracket-link-regexp nil t)
-	(org-if-unprotected
-	 (let* ((s (concat "[[" (setq xx (save-match-data
-					   (org-link-expand-abbrev (match-string 1))))
-			   "]"
-			   (if (match-end 3)
-			       (match-string 2)
-			     (concat "[" xx "]"))
-			   "]")))
-	   (put-text-property 0 (length s) 'face 'org-link s)
-	   (replace-match s t t))))
+      ;; and expand link abbreviations
+      (org-export-normalize-links)
 
       ;; Find multiline emphasis and put them into single line
-      (when (plist-get  parameters :emph-multiline)
-	(goto-char (point-min))
-	(while (re-search-forward org-emph-re nil t)
-	  (if (not (= (char-after (match-beginning 3))
-		      (char-after (match-beginning 4))))
-	      (org-if-unprotected
-	       (subst-char-in-region (match-beginning 0) (match-end 0)
-				     ?\n ?\  t)
-	       (goto-char (1- (match-end 0))))
-	    (goto-char (1+ (match-beginning 0))))))
+      (when (plist-get parameters :emph-multiline)
+	(org-export-concatenate-multiline-emphasis))
 
       (setq rtn (buffer-string)))
     (kill-buffer " org-mode-tmp")
     rtn))
 
+(defun org-export-kill-licensed-text ()
+  "Remove all text that is marked with a :org-license-to-kill property."
+  (let (p)
+    (while (setq p (text-property-any (point-min) (point-max)
+				      :org-license-to-kill t))
+      (delete-region p (next-single-property-change p :org-license-to-kill)))))
+
+(defun org-export-define-heading-targets (target-alist)
+  "Find all headings and define the targets for them.
+The new targets are added to TARGET-ALIST, which is also returned."
+  (goto-char (point-min))
+  (org-init-section-numbers)
+  (let ((re (concat "^" org-outline-regexp))
+	level target)
+    (while (re-search-forward re nil t)
+      (setq level (org-reduced-level
+		   (save-excursion (goto-char (point-at-bol))
+				   (org-outline-level))))
+      (setq target (org-solidify-link-text
+		    (format "sec-%s" (org-section-number level))))
+      (push (cons target target) target-alist)
+      (add-text-properties
+       (point-at-bol) (point-at-eol)
+       (list 'target target))))
+  target-alist)
+
+(defun org-export-handle-invisible-targets (target-alist)
+  "Find targets in comments and move them out of comments.
+Mark them as invisible targets."
+  (let (target tmp)
+    (goto-char (point-min))
+    (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t)
+      ;; Check if the line before or after is a headline with a target
+      (if (setq target (or (get-text-property (point-at-bol 0) 'target)
+			   (get-text-property (point-at-bol 2) 'target)))
+	  (progn
+	    ;; use the existing target in a neighboring line
+	    (setq tmp (match-string 2))
+	    (replace-match "")
+	    (and (looking-at "\n") (delete-char 1))
+	    (push (cons (org-solidify-link-text tmp) target)
+		  target-alist))
+	;; Make an invisible target
+	(replace-match "\\1(INVISIBLE)"))))
+  target-alist)
+
+(defun org-export-target-internal-links (target-alist)
+  "Find all internal links and assign target to them.
+If a link has a fuzzy match (i.e. not a *dedicated* target match),
+let the link  point to the corresponding section."
+  (goto-char (point-min))
+  (while (re-search-forward org-bracket-link-regexp nil t)
+    (org-if-unprotected
+     (let* ((md (match-data))
+	    (desc (match-end 2))
+	    (link (org-link-unescape (match-string 1)))
+	    (slink (org-solidify-link-text link))
+	    found props pos
+	    (target
+	     (or (cdr (assoc slink target-alist))
+		 (save-excursion
+		   (unless (string-match org-link-types-re link)
+		     (setq found (condition-case nil (org-link-search link)
+				   (error nil)))
+		     (when (and found
+				(or (org-on-heading-p)
+				    (not (eq found 'dedicated))))
+		       (or (get-text-property (point) 'target)
+			   (get-text-property
+			    (max (point-min)
+				 (1- (previous-single-property-change
+				      (point) 'target)))
+			    'target))))))))
+       (when target
+	 (set-match-data md)
+	 (goto-char (match-beginning 1))
+	 (setq props (text-properties-at (point)))
+	 (delete-region (match-beginning 1) (match-end 1))
+	 (setq pos (point))
+	 (insert target)
+	 (unless desc (insert "][" link))
+	 (add-text-properties pos (point) props))))))
+
+(defun org-export-remove-or-extract-drawers (all-drawers exp-drawers)
+  "Remove drawers, or extract the content.
+ALL-DRAWERS is a list of all drawer names valid in the current buffer.
+EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
+whose content to keep."
+  (unless (eq t exp-drawers)
+    (goto-char (point-min))
+    (let ((re (concat "^[ \t]*:\\("
+		      (mapconcat
+		       'identity
+		       (org-delete-all exp-drawers
+				       (copy-sequence all-drawers))
+		       "\\|")
+		      "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
+      (while (re-search-forward re nil t)
+	(replace-match "")))))
+
+(defun org-export-remove-archived-trees (export-archived-trees)
+  "Remove archived trees.
+When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
+When it is t, the entire archived tree will be exported.
+When it is nil the entire tree including the headline will be removed
+from the buffer."
+  (let ((re-archive (concat ":" org-archive-tag ":"))
+	a b)
+    (when (not (eq export-archived-trees t))
+      (goto-char (point-min))
+      (while (re-search-forward re-archive nil t)
+	(if (not (org-on-heading-p t))
+	    (org-end-of-subtree t)
+	  (beginning-of-line 1)
+	  (setq a (if export-archived-trees
+		      (1+ (point-at-eol)) (point))
+		b (org-end-of-subtree t))
+	  (if (> b a) (delete-region a b)))))))
+
+(defun org-export-protect-quoted-subtrees ()
+  "Mark quoted subtrees with the protection property."
+  (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
+    (goto-char (point-min))
+    (while (re-search-forward re-quote nil t)
+      (goto-char (match-beginning 0))
+      (end-of-line 1)
+      (add-text-properties (point) (org-end-of-subtree t)
+			   '(org-protected t)))))
+
+(defun org-export-protect-verbatim ()
+  "Mark verbatim snippets with the protection property."
+  (goto-char (point-min))
+  (while (re-search-forward org-verbatim-re nil t)
+    (add-text-properties (match-beginning 4) (match-end 4)
+			 '(org-protected t))
+    (goto-char (1+ (match-end 4)))))
+
+(defun org-export-protect-examples ()
+  "Protect code that should be exported as monospaced examples."
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
+    (goto-char (match-end 0))
+    (while (and (not (looking-at "#\\+END_EXAMPLE")) (not (eobp)))
+      (insert ":  ")
+      (beginning-of-line 2)))
+  (goto-char (point-min))
+  (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
+    (add-text-properties (match-beginning 0) (match-end 0)
+			 '(org-protected t))))
+
+(defun org-export-select-backend-specific-text (backend)
+  (let ((formatters
+	 '((html "HTML" "BEGIN_HTML" "END_HTML")
+	   (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
+	   (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
+	fmt)
+
+    (while formatters
+      (setq fmt (pop formatters))
+      (when (eq (car fmt) backend)
+	;; This is selected code, put it into the file for real
+	(goto-char (point-min))
+	(while (re-search-forward (concat "^#\\+" (cadr fmt)
+					  ":[ \t]*\\(.*\\)") nil t)
+	  (replace-match "\\1" t)
+	  (add-text-properties
+	   (point-at-bol) (min (1+ (point-at-eol)) (point-max))
+	   '(org-protected t))))
+      (goto-char (point-min))
+      (while (re-search-forward
+	      (concat "^#\\+"
+		      (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+"
+		      (cadddr fmt) "\\>.*\n?") nil t)
+	(if (eq (car fmt) backend)
+	    ;; yes, keep this
+	    (add-text-properties (match-beginning 1) (1+ (match-end 1))
+				 '(org-protected t))
+	  ;; No, this is for a different backend, kill it
+	  (delete-region (match-beginning 0) (match-end 0)))))))
+
+(defun org-export-mark-blockquote-and-verse ()
+  "Mark block quote and verse environments with special cookies.
+These special cookies will later be interpreted by the backend."
+  ;; Blockquotes
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+\\(begin\\|end\\)_\\(block\\)?quote\\>.*"
+			    nil t)
+    (replace-match (if (equal (downcase (match-string 1)) "end")
+		       "ORG-BLOCKQUOTE-END" "ORG-BLOCKQUOTE-START")
+		   t t))
+  ;; Verse
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+\\(begin\\|end\\)_verse\\>.*" nil t)
+    (replace-match (if (equal (downcase (match-string 1)) "end")
+		       "ORG-VERSE-END" "ORG-VERSE-START")
+		   t t)))
+
+(defun org-export-remove-comment-blocks-and-subtrees ()
+  "Remove the comment environment, and also commented subtrees."
+  (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")))
+    ;; Remove comment environment
+    (goto-char (point-min))
+    (while (re-search-forward
+	    "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*" nil t)
+      (replace-match "" t t))
+    ;; Remove subtrees that are commented
+    (goto-char (point-min))
+    (while (re-search-forward re-commented nil t)
+      (goto-char (match-beginning 0))
+      (delete-region (point) (org-end-of-subtree t)))))
+
+(defun org-export-handle-comments (commentsp)
+  "Remove comments, or convert to backend-specific format.
+COMMENTSP can be a format string for publishing comments.
+When it is nil, all comments will be removed."
+  (let ((re "^#\\(.*\n?\\)")
+	pos)
+    (goto-char (point-min))
+    (while (or (looking-at re)
+	       (re-search-forward re nil t))
+      (setq pos (match-beginning 0))
+      (if commentsp
+	  (progn (add-text-properties
+		  (match-beginning 0) (match-end 0) '(org-protected t))
+		 (replace-match (format commentsp (match-string 1)) t t))
+	(goto-char (1+ pos))
+	(org-if-unprotected
+	 (replace-match "")
+	 (goto-char (max (point-min) (1- pos))))))))
+
+(defun org-export-mark-radio-links ()
+  "Find all matches for radio targets and turn them into internal links."
+  (let ((re-radio (and org-target-link-regexp
+		       (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)"))))
+    (goto-char (point-min))
+    (when re-radio
+      (while (re-search-forward re-radio nil t)
+	(org-if-unprotected
+	 (replace-match "\\1[[\\2]]"))))))
+
+(defun org-export-remove-special-table-lines ()
+  "Remove tables lines that are used for internal purposes."
+  (goto-char (point-min))
+  (while (re-search-forward "^[ \t]*|" nil t)
+    (beginning-of-line 1)
+    (if (or (looking-at "[ \t]*| *[!_^] *|")
+	    (and (looking-at ".*?| *<[0-9]+> *|")
+		 (not (looking-at ".*?| *[^ <|]"))))
+	(delete-region (max (point-min) (1- (point-at-bol)))
+		       (point-at-eol))
+      (end-of-line 1))))
+
+(defun org-export-normalize-links ()
+  "Convert all links to bracket links, and expand link abbreviations."
+  (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
+	(re-angle-link (concat "\\([^[]\\)" org-angle-link-re)))
+    (goto-char (point-min))
+    (while (re-search-forward re-plain-link nil t)
+      (goto-char (1- (match-end 0)))
+      (org-if-unprotected
+       (let* ((s (concat (match-string 1) "[[" (match-string 2)
+			 ":" (match-string 3) "]]")))
+	 ;; added 'org-link face to links
+	 (put-text-property 0 (length s) 'face 'org-link s)
+	 (replace-match s t t))))
+    (goto-char (point-min))
+    (while (re-search-forward re-angle-link nil t)
+      (goto-char (1- (match-end 0)))
+      (org-if-unprotected
+       (let* ((s (concat (match-string 1) "[[" (match-string 2)
+			 ":" (match-string 3) "]]")))
+	 (put-text-property 0 (length s) 'face 'org-link s)
+	 (replace-match s t t))))
+    (goto-char (point-min))
+    (while (re-search-forward org-bracket-link-regexp nil t)
+      (org-if-unprotected
+       (let* ((xx (save-match-data
+		    (org-link-expand-abbrev (match-string 1))))
+	      (s (concat
+		  "[[" xx "]"
+		  (if (match-end 3)
+		      (match-string 2)
+		    (concat "[" xx "]"))
+		  "]")))
+	 (put-text-property 0 (length s) 'face 'org-link s)
+	 (replace-match s t t))))))
+  
+(defun org-export-concatenate-multiline-links ()
+  "Find multi-line links and put it all into a single line.
+This is to make sure that the line-processing export backends
+can work correctly."
+  (goto-char (point-min))
+  (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t)
+    (org-if-unprotected
+     (replace-match "\\1 \\3")
+     (goto-char (match-beginning 0)))))
+
+(defun org-export-concatenate-multiline-emphasis ()
+  "Find multi-line emphasis and put it all into a single line.
+This is to make sure that the line-processing export backends
+can work correctly."
+  (goto-char (point-min))
+  (while (re-search-forward org-emph-re nil t)
+    (if (not (= (char-after (match-beginning 3))
+		(char-after (match-beginning 4))))
+	(org-if-unprotected
+	 (subst-char-in-region (match-beginning 0) (match-end 0)
+			       ?\n ?\  t)
+	 (goto-char (1- (match-end 0))))
+      (goto-char (1+ (match-beginning 0))))))
+
 (defun org-export-grab-title-from-buffer ()
   "Get a title for the current document, from looking at the buffer."
   (let ((inhibit-read-only t))
@@ -1463,18 +1705,19 @@
 
 (defun org-export-get-title-from-subtree ()
   "Return subtree title and exclude it from export."
-  (let (title (m (mark)))
+  (let (title (m (mark)) (rbeg (region-beginning)) (rend (region-end)))
     (save-excursion
-      (goto-char (region-beginning))
+      (goto-char rbeg)
       (when (and (org-at-heading-p)
-		 (>= (org-end-of-subtree t t) (region-end)))
+		 (>= (org-end-of-subtree t t) rend))
 	;; This is a subtree, we take the title from the first heading
-	(goto-char (region-beginning))
+	(goto-char rbeg)
 	(looking-at org-todo-line-regexp)
 	(setq title (match-string 3))
 	(org-unmodified
 	 (add-text-properties (point) (1+ (point-at-eol))
-			      (list :org-license-to-kill t)))))
+			      (list :org-license-to-kill t)))
+	(setq title (or (org-entry-get nil "EXPORT_TITLE") title))))
     title))
 
 (defun org-solidify-link-text (s &optional alist)
@@ -1512,14 +1755,19 @@
 	(if (string-match "\\`[A-Z]\\'" number-string)
 	    (aset org-section-numbers i
 		  (- (string-to-char number-string) ?A -1))
-	    (aset org-section-numbers i (string-to-number number-string)))
+	  (aset org-section-numbers i (string-to-number number-string)))
 	(pop numbers))
       (setq i (1- i)))))
 
 (defun org-section-number (&optional level)
   "Return a string with the current section number.
 When LEVEL is non-nil, increase section numbers on that level."
-  (let* ((depth (1- (length org-section-numbers))) idx n (string ""))
+  (let* ((depth (1- (length org-section-numbers)))
+	 (string "")
+	 (fmts (car org-export-section-number-format))
+	 (term (cdr org-export-section-number-format))
+	 (sep "")
+	 ctype fmt idx n)
     (when level
       (when (> level -1)
 	(aset org-section-numbers
@@ -1531,16 +1779,153 @@
 	(setq idx (1+ idx))))
     (setq idx 0)
     (while (<= idx depth)
-      (setq n (aref org-section-numbers idx))
-      (setq string (concat string (if (not (string= string "")) "." "")
-			   (int-to-string n)))
+      (when (> (aref org-section-numbers idx) 0)
+	(setq fmt (or (pop fmts) fmt)
+	      ctype (car fmt)
+	      n (aref org-section-numbers idx)
+	      string (if (> n 0)
+			 (concat string sep (org-number-to-counter n ctype))
+		       (concat string ".0"))
+	      sep (nth 1 fmt)))
       (setq idx (1+ idx)))
     (save-match-data
       (if (string-match "\\`\\([@0]\\.\\)+" string)
 	  (setq string (replace-match "" t nil string)))
       (if (string-match "\\(\\.0\\)+\\'" string)
 	  (setq string (replace-match "" t nil string))))
-    string))
+    (concat string term)))
+
+(defun org-number-to-counter (n type)
+  "Concert number N to a string counter, according to TYPE.
+TYPE must be a string, any of:
+ 1  number
+ A  A,B,....
+ a  a,b,....
+ I  uppper case roman numeral
+ i  lower case roman numeral"
+  (cond
+   ((equal type "1") (number-to-string n))
+   ((equal type "A") (char-to-string (+ ?A n -1)))
+   ((equal type "a") (char-to-string (+ ?a n -1)))
+   ((equal type "I") (org-number-to-roman n))
+   ((equal type "i") (downcase (org-number-to-roman n)))
+   (t (error "Invalid counter type `%s'" type))))
+
+(defun org-number-to-roman (n)
+  "Convert integer N into a roman numeral."
+  (let ((roman '((1000 . "M") (900 . "CM") (500 . "D") (400 . "CD")
+		 ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
+		 (  10 . "X") (  9 . "IX") (  5 . "V") (  4 . "IV")
+		 (   1 . "I")))
+	(res ""))
+    (if (<= n 0)
+	(number-to-string n)
+      (while roman
+	(if (>= n (caar roman))
+	    (setq n (- n (caar roman))
+		  res (concat res (cdar roman)))
+	  (pop roman)))
+      res)))
+
+(org-number-to-roman 1961)
+   
+
+;;; Include files
+
+(defun org-export-handle-include-files ()
+  "Include the contents of include files, with proper formatting."
+  (let ((case-fold-search t)
+	params file markup lang start end)
+    (goto-char (point-min))
+    (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
+      (setq params (read (concat "(" (match-string 1) ")"))
+	    file (org-symname-or-string (pop params))
+	    markup (org-symname-or-string (pop params))
+	    lang (org-symname-or-string (pop params)))
+      (delete-region (match-beginning 0) (match-end 0))
+      (if (or (not file)
+	      (not (file-exists-p file))
+	      (not (file-readable-p file)))
+	  (insert (format "CANNOT INCLUDE FILE %s" file))
+	(when markup
+	  (if (equal (downcase markup) "src")
+	      (setq start (format "#+begin_src %s\n" (or lang "fundamental"))
+		    end "#+end_src")
+	    (setq start (format "#+begin_%s\n" markup)
+		  end  (format "#+end_%s" markup))))
+	(insert (or start ""))
+	(forward-char (nth 1 (insert-file-contents (expand-file-name file))))
+	(or (bolp) (newline))
+	(insert (or end ""))))))
+
+(defun org-symname-or-string (s)
+  (if (symbolp s)
+      (if s (symbol-name s) s)
+    s))
+
+;;; Fontification of code
+;; Currently only for th HTML backend, but who knows....
+(defun org-export-replace-src-segments ()
+  "Replace source code segments with special code for export."
+  (let ((case-fold-search t)
+	lang code trans)
+    (goto-char (point-min))
+    (while (re-search-forward
+	    "^#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)[ \t]*\n\\([^\000]+?\n\\)#\\+END_SRC.*"
+	    nil t)
+      (setq lang (match-string 1) code (match-string 2)
+	    trans (org-export-format-source-code lang code))
+      (replace-match trans t t))))
+
+(defvar htmlp)  ;; dynamically scoped from org-exp.el
+
+(defun org-export-format-source-code (lang code)
+  "Format CODE from language LANG and return it formatted for export.
+Currently, this only does something for HTML export, for all other
+backends, it converts the segment into an EXAMPLE segment."
+  (save-match-data
+    (cond
+     (htmlp
+      ;; We are exporting to HTML
+      (condition-case nil (require 'htmlize) (nil t))
+      (if (not (fboundp 'htmlize-region-for-paste))
+	  (progn
+	    ;; we do not have htmlize.el, or an old version of it
+	    (message
+	     "htmlize.el 1.34 or later is needed for source code formatting")
+	    (concat "#+BEGIN_EXAMPLE\n" code
+		    (if (string-match "\n\\'" code) "" "\n")
+		    "#+END_EXAMPLE\n"))
+	;; ok, we are good to go
+	(let* ((mode (and lang (intern (concat lang "-mode"))))
+	       (org-inhibit-startup t)
+	       (org-startup-folded nil)
+	       (htmltext
+		(with-temp-buffer
+		  (insert code)
+		  ;; Free up the protected stuff
+		  (goto-char (point-min))
+		  (while (re-search-forward "^," nil t)
+		    (replace-match "")
+		    (end-of-line 1))
+		  (if (functionp mode)
+		      (funcall mode)
+		    (fundamental-mode))
+		  (font-lock-fontify-buffer)
+		  (org-export-htmlize-region-for-paste
+		   (point-min) (point-max)))))
+	  (if (string-match "<pre\\([^>]*\\)>\n?" htmltext)
+	      (setq htmltext (replace-match "<pre class=\"src\">"
+					    t t htmltext)))
+	  (concat "#+BEGIN_HTML\n" htmltext "\n#+END_HTML\n"))))
+     (t
+      ;; This is not HTML, so just make it an example.
+      (when (equal lang "org")
+	(while (string-match "^," code)
+	  (setq code (replace-match "" t t code))))
+      (concat "#+BEGIN_EXAMPLE\n" code
+	      (if (string-match "\n\\'" code) "" "\n")
+	      "#+END_EXAMPLE\n")))))
 
 ;;; ASCII export
 
@@ -1560,12 +1945,17 @@
   (let* ((opt-plist (org-combine-plists (org-default-export-plist)
 					(org-infile-export-plist)))
 	 (region-p (org-region-active-p))
+	 (rbeg (and region-p (region-beginning)))
+	 (rend (and region-p (region-end)))
 	 (subtree-p
 	  (when region-p
 	    (save-excursion
-	      (goto-char (region-beginning))
+	      (goto-char rbeg)
 	      (and (org-at-heading-p)
-		   (>= (org-end-of-subtree t t) (region-end))))))
+		   (>= (org-end-of-subtree t t) rend)))))
+	 (opt-plist (if subtree-p 
+			(org-export-add-subtree-options opt-plist rbeg)
+		      opt-plist))
 	 (custom-times org-display-custom-times)
 	 (org-ascii-current-indentation '(0 . 0))
 	 (level 0) line txt
@@ -1673,7 +2063,8 @@
     (if org-export-with-toc
 	(progn
 	  (push (concat (nth 3 lang-words) "\n") thetoc)
-	  (push (concat (make-string (length (nth 3 lang-words)) ?=) "\n") thetoc)
+	  (push (concat (make-string (string-width (nth 3 lang-words)) ?=)
+			"\n") thetoc)
 	  (mapc '(lambda (line)
 		   (if (string-match org-todo-line-regexp
 				     line)
@@ -1810,7 +2201,7 @@
 	(goto-char beg)))
     (goto-char (point-min))))
 
-(defun org-export-ascii-clean-string ()
+(defun org-export-ascii-preprocess ()
   "Do extra work for ASCII export"
   (goto-char (point-min))
   (while (re-search-forward org-verbatim-re nil t)
@@ -1847,7 +2238,7 @@
 
 (defun org-insert-centered (s &optional underline)
   "Insert the string S centered and underline it with character UNDERLINE."
-  (let ((ind (max (/ (- 80 (string-width s)) 2) 0)))
+  (let ((ind (max (/ (- fill-column (string-width s)) 2) 0)))
     (insert (make-string ind ?\ ) s "\n")
     (if underline
 	(insert (make-string ind ?\ )
@@ -1984,6 +2375,7 @@
 #+DRAWERS:   %s
 #+STARTUP:   %s %s %s %s %s
 #+TAGS:      %s
+#+FILETAGS:  %s
 #+ARCHIVE:   %s
 #+LINK:      %s
 "
@@ -2006,7 +2398,7 @@
    org-export-skip-text-before-1st-heading
    org-export-with-drawers
    org-export-with-tags
-   (if (featurep 'org-infojs) (org-infojs-options-inbuffer-template) "")
+   (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "")
    org-export-html-link-up
    org-export-html-link-home
    (file-name-nondirectory buffer-file-name)
@@ -2029,10 +2421,21 @@
 		     ((cdr x) (format "%s(%c)" (car x) (cdr x)))
 		     (t (car x))))
 		  (or org-tag-alist (org-get-buffer-tags)) " ") "")
+   (mapconcat 'identity org-file-tags " ")
    org-archive-location
    "org file:~/org/%s.org"
    ))
 
+(defun org-export-html-preprocess (parameters)
+  ;; Convert LaTeX fragments to images
+  (when (plist-get parameters :LaTeX-fragments)
+    (org-format-latex
+     (concat "ltxpng/" (file-name-sans-extension
+			(file-name-nondirectory
+			 org-current-export-file)))
+     org-current-export-dir nil "Creating LaTeX image %s"))
+  (message "Exporting..."))
+
 ;;;###autoload
 (defun org-insert-export-options-template ()
   "Insert into the buffer a template with information for exporting."
@@ -2171,12 +2574,17 @@
 	 valid thetoc have-headings first-heading-pos
 	 (odd org-odd-levels-only)
 	 (region-p (org-region-active-p))
+	 (rbeg (and region-p (region-beginning)))
+	 (rend (and region-p (region-end)))
 	 (subtree-p
 	  (when region-p
 	    (save-excursion
-	      (goto-char (region-beginning))
+	      (goto-char rbeg)
 	      (and (org-at-heading-p)
-		   (>= (org-end-of-subtree t t) (region-end))))))
+		   (>= (org-end-of-subtree t t) rend)))))
+	 (opt-plist (if subtree-p 
+			(org-export-add-subtree-options opt-plist rbeg)
+		      opt-plist))
 	 ;; The following two are dynamically scoped into other
 	 ;; routines below.
 	 (org-current-export-dir
@@ -2222,7 +2630,7 @@
 	 (inquote     nil)
 	 (infixed     nil)
 	 (in-local-list nil)
-	 (local-list-num nil)
+	 (local-list-type nil)
 	 (local-list-indent nil)
 	 (llt org-plain-list-ordered-item-terminator)
 	 (email       (plist-get opt-plist :email))
@@ -2262,9 +2670,9 @@
 	   "[\r\n]"))
 	 table-open type
 	 table-buffer table-orig-buffer
-	 ind start-is-num starter didclose
+	 ind item-type starter didclose
 	 rpl path desc descp desc1 desc2 link
-	 snumber fnc
+	 snumber fnc item-tag
 	 )
 
     (let ((inhibit-read-only t))
@@ -2435,9 +2843,9 @@
 	      (setq infixed t)
 	      (insert "<pre>\n"))
 	    (insert (org-html-protect (match-string 1 line)) "\n")
-	    (when (and lines
-		       (not (string-match "^[ \t]*\\(:.*\\)"
-					  (car lines))))
+	    (when (or (not lines)
+		      (not (string-match "^[ \t]*\\(:.*\\)"
+					 (car lines))))
 	      (setq infixed nil)
 	      (insert "</pre>\n"))
 	    (throw 'nextline nil))
@@ -2451,6 +2859,7 @@
 		(replace-match "\\2\n"))
 	      (insert line "\n")
 	      (while (and lines
+			  (not (string-match "^[ \t]*:" (car lines)))
 			  (or (= (length (car lines)) 0)
 			      (get-text-property 0 'org-protected (car lines))))
 		(insert (pop lines) "\n"))
@@ -2462,6 +2871,20 @@
 	    (insert "\n<hr/>\n")
 	    (throw 'nextline nil))
 
+	  ;; Blockquotes and verse
+	  (when (equal "ORG-BLOCKQUOTE-START" line)
+	    (insert "<blockquote>\n<p>\n")
+	    (throw 'nextline nil))
+	  (when (equal "ORG-BLOCKQUOTE-END" line)
+	    (insert "</p>\n</blockquote>\n")
+	    (throw 'nextline nil))
+	  (when (equal "ORG-VERSE-START" line)
+	    (insert "<verse>\n<p>\n")
+	    (throw 'nextline nil))
+	  (when (equal "ORG-VERSE-END" line)
+	    (insert "</p>\n</verse>\n")
+	    (throw 'nextline nil))
+
 	  ;; make targets to anchors
 	  (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
 	    (cond
@@ -2620,10 +3043,10 @@
 		(setq head-count (+ head-count 1)))
 	    (when in-local-list
 	      ;; Close any local lists before inserting a new header line
-	      (while local-list-num
-		(org-close-li)
-		(insert (if (car local-list-num) "</ol>\n" "</ul>"))
-		(pop local-list-num))
+	      (while local-list-type
+		(org-close-li (car local-list-type))
+		(insert (format "</%sl>\n" (car local-list-type)))
+		(pop local-list-type))
 	      (setq local-list-indent nil
 		    in-local-list nil))
 	    (setq first-heading-pos (or first-heading-pos (point)))
@@ -2661,11 +3084,17 @@
 		    (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
 		   line)
 	      (setq ind (org-get-string-indentation line)
-		    start-is-num (match-beginning 4)
+		    item-type (if (match-beginning 4) "o" "u")
 		    starter (if (match-beginning 2)
 				(substring (match-string 2 line) 0 -1))
-		    line (substring line (match-beginning 5)))
-	      (unless (string-match "[^ \t]" line)
+		    line (substring line (match-beginning 5))
+		    item-tag nil)
+	      (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line))
+		  (setq item-type "d"
+			item-tag (match-string 1 line)
+			line (substring line (match-end 0))))
+	      (when (and (not (equal item-type "d"))
+			 (not (string-match "[^ \t]" line)))
 		;; empty line.  Pretend indentation is large.
 		(setq ind (if org-empty-line-terminates-plain-lists
 			      0
@@ -2676,9 +3105,9 @@
 				   (not starter))
 			      (< ind (car local-list-indent))))
 		(setq didclose t)
-		(org-close-li)
-		(insert (if (car local-list-num) "</ol>\n" "</ul>"))
-		(pop local-list-num) (pop local-list-indent)
+		(org-close-li (car local-list-type))
+		(insert (format "</%sl>\n" (car local-list-type)))
+		(pop local-list-type) (pop local-list-indent)
 		(setq in-local-list local-list-indent))
 	      (cond
 	       ((and starter
@@ -2686,14 +3115,21 @@
 			 (> ind (car local-list-indent))))
 		;; Start new (level of) list
 		(org-close-par-maybe)
-		(insert (if start-is-num "<ol>\n<li>\n" "<ul>\n<li>\n"))
-		(push start-is-num local-list-num)
+		(insert (cond
+			 ((equal item-type "u") "<ul>\n<li>\n")
+			 ((equal item-type "o") "<ol>\n<li>\n")
+			 ((equal item-type "d") 
+			  (format "<dl>\n<dt>%s</dt><dd>\n" item-tag))))
+		(push item-type local-list-type)
 		(push ind local-list-indent)
 		(setq in-local-list t))
 	       (starter
 		;; continue current list
-		(org-close-li)
-		(insert "<li>\n"))
+		(org-close-li (car local-list-type))
+		(insert (cond
+			 ((equal (car local-list-type) "d")
+			  (format "<dt>%s</dt><dd>\n" (or item-tag "???")))
+			 (t "<li>\n"))))
 	       (didclose
 		;; we did close a list, normal text follows: need <p>
 		(org-open-par)))
@@ -2716,7 +3152,8 @@
 		(org-close-par-maybe)
 		(let ((n (match-string 1 line)))
 		  (setq line (replace-match
-			      (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line)))))
+			      (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line))
+		  (setq line (concat line "</p>")))))
 
 	    ;; Check if the line break needs to be conserved
 	    (cond
@@ -2731,10 +3168,10 @@
       (when inquote (insert "</pre>\n"))
       (when in-local-list
 	;; Close any local lists before inserting a new header line
-	(while local-list-num
-	  (org-close-li)
-	  (insert (if (car local-list-num) "</ol>\n" "</ul>\n"))
-	  (pop local-list-num))
+	(while local-list-type
+	  (org-close-li (car local-list-type))
+	  (insert (format "</%sl>\n" (car local-list-type)))
+	  (pop local-list-type))
 	(setq local-list-indent nil
 	      in-local-list nil))
       (org-html-level-start 1 nil umax
@@ -2762,6 +3199,8 @@
 	    (insert "<p class=\"date\"> "
 		    (nth 2 lang-words) ": "
 		    date "</p>\n"))
+	  (insert (format "<p>HTML generated by org-mode %s in emacs %s<\p>\n"
+			  org-version emacs-major-version))
 	  (insert "</div>"))
 
 	(if org-export-html-with-timestamp
@@ -3106,6 +3545,54 @@
 	  (setq r (concat r "@<br/>")))
 	r))))
 
+(defun org-export-htmlize-region-for-paste (beg end)
+  "Convert the region to HTML, using htmlize.el.
+This is much like `htmlize-region-for-paste', only that it uses
+the settings define in the org-... variables."
+  (let* ((htmlize-output-type org-export-htmlize-output-type)
+	 (htmlize-css-name-prefix org-export-htmlize-css-font-prefix)
+	 (htmlbuf (htmlize-region beg end)))
+    (unwind-protect
+	(with-current-buffer htmlbuf
+	  (buffer-substring (plist-get htmlize-buffer-places 'content-start)
+			    (plist-get htmlize-buffer-places 'content-end)))
+      (kill-buffer htmlbuf))))
+
+;;;###autoload
+(defun org-export-htmlize-generate-css ()
+  "Create the CSS for all font definitions in the current Emacs session.
+Use this to create face definitions in your CSS style file that can then
+be used by code snippets transformed by htmlize.
+This command just produces a buffer that contains class definitions for all
+faces used in the current Emacs session.  You can copy and paste the ones you
+need into your CSS file.
+
+If you then set `org-export-htmlize-output-type' to `css', calls to
+the function `org-export-htmlize-region-for-paste' will produce code
+that uses these same face definitions."
+  (interactive)
+  (require 'htmlize)
+  (and (get-buffer "*html*") (kill-buffer "*html*"))
+  (with-temp-buffer
+    (let ((fl (face-list))
+	  (htmlize-css-name-prefix "org-")
+	  (htmlize-output-type 'css)
+	  f i)
+      (while (setq f (pop fl)
+		   i (and f (face-attribute f :inherit)))
+	(when (and (symbolp f) (or (not i) (not (listp i))))
+	  (insert (org-add-props (copy-sequence "1") nil 'face f))))
+      (htmlize-region (point-min) (point-max))))
+  (switch-to-buffer "*html*")
+  (goto-char (point-min))
+  (if (re-search-forward "<style" nil t)
+      (delete-region (point-min) (match-beginning 0)))
+  (if (re-search-forward "</style>" nil t)
+      (delete-region (1+ (match-end 0)) (point-max)))
+  (beginning-of-line 1)
+  (if (looking-at " +") (replace-match ""))
+  (goto-char (point-min)))
+
 (defun org-html-protect (s)
   ;; convert & to &amp;, < to &lt; and > to &gt;
   (let ((start 0))
@@ -3280,10 +3767,10 @@
   (when org-par-open
     (insert "</p>")
     (setq org-par-open nil)))
-(defun org-close-li ()
+(defun org-close-li (&optional type)
   "Close <li> if necessary."
   (org-close-par-maybe)
-  (insert "</li>\n"))
+  (insert (if (equal type "d") "</dd>\n" "</li>\n")))
 
 (defvar body-only) ; dynamically scoped into this.
 (defun org-html-level-start (level title umax with-toc head-count)
@@ -3417,12 +3904,17 @@
 	    (when (or (and combine (not files)) (not combine))
 	      (org-finish-icalendar-file)
 	      (set-buffer ical-buffer)
+	      (run-hooks 'org-before-save-iCalendar-file-hook)
 	      (save-buffer)
 	      (run-hooks 'org-after-save-iCalendar-file-hook)
 	      (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))
 	      ))))
       (org-release-buffers org-agenda-new-buffers))))
 
+(defvar org-before-save-iCalendar-file-hook nil
+  "Hook run before  an iCalendar file has been saved.
+This can be used to modify the result of the export.")
+
 (defvar org-after-save-iCalendar-file-hook nil
   "Hook run after an iCalendar file has been saved.
 The iCalendar buffer is still current when this hook is run.
@@ -3440,7 +3932,8 @@
 	      (format-time-string (cdr org-time-stamp-formats) (current-time))
 	      "DTSTART"))
 	hd ts ts2 state status (inc t) pos b sexp rrule
-	scheduledp deadlinep tmp pri category entry location summary desc
+	scheduledp deadlinep prefix
+	tmp pri category entry location summary desc uid
 	(sexp-buffer (get-buffer-create "*ical-tmp*")))
     (org-refresh-category-properties)
     (save-excursion
@@ -3456,7 +3949,9 @@
 	  (setq pos (match-beginning 0)
 		ts (match-string 0)
 		inc t
-		hd (condition-case nil (org-get-heading)
+		hd (condition-case nil
+		       (org-icalendar-cleanup-string
+			(org-get-heading))
 		     (error (throw :skip nil)))
 		summary (org-icalendar-cleanup-string
 			 (org-entry-get nil "SUMMARY"))
@@ -3466,11 +3961,16 @@
 		      t org-icalendar-include-body)
 		location (org-icalendar-cleanup-string
 			  (org-entry-get nil "LOCATION"))
-		category (org-get-category))
+		uid (if org-icalendar-store-UID
+			(org-id-get-create)
+		      (or (org-id-get) (org-id-new)))
+		category (org-get-category)
+		deadlinep nil scheduledp nil)
 	  (if (looking-at re2)
 	      (progn
 		(goto-char (match-end 0))
-		(setq ts2 (match-string 1) inc nil))
+		(setq ts2 (match-string 1)
+		      inc (not (string-match "[0-9]\\{1,2\\}:[0-9][0-9]" ts2))))
 	    (setq tmp (buffer-substring (max (point-min)
 					     (- pos org-ds-keyword-length))
 					pos)
@@ -3483,6 +3983,7 @@
 		  scheduledp (string-match org-scheduled-regexp tmp)
 		  ;; donep (org-entry-is-done-p)
 		  ))
+	  (setq prefix (if deadlinep "DL-" (if scheduledp "SC-" "TS-")))
 	  (if (or (string-match org-tr-regexp hd)
 		  (string-match org-ts-regexp hd))
 	      (setq hd (replace-match "" t t hd)))
@@ -3500,19 +4001,21 @@
 	      (setq summary
 		    (replace-match (if (match-end 3)
 				       (match-string 3 summary)
-					(match-string 1 summary))
-				      t t summary)))
+				     (match-string 1 summary))
+				   t t summary)))
 	  (if deadlinep (setq summary (concat "DL: " summary)))
 	  (if scheduledp (setq summary (concat "S: " summary)))
 	  (if (string-match "\\`<%%" ts)
 	      (with-current-buffer sexp-buffer
 		(insert (substring ts 1 -1) " " summary "\n"))
 	    (princ (format "BEGIN:VEVENT
+UID: %s
 %s
 %s%s
 SUMMARY:%s%s%s
 CATEGORIES:%s
 END:VEVENT\n"
+			   (concat prefix uid)
 			   (org-ical-ts-to-string ts "DTSTART")
 			   (org-ical-ts-to-string ts2 "DTEND" inc)
 			   rrule summary
@@ -3521,7 +4024,6 @@
 			   (if (and location (string-match "\\S-" location))
 			       (concat "\nLOCATION: " location) "")
 			   category)))))
-
       (when (and org-icalendar-include-sexps
 		 (condition-case nil (require 'icalendar) (error nil))
 		 (fboundp 'icalendar-export-region))
@@ -3536,10 +4038,12 @@
 	    (end-of-line 1)
 	    (setq sexp (buffer-substring b (point)))
 	    (with-current-buffer sexp-buffer
-	      (insert sexp "\n"))
-	    (princ (org-diary-to-ical-string sexp-buffer)))))
-
+	      (insert sexp "\n"))))
+	(princ (org-diary-to-ical-string sexp-buffer))
+	(kill-buffer sexp-buffer))
+      
       (when org-icalendar-include-todo
+	(setq prefix "TODO-")
 	(goto-char (point-min))
 	(while (re-search-forward org-todo-line-regexp nil t)
 	  (catch :skip
@@ -3565,7 +4069,10 @@
 			      (and org-icalendar-include-body (org-get-entry)))
 			  t org-icalendar-include-body)
 		    location (org-icalendar-cleanup-string
-			      (org-entry-get nil "LOCATION")))
+			      (org-entry-get nil "LOCATION"))
+		    uid (if org-icalendar-store-UID
+			    (org-id-get-create)
+			  (or (org-id-get) (org-id-new))))
 	      (if (string-match org-bracket-link-regexp hd)
 		  (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
 					    (match-string 1 hd))
@@ -3579,6 +4086,7 @@
 					    (- org-lowest-priority org-highest-priority))))))
 
 	      (princ (format "BEGIN:VTODO
+UID: %s
 %s
 SUMMARY:%s%s%s
 CATEGORIES:%s
@@ -3586,13 +4094,15 @@
 PRIORITY:%d
 STATUS:%s
 END:VTODO\n"
+			     (concat prefix uid)
 			     dts
 			     (or summary hd)
 			     (if (and location (string-match "\\S-" location))
 				 (concat "\nLOCATION: " location) "")
 			     (if (and desc (string-match "\\S-" desc))
 				 (concat "\nDESCRIPTION: " desc) "")
-			     category pri status)))))))))
+			     category
+			     pri status)))))))))
 
 (defun org-icalendar-cleanup-string (s &optional is-body maxlength)
   "Take out stuff and quote what needs to be quoted.
@@ -3607,7 +4117,7 @@
 	(while (string-match re s) (setq s (replace-match "" t t s)))
 	(while (string-match re2 s) (setq s (replace-match "" t t s)))))
     (let ((start 0))
-      (while (string-match "\\([,;\\]\\)" s start)
+      (while (string-match "\\([,;]\\)" s start)
 	(setq start (+ (match-beginning 0) 2)
 	      s (replace-match "\\\\\\1" nil nil s))))
     (when is-body
@@ -3756,12 +4266,7 @@
 
 (provide 'org-exp)
 
+;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
+
 ;;; org-exp.el ends here
 
-
-(defun org-export-process-option-filters (plist)
-  (let ((functions org-export-options-filters) f)
-    (while (setq f (pop functions))
-      (setq plist (funcall f plist))))
-  plist)
-;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
--- a/lisp/org/org-export-latex.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-export-latex.el	Tue Jun 17 15:22:00 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 6.02b
+;; Version: 6.05a
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
@@ -361,12 +361,19 @@
   (let* ((wcf (current-window-configuration))
 	 (opt-plist org-export-latex-options-plist)
 	 (region-p (org-region-active-p))
+	 (rbeg (and region-p (region-beginning)))
+	 (rend (and region-p (region-end)))
 	 (subtree-p
 	  (when region-p
 	    (save-excursion
-	      (goto-char (region-beginning))
+	      (goto-char rbeg)
 	      (and (org-at-heading-p)
-		   (>= (org-end-of-subtree t t) (region-end))))))
+		   (>= (org-end-of-subtree t t) rend)))))
+	 (opt-plist (if subtree-p 
+			(org-export-add-subtree-options opt-plist rbeg)
+		      opt-plist))
+	 ;; Make sure the variable contains the updated values.
+	 (org-export-latex-options-plist opt-plist)
 	 (title (or (and subtree-p (org-export-get-title-from-subtree))
 		    (plist-get opt-plist :title)
 		    (and (not
@@ -378,8 +385,11 @@
 			    (or pub-dir
 				(org-export-directory :LaTeX ext-plist)))
 			   (file-name-sans-extension
-			    (file-name-nondirectory ;sans-extension
-			     buffer-file-name)) ".tex"))
+			    (or (and subtree-p
+				     (org-entry-get rbeg "EXPORT_FILE_NAME" t))
+				(file-name-nondirectory ;sans-extension
+				 buffer-file-name)))
+			   ".tex"))
 	 (filename (if (equal (file-truename filename)
 			      (file-truename buffer-file-name))
 		       (concat filename ".tex")
@@ -1094,6 +1104,22 @@
     (replace-match (org-export-latex-protect-string
 		    (concat (match-string 1) "\\LaTeX{}")) t t)))
 
+  ;; Convert blockquotes
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+BEGIN_QUOTE" nil t)
+    (replace-match "\\begin{quote}" t t))
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+END_QUOTE" nil t)
+    (replace-match "\\end{quote}" t t))
+
+  ;; Convert verse
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+BEGIN_VERSE" nil t)
+    (replace-match "\\begin{verse}" t t))
+  (goto-char (point-min))
+  (while (re-search-forward "^#\\+END_VERSE" nil t)
+    (replace-match "\\end{verse}" t t))
+
   ;; Convert horizontal rules
   (goto-char (point-min))
   (while (re-search-forward "^----+.$" nil t)
@@ -1538,4 +1564,5 @@
 (provide 'org-export-latex)
 
 ;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
+
 ;;; org-export-latex.el ends here
--- a/lisp/org/org-faces.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-faces.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -148,13 +148,41 @@
 (defface org-column
   (org-compatible-face nil
     '((((class color) (min-colors 16) (background light))
-       (:background "grey90"))
+       (:background "grey90" :weight normal :slant normal :strike-through nil
+		    :underline nil))
       (((class color) (min-colors 16) (background dark))
-       (:background "grey30"))
+       (:background "grey30" :weight normal :slant normal :strike-through nil
+		    :underline nil))
       (((class color) (min-colors 8))
-       (:background "cyan" :foreground "black"))
+       (:background "cyan" :foreground "black"
+		    :weight normal :slant normal :strike-through nil
+		    :underline nil))
       (t (:inverse-video t))))
-  "Face for column display of entry properties."
+  "Face for column display of entry properties.
+This is actually only part of the face definition for the text in column view.
+The following faces apply, with this priority.
+
+1. The color of the reference face.  This is normally the level fact that
+   is used in the outline.  In agenda-mode, it will be the face of the 
+   first character in the line.  The color is explicitly retained to
+   make sure that the column line still looks a bit like the structure
+   line it is masking.
+
+2. The `org-column' face.
+
+3. The remaining properties of the reference face.
+
+Since column view works by putting overlays with a display property
+over individual characters in the buffer, the face of the underlining
+character (this might for example be the a TODO keyword) might still
+shine through in some properties.  So when your column view looks
+funny, with \"random\" colors, weight, strike-through, try to explicitly
+set the properties in the `org-column' face.  For example, set
+:underline to nil, or the :slant to `normal'.
+
+Under XEmacs, the rules are simpler, because the XEmacs version of
+column view defines special faces for each outline level.  See the file
+`org-colview-xemacs.el' for details."
   :group 'org-faces)
 
 (defface org-column-title
@@ -457,4 +485,5 @@
 (provide 'org-faces)
 
 ;; arch-tag: 9dab5f91-c4b9-4d6f-bac3-1f6211ad0a04
+
 ;;; org-faces.el ends here
--- a/lisp/org/org-gnus.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-gnus.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -125,4 +125,5 @@
 (provide 'org-gnus)
 
 ;; arch-tag: 512e0840-58fa-45b3-b456-71e10fa2376d
+
 ;;; org-gnus.el ends here
--- a/lisp/org/org-info.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-info.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -78,4 +78,5 @@
 (provide 'org-info)
 
 ;; arch-tag: 1e289f54-7176-487f-b575-dd4854bab15e
+
 ;;; org-info.el ends here
--- a/lisp/org/org-irc.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-irc.el	Tue Jun 17 15:22:00 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -252,4 +252,5 @@
 (provide 'org-irc)
 
 ;; arch-tag: 018d7dda-53b8-4a35-ba92-6670939e525a
+
 ;;; org-irc.el ends here
--- a/lisp/org/org-jsinfo.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-jsinfo.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -66,6 +66,7 @@
   '((path PATH "http://orgmode.org/org-info.js")
     (view VIEW "info")
     (toc TOC :table-of-contents)
+    (ftoc FIXED_TOC "0")
     (tdepth TOC_DEPTH "max")
     (sdepth SECTION_DEPTH "max")
     (mouse MOUSE_HINT "underline")
@@ -200,6 +201,8 @@
 	  (cdr (assoc 'path org-infojs-options))))
 
 (provide 'org-infojs)
+(provide 'org-jsinfo)
 
 ;; arch-tag: c71d1d85-3337-4817-a066-725e74ac9eac
+
 ;;; org-jsinfo.el ends here
--- a/lisp/org/org-mac-message.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-mac-message.el	Tue Jun 17 15:22:00 2008 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2008 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.02b
+;; Version: 6.05a
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
@@ -79,4 +79,5 @@
 (provide 'org-mac-message)
 
 ;; arch-tag: 3806d0c1-abe1-4db6-9c31-f3ed7d4a9b32
+
 ;;; org-mac-message.el ends here
--- a/lisp/org/org-macs.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-macs.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -89,9 +89,9 @@
 (defmacro org-with-point-at (pom &rest body)
   "Move to buffer and point of point-or-marker POM for the duration of BODY."
   `(save-excursion
-     (if (markerp pom) (set-buffer (marker-buffer pom)))
+     (if (markerp ,pom) (set-buffer (marker-buffer ,pom)))
      (save-excursion
-       (goto-char (or pom (point)))
+       (goto-char (or ,pom (point)))
        ,@body)))
 
 (defmacro org-no-warnings (&rest body)
@@ -220,4 +220,5 @@
 (provide 'org-macs)
 
 ;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668
+
 ;;; org-macs.el ends here
--- a/lisp/org/org-mew.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-mew.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 
 ;; This file is part of GNU Emacs.
 
@@ -123,4 +123,5 @@
 (provide 'org-mew)
 
 ;; arch-tag: 07ccdca7-6020-4941-a593-588a1e51b870
+
 ;;; org-mew.el ends here
--- a/lisp/org/org-mhe.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-mhe.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -71,6 +71,7 @@
 (defvar mh-show-folder-buffer)
 (defvar mh-index-folder)
 (defvar mh-searcher)
+(defvar mh-search-regexp-builder)
 
 ;; Install the link type
 (org-add-link-type "mhe" 'org-mhe-open)
@@ -137,11 +138,11 @@
       )))
 
 (defun org-mhe-get-message-folder-from-index ()
-  "Return the name of the message folder in a index folder buffer."
+  "Return the name of the message folder in an index folder buffer."
   (save-excursion
     (mh-index-previous-folder)
-    (re-search-forward "^\\(+.*\\)$" nil t)
-    (message "%s" (match-string 1))))
+    (if (re-search-forward "^\\(+.*\\)$" nil t)
+	(message "%s" (match-string 1)))))
 
 (defun org-mhe-get-message-folder ()
   "Return the name of the current message folder.
@@ -194,16 +195,19 @@
   (mh-find-path)
   (if (not article)
       (mh-visit-folder (mh-normalize-folder-name folder))
-    (setq article (org-add-angle-brackets article))
     (mh-search-choose)
     (if (equal mh-searcher 'pick)
         (progn
+	  (setq article (org-add-angle-brackets article))
           (mh-search folder (list "--message-id" article))
           (when (and org-mhe-search-all-folders
                      (not (org-mhe-get-message-real-folder)))
             (kill-this-buffer)
             (mh-search "+" (list "--message-id" article))))
-      (mh-search "+" article))
+      (if mh-search-regexp-builder
+          (mh-search "+" (funcall mh-search-regexp-builder
+				  (list (cons 'message-id article))))
+        (mh-search "+" article)))
     (if (org-mhe-get-message-real-folder)
         (mh-show-msg 1)
       (kill-this-buffer)
@@ -212,4 +216,5 @@
 (provide 'org-mhe)
 
 ;; arch-tag: dcb05484-8627-491d-a8c1-01dbd2bde4ae
+
 ;;; org-mhe.el ends here
--- a/lisp/org/org-mouse.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-mouse.el	Tue Jun 17 15:22:00 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -1113,3 +1113,5 @@
 (provide 'org-mouse)
 
 ;; arch-tag: ff1ae557-3529-41a3-95c6-baaebdcc280f
+
+;;; org-mouse.el ends-here
--- a/lisp/org/org-publish.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-publish.el	Tue Jun 17 15:22:00 2008 +0000
@@ -4,7 +4,7 @@
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 6.02b
+;; Version: 6.05a
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -149,15 +149,17 @@
 
 (eval-when-compile
   (require 'cl))
+(require 'org)
+(require 'org-exp)
 
 (eval-and-compile
   (unless (fboundp 'declare-function)
     (defmacro declare-function (fn file &optional arglist fileonly))))
 
 (defgroup org-publish nil
-	"Options for publishing a set of Org-mode and related files."
-   :tag "Org Publishing"
-   :group 'org)
+  "Options for publishing a set of Org-mode and related files."
+  :tag "Org Publishing"
+  :group 'org)
 
 (defcustom org-publish-project-alist nil
   "Association list to control publishing behavior.
@@ -195,8 +197,8 @@
 file names you don't want to be published.
 
 The :include property may be used to include extra files.  Its
-value may be a list of filenames to include.  The filenames are
-considered relative to the publishing directory.
+value may be a list of filenames to include. The filenames are
+considered relative to the base directory.
 
 When both :include and :exclude properties are given values, the
 exclusion step happens first.
@@ -219,6 +221,8 @@
 
   :preparation-function   Function to be called before publishing
                           this project.
+  :completion-function    Function to be called after publishing
+                          this project.
 
 Some properties control details of the Org publishing process,
 and are equivalent to the corresponding user variables listed in
@@ -449,6 +453,11 @@
 				  ;; FIXME distinguish exclude regexp
 				  ;; for skip-file and skip-dir?
 				  exclude-regexp exclude-regexp)
+    (mapc (lambda (f)
+	    (pushnew 
+	     (expand-file-name (concat base-dir f))
+	     org-publish-temp-files))
+	  include-list)
     org-publish-temp-files))
 
 (defun org-publish-get-project-from-filename (filename)
@@ -512,6 +521,8 @@
     (require 'eshell)
     (require 'esh-maint)
     (require 'em-unix))
+  (unless (file-directory-p pub-dir)
+    (make-directory pub-dir t))
   (eshell/cp filename pub-dir))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -559,19 +570,22 @@
 If :auto-index is set, publish the index too."
   (mapc
    (lambda (project)
-     (let* ((project-plist (cdr project))
-	    (exclude-regexp (plist-get project-plist :exclude))
-	    (index-p (plist-get project-plist :auto-index))
-	    (index-filename (or (plist-get project-plist :index-filename)
-				"index.org"))
-	    (index-function (or (plist-get project-plist :index-function)
-				'org-publish-org-index))
-	    (preparation-function (plist-get project-plist :preparation-function))
-	    (files (org-publish-get-base-files project exclude-regexp)) file)
+     (let*
+	 ((project-plist (cdr project))
+	  (exclude-regexp (plist-get project-plist :exclude))
+	  (index-p (plist-get project-plist :auto-index))
+	  (index-filename (or (plist-get project-plist :index-filename)
+			      "index.org"))
+	  (index-function (or (plist-get project-plist :index-function)
+			      'org-publish-org-index))
+	  (preparation-function (plist-get project-plist :preparation-function))
+	  (completion-function (plist-get project-plist :completion-function))
+	  (files (org-publish-get-base-files project exclude-regexp)) file)
        (when preparation-function (funcall preparation-function))
        (if index-p (funcall index-function project index-filename))
        (while (setq file (pop files))
-	 (org-publish-file file project))))
+	 (org-publish-file file project))
+       (when completion-function (funcall completion-function))))
    (org-publish-expand-projects projects)))
 
 (defun org-publish-org-index (project &optional index-filename)
@@ -581,9 +595,13 @@
   (let* ((project-plist (cdr project))
 	 (dir (file-name-as-directory
 	       (plist-get project-plist :base-directory)))
+	 (localdir (file-name-directory dir))
+	 (indent-str (make-string 2 ?\ ))
 	 (exclude-regexp (plist-get project-plist :exclude))
-	 (files (org-publish-get-base-files project exclude-regexp))
+	 (files (nreverse (org-publish-get-base-files project exclude-regexp)))
 	 (index-filename (concat dir (or index-filename "index.org")))
+	 (index-title (or (plist-get project-plist :index-title)
+			  (concat "Index for project " (car project))))
 	 (index-buffer (find-buffer-visiting index-filename))
 	 (ifn (file-name-nondirectory index-filename))
 	 file)
@@ -591,16 +609,47 @@
     (if index-buffer
 	(kill-buffer index-buffer))
     (with-temp-buffer
+      (insert (concat index-title "\n\n"))
       (while (setq file (pop files))
-	(let ((fn (file-name-nondirectory file)))
+	(let ((fn (file-name-nondirectory file))
+	      (link (file-relative-name file dir))
+	      (oldlocal localdir))
 	  ;; index shouldn't index itself
 	  (unless (string= fn ifn)
-	    (insert (concat " + [[file:" fn "]["
+	    (setq localdir (concat (file-name-as-directory dir)
+				   (file-name-directory link)))
+	    (unless (string= localdir oldlocal)
+	      (if (string= localdir dir)
+		  (setq indent-str (make-string 2 ?\ ))
+		(let ((subdirs
+		       (split-string
+			(directory-file-name
+			 (file-name-directory
+			  (file-relative-name localdir dir))) "/"))
+		      (subdir ""))
+		  (setq indent-str (make-string 2 ?\ ))
+		  (dolist (d subdirs)
+		    (setq subdir (concat subdir d "/"))
+		    (insert (concat indent-str " + [[file:" subdir "][" d "/]]\n"))
+		    (setq indent-str (make-string (+ (length indent-str) 2) ?\ ))))))
+	    (insert (concat indent-str " + [[file:" link "]["
 			    (file-name-sans-extension fn)
 			    "]]\n")))))
       (write-file index-filename)
       (kill-buffer (current-buffer)))))
 
+(defun org-publish-find-title (file)
+  "Find the title of file in project."
+  (save-excursion
+    (set-buffer (find-file-noselect file))
+    (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+ 					  (org-infile-export-plist))))
+      (or (plist-get opt-plist :title)
+ 	  (and (not
+ 		(plist-get opt-plist :skip-before-1st-heading))
+ 	       (org-export-grab-title-from-buffer))
+ 	  (file-name-sans-extension file)))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Interactive publishing functions
 
@@ -663,4 +712,5 @@
 
 
 ;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
+
 ;;; org-publish.el ends here
--- a/lisp/org/org-remember.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-remember.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -50,9 +50,12 @@
   :group 'org)
 
 (defcustom org-remember-store-without-prompt t
-  "Non-nil means, `C-c C-c' stores remember note without further promts.
-In this case, you need `C-u C-c C-c' to get the prompts for
-note file and headline.
+  "Non-nil means, `C-c C-c' stores remember note without further prompts.
+It then uses the file and headline specified by the template or (if the
+themplate does not specify them) by the variables `org-default-notes-file'
+and `org-remember-default-headline'.  To force prompting anyway, use 
+`C-u C-c C-c' to file the note.
+
 When this variable is nil, `C-c C-c' gives you the prompts, and
 `C-u C-c C-c' triggers the fasttrack."
   :group 'org-remember
@@ -99,13 +102,16 @@
 
 An optional fifth element can specify the headline in that file that should
 be offered first when the user is asked to file the entry.  The default
-headline is given in the variable `org-remember-default-headline'.
+headline is given in the variable `org-remember-default-headline'.  When
+this element is `top' or `bottom', the note will be placed as a level-1
+entry at the beginning or end of the file, respectively.
 
-An optional sixth element specifies the contexts in which the user can
-select the template.  This element can be either a list of major modes
-or a function.  `org-remember' will first check whether the function
-returns `t' or if we are in any of the listed major modes, and select
-the template accordingly.
+An optional sixth element specifies the contexts in which the template
+will be offered to the user.  This element can be a list of major modes
+or a function, and the template will only be offered if `org-remember'
+is called from a mode in the list, or if the function returns t.
+Templates that specify t or nil for the context will be always be added
+to the list of selectable templates.
 
 The template specifies the structure of the remember buffer.  It should have
 a first line starting with a star, to act as the org-mode headline.
@@ -117,19 +123,23 @@
   %t          time stamp, date only
   %T          time stamp with date and time
   %u, %U      like the above, but inactive time stamps
-  %^t         like %t, but prompt for date.  Similarly %^T, %^u, %^U
-              You may define a prompt like %^{Please specify birthday}t
+  %^t         like %t, but prompt for date.  Similarly %^T, %^u, %^U.
+              You may define a prompt like %^{Please specify birthday
   %n          user name (taken from `user-full-name')
   %a          annotation, normally the link created with org-store-link
   %i          initial content, the region active.  If %i is indented,
               the entire inserted text will be indented as well.
-  %c          content of the clipboard, or current kill ring head
+  %c          current kill ring head
+  %x          content of the X clipboard
+  %^C         Interactive selection of which kill or clip to use
+  %^L         Like %^C, but insert as link
   %^g         prompt for tags, with completion on tags in target file
   %^G         prompt for tags, with completion all tags in all agenda files
   %:keyword   specific information for certain link types, see below
   %[pathname] insert the contents of the file given by `pathname'
   %(sexp)     evaluate elisp `(sexp)' and replace with the result
   %!          Store this note immediately after filling the template
+  %&          Visit note immediately after storing it
 
   %?          After completing the template, position cursor here.
 
@@ -164,19 +174,34 @@
 		(string :tag "Name")
 		(character :tag "Selection Key")
 		(string :tag "Template")
-		(choice
-		 (file :tag "Destination file")
-		 (const :tag "Prompt for file" nil))
-		(choice
-		 (string :tag "Destination headline")
-		 (const :tag "Selection interface for heading"))
-		(choice
-		 (const :tag "Use by default" nil)
+		(choice :tag "Destination file"
+		 (file :tag "Specify")
+		 (const :tag "Use `org-default-notes-file'" nil))
+		(choice :tag "Destin. headline"
+		 (string :tag "Specify")
+		 (const :tag "Use `org-remember-default-headline'" nil)
+		 (const :tag "Level 1 at beginning of file" top)
+		 (const :tag "Level 1 at end of file" bottom))
+		(choice :tag "Context"
+		 (const :tag "Use in all contexts" nil)
 		 (const :tag "Use in all contexts" t)
 		 (repeat :tag "Use only if in major mode"
 			 (symbol :tag "Major mode"))
 		 (function :tag "Perform a check against function")))))
 
+(defcustom org-remember-clock-out-on-exit 'query
+  "Non-nil means, stop the clock when exiting a clocking remember buffer.
+This only applies if the clock is running in the remember buffer.  If the
+clock is not stopped, it continues to run in the storage location.
+Instead of nil or t, this may also be the symbol `query' to prompt the
+user each time a remember buffer with a running clock is filed away.  "
+  :group 'org-remember
+  :type '(choice
+	  (const :tag "Never" nil)
+	  (const :tag "Always" t)
+	  (const :tag "Query user" query)))
+
+
 (defvar annotation) ; from remember.el, dynamically scoped in `remember-mode'
 (defvar initial)    ; from remember.el, dynamically scoped in `remember-mode'
 
@@ -203,6 +228,7 @@
 RET at beg-of-buf -> Append to file as level 2 headline
 <left>/<right>    -> before/after current headline, same headings level")
 
+(defvar org-jump-to-target-location nil)
 (defvar org-remember-previous-location nil)
 (defvar org-force-remember-template-char) ;; dynamically scoped
 
@@ -289,6 +315,7 @@
 to be run from that hook to function properly."
   (if org-remember-templates
       (let* ((entry (org-select-remember-template use-char))
+	     (ct (or org-overriding-default-time (org-current-time)))
 	     (tpl (car entry))
 	     (plist-p (if org-store-link-plist t nil))
 	     (file (if (and (nth 1 entry) (stringp (nth 1 entry))
@@ -300,8 +327,8 @@
 	     (v-x (or (org-get-x-clipboard 'PRIMARY)
 		      (org-get-x-clipboard 'CLIPBOARD)
 		      (org-get-x-clipboard 'SECONDARY)))
-	     (v-t (format-time-string (car org-time-stamp-formats) (org-current-time)))
-	     (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time)))
+	     (v-t (format-time-string (car org-time-stamp-formats) ct))
+	     (v-T (format-time-string (cdr org-time-stamp-formats) ct))
 	     (v-u (concat "[" (substring v-t 1 -1) "]"))
 	     (v-U (concat "[" (substring v-T 1 -1) "]"))
 	     ;; `initial' and `annotation' are bound in `remember'
@@ -394,11 +421,11 @@
 	(org-set-local 'org-finish-function 'org-remember-finalize)
 	(if (and file (string-match "\\S-" file) (not (file-directory-p file)))
 	    (org-set-local 'org-default-notes-file file))
-	(if (and headline (stringp headline) (string-match "\\S-" headline))
+	(if headline
 	    (org-set-local 'org-remember-default-headline headline))
 	;; Interactive template entries
 	(goto-char (point-min))
-	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGuUtTCL]\\)?" nil t)
+	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCL]\\)?" nil t)
 	  (setq char (if (match-end 3) (match-string 3))
 		prompt (if (match-end 2) (match-string 2)))
 	  (goto-char (match-beginning 0))
@@ -444,6 +471,7 @@
 						   '(clipboards . 1)
 						   (car clipboards))))))
 	   (char
+	    ;; These are the date/time related ones
 	    (setq org-time-was-given (equal (upcase char) char))
 	    (setq time (org-read-date (equal (upcase char) "U") t nil
 				      prompt))
@@ -464,6 +492,11 @@
     (org-set-local 'org-finish-function 'org-remember-finalize))
   (when (save-excursion
 	  (goto-char (point-min))
+	  (re-search-forward "%&" nil t))
+    (replace-match "")
+    (org-set-local 'org-jump-to-target-location t))
+  (when (save-excursion
+	  (goto-char (point-min))
 	  (re-search-forward "%!" nil t))
     (replace-match "")
     (add-hook 'post-command-hook 'org-remember-finish-immediately 'append)))
@@ -476,15 +509,34 @@
   (when org-finish-function
     (funcall org-finish-function)))
 
-(defvar org-clock-marker) ; Defined below
+(defun org-remember-visit-immediately ()
+  "File remember note immediately.
+This should be run in `post-command-hook' and will remove itself
+from that hook."
+  (org-remember '(16))
+  (goto-char (or (text-property-any
+		  (point) (save-excursion (org-end-of-subtree t t))
+		  'org-position-cursor t)
+		 (point)))
+  (message "%s"
+	   (format
+	    (substitute-command-keys 
+	     "Restore window configuration with \\[jump-to-register] %c")
+	    remember-register)))
+
+(defvar org-clock-marker) ; Defined in org.el
 (defun org-remember-finalize ()
   "Finalize the remember process."
   (unless (fboundp 'remember-finalize)
     (defalias 'remember-finalize 'remember-buffer))
   (when (and org-clock-marker
 	     (equal (marker-buffer org-clock-marker) (current-buffer)))
-    ;; FIXME: test this, this is w/o notetaking!
-    (let (org-log-note-clock-out) (org-clock-out)))
+    ;; the clock is running in this buffer.
+    (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
+	       (or (eq org-remember-clock-out-on-exit t)
+		   (and org-remember-clock-out-on-exit
+			(y-or-n-p "The clock is running in this buffer.  Clock out now? "))))
+      (let (org-log-note-clock-out) (org-clock-out))))
   (when buffer-file-name
     (save-buffer)
     (setq buffer-file-name nil))
@@ -525,10 +577,14 @@
 	  (org-do-remember (buffer-substring (point) (mark)))
 	(org-do-remember))))))
 
+(defvar org-remember-last-stored-marker (make-marker)
+  "Marker pointing to the entry most recently stored with `org-remember'.")
+
 (defun org-remember-goto-last-stored ()
   "Go to the location where the last remember note was stored."
   (interactive)
-  (bookmark-jump "org-remember-last-stored")
+  (org-goto-marker-or-bmk org-remember-last-stored-marker
+			  "org-remember-last-stored")
   (message "This is the last note stored by remember"))
 
 (defun org-go-to-remember-target (&optional template-key)
@@ -594,6 +650,11 @@
 \(i.e. after the stars).
 
 See also the variable `org-reverse-note-order'."
+  (when (org-bound-and-true-p org-jump-to-target-location)
+    (let* ((end (min (point-max) (1+ (point))))
+	   (beg (point)))
+      (if (= end beg) (setq beg (1- beg)))
+      (put-text-property beg end 'org-position-cursor t)))
   (goto-char (point-min))
   (while (looking-at "^[ \t]*\n\\|^##.*\n")
     (replace-match ""))
@@ -604,7 +665,7 @@
     (beginning-of-line 1))
   (catch 'quit
     (if org-note-abort (throw 'quit nil))
-    (let* ((txt (buffer-substring (point-min) (point-max)))
+    (let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
 	   (fastp (org-xor (equal current-prefix-arg '(4))
 			   org-remember-store-without-prompt))
 	   (file (cond
@@ -620,46 +681,39 @@
 	   (org-startup-folded nil)
 	   (org-startup-align-all-tables nil)
 	   (org-goto-start-pos 1)
-	   spos exitcmd level indent reversed)
+	   spos exitcmd level reversed txt)
       (if (and (equal current-prefix-arg '(16)) org-remember-previous-location)
 	  (setq file (car org-remember-previous-location)
 		heading (cdr org-remember-previous-location)
 		fastp t))
       (setq current-prefix-arg nil)
-      (if (string-match "[ \t\n]+\\'" txt)
-	  (setq txt (replace-match "" t t txt)))
       ;; Modify text so that it becomes a nice subtree which can be inserted
       ;; into an org tree.
-      (let* ((lines (split-string txt "\n"))
-	     first)
-	(setq first (car lines) lines (cdr lines))
-	(if (string-match "^\\*+ " first)
-	    ;; Is already a headline
-	    (setq indent nil)
-	  ;; We need to add a headline:  Use time and first buffer line
-	  (setq lines (cons first lines)
-		first (concat "* " (current-time-string)
-			      " (" (remember-buffer-desc) ")")
-		indent "  "))
-	(if (and org-adapt-indentation indent)
-	    (setq lines (mapcar
-			 (lambda (x)
-			   (if (string-match "\\S-" x)
-			       (concat indent x) x))
-			 lines)))
-	(setq txt (concat first "\n"
-			  (mapconcat 'identity lines "\n"))))
-      (if (string-match "\n[ \t]*\n[ \t\n]*\\'" txt)
-	  (setq txt (replace-match "\n\n" t t txt))
-	(if (string-match "[ \t\n]*\\'" txt)
-	    (setq txt (replace-match "\n" t t txt))))
-      ;; Put the modified text back into the remember buffer, for refile.
-      (erase-buffer)
-      (insert txt)
+      (goto-char (point-min))
+      (if (re-search-forward "[ \t\n]+\\'" nil t)
+	  ;; remove empty lines at end
+	  (replace-match ""))
       (goto-char (point-min))
+      (unless (looking-at org-outline-regexp)
+	;; add a headline
+	(insert (concat "* " (current-time-string)
+			" (" (remember-buffer-desc) ")\n"))
+	(backward-char 1)
+	(when org-adapt-indentation
+	  (while (re-search-forward "^" nil t)
+	    (insert "  "))))
+      (goto-char (point-min))
+      (if (re-search-forward "\n[ \t]*\n[ \t\n]*\\'" nil t)
+	  (replace-match "\n\n")
+	(if (re-search-forward "[ \t\n]*\\'")
+	    (replace-match "\n")))
+      (goto-char (point-min))
+      (setq txt (buffer-string))
+      (org-save-markers-in-region (point-min) (point-max))
       (when (and (eq org-remember-interactive-interface 'refile)
 		 (not fastp))
 	(org-refile nil (or visiting (find-file-noselect file)))
+	(and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
 	(throw 'quit t))
       ;; Find the file
       (if (not visiting) (find-file-noselect file))
@@ -671,25 +725,43 @@
 	    (widen)
 	    (and (goto-char (point-min))
 		 (not (re-search-forward "^\\* " nil t))
-		 (insert "\n* " (or heading "Notes") "\n"))
+		 (insert "\n* " (or (and (stringp heading) heading)
+				    "Notes") "\n"))
 	    (setq reversed (org-notes-order-reversed-p))
 
 	    ;; Find the default location
-	    (when (and heading (stringp heading) (string-match "\\S-" heading))
-	      (goto-char (point-min))
-	      (if (re-search-forward
-		   (concat "^\\*+[ \t]+" (regexp-quote heading)
-			   (org-re "\\([ \t]+:[[:alnum:]@_:]*\\)?[ \t]*$"))
-		   nil t)
-		  (setq org-goto-start-pos (match-beginning 0))
-		(when fastp
-		  (goto-char (point-max))
-		  (unless (bolp) (newline))
-		  (insert "* " heading "\n")
-		  (setq org-goto-start-pos (point-at-bol 0)))))
+	    (when heading
+	      (cond
+	       ((eq heading 'top)
+		(goto-char (point-min))
+		(or (looking-at org-outline-regexp)
+		    (re-search-forward org-outline-regexp nil t))
+		(setq org-goto-start-pos (or (match-beginning 0) (point-min))))
+	       ((eq heading 'bottom)
+		(goto-char (point-max))
+		(re-search-backward "^\\* " nil t)
+		(or (bolp) (newline))
+		(setq org-goto-start-pos (point)))
+	       ((and (stringp heading) (string-match "\\S-" heading))
+		(goto-char (point-min))
+		(if (re-search-forward
+		     (concat "^\\*+[ \t]+" (regexp-quote heading)
+			     (org-re "\\([ \t]+:[[:alnum:]@_:]*\\)?[ \t]*$"))
+		     nil t)
+		    (setq org-goto-start-pos (match-beginning 0))
+		  (when fastp
+		    (goto-char (point-max))
+		    (unless (bolp) (newline))
+		    (insert "* " heading "\n")
+		    (setq org-goto-start-pos (point-at-bol 0)))))
+	       (t (goto-char (point-min)) (setq org-goto-start-pos (point)
+						heading 'top))))
 
 	    ;; Ask the User for a location, using the appropriate interface
 	    (cond
+	     ((and fastp (memq heading '(top bottom)))
+	      (setq spos org-goto-start-pos
+			  exitcmd (if (eq heading 'top) 'left 'right)))
 	     (fastp (setq spos org-goto-start-pos
 			  exitcmd 'return))
 	     ((eq org-remember-interactive-interface 'outline)
@@ -706,6 +778,7 @@
 	     (t (error "This should not happen")))
 	    (if (not spos) (throw 'quit nil)) ; return nil to show we did
 					; not handle this note
+	    (and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
 	    (goto-char spos)
 	    (cond ((org-on-heading-p t)
 		   (org-back-to-heading t)
@@ -724,17 +797,23 @@
 			       (beginning-of-line 2)
 			     (end-of-line 1)
 			     (insert "\n"))))
+		     (org-paste-subtree (org-get-valid-level level 1) txt)
+		     (and org-auto-align-tags (org-set-tags nil t))
 		     (bookmark-set "org-remember-last-stored")
-		     (org-paste-subtree (org-get-valid-level level 1) txt))
+		     (move-marker org-remember-last-stored-marker (point)))
 		    ((eq exitcmd 'left)
 		     ;; before current
+		     (org-paste-subtree level txt)
+		     (and org-auto-align-tags (org-set-tags nil t))
 		     (bookmark-set "org-remember-last-stored")
-		     (org-paste-subtree level txt))
+		     (move-marker org-remember-last-stored-marker (point)))
 		    ((eq exitcmd 'right)
 		     ;; after current
 		     (org-end-of-subtree t)
+		     (org-paste-subtree level txt)
+		     (and org-auto-align-tags (org-set-tags nil t))
 		     (bookmark-set "org-remember-last-stored")
-		     (org-paste-subtree level txt))
+		     (move-marker org-remember-last-stored-marker (point)))
 		    (t (error "This should not happen"))))
 
 		  ((and (bobp) (not reversed))
@@ -743,8 +822,10 @@
 		     (widen)
 		     (goto-char (point-max))
 		     (if (not (bolp)) (newline))
+		     (org-paste-subtree (org-get-valid-level 1 1) txt)
+		     (and org-auto-align-tags (org-set-tags nil t))
 		     (bookmark-set "org-remember-last-stored")
-		     (org-paste-subtree (org-get-valid-level 1 1) txt)))
+		     (move-marker org-remember-last-stored-marker (point))))
 
 		  ((and (bobp) reversed)
 		   ;; Put it at the start, as level 1
@@ -753,18 +834,26 @@
 		     (goto-char (point-min))
 		     (re-search-forward "^\\*+ " nil t)
 		     (beginning-of-line 1)
+		     (org-paste-subtree 1 txt)
+		     (and org-auto-align-tags (org-set-tags nil t))
 		     (bookmark-set "org-remember-last-stored")
-		     (org-paste-subtree 1 txt)))
+		     (move-marker org-remember-last-stored-marker (point))))
 		  (t
 		   ;; Put it right there, with automatic level determined by
 		   ;; org-paste-subtree or from prefix arg
-		   (bookmark-set "org-remember-last-stored")
 		   (org-paste-subtree
 		    (if (numberp current-prefix-arg) current-prefix-arg)
-		    txt)))
+		    txt)
+		   (and org-auto-align-tags (org-set-tags nil t))
+		   (bookmark-set "org-remember-last-stored")
+		   (move-marker org-remember-last-stored-marker (point))))
+
 	    (when remember-save-after-remembering
 	      (save-buffer)
-	      (if (not visiting) (kill-buffer (current-buffer)))))))))
+	      (if (and (not visiting)
+		       (not (equal (marker-buffer org-clock-marker)
+				   (current-buffer))))
+		  (kill-buffer (current-buffer)))))))))
 
   t)    ;; return t to indicate that we took care of this note.
 
@@ -775,6 +864,6 @@
 
 (provide 'org-remember)
 
-;;; org-remember.el ends here
+;; arch-tag: 497f30d0-4bc3-4097-8622-2d27ac5f2698
 
-;; arch-tag: 497f30d0-4bc3-4097-8622-2d27ac5f2698
+;;; org-remember.el ends here
--- a/lisp/org/org-rmail.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-rmail.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -105,4 +105,5 @@
 (provide 'org-rmail)
 
 ;; arch-tag: c6cf4a8b-6639-4b7f-821f-bdf10746b173
+
 ;;; org-rmail.el ends here
--- a/lisp/org/org-table.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-table.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -187,7 +187,7 @@
 
 (defcustom org-calc-default-modes
   '(calc-internal-prec 12
-    calc-float-format  (float 5)
+    calc-float-format  (float 8)
     calc-angle-mode    deg
     calc-prefer-frac   nil
     calc-symbolic-mode nil
@@ -249,12 +249,11 @@
   :tag "Org Table Import Export"
   :group 'org-table)
 
-(defcustom org-table-export-default-format
-  "orgtbl-to-generic :splice t :sep \"\t\""
+(defcustom org-table-export-default-format "orgtbl-to-tsv"
   "Default export parameters for org-table-export. These can be
-  overridden on for a specific table by setting the
-  TABLE_EXPORT_FORMAT parameter. See orgtbl-export for the
-  different export transforms and available parameters."
+overridden on for a specific table by setting the TABLE_EXPORT_FORMAT
+property.  See the manual section on orgtbl radio tables for the different
+export transformations and available parameters."
   :group 'org-table-import-export
   :type 'string)
 
@@ -428,7 +427,7 @@
 (defvar org-table-last-alignment)
 (defvar org-table-last-column-widths)
 (defun org-table-export (&optional file format)
-  "Export table as a tab-separated file.
+  "Export table to a file, with configurable format.
 Such a file can be imported into a spreadsheet program like Excel.
 FILE can be the output file name.  If not given, it will be taken from
 a TABLE_EXPORT_FILE property in the current entry or higher up in the
@@ -439,19 +438,33 @@
 first checks if there is an export format specified in a TABLE_EXPORT_FORMAT
 property, locally or anywhere up in the hierarchy."
   (interactive)
+  (unless (org-at-table-p)
+    (error "No table at point"))
+  (require 'org-exp)
   (org-table-align) ;; make sure we have everything we need
   (let* ((beg (org-table-begin))
 	 (end (org-table-end))
 	 (txt (buffer-substring-no-properties beg end))
-	 (file (or file (org-entry-get beg "TABLE_EXPORT_FILE" t)
-		   (read-file-name "Export table to: ")))
-	 (format (or (org-entry-get beg "TABLE_EXPORT_FORMAT" t)
-		     org-table-export-default-format))
-	 buf)
-    (unless (or (not (file-exists-p file))
-		(y-or-n-p (format "Overwrite file %s? " file)))
-      (error "Abort"))
-    (message format)
+	 (file (or file (org-entry-get beg "TABLE_EXPORT_FILE" t)))
+	 (format (or format (org-entry-get beg "TABLE_EXPORT_FORMAT" t)))
+	 buf deffmt-readable)
+    (unless file
+      (setq file (read-file-name "Export table to: "))
+      (unless (or (not (file-exists-p file))
+		  (y-or-n-p (format "Overwrite file %s? " file)))
+	(error "Abort")))
+    (if (file-directory-p file)
+	(error "This is a directory path, not a file"))
+    (if (equal (file-truename file)
+	       (file-truename (buffer-file-name)))
+	(error "Please specify a file name that is different from current"))
+    (unless format
+      (setq deffmt-readable org-table-export-default-format)
+      (while (string-match "\t" deffmt-readable)
+	(setq deffmt-readable (replace-match "\\t" t t deffmt-readable)))
+      (while (string-match "\n" deffmt-readable)
+	(setq deffmt-readable (replace-match "\\n" t t deffmt-readable)))
+      (setq format (read-string "Format: " deffmt-readable)))
 
     (if (string-match "\\([^ \t\r\n]+\\)\\( +.*\\)?" format)
 	(let* ((transform (intern (match-string 1 format)))
@@ -2363,7 +2376,7 @@
       (goto-char beg)
       (and all (message "Re-applying formulas to full table..."))
 
-      ;; First find the named fields, and mark them untouchanble
+      ;; First find the named fields, and mark them untouchable
       (remove-text-properties beg end '(org-untouchable t))
       (while (setq eq (pop eqlname))
 	(setq name (car eq)
@@ -2371,8 +2384,11 @@
 	(and (not a)
 	     (string-match "@\\([0-9]+\\)\\$\\([0-9]+\\)" name)
 	     (setq a (list name
-			   (aref org-table-dlines
-				 (string-to-number (match-string 1 name)))
+			   (condition-case nil
+			       (aref org-table-dlines
+				     (string-to-number (match-string 1 name)))
+			     (error (error "Invalid row number in %s"
+					   name)))
 			   (string-to-number (match-string 2 name)))))
 	(when (and a (or all (equal (nth 1 a) thisline)))
 	  (message "Re-applying formula to field: %s" name)
@@ -3497,7 +3513,7 @@
     (goto-char (org-table-begin))
     (let (rtn)
       (beginning-of-line 0)
-      (while (looking-at "#\\+ORGTBL: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
+      (while (looking-at "#\\+ORGTBL[: \t][ \t]*SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
 	(let ((name (org-no-properties (match-string 1)))
 	      (transform (intern (match-string 2)))
 	      (params (if (match-end 3)
@@ -3629,6 +3645,7 @@
 ;; Formatting parameters for the current table section.
 (defvar *orgtbl-hline* nil "Text used for horizontal lines")
 (defvar *orgtbl-sep* nil "Text used as a column separator")
+(defvar *orgtbl-default-fmt* nil "Default format for each entry")
 (defvar *orgtbl-fmt* nil "Format for each entry")
 (defvar *orgtbl-efmt* nil "Format for numbers")
 (defvar *orgtbl-lfmt* nil "Format for an entire line, overrides fmt")
@@ -3670,7 +3687,9 @@
 			     (orgtbl-apply-fmt efmt (match-string 1 f)
 					       (match-string 2 f))
 			   f)))
-		 (orgtbl-apply-fmt (orgtbl-get-fmt *orgtbl-fmt* i) f)))
+                 (orgtbl-apply-fmt (or (orgtbl-get-fmt *orgtbl-fmt* i)
+                                       *orgtbl-default-fmt*)
+                                   f)))
 	     line)))
       (push (if *orgtbl-lfmt*
 		(orgtbl-apply-fmt *orgtbl-lfmt* line)
@@ -3698,13 +3717,14 @@
 separator line, or a list of fields for that line.
 PARAMS is a property list of parameters that can influence the conversion.
 For the generic converter, some parameters are obligatory:  You need to
-specify either :lfmt, or all of (:lstart :lend :sep).  If you do not use
-:splice, you must have :tstart and :tend.
+specify either :lfmt, or all of (:lstart :lend :sep).
 
 Valid parameters are
 
 :splice     When set to t, return only table body lines, don't wrap
-            them into :tstart and :tend.  Default is nil.
+            them into :tstart and :tend.  Default is nil.  When :splice
+            is non-nil, this also means that the exporter should not look
+            for and interpret header and footer sections.
 
 :hline      String to be inserted on horizontal separation lines.
             May be nil to ignore hlines.
@@ -3713,8 +3733,8 @@
 :remove-nil-lines Do not include lines that evaluate to nil.
 
 
-  Each in the following group may be either a string or a function
-  of no arguments returning a string:
+Each in the following group may be either a string or a function
+of no arguments returning a string:
 :tstart     String to start the table.  Ignored when :splice is t.
 :tend       String to end the table.  Ignored when :splice is t.
 :lstart     String to start a new table line.
@@ -3722,9 +3742,9 @@
 :lend       String to end a table line
 :llend      String to end the last table line, defaults to :lend.
 
-  Each in the following group may be a string, a function of one
-  argument (the field or line) returning a string, or a plist
-  mapping columns to either of the above:
+Each in the following group may be a string, a function of one
+argument (the field or line) returning a string, or a plist
+mapping columns to either of the above:
 :lfmt       Format for entire line, with enough %s to capture all fields.
             If this is present, :lstart, :lend, and :sep are ignored.
 :llfmt      Format for the entire last line, defaults to :lfmt.
@@ -3739,7 +3759,7 @@
             All lines before the first hline are treated as header.
             If any of these is not present, the data line value is used.
 
-  This may be either a string or a function of two arguments:
+This may be either a string or a function of two arguments:
 :efmt       Use this format to print numbers with exponentials.
             The format should have %s twice for inserting mantissa
             and exponent, for example \"%s\\\\times10^{%s}\".  This
@@ -3768,8 +3788,9 @@
 
     ;; Put header
     (unless splicep
-      (push (or (orgtbl-eval-str (plist-get params :tstart))
-		"ERROR: no :tstart") *orgtbl-rtn*))
+      (when (plist-member params :tstart)
+	(let ((tstart (orgtbl-eval-str (plist-get params :tstart))))
+	  (if tstart (push tstart *orgtbl-rtn*)))))
 
     ;; Do we have a heading section?  If so, format it and handle the
     ;; trailing hline.
@@ -3796,13 +3817,24 @@
     (orgtbl-format-section nil)
 
     (unless splicep
-      (push (or (orgtbl-eval-str (plist-get params :tend))
-		"ERROR: no :tend") *orgtbl-rtn*))
+      (when (plist-member params :tend)
+        (let ((tend (orgtbl-eval-str (plist-get params :tend))))
+          (if tend (push tend *orgtbl-rtn*)))))
 
     (mapconcat 'identity (nreverse (if remove-nil-linesp
 				       (remq nil *orgtbl-rtn*)
 				     *orgtbl-rtn*)) "\n")))
 
+(defun orgtbl-to-tsv (table params)
+  "Convert the orgtbl-mode table to TAB separated material."
+  (orgtbl-to-generic table (org-combine-plists '(:sep "\t") params)))
+(defun orgtbl-to-csv (table params)
+  "Convert the orgtbl-mode table to CSV material.
+This does take care of the proper quoting of fields with comma or quotes."
+  (orgtbl-to-generic table (org-combine-plists
+			    '(:sep "," :fmt org-quote-csv-field)
+			    params)))
+
 (defun orgtbl-to-latex (table params)
   "Convert the orgtbl-mode TABLE to LaTeX.
 TABLE is a list, each entry either the symbol `hline' for a horizontal
@@ -3908,7 +3940,24 @@
 	   :hlstart "@headitem ")))
     (orgtbl-to-generic table (org-combine-plists params2 params))))
 
+(defun orgtbl-to-orgtbl (table params)
+  "Convert the orgtbl-mode TABLE into another orgtbl-mode table.
+Useful when slicing one table into many.  The :hline, :sep,
+:lstart, and :lend provide orgtbl framing.  The default nil :tstart
+and :tend suppress strings without splicing; they can be set to
+provide ORGTBL directives for the generated table."
+  (let* ((params2
+	  (list
+           :tstart nil :tend nil
+           :hline "|---"
+           :sep " | "
+           :lstart "| "
+           :lend " |"))
+	 (params (org-combine-plists params2 params)))
+    (orgtbl-to-generic table params)))
+
 (provide 'org-table)
 
 ;; arch-tag: 4d21cfdd-0268-440a-84b0-09237a0fe0ef
+
 ;;; org-table.el ends here
--- a/lisp/org/org-vm.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-vm.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -126,4 +126,5 @@
 (provide 'org-vm)
 
 ;; arch-tag: cbc3047b-935e-4d2a-96e7-c5b0117aaa6d
+
 ;;; org-vm.el ends here
--- a/lisp/org/org-wl.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org-wl.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -142,4 +142,5 @@
 (provide 'org-wl)
 
 ;; arch-tag: 29b75a0f-ef2e-430b-8abc-acff75bde54a
+
 ;;; org-wl.el ends here
--- a/lisp/org/org.el	Tue Jun 17 11:28:06 2008 +0000
+++ b/lisp/org/org.el	Tue Jun 17 15:22:00 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.02b
+;; Version: 6.05a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -91,7 +91,7 @@
 
 ;;; Version
 
-(defconst org-version "6.02b"
+(defconst org-version "6.05a"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -161,6 +161,7 @@
 	(const :tag "   bbdb:              Links to BBDB entries" org-bbdb)
 	(const :tag "   bibtex:            Links to BibTeX entries" org-bibtex)
 	(const :tag "   gnus:              Links to GNUS folders/messages" org-gnus)
+	(const :tag "   id:                Global id's for identifying entries" org-id)
 	(const :tag "   info:              Links to Info nodes" org-info)
 	(const :tag "   jsinfo:            Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
 	(const :tag "   irc:               Links to IRC/ERC chat sessions" org-irc)
@@ -173,15 +174,17 @@
 	(const :tag "   mouse:             Additional mouse support" org-mouse)
 
 	(const :tag "C  annotate-file:     Annotate a file with org syntax" org-annotate-file)
+	(const :tag "C  annotation-helper: Call Remeber directly from Browser" org-annotation-helper)
 	(const :tag "C  bookmark:          Org links to bookmarks" org-bookmark)
 	(const :tag "C  depend:            TODO dependencies for Org-mode" org-depend)
 	(const :tag "C  elisp-symbol:      Org links to emacs-lisp symbols" org-elisp-symbol)
+	(const :tag "C  eval:              Include command output as text" org-eval)
 	(const :tag "C  expiry:            Expiry mechanism for Org entries" org-expiry)
 	(const :tag "C  id:                Global id's for identifying entries" org-id)
 	(const :tag "C  interactive-query: Interactive modification of tags query" org-interactive-query)
 	(const :tag "C  mairix:            Hook mairix search into Org for different MUAs" org-mairix)
 	(const :tag "C  man:               Support for links to manpages in Org-mode" org-man)
-	(const :tag "C  mew:               Support for links to messages in Mew" org-mew)
+	(const :tag "C  mtags:             Support for muse-like tags" org-mtags)
 	(const :tag "C  panel:             Simple routines for us with bad memory" org-panel)
 	(const :tag "C  registry:          A registry for Org links" org-registry)
 	(const :tag "C  org2rem:           Convert org appointments into reminders" org2rem)
@@ -217,6 +220,20 @@
   :group 'org-startup
   :type 'boolean)
 
+(defcustom org-startup-indented nil
+  "Non-nil means, turn on `org-indent-mode' on startup.
+This can also be configured on a per-file basis by adding one of
+the following lines anywhere in the buffer:
+
+   #+STARTUP: localindent
+   #+STARTUP: indent
+   #+STARTUP: noindent"
+  :group 'org-structure
+  :type '(choice
+	  (const :tag "Not" nil)
+	  (const :tag "Locally" local)
+	  (const :tag "Globally (slow on startup in large files)" t)))
+
 (defcustom org-startup-align-all-tables nil
   "Non-nil means, align all tables when visiting a file.
 This is useful when the column width in tables is forced with <N> cookies
@@ -748,6 +765,12 @@
   :group 'org-plain-lists
   :type 'boolean)
 
+(defcustom org-description-max-indent 20
+  "Maximum indentation for the second line of a description list.
+When the indentation would be larger than this, it will become
+5 characters instead."
+  :group 'org-plain-lists
+  :type 'integer)
 
 (defgroup org-imenu-and-speedbar nil
   "Options concerning imenu and speedbar in Org-mode."
@@ -1380,6 +1403,13 @@
 	  (const :tag "By default" t)
 	  (const :tag "Only with C-u C-c C-t" prefix)))
 
+(defcustom org-provide-todo-statistics t
+  "Non-nil means, update todo statistics after insert and toggle.
+When this is set, todo statistics is updated in the parent of the current
+entry each time a todo state is changed."
+  :group 'org-todo
+  :type 'boolean)
+
 (defcustom org-after-todo-state-change-hook nil
   "Hook which is run after the state of a TODO item was changed.
 The new state (a string with a TODO keyword, or nil) is available in the
@@ -1463,8 +1493,8 @@
   "Non-nil means, record moving through the DONE state when triggering repeat.
 An auto-repeating tasks  is immediately switched back to TODO when marked
 done.  If you are not logging state changes (by adding \"@\" or \"!\" to
-the TODO keyword definition, or recording a cloing note by setting
-`org-log-done', there will be no record of the task moving trhough DONE.
+the TODO keyword definition, or recording a closing note by setting
+`org-log-done', there will be no record of the task moving through DONE.
 This variable forces taking a note anyway.  Possible values are:
 
 nil     Don't force a record
@@ -1590,6 +1620,12 @@
 	(concat "[" (substring f 1 -1) "]")
       f)))
 
+(defcustom org-time-clocksum-format "%d:%02d"
+  "The format string used when creating CLOCKSUM lines, or when
+org-mode generates a time duration."
+  :group 'org-time
+  :type 'string)
+  
 (defcustom org-deadline-warning-days 14
   "No. of days before expiration during which a deadline becomes active.
 This variable governs the display in sparse trees and in the agenda.
@@ -1682,6 +1718,12 @@
 	   (const :tag "Start radio group" (:startgroup))
 	   (const :tag "End radio group" (:endgroup)))))
 
+(defvar org-file-tags nil
+  "List of tags that can be inherited by all entries in the file.
+The tags will be inherited if the variable `org-use-tag-inheritance'
+says they should be.
+This variable is populated from #+TAG lines.")
+
 (defcustom org-use-fast-tag-selection 'auto
   "Non-nil means, use fast tag selection scheme.
 This is a special interface to select and deselect tags with single keys.
@@ -1732,8 +1774,10 @@
 (defcustom org-use-tag-inheritance t
   "Non-nil means, tags in levels apply also for sublevels.
 When nil, only the tags directly given in a specific line apply there.
-If you turn off this option, you very likely want to turn on the
-companion option `org-tags-match-list-sublevels'.
+If this option is t, a match early-on in a tree can lead to a large
+number of matches in the subtree.  If you only want to see the first
+match in a tree during a search, check out the variable
+`org-tags-match-list-sublevels'.
 
 This may also be a list of tags that should be inherited, or a regexp that
 matches tags that should be inherited."
@@ -1755,7 +1799,7 @@
     (member tag org-use-tag-inheritance))
    (t (error "Invalid setting of `org-use-tag-inheritance'"))))
 
-(defcustom org-tags-match-list-sublevels nil
+(defcustom org-tags-match-list-sublevels t
   "Non-nil means list also sublevels of headlines matching tag search.
 Because of tag inheritance (see variable `org-use-tag-inheritance'),
 the sublevels of a headline matching a tag search often also match
@@ -1839,6 +1883,17 @@
   :group 'org-properties
   :type 'string)
 
+(defcustom org-columns-ellipses ".."
+  "The ellipses to be used when a field in column view is truncated.
+When this is the empty string, as many characters as possible are shown,
+but then there will be no visual indication that the field has been truncated.
+When this is a string of length N, the last N characters of a truncated
+field are replaced by this string.  If the column is narrower than the
+ellipses string, only part of the ellipses string will be shown."
+  :group 'org-properties
+  :type 'string)
+
+
 (defcustom org-effort-property "Effort"
   "The property that is being used to keep track of effort estimates.
 Effort estimates given in this property need to have the format H:MM."
@@ -1846,6 +1901,12 @@
   :group 'org-progress
   :type '(string :tag "Property"))
 
+(defconst org-global-properties-fixed
+  '(("VISIBILITY_ALL" . "folded children content all"))
+  "List of property/value pairs that can be inherited by any entry.
+These are fixed values, for the preset properties.")
+
+
 (defcustom org-global-properties nil
   "List of property/value pairs that can be inherited by any entry.
 You can set buffer-local values for this by adding lines like
@@ -1856,10 +1917,11 @@
 	  (cons (string :tag "Property")
 		(string :tag "Value"))))
 
-(defvar org-local-properties nil
+(defvar org-file-properties nil
   "List of property/value pairs that can be inherited by any entry.
 Valid for the current buffer.
 This variable is populated from #+PROPERTY lines.")
+(make-variable-buffer-local 'org-file-properties)
 
 (defgroup org-agenda nil
   "Options concerning agenda views in Org-mode."
@@ -1938,9 +2000,19 @@
   :group 'org-agenda
   :type 'sexp)
 
+(defcustom org-calendar-agenda-action-key [?k]
+  "The key to be installed in `calendar-mode-map' for agenda-action.
+The command `org-agenda-action' will be bound to this key.  The
+default is the character `k' because we use the same key in the agenda."
+  :group 'org-agenda
+  :type 'sexp)
+
 (eval-after-load "calendar"
-  '(org-defkey calendar-mode-map org-calendar-to-agenda-key
-     'org-calendar-goto-agenda))
+  '(progn
+     (org-defkey calendar-mode-map org-calendar-to-agenda-key
+		 'org-calendar-goto-agenda)
+     (org-defkey calendar-mode-map org-calendar-agenda-action-key
+		 'org-agenda-action)))
 
 (defgroup org-latex nil
   "Options for embedding LaTeX code into Org-mode."
@@ -2123,7 +2195,7 @@
 	  (sexp    :tag "Forbidden chars in border ")
 	  (sexp    :tag "Regexp for body           ")
 	  (integer :tag "number of newlines allowed")
-	  (option (boolean :tag "Stacking (DISABLED)       "))))
+	  (option (boolean :tag "Please ignore this button"))))
 
 (defcustom org-emphasis-alist
   `(("*" bold "<b>" "</b>")
@@ -2200,6 +2272,8 @@
 		  (newhead hdmarker &optional fixface))
 (declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
 (declare-function org-agenda-maybe-redo "org-agenda" ())
+(declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
+		  (beg end))
 (declare-function parse-time-string "parse-time" (string))
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
@@ -2345,6 +2419,7 @@
    org-replace-region-by-html org-export-region-as-html
    org-export-as-html org-export-icalendar-this-file
    org-export-icalendar-all-agenda-files
+   org-table-clean-before-export
    org-export-icalendar-combine-agenda-files org-export-as-xoxo)))
 
 ;; Declare and autoload functions from org-exp.el
@@ -2364,6 +2439,11 @@
 
 ;; Autoload org-clock.el
 
+
+(declare-function org-clock-save-markers-for-cut-and-paste "org-clock"
+		  (beg end))
+(declare-function org-update-mode-line "org-clock" ())
+(defvar org-clock-start-time)
 (defvar org-clock-marker (make-marker)
   "Marker recording the last clock-in.")
 
@@ -2385,15 +2465,26 @@
     (skip-chars-forward " \t")
     (when (looking-at org-clock-string)
       (let ((re (concat "[ \t]*" org-clock-string
-			" *[[<]\\([^]>]+\\)[]>]-+[[<]\\([^]>]+\\)[]>]"
-			"\\([ \t]*=>.*\\)?"))
+			" *[[<]\\([^]>]+\\)[]>]\\(-+[[<]\\([^]>]+\\)[]>]"
+			"\\([ \t]*=>.*\\)?\\)?"))
 	    ts te h m s)
-	(if (not (looking-at re))
-	    nil
-	  (and (match-end 3) (delete-region (match-beginning 3) (match-end 3)))
+	(cond
+	 ((not (looking-at re))
+	  nil)
+	 ((not (match-end 2))
+	  (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
+		     (> org-clock-marker (point))
+		     (<= org-clock-marker (point-at-eol)))
+	    ;; The clock is running here
+	    (setq org-clock-start-time
+		  (apply 'encode-time 
+			 (org-parse-time-string (match-string 1))))
+	    (org-update-mode-line)))
+	 (t
+	  (and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
 	  (end-of-line 1)
 	  (setq ts (match-string 1)
-		te (match-string 2))
+		te (match-string 3))
 	  (setq s (- (time-to-seconds
 		      (apply 'encode-time (org-parse-time-string te)))
 		     (time-to-seconds
@@ -2403,7 +2494,7 @@
 		m (floor (/ s 60))
 		s (- s (* 60 s)))
 	  (insert " => " (format "%2d:%02d" h m))
-	  t)))))
+	  t))))))
 
 (defun org-check-running-clock ()
   "Check if the current buffer contains the running clock.
@@ -2552,6 +2643,14 @@
    org-columns-compute org-agenda-columns org-columns-remove-overlays
    org-columns org-insert-columns-dblock))
 
+;; Autoload ID code
+
+(org-autoload "org-id"
+ '(org-id-get-create org-id-new org-id-copy org-id-get 
+   org-id-get-with-outline-path-completion 
+   org-id-get-with-outline-drilling
+   org-id-goto org-id-find))
+
 ;;; Variables for pre-computed regular expressions, all buffer local
 
 (defvar org-drawer-regexp nil
@@ -2699,19 +2798,27 @@
     (org-set-local 'org-todo-heads nil)
     (org-set-local 'org-todo-sets nil)
     (org-set-local 'org-todo-log-states nil)
+    (org-set-local 'org-file-properties nil)
+    (org-set-local 'org-file-tags nil)
     (let ((re (org-make-options-regexp
 	       '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS"
-		 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES"
-		 "CONSTANTS" "PROPERTY" "DRAWERS")))
+		 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
+		 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE")))
 	  (splitre "[ \t]+")
 	  kwds kws0 kwsa key log value cat arch tags const links hw dws
-	  tail sep kws1 prio props drawers)
+	  tail sep kws1 prio props ftags drawers
+	  ext-setup-or-nil setup-contents (start 0))
       (save-excursion
 	(save-restriction
 	  (widen)
 	  (goto-char (point-min))
-	  (while (re-search-forward re nil t)
-	    (setq key (match-string 1) value (org-match-string-no-properties 2))
+	  (while (or (and ext-setup-or-nil
+			  (string-match re ext-setup-or-nil start)
+			  (setq start (match-end 0)))
+		     (and (setq ext-setup-or-nil nil start 0)
+			  (re-search-forward re nil t)))
+	    (setq key (upcase (match-string 1 ext-setup-or-nil))
+		  value (org-match-string-no-properties 2 ext-setup-or-nil))
 	    (cond
 	     ((equal key "CATEGORY")
 	      (if (string-match "[ \t]+$" value)
@@ -2736,6 +2843,14 @@
 	      (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value)
 		(push (cons (match-string 1 value) (match-string 2 value))
 		      props)))
+	     ((equal key "FILETAGS")
+	      (when (string-match "\\S-" value)
+		(setq ftags
+		      (append
+		       ftags
+		       (apply 'append
+			      (mapcar (lambda (x) (org-split-string x ":"))
+				      (org-split-string value)))))))
 	     ((equal key "DRAWERS")
 	      (setq drawers (org-split-string value splitre)))
 	     ((equal key "CONSTANTS")
@@ -2756,8 +2871,19 @@
 	      (string-match " *$" value)
 	      (setq arch (replace-match "" t t value))
 	      (remove-text-properties 0 (length arch)
-				      '(face t fontified t) arch)))
-	    )))
+				      '(face t fontified t) arch))
+	     ((equal key "SETUPFILE")
+	      (setq setup-contents (org-file-contents
+				    (expand-file-name
+				     (org-remove-double-quotes value))
+				    'noerror))
+	      (if (not ext-setup-or-nil)
+		  (setq ext-setup-or-nil setup-contents start 0)
+		(setq ext-setup-or-nil
+		      (concat (substring ext-setup-or-nil 0 start)
+			      "\n" setup-contents "\n"
+			      (substring ext-setup-or-nil start)))))
+	     ))))
       (when cat
 	(org-set-local 'org-category (intern cat))
 	(push (cons "CATEGORY" cat) props))
@@ -2767,7 +2893,8 @@
 	(org-set-local 'org-highest-priority (nth 0 prio))
 	(org-set-local 'org-lowest-priority  (nth 1 prio))
 	(org-set-local 'org-default-priority (nth 2 prio)))
-      (and props (org-set-local 'org-local-properties (nreverse props)))
+      (and props (org-set-local 'org-file-properties (nreverse props)))
+      (and ftags (org-set-local 'org-file-tags ftags))
       (and drawers (org-set-local 'org-drawers drawers))
       (and arch (org-set-local 'org-archive-location arch))
       (and links (setq org-link-abbrev-alist-local (nreverse links)))
@@ -2838,87 +2965,101 @@
 	  (while (setq e (pop tgs))
 	    (or (and (stringp (car e))
 		     (assoc (car e) org-tag-alist))
-		(push e org-tag-alist))))))
-
-    ;; Compute the regular expressions and other local variables
-    (if (not org-done-keywords)
-	(setq org-done-keywords (list (org-last org-todo-keywords-1))))
-    (setq org-ds-keyword-length (+ 2 (max (length org-deadline-string)
-					  (length org-scheduled-string)
-					  (length org-clock-string)
-					  (length org-closed-string)))
-	  org-drawer-regexp
-	  (concat "^[ \t]*:\\("
-		  (mapconcat 'regexp-quote org-drawers "\\|")
-		  "\\):[ \t]*$")
-	  org-not-done-keywords
-	  (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1))
-	  org-todo-regexp
-	  (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1
-				      "\\|") "\\)\\>")
-	  org-not-done-regexp
-	  (concat "\\<\\("
-		  (mapconcat 'regexp-quote org-not-done-keywords "\\|")
-		  "\\)\\>")
-	  org-todo-line-regexp
-	  (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
-		  (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
-		  "\\)\\>\\)?[ \t]*\\(.*\\)")
-	  org-complex-heading-regexp
-	  (concat "^\\(\\*+\\)\\(?:[ \t]+\\("
-		  (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
-		  "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
-		  "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
-	  org-nl-done-regexp
-	  (concat "\n\\*+[ \t]+"
-		  "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
-		  "\\)" "\\>")
-	  org-todo-line-tags-regexp
-	  (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
-		  (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
-		  (org-re
-		   "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)"))
-	  org-looking-at-done-regexp
-	  (concat "^" "\\(?:"
-		  (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)"
-		  "\\>")
-	  org-deadline-regexp (concat "\\<" org-deadline-string)
-	  org-deadline-time-regexp
-	  (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
-	  org-deadline-line-regexp
-	  (concat "\\<\\(" org-deadline-string "\\).*")
-	  org-scheduled-regexp
-	  (concat "\\<" org-scheduled-string)
-	  org-scheduled-time-regexp
-	  (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
-	  org-closed-time-regexp
-	  (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
-	  org-keyword-time-regexp
-	  (concat "\\<\\(" org-scheduled-string
-		  "\\|" org-deadline-string
-		  "\\|" org-closed-string
-		  "\\|" org-clock-string "\\)"
-		  " *[[<]\\([^]>]+\\)[]>]")
-	  org-keyword-time-not-clock-regexp
-	  (concat "\\<\\(" org-scheduled-string
-		  "\\|" org-deadline-string
-		  "\\|" org-closed-string
-		  "\\)"
-		  " *[[<]\\([^]>]+\\)[]>]")
-	  org-maybe-keyword-time-regexp
-	  (concat "\\(\\<\\(" org-scheduled-string
-		  "\\|" org-deadline-string
-		  "\\|" org-closed-string
-		  "\\|" org-clock-string "\\)\\)?"
-		  " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
-	  org-planning-or-clock-line-re
-	  (concat "\\(?:^[ \t]*\\(" org-scheduled-string
-		  "\\|" org-deadline-string
-		  "\\|" org-closed-string "\\|" org-clock-string
-		  "\\)\\>\\)")
-	  )
-    (org-compute-latex-and-specials-regexp)
-    (org-set-font-lock-defaults)))
+		(push e org-tag-alist)))))
+
+      ;; Compute the regular expressions and other local variables
+      (if (not org-done-keywords)
+	  (setq org-done-keywords (list (org-last org-todo-keywords-1))))
+      (setq org-ds-keyword-length (+ 2 (max (length org-deadline-string)
+					    (length org-scheduled-string)
+					    (length org-clock-string)
+					    (length org-closed-string)))
+	    org-drawer-regexp
+	    (concat "^[ \t]*:\\("
+		    (mapconcat 'regexp-quote org-drawers "\\|")
+		    "\\):[ \t]*$")
+	    org-not-done-keywords
+	    (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1))
+	    org-todo-regexp
+	    (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1
+					"\\|") "\\)\\>")
+	    org-not-done-regexp
+	    (concat "\\<\\("
+		    (mapconcat 'regexp-quote org-not-done-keywords "\\|")
+		    "\\)\\>")
+	    org-todo-line-regexp
+	    (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
+		    (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
+		    "\\)\\>\\)?[ \t]*\\(.*\\)")
+	    org-complex-heading-regexp
+	    (concat "^\\(\\*+\\)\\(?:[ \t]+\\("
+		    (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
+		    "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
+		    "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
+	    org-nl-done-regexp
+	    (concat "\n\\*+[ \t]+"
+		    "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
+		    "\\)" "\\>")
+	    org-todo-line-tags-regexp
+	    (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
+		    (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
+		    (org-re
+		     "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)"))
+	    org-looking-at-done-regexp
+	    (concat "^" "\\(?:"
+		    (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)"
+		    "\\>")
+	    org-deadline-regexp (concat "\\<" org-deadline-string)
+	    org-deadline-time-regexp
+	    (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
+	    org-deadline-line-regexp
+	    (concat "\\<\\(" org-deadline-string "\\).*")
+	    org-scheduled-regexp
+	    (concat "\\<" org-scheduled-string)
+	    org-scheduled-time-regexp
+	    (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
+	    org-closed-time-regexp
+	    (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
+	    org-keyword-time-regexp
+	    (concat "\\<\\(" org-scheduled-string
+		    "\\|" org-deadline-string
+		    "\\|" org-closed-string
+		    "\\|" org-clock-string "\\)"
+		    " *[[<]\\([^]>]+\\)[]>]")
+	    org-keyword-time-not-clock-regexp
+	    (concat "\\<\\(" org-scheduled-string
+		    "\\|" org-deadline-string
+		    "\\|" org-closed-string
+		    "\\)"
+		    " *[[<]\\([^]>]+\\)[]>]")
+	    org-maybe-keyword-time-regexp
+	    (concat "\\(\\<\\(" org-scheduled-string
+		    "\\|" org-deadline-string
+		    "\\|" org-closed-string
+		    "\\|" org-clock-string "\\)\\)?"
+		    " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
+	    org-planning-or-clock-line-re
+	    (concat "\\(?:^[ \t]*\\(" org-scheduled-string
+		    "\\|" org-deadline-string
+		    "\\|" org-closed-string "\\|" org-clock-string
+		    "\\)\\>\\)")
+	    )
+      (org-compute-latex-and-specials-regexp)
+      (org-set-font-lock-defaults))))
+
+(defun org-file-contents (file &optional noerror)
+  "Return the contents of FILE, as a string."
+  (if (or (not file)
+	  (not (file-readable-p file)))
+      (if noerror
+	  (progn
+	    (message "Cannot read file %s" file)
+	    (ding) (sit-for 2)
+	    "")
+	(error "Cannot read file %s" file))
+    (with-temp-buffer
+      (insert-file-contents file)
+      (buffer-string))))
 
 (defun org-extract-log-state-settings (x)
   "Extract the log state setting from a TODO keyword string.
@@ -3123,13 +3264,7 @@
       (let ((bmp (buffer-modified-p)))
 	(org-table-map-tables 'org-table-align)
 	(set-buffer-modified-p bmp)))
-    (org-cycle-hide-drawers 'all)
-    (cond
-     ((eq org-startup-folded t)
-      (org-cycle '(4)))
-     ((eq org-startup-folded 'content)
-      (let ((this-command 'org-cycle) (last-command 'org-cycle))
-	(org-cycle '(4)) (org-cycle '(4)))))))
+    (org-set-startup-visibility)))
 
 (put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify)
 
@@ -3583,14 +3718,22 @@
 
 (defvar org-font-lock-keywords nil)
 
-(defconst org-property-re (org-re "^[ \t]*\\(:\\([[:alnum:]_]+\\):\\)[ \t]*\\([^ \t\r\n].*\\)")
+(defconst org-property-re (org-re "^[ \t]*\\(:\\([-[:alnum:]_]+\\):\\)[ \t]*\\([^ \t\r\n].*\\)")
   "Regular expression matching a property line.")
 
+(defvar org-font-lock-hook nil
+  "Functions to be called for special font lock stuff.")
+
+(defun org-font-lock-hook (limit)
+  (run-hook-with-args 'org-font-lock-hook limit))
+
 (defun org-set-font-lock-defaults ()
   (let* ((em org-fontify-emphasized-text)
 	 (lk org-activate-links)
 	 (org-font-lock-extra-keywords
 	  (list
+	   ;; Call the hook
+	   '(org-font-lock-hook)
 	   ;; Headlines
 	   '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1))
 	     (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
@@ -3647,6 +3790,9 @@
 	   (if org-provide-checkbox-statistics
 	       '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
 		 (0 (org-get-checkbox-statistics-face) t)))
+	   ;; Description list items
+	   '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(.*? ::\\)"
+	     2 'bold prepend)
 	   (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)")
 		 '(1 'org-archived prepend))
 	   ;; Specials
@@ -3716,6 +3862,9 @@
   1. OVERVIEW: Show only top-level headlines.
   2. CONTENTS: Show all headlines of all levels, but no body text.
   3. SHOW ALL: Show everything.
+  When called with two C-c C-u prefixes, switch to the startup visibility,
+  determined by the variable `org-startup-folded', and by any VISIBILITY
+  properties in the buffer.
 
 - When point is at the beginning of a headline, rotate the subtree started
   by this line through 3 different states (local cycling)
@@ -3729,8 +3878,8 @@
   a `show-subtree' and return to the previous cursor position.  If ARG
   is negative, go up that many levels.
 
-- When point is not at the beginning of a headline, execute
-  `indent-relative', like TAB normally does.  See the option
+- When point is not at the beginning of a headline, execute the global
+  binding for TAB, which is re-indenting the line.  See the option
   `org-cycle-emulate-tab' for details.
 
 - Special case: if point is at the beginning of the buffer and there is
@@ -3757,6 +3906,10 @@
 
     (cond
 
+     ((equal arg '(16))
+      (org-set-startup-visibility)
+      (message "Startup visibility, plus VISIBILITY properties."))
+
      ((org-at-table-p 'any)
       ;; Enter the table or move to the next field in the table
       (or (org-table-recognize-table.el)
@@ -3865,9 +4018,11 @@
 	  (setq org-cycle-subtree-status 'folded)
 	  (run-hook-with-args 'org-cycle-hook 'folded)))))
 
-     ;; TAB emulation
+     ;; TAB emulation and template completion
      (buffer-read-only (org-back-to-heading))
 
+     ((org-try-structure-completion))
+
      ((org-try-cdlatex-tab))
 
      ((and (eq org-cycle-emulate-tab 'exc-hl-bol)
@@ -3891,16 +4046,67 @@
 
 ;;;###autoload
 (defun org-global-cycle (&optional arg)
-  "Cycle the global visibility.  For details see `org-cycle'."
+  "Cycle the global visibility.  For details see `org-cycle'.
+With C-u prefix arg, switch to startup visibility.
+With a numeric prefix, show all headlines up to that level."
   (interactive "P")
   (let ((org-cycle-include-plain-lists
 	 (if (org-mode-p) org-cycle-include-plain-lists nil)))
-    (if (integerp arg)
-	(progn
-	  (show-all)
-	  (hide-sublevels arg)
-	  (setq org-cycle-global-status 'contents))
-      (org-cycle '(4)))))
+    (cond
+     ((integerp arg)
+      (show-all)
+      (hide-sublevels arg)
+      (setq org-cycle-global-status 'contents))
+     ((equal arg '(4))
+      (org-set-startup-visibility)
+      (message "Startup visibility, plus VISIBILITY properties."))
+     (t
+      (org-cycle '(4))))))
+
+(defun org-set-startup-visibility ()
+  "Set the visibility required by startup options and properties."
+  (cond
+   ((eq org-startup-folded t)
+    (org-cycle '(4)))
+   ((eq org-startup-folded 'content)
+    (let ((this-command 'org-cycle) (last-command 'org-cycle))
+      (org-cycle '(4)) (org-cycle '(4)))))
+  (org-set-visibility-according-to-property 'no-cleanup)
+  (org-cycle-hide-archived-subtrees 'all)
+  (org-cycle-hide-drawers 'all)
+  (org-cycle-show-empty-lines 'all))
+
+(defun org-set-visibility-according-to-property (&optional no-cleanup)
+  "Switch subtree visibilities according to :VISIBILITY: property."
+  (interactive)
+  (let (state)
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward
+	      "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)"
+	      nil t)
+	(setq state (match-string 1))
+	(save-excursion
+	  (org-back-to-heading t)
+	  (hide-subtree)
+	  (org-reveal)
+	  (cond
+	   ((equal state '("fold" "folded"))
+	    (hide-subtree))
+	   ((equal state "children")
+	    (org-show-hidden-entry)
+	    (show-children))
+	   ((equal state "content")
+	    (save-excursion
+	      (save-restriction
+		(org-narrow-to-subtree)
+		(org-content))))
+	   ((member state '("all" "showall"))
+	    (show-subtree)))))
+      (unless no-cleanup
+	(org-cycle-hide-archived-subtrees 'all)
+	(org-cycle-hide-drawers 'all)
+	(org-cycle-show-empty-lines 'all)))))
 
 (defun org-overview ()
   "Switch to overview mode, shoing only top-level headlines.
@@ -4024,8 +4230,6 @@
 	    (outline-flag-region b (point-at-eol) flag)
 	  (error ":END: line missing"))))))
 
-
-
 (defun org-subtree-end-visible-p ()
   "Is the end of the current subtree visible?"
   (pos-visible-in-window-p
@@ -4083,6 +4287,7 @@
 
 (defvar org-goto-start-pos) ; dynamically scoped parameter
 
+;; FIXME: Docstring doe not mention both interfaces
 (defun org-goto (&optional alternative-interface)
   "Look up a different location in the current file, keeping current visibility.
 
@@ -4405,7 +4610,9 @@
 	    (not (match-beginning 2))
 	    (member (match-string 2) org-done-keywords))
 	(insert (car org-todo-keywords-1) " ")
-      (insert (match-string 2) " "))))
+      (insert (match-string 2) " "))
+    (when org-provide-todo-statistics
+      (org-update-parent-todo-statistics))))
 
 (defun org-insert-subheading (arg)
   "Insert a new subheading and demote it.
@@ -4665,10 +4872,14 @@
     (setq ne-ins (org-back-over-empty-lines))
     (move-marker ins-point (point))
     (setq txt (buffer-substring beg end))
+    (org-save-markers-in-region beg end)
     (delete-region beg end)
     (outline-flag-region (1- beg) beg nil)
     (outline-flag-region (1- (point)) (point) nil)
-    (insert txt)
+    (let ((bbb (point)))
+      (insert-before-markers txt)
+      (org-reinstall-markers-in-region bbb)
+      (move-marker ins-point bbb))
     (or (bolp) (insert "\n"))
     (setq ins-end (point))
     (goto-char ins-point)
@@ -4705,11 +4916,14 @@
   (interactive "p")
   (org-copy-subtree n 'cut))
 
-(defun org-copy-subtree (&optional n cut)
+(defun org-copy-subtree (&optional n cut force-store-markers)
   "Cut the current subtree into the clipboard.
 With prefix arg N, cut this many sequential subtrees.
 This is a short-hand for marking the subtree and then copying it.
-If CUT is non-nil, actually cut the subtree."
+If CUT is non-nil, actually cut the subtree.
+If FORCE-STORE-MARKERS is non-nil, store the relative locations
+of some markers in the region, even if CUT is non-nil.  This is
+useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
   (interactive "p")
   (let (beg end folded (beg0 (point)))
     (if (interactive-p)
@@ -4730,6 +4944,8 @@
     (goto-char beg0)
     (when (> end beg)
       (setq org-subtree-clip-folded folded)
+      (when (or cut force-store-markers)
+	(org-save-markers-in-region beg end))
       (if cut (kill-region beg end) (copy-region-as-kill beg end))
       (setq org-subtree-clip (current-kill 0))
       (message "%s: Subtree(s) with %d characters"
@@ -4807,6 +5023,7 @@
     (setq beg (point))
     (insert-before-markers txt)
     (unless (string-match "\n\\'" txt) (insert "\n"))
+    (org-reinstall-markers-in-region beg)
     (setq end (point))
     (goto-char beg)
     (skip-chars-forward " \t\n\r")
@@ -4851,6 +5068,40 @@
 	    (throw 'exit nil)))
 	t))))
 
+(defvar org-markers-to-move nil
+  "Markers that should be moved with a cut-and-paste operation.
+Those markers are stored together with their positions relative to
+the start of the region.")
+
+(defun org-save-markers-in-region (beg end)
+  "Check markers in region.
+If these markers are between BEG and END, record their position relative
+to BEG, so that after moving the block of text, we can put the markers back
+into place.
+This function gets called just before an entry or tree gets cut from the
+buffer.  After re-insertion, `org-reinstall-markers-in-region' must be
+called immediately, to move the markers with the entries."
+  (setq org-markers-to-move nil)
+  (when (featurep 'org-clock)
+    (org-clock-save-markers-for-cut-and-paste beg end))
+  (when (featurep 'org-agenda)
+    (org-agenda-save-markers-for-cut-and-paste beg end)))
+
+(defun org-check-and-save-marker (marker beg end)
+  "Check if MARKER is between BEG and END.
+If yes, remember the marker and the distance to BEG."
+  (when (and (marker-buffer marker)
+	     (equal (marker-buffer marker) (current-buffer)))
+    (if (and (>= marker beg) (< marker end))
+	(push (cons marker (- marker beg)) org-markers-to-move))))
+
+(defun org-reinstall-markers-in-region (beg)
+  "Move all remembered markers to their position relative to BEG."
+  (mapc (lambda (x)
+	  (move-marker (car x) (+ beg (cdr x))))
+	org-markers-to-move)
+  (setq org-markers-to-move nil))
+
 (defun org-narrow-to-subtree ()
   "Narrow buffer to the current subtree."
   (interactive)
@@ -5104,6 +5355,147 @@
 		  table)
 	  (lambda (a b) (funcall comparefun (car a) (car b))))))
 
+;;; Editing source examples
+
+(defvar org-exit-edit-mode-map (make-sparse-keymap))
+(define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit)
+(defvar org-edit-src-force-single-line nil)
+(defvar org-edit-src-from-org-mode nil)
+
+(define-minor-mode org-exit-edit-mode
+  "Minor mode installing a single key binding, \"C-c '\" to exit special edit.")
+
+(defun org-edit-src-code ()
+  "Edit the source code example at point.
+An indirect buffer is created, and that buffer is then narrowed to the
+example at point and switched to the correct language mode.  When done,
+exit by killing the buffer with \\[org-edit-src-exit]."
+  (interactive)
+  (let ((line (org-current-line))
+	(case-fold-search t)
+	(msg (substitute-command-keys
+	      "Edit, then exit with C-c ' (C-c and single quote)"))
+	(info (org-edit-src-find-region-and-lang))
+	(org-mode-p (eq major-mode 'org-mode))
+	beg end lang lang-f single)
+    (if (not info)
+	nil
+      (setq beg (nth 0 info)
+	    end (nth 1 info)
+	    lang (nth 2 info)
+	    single (nth 3 info)
+	    lang-f (intern (concat lang "-mode")))
+      (unless (functionp lang-f)
+	(error "No such language mode: %s" lang-f))
+      (goto-line line)
+      (if (get-buffer "*Org Edit Src Example*")
+	  (kill-buffer "*Org Edit Src Example*"))
+      (switch-to-buffer (make-indirect-buffer (current-buffer)
+					      "*Org Edit Src Example*"))
+      (narrow-to-region beg end)
+      (remove-text-properties beg end '(display nil invisible nil
+						intangible nil))
+      (let ((org-inhibit-startup t))
+	(funcall lang-f))
+      (set (make-local-variable 'org-edit-src-force-single-line) single)
+      (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
+      (when org-mode-p
+	(goto-char (point-min))
+	(while (re-search-forward "^," nil t)
+	  (replace-match "")))
+      (goto-line line)
+      (org-exit-edit-mode)
+      (org-set-local 'header-line-format msg)
+      (message "%s" msg)
+      t)))
+
+(defun org-edit-src-find-region-and-lang ()
+  "Find the region and language for a local edit.
+Return a list with beginning and end of the region, a string representing
+the language, a switch telling of the content should be in a single line."
+  (let ((re-list
+	 '(
+	   ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang)
+	   ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style)
+	   ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental")
+	   ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp")
+	   ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl")
+	   ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python")
+	   ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby")
+	   ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2)
+	   ("^#\\+begin_example.*\n" "^#\\+end_example" "fundamental")
+	   ("^#\\+html:" "\n" "html" single-line)
+	   ("^#\\+begin_html.*\n" "\n#\\+end_html" "html")
+	   ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex")
+	   ("^#\\+latex:" "\n" "latex" single-line)
+	   ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental")
+	   ("^#\\+ascii:" "\n" "ascii" single-line)
+	 ))
+	(pos (point))
+	re re1 re2 single beg end lang)
+    (catch 'exit
+      (while (setq entry (pop re-list))
+	(setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry)
+	      single (nth 3 entry))
+	(save-excursion
+	  (if (or (looking-at re1)
+		  (re-search-backward re1 nil t))
+	      (progn
+		(setq beg (match-end 0) lang (org-edit-src-get-lang lang))
+		(if (and (re-search-forward re2 nil t)
+			 (>= (match-end 0) pos))
+		    (throw 'exit (list beg (match-beginning 0) lang single))))
+	    (if (or (looking-at re2)
+		    (re-search-forward re2 nil t))
+		(progn
+		  (setq end (match-beginning 0))
+		  (if (and (re-search-backward re1 nil t)
+			   (<= (match-beginning 0) pos))
+		      (throw 'exit
+			     (list (match-end 0) end
+				   (org-edit-src-get-lang lang) single)))))))))))
+
+(defun org-edit-src-get-lang (lang)
+  "Extract the src language."
+  (let ((m (match-string 0)))
+    (cond
+     ((stringp lang) lang)
+     ((integerp lang) (match-string lang))
+     ((and (eq lang lang)
+	   (string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m))
+      (match-string 1 m))
+     ((and (eq lang lang)
+	   (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m))
+      (match-string 1 m))
+     (t "fundamental"))))
+      
+(defun org-edit-src-exit ()
+  "Exit special edit and protect problematic lines."
+  (interactive)
+  (unless (buffer-base-buffer (current-buffer))
+    (error "This is not an indirect buffer, something is wrong..."))
+  (unless (> (point-min) 1)
+    (error "This buffer is not narrowed, something is wrong..."))
+  (goto-char (point-min))
+  (if (looking-at "[ \t\n]*\n") (replace-match ""))
+  (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))
+  (when (org-bound-and-true-p org-edit-src-force-single-line)
+    (goto-char (point-min))
+    (while (re-search-forward "\n" nil t)
+      (replace-match " "))
+    (goto-char (point-min))
+    (if (looking-at "\\s-*") (replace-match " "))
+    (if (re-search-forward "\\s-+\\'" nil t)
+	(replace-match "")))
+  (when (org-bound-and-true-p org-edit-src-from-org-mode)
+    (goto-char (point-min))
+    (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*#]\\)") nil t)
+      (replace-match ",\\1"))
+    (when font-lock-mode
+      (font-lock-unfontify-region (point-min) (point-max)))
+    (put-text-property (point-min) (point-max) 'font-lock-fontified t))
+  (kill-buffer (current-buffer)))
+
 ;;;; Plain list items, including checkboxes
 
 ;;; Plain list items
@@ -5143,10 +5535,15 @@
 		t)
 	    (error nil)))
     (let* ((bul (match-string 0))
+	   (descp (save-excursion (goto-char (match-beginning 0))
+				  (beginning-of-line 1)
+				  (save-match-data
+				    (looking-at "[ \t]*.*? ::"))))
 	   (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
 				(match-end 0)))
 	   (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
 	   pos)
+      (if descp (setq checkbox nil))
       (cond
        ((and (org-at-item-p) (<= (point) eow))
 	;; before the bullet
@@ -5159,7 +5556,10 @@
 	  (end-of-line 1)
 	  (delete-horizontal-space))
 	(newline (if blank 2 1))))
-      (insert bul (if checkbox "[ ]" ""))
+      (insert bul
+	      (if checkbox "[ ]" "")
+	      (if descp (concat (if checkbox " " "")
+				(read-string "Term: ") " :: ") ""))
       (just-one-space)
       (setq pos (point))
       (end-of-line 1)
@@ -6197,7 +6597,10 @@
 		     (t nil)))
 	  (when (or (null txt) (string-match "\\S-" txt))
 	    (setq cpltxt
-		  (concat cpltxt "::" (org-make-org-heading-search-string txt))
+		  (concat cpltxt "::"
+			  (condition-case nil
+			      (org-make-org-heading-search-string txt)
+			    (error "")))
 		  desc "NONE"))))
       (if (string-match "::\\'" cpltxt)
 	  (setq cpltxt (substring cpltxt 0 -2)))
@@ -7084,6 +7487,10 @@
   (if (equal (substring s 0 1) "<") nil (setq s (concat "<" s)))
   (if (equal (substring s -1) ">") nil (setq s (concat s ">")))
   s)
+(defun org-remove-double-quotes (s)
+  (if (equal (substring s 0 1) "\"") (setq s (substring s 1)))
+  (if (equal (substring s -1) "\"") (setq s (substring s 0 -1)))
+  s)
 
 ;;; Following specific links
 
@@ -7157,7 +7564,9 @@
 	(setq cmd (replace-match "%s" t t cmd)))
       (while (string-match "%s" cmd)
 	(setq cmd (replace-match
-		   (save-match-data (shell-quote-argument file))
+		   (save-match-data
+		     (shell-quote-argument
+		      (convert-standard-filename file)))
 		   t t cmd)))
       (save-window-excursion
 	(start-process-shell-command cmd nil cmd)
@@ -7170,7 +7579,8 @@
       (if line (goto-line line)
 	(if search (org-link-search search))))
      ((consp cmd)
-      (eval cmd))
+      (let ((file (convert-standard-filename file)))
+	(eval cmd)))
      (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
     (and (org-mode-p) (eq old-mode 'org-mode)
 	 (or (not (equal old-buffer (current-buffer)))
@@ -7346,7 +7756,7 @@
 	      (switch-to-buffer nbuf)
 	      (goto-char pos)
 	      (org-show-context 'org-goto))
-	  (org-copy-special)
+	  (org-copy-subtree 1 nil t)
 	  (save-excursion
 	    (set-buffer (setq nbuf (or (find-buffer-visiting file)
 				       (find-file-noselect file))))
@@ -7365,7 +7775,8 @@
 		       (point-max))))
 		(bookmark-set "org-refile-last-stored")
 		(org-paste-subtree level))))
-	  (org-cut-special)
+	  (org-cut-subtree)
+	  (setq org-markers-to-move nil)
 	  (message "Entry refiled to \"%s\"" (car it)))))))
 
 (defun org-refile-goto-last-stored ()
@@ -7382,20 +7793,54 @@
   (unless org-refile-target-table
     (error "No refile targets"))
   (let* ((cbuf (current-buffer))
+	 (cfunc (if org-refile-use-outline-path
+		    'org-olpath-completing-read
+		  'completing-read))
+	 (extra (if org-refile-use-outline-path "/" ""))
 	 (filename (buffer-file-name (buffer-base-buffer cbuf)))
 	 (fname (and filename (file-truename filename)))
 	 (tbl (mapcar
 	       (lambda (x)
 		 (if (not (equal fname (file-truename (nth 1 x))))
-		     (cons (concat (car x) " (" (file-name-nondirectory
-						 (nth 1 x)) ")")
+		     (cons (concat (car x) extra " ("
+				   (file-name-nondirectory (nth 1 x)) ")")
 			   (cdr x))
-		   x))
+		   (cons (concat (car x) extra) (cdr x))))
 	       org-refile-target-table))
 	 (completion-ignore-case t))
-    (assoc (completing-read prompt tbl nil t nil 'org-refile-history)
+    (assoc (funcall cfunc prompt tbl nil t nil 'org-refile-history)
 	   tbl)))
 
+(defun org-olpath-completing-read (prompt collection &rest args)
+  "Read an outline path like a file name."
+  (let ((thetable collection))
+    (apply 
+     'completing-read prompt
+     (lambda (string predicate &optional flag)
+       (let (rtn r s f (l (length string)))
+	 (cond
+	  ((eq flag nil)
+	   ;; try completion
+	   (try-completion string thetable))
+	  ((eq flag t)
+	   ;; all-completions
+	   (setq rtn (all-completions string thetable predicate))
+	   (mapcar
+	    (lambda (x)
+	      (setq r (substring x l))
+	      (if (string-match " ([^)]*)$" x)
+		  (setq f (match-string 0 x))
+		(setq f ""))
+	      (if (string-match "/" r)
+		  (concat string (substring r 0 (match-end 0)) f)
+		x))
+	    rtn))
+	  ((eq flag 'lambda)
+	   ;; exact match?
+	   (assoc string thetable)))
+	 ))
+     args)))
+
 ;;;; Dynamic blocks
 
 (defun org-find-dblock (name)
@@ -7521,6 +7966,82 @@
     "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM"
     "BEGIN_EXAMPLE" "END_EXAMPLE"))
 
+(defcustom org-structure-template-alist
+  '(
+    ("s" "#+begin_src ?\n\n#+end_src" 
+         "<src lang=\"?\">\n\n</src>")
+    ("e" "#+begin_example\n?\n#+end_example"
+         "<example>\n?\n</example>")
+    ("q" "#+begin_quote\n?\n#+end_quote"
+         "<quote>\n?\n</quote>")
+    ("v" "#+begin_verse\n?\n#+end_verse"
+         "<verse>\n?\n/verse>")
+    ("l" "#+begin_latex\n?\n#+end_latex"
+         "<literal style=\"latex\">\n?\n</literal>")
+    ("L" "#+latex: "
+         "<literal style=\"latex\">?</literal>")
+    ("h" "#+begin_html\n?\n#+end_html"
+         "<literal style=\"html\">\n?\n</literal>")
+    ("H" "#+html: "
+         "<literal style=\"html\">?</literal>")
+    ("a" "#+begin_ascii\n?\n#+end_ascii")
+    ("A" "#+ascii: ")
+    ("i" "#+include %file ?"
+         "<include file=%file markup=\"?\">")
+    )
+  "Structure completion elements.
+This is a list of abbreviation keys and values.  The value gets inserted
+it you type @samp{.} followed by the key and then the completion key,
+usually `M-TAB'.  %file will be replaced by a file name after prompting
+for the file uning completion.
+There are two templates for each key, the first uses the original Org syntax,
+the second uses Emacs Muse-like syntax tags.  These Muse-like tags become
+the default when the /org-mtags.el/ module has been loaded. See also the
+variable `org-mtags-prefere-muse-templates'.
+This is an experimental feature, it is undecided if it is going to stay in."
+  :group 'org-completion
+  :type '(repeat
+	  (string :tag "Key")
+	  (string :tag "Template")
+	  (string :tag "Muse Template")))
+
+(defun org-try-structure-completion ()
+  "Try to complete a structure template before point.
+This looks for strings like \"<e\" on an otherwise empty line and
+expands them."
+  (let ((l (buffer-substring (point-at-bol) (point)))
+	a)
+    (when (and (looking-at "[ \t]*$")
+	       (string-match "^[ \t]*<\\([a-z]+\\)$"l)
+	       (setq a (assoc (match-string 1 l) org-structure-template-alist)))
+      (org-complete-expand-structure-template (+ -1 (point-at-bol)
+						 (match-beginning 1)) a)
+      t)))
+
+(defun org-complete-expand-structure-template (start cell)
+  "Expand a structure template."
+  (let* ((musep (org-bound-and-true-p org-mtags-prefere-muse-templates))
+	 (rpl (nth (if musep 2 1) cell)))
+    (delete-region start (point))
+    (when (string-match "\\`#\\+" rpl)
+      (cond
+       ((bolp))
+       ((not (string-match "\\S-" (buffer-substring (point-at-bol) (point))))
+	(delete-region (point-at-bol) (point)))
+       (t (newline))))
+    (setq start (point))
+    (if (string-match "%file" rpl)
+	(setq rpl (replace-match 
+		   (concat
+		    "\""
+		    (save-match-data
+		      (abbreviate-file-name (read-file-name "Include file: ")))
+		    "\"")
+		   t t rpl)))
+    (insert rpl)
+    (if (re-search-backward "\\?" start t) (delete-char 1))))
+    
+
 (defun org-complete (&optional arg)
   "Perform completion on word at point.
 At the beginning of a headline, this completes TODO keywords as given in
@@ -7535,7 +8056,8 @@
   (interactive "P")
   (org-without-partial-completion
    (catch 'exit
-     (let* ((end (point))
+     (let* ((a nil)
+	    (end (point))
 	    (beg1 (save-excursion
 		    (skip-chars-backward (org-re "[:alnum:]_@"))
 		    (point)))
@@ -7544,6 +8066,12 @@
 		   (point)))
 	    (confirm (lambda (x) (stringp (car x))))
 	    (searchhead (equal (char-before beg) ?*))
+	    (struct
+	     (when (and (member (char-before beg1) '(?. ?<))
+			(setq a (assoc (buffer-substring beg1 (point))
+				       org-structure-template-alist)))
+	       (org-complete-expand-structure-template (1- beg1) a)
+	       (throw 'exit t)))
 	    (tag (and (equal (char-before beg1) ?:)
 		      (equal (char-after (point-at-bol)) ?*)))
 	    (prop (and (equal (char-before beg1) ?:)
@@ -7868,6 +8396,8 @@
 	    (org-add-log-setup 'state state 'findpos dolog)))
 	;; Fixup tag positioning
 	(and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
+	(when org-provide-todo-statistics
+	  (org-update-parent-todo-statistics))
 	(run-hooks 'org-after-todo-state-change-hook)
 	(if (and arg (not (member state org-done-keywords)))
 	    (setq head (org-get-todo-sequence-head state)))
@@ -7887,6 +8417,51 @@
 	  (save-excursion
 	    (run-hook-with-args 'org-trigger-hook change-plist)))))))
 
+(defun org-update-parent-todo-statistics ()
+  "Update any statistics cookie in the parent of the current headline."
+  (interactive)
+  (let ((box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
+	level (cnt-all 0) (cnt-done 0) is-percent kwd)
+    (catch 'exit
+      (save-excursion
+	(setq level (org-up-heading-safe))
+	(unless (and level
+		     (re-search-forward box-re (point-at-eol) t))
+	  (throw 'exit nil))
+	(setq is-percent (match-end 2))
+	(save-match-data
+	  (unless (outline-next-heading) (throw 'exit nil))
+	  (while (looking-at org-todo-line-regexp)
+	    (setq kwd (match-string 2))
+	    (and kwd (setq cnt-all (1+ cnt-all)))
+	    (and (member kwd org-done-keywords)
+		 (setq cnt-done (1+ cnt-done)))
+	    (condition-case nil
+		(outline-forward-same-level 1)
+	      (error (end-of-line 1)))))
+	(replace-match 
+	 (if is-percent
+	     (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
+	   (format "[%d/%d]" cnt-done cnt-all)))
+	(run-hook-with-args 'org-after-todo-statistics-hook
+			    cnt-done (- cnt-all cnt-done))))))
+
+(defvar org-after-todo-statistics-hook nil
+  "Hook that is called after a TODO statistics cookie has been updated.
+Each function is called with two arguments: the number of not-done entries
+and the number of done entries.
+
+For example, the following function, when added to this hook, will switch
+an entry to DONE when all children are done, and back to TODO when new
+entries are set to a TODO status.  Note that this hook is only called
+when there is a statistics cookie in the headline!
+
+ (defun org-summary-todo (n-done n-not-done)
+   \"Switch entry to DONE when all subentries are done, to TODO otherwise.\"
+   (let (org-log-done org-log-states)   ; turn off logging
+     (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
+")
+	 
 (defun org-local-logging (value)
   "Get logging settings from a property VALUE."
   (let* (words w a)
@@ -8020,6 +8595,7 @@
 	  (match-string 1)))))
 
 (defvar org-last-changed-timestamp)
+(defvar org-last-inserted-timestamp)
 (defvar org-log-post-message)
 (defvar org-log-note-purpose)
 (defvar org-log-note-how)
@@ -8120,25 +8696,35 @@
     (message "%d TODO entries found"
 	     (org-occur (concat "^" outline-regexp " *" kwd-re )))))
 
-(defun org-deadline (&optional remove)
+(defun org-deadline (&optional remove time)
   "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
-With argument REMOVE, remove any deadline from the item."
+With argument REMOVE, remove any deadline from the item.
+When TIME is set, it should be an internal time specification, and the
+scheduling will use the corresponding date."
   (interactive "P")
   (if remove
       (progn
 	(org-remove-timestamp-with-keyword org-deadline-string)
 	(message "Item no longer has a deadline."))
-    (org-add-planning-info 'deadline nil 'closed)))
-
-(defun org-schedule (&optional remove)
+    (if (org-get-repeat)
+	(error "Cannot change deadline on task with repeater, please do that by hand")
+      (org-add-planning-info 'deadline time 'closed)
+      (message "Deadline on %s" org-last-inserted-timestamp))))
+
+(defun org-schedule (&optional remove time)
   "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
-With argument REMOVE, remove any scheduling date from the item."
+With argument REMOVE, remove any scheduling date from the item.
+When TIME is set, it should be an internal time specification, and the
+scheduling will use the corresponding date."
   (interactive "P")
   (if remove
       (progn
 	(org-remove-timestamp-with-keyword org-scheduled-string)
 	(message "Item is no longer scheduled."))
-    (org-add-planning-info 'scheduled nil 'closed)))
+    (if (org-get-repeat)
+	(error "Cannot reschedule task with repeater, please do that by hand")
+      (org-add-planning-info 'scheduled time 'closed)
+      (message "Scheduled to %s" org-last-inserted-timestamp))))
 
 (defun org-remove-timestamp-with-keyword (keyword)
   "Remove all time stamps with KEYWORD in the current entry."
@@ -8150,8 +8736,13 @@
       (org-end-of-subtree t t)
       (while (re-search-backward re beg t)
 	(replace-match "")
-	(unless (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
-	  (delete-region (point-at-bol) (min (1+ (point)) (point-max))))))))
+	(if (and (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
+		 (equal (char-before) ?\ ))
+	    (backward-delete-char 1)
+	  (if (string-match "^[ \t]*$" (buffer-substring
+					(point-at-bol) (point-at-eol)))
+	      (delete-region (point-at-bol)
+			     (min (point-max) (1+ (point-at-eol))))))))))
 
 (defun org-add-planning-info (what &optional time &rest remove)
   "Insert new timestamp with keyword in the line directly after the headline.
@@ -8205,7 +8796,7 @@
 	    (insert-before-markers "\n")
 	    (backward-char 1)
 	    (narrow-to-region (point) (point))
-	    (org-indent-to-column col))
+	    (and org-adapt-indentation (org-indent-to-column col)))
 	  ;; Check if we have to remove something.
 	  (setq list (cons what remove))
 	  (while list
@@ -8223,7 +8814,7 @@
 	  (goto-char (point-max))
 	  (when what
 	    (insert
-	     (if (not (equal (char-before) ?\ )) " " "")
+	     (if (not (or (bolp) (eq (char-before) ?\ ))) " " "")
 	     (cond ((eq what 'scheduled) org-scheduled-string)
 		   ((eq what 'deadline) org-deadline-string)
 		   ((eq what 'closed) org-closed-string))
@@ -8239,7 +8830,7 @@
 	  (widen)
 	  (if (and (looking-at "[ \t]+\n")
 		   (equal (char-before) ?\n))
-	      (backward-delete-char 1))
+	      (delete-region (1- (point)) (point-at-eol)))
 	  ts)))))
 
 (defvar org-log-note-marker (make-marker))
@@ -8607,10 +9198,15 @@
 
 (defun org-scan-tags (action matcher &optional todo-only)
   "Scan headline tags with inheritance and produce output ACTION.
-ACTION can be `sparse-tree' or `agenda'.  MATCHER is a Lisp form to be
-evaluated, testing if a given set of tags qualifies a headline for
-inclusion.  When TODO-ONLY is non-nil, only lines with a TODO keyword
-are included in the output."
+
+ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
+or `agenda' to produce an entry list for an agenda view.  It can also be
+a Lisp form or a function that should be called at each matched headline, in
+this case the return value is a list of all return values from these calls.
+
+MATCHER is a Lisp form to be evaluated, testing if a given set of tags
+qualifies a headline for inclusion.  When TODO-ONLY is non-nil,
+only lines with a TODO keyword are included in the output."
   (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
 		     (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
 		     (org-re
@@ -8628,9 +9224,12 @@
 			       (or (buffer-file-name (buffer-base-buffer))
 				   (buffer-name (buffer-base-buffer)))))))
 	 (case-fold-search nil)
-         lspos
-	 tags tags-list tags-alist (llast 0) rtn level category i txt
+         lspos tags tags-list
+	 (tags-alist (list (cons 0 (mapcar 'downcase org-file-tags))))
+	 (llast 0) rtn rtn1 level category i txt
 	 todo marker entry priority)
+    (when (not (member action '(agenda sparse-tree)))
+      (setq action (list 'lambda nil action)))
     (save-excursion
       (goto-char (point-min))
       (when (eq action 'sparse-tree)
@@ -8668,16 +9267,18 @@
 		     (eval matcher)
 		     (or (not org-agenda-skip-archived-trees)
 			 (not (member org-archive-tag tags-list))))
-	    (and (eq action 'agenda) (org-agenda-skip))
-	    ;; list this headline
-
-	    (if (eq action 'sparse-tree)
-		(progn
-		  (and org-highlight-sparse-tree-matches
-		       (org-get-heading) (match-end 0)
-		       (org-highlight-new-match
-			(match-beginning 0) (match-beginning 1)))
-		  (org-show-context 'tags-tree))
+	    (unless (eq action 'sparse-tree) (org-agenda-skip))
+
+	    ;; select this headline
+
+	    (cond
+	     ((eq action 'sparse-tree)
+	      (and org-highlight-sparse-tree-matches
+		   (org-get-heading) (match-end 0)
+		   (org-highlight-new-match
+		    (match-beginning 0) (match-beginning 1)))
+	      (org-show-context 'tags-tree))
+	     ((eq action 'agenda)
 	      (setq txt (org-format-agenda-item
 			 ""
 			 (concat
@@ -8692,6 +9293,13 @@
 		'org-marker marker 'org-hd-marker marker 'org-category category
 		'priority priority 'type "tagsmatch")
 	      (push txt rtn))
+	     ((functionp action)
+	      (save-excursion
+		(setq rtn1 (funcall action))
+		(push rtn1 rtn))
+	      (goto-char (point-at-eol)))
+	     (t (error "Invalid action")))
+
 	    ;; if we are to skip sublevels, jump to end of subtree
 	    (or org-tags-match-list-sublevels (org-end-of-subtree t))))))
     (when (and (eq action 'sparse-tree)
@@ -8897,7 +9505,7 @@
   "Get a list of all headline tags applicable at POS.
 POS defaults to point.  If tags are inherited, the list contains
 the targets in the same sequence as the headlines appear, i.e.
-sthe tags of the current headline come last."
+the tags of the current headline come last."
   (interactive)
   (let (tags ltags lastpos parent)
     (save-excursion
@@ -8919,7 +9527,7 @@
 		  (org-up-heading-all 1)
 		  (setq parent t)))
 	    (error nil))))
-      tags)))
+      (append (org-remove-uniherited-tags org-file-tags) tags))))
 
 (defun org-toggle-tag (tag &optional onoff)
   "Toggle the tag TAG for the current line.
@@ -8973,7 +9581,7 @@
 	  (setq p (point))
 	  (insert (make-string (- ncol (current-column)) ?\ ))
 	  (setq ncol (current-column))
-	  (tabify p (point-at-eol))
+	  (when indent-tabs-mode (tabify p (point-at-eol)))
 	  (org-move-to-column (min ncol col) t))
       (goto-char pos))))
 
@@ -9351,6 +9959,89 @@
 		(org-split-string (org-match-string-no-properties 1) ":")))))
     (mapcar 'list tags)))
 
+;;;; The mapping API
+
+;;;###autoload
+(defun org-map-entries (func &optional match scope &rest skip)
+  "Call FUNC at each headline selected by MATCH in SCOPE.
+
+FUNC is a function or a lisp form.  The function will be called without
+arguments, with the cursor positioned at the beginning of the headline.
+The return values of all calls to the function will be collected and
+returned as a list.
+
+MATCH is a tags/property/todo match as it is used in the agenda tags view.
+Only headlines that are matched by this query will be considered during
+the iteration.  When MATCH is nil or t, all headlines will be
+visited by the iteration.
+
+SCOPE determines the scope of this command.  It can be any of:
+
+nil     The current buffer, respecting the restriction if any
+tree    The subtree started with the entry at point
+file    The current buffer, without restriction
+file-with-archives
+        The current buffer, and any archives associated with it
+agenda  All agenda files
+agenda-with-archives
+        All agenda files with any archive files associated with them
+\(file1 file2 ...)
+        If this is a list, all files in the list will be scanned
+
+The remaining args are treated as settings for the skipping facilities of
+the scanner.  The following items can be given here:
+
+  archive    skip trees with the archive tag.
+  comment    skip trees with the COMMENT keyword
+  function or Emacs Lisp form:
+             will be used as value for `org-agenda-skip-function', so whenever
+             the the function returns t, FUNC will not be called for that
+             entry and search will continue from the point where the
+             function leaves it."
+  (let* ((org-agenda-skip-archived-trees (memq 'archive skip))
+	 (org-agenda-skip-comment-trees (memq 'comment skip))
+	 (org-agenda-skip-function
+	  (car (org-delete-all '(comment archive) skip)))
+	 (org-tags-match-list-sublevels t)
+	 matcher pos)
+
+    (cond
+     ((eq match t)   (setq matcher t))
+     ((eq match nil) (setq matcher t))
+     (t (setq matcher (if match (org-make-tags-matcher match) t))))
+    
+    (when (eq scope 'tree)
+      (org-back-to-heading t)
+      (org-narrow-to-subtree)
+      (setq scope nil))
+    
+    (if (not scope)
+	(progn
+	  (org-prepare-agenda-buffers
+	   (list (buffer-file-name (current-buffer))))
+	  (org-scan-tags func matcher))
+      ;; Get the right scope
+      (setq pos (point))
+      (cond
+       ((and scope (listp scope) (symbolp (car scope)))
+	(setq scope (eval scope)))
+       ((eq scope 'agenda)
+	(setq scope (org-agenda-files t)))
+       ((eq scope 'agenda-with-archives)
+	(setq scope (org-agenda-files t))
+	(setq scope (org-add-archive-files scope)))
+       ((eq scope 'file)
+	(setq scope (list (buffer-file-name))))
+       ((eq scope 'file-with-archives)
+	(setq scope (org-add-archive-files (list (buffer-file-name))))))
+      (org-prepare-agenda-buffers scope)
+      (while (setq file (pop scope))
+	(with-current-buffer (org-find-base-buffer-visiting file)
+	  (save-excursion
+	    (save-restriction
+	      (widen)
+	      (goto-char (point-min))
+	      (org-scan-tags func matcher))))))))
 
 ;;;; Properties
 
@@ -9366,7 +10057,9 @@
 
 (defconst org-default-properties
   '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
-    "LOCATION" "LOGGING" "COLUMNS")
+    "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
+    "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
+    "EXPORT_FILE_NAME" "EXPORT_TITLE")
   "Some properties that are used by Org-mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -9594,8 +10287,10 @@
 	      (move-marker org-entry-property-inherited-from (point))
 	      (throw 'ex tmp))
 	    (or (org-up-heading-safe) (throw 'ex nil)))))
-      (or tmp (cdr (assoc property org-local-properties))
-	  (cdr (assoc property org-global-properties))))))
+      (or tmp 
+	  (cdr (assoc property org-file-properties))
+	  (cdr (assoc property org-global-properties))
+	  (cdr (assoc property org-global-properties-fixed))))))
 
 (defun org-entry-put (pom property value)
   "Set PROPERTY to VALUE for entry at point-or-marker POM."
@@ -9751,14 +10446,21 @@
 xxx_ALL property) or on existing values in other instances of this property
 in the current file."
   (interactive
-   (let* ((prop	(completing-read
-		 "Property: " (mapcar 'list (org-buffer-property-keys nil t t))))
+   (let* ((completion-ignore-case t)
+	  (keys (org-buffer-property-keys nil t t))
+	  (prop0 (completing-read "Property: " (mapcar 'list keys)))
+	  (prop (if (member prop0 keys)
+		    prop0
+		  (or (cdr (assoc (downcase prop0)
+				  (mapcar (lambda (x) (cons (downcase x) x))
+					  keys)))
+		      prop0)))
 	  (cur (org-entry-get nil prop))
 	  (allowed (org-property-get-allowed-values nil prop 'table))
 	  (existing (mapcar 'list (org-property-values prop)))
 	  (val (if allowed
-		   (completing-read "Value: " allowed nil 'req-match)
-		 (completing-read
+		   (org-completing-read "Value: " allowed nil 'req-match)
+		 (org-completing-read
 		  (concat "Value" (if (and cur (string-match "\\S-" cur))
 				      (concat "[" cur "]") "")
 			  ": ")
@@ -9770,7 +10472,8 @@
 (defun org-delete-property (property)
   "In the current entry, delete PROPERTY."
   (interactive
-   (let* ((prop (completing-read
+   (let* ((completion-ignore-case t)
+	  (prop (completing-read
 		 "Property: " (org-entry-properties nil 'standard))))
      (list prop)))
   (message "Property %s %s" property
@@ -9781,7 +10484,8 @@
 (defun org-delete-property-globally (property)
   "Remove PROPERTY globally, from all entries."
   (interactive
-   (let* ((prop (completing-read
+   (let* ((completion-ignore-case t)
+	  (prop (completing-read
 		 "Globally remove property: "
 		 (mapcar 'list (org-buffer-property-keys)))))
      (list prop)))
@@ -9894,6 +10598,8 @@
 ;;;; Timestamps
 
 (defvar org-last-changed-timestamp nil)
+(defvar org-last-inserted-timestamp nil
+  "The last time stamp inserted with `org-insert-time-stamp'.")
 (defvar org-time-was-given) ; dynamically scoped parameter
 (defvar org-end-time-was-given) ; dynamically scoped parameter
 (defvar org-ts-what) ; dynamically scoped parameter
@@ -9983,6 +10689,7 @@
 
 (defvar org-plain-time-of-day-regexp) ; defined below
 
+(defvar org-overriding-default-time nil) ; dynamically scoped
 (defvar org-read-date-overlay nil)
 (defvar org-dcst nil) ; dynamically scoped
 
@@ -10040,7 +10747,7 @@
 	  (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
 	 (org-dcst org-display-custom-times)
 	 (ct (org-current-time))
-	 (def (or default-time ct))
+	 (def (or org-overriding-default-time default-time ct))
 	 (defdecode (decode-time def))
 	 (dummy (progn
 		  (when (< (nth 2 defdecode) org-extend-today-until)
@@ -10181,6 +10888,9 @@
 	      hour minute second wday pm h2 m2 tl wday1
 	      iso-year iso-weekday iso-week iso-year iso-date)
 
+    (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
+      (setq ans "+0"))
+
     (when (setq delta (org-read-date-get-relative ans (current-time) def))
       (setq ans (replace-match "" t t ans)
 	    deltan (car delta)
@@ -10401,7 +11111,7 @@
       (insert-before-markers extra)
       (forward-char 1))
     (insert-before-markers (or post ""))
-    stamp))
+    (setq org-last-inserted-timestamp stamp)))
 
 (defun org-toggle-time-stamp-overlays ()
   "Toggle the use of custom time stamp formats."
@@ -10425,7 +11135,7 @@
     (message "Time stamp overlays removed")))
 
 (defun org-display-custom-time (beg end)
-  "Overlay modified time stamp format over timestamp between BED and END."
+  "Overlay modified time stamp format over timestamp between BEG and END."
   (let* ((ts (buffer-substring beg end))
 	 t1 w1 with-hm tf time str w2 (off 0))
     (save-match-data
@@ -10724,7 +11434,6 @@
 	  (setq e (match-end 0)))
       (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
     (kill-buffer buf)
-    (kill-buffer frombuf)
     (delete-file tmpfile)
     rtn))
 
@@ -11055,7 +11764,7 @@
   "Compute H:MM from a number of minutes."
   (let ((h (/ m 60)))
     (setq m (- m (* 60 h)))
-    (format "%d:%02d" h m)))
+    (format org-time-clocksum-format h m)))
 
 (defun org-hh:mm-string-to-minutes (s)
   "Convert a string H:MM to a number of minutes."
@@ -11768,7 +12477,7 @@
 (org-defkey org-mode-map "\C-c "    'org-table-blank-field)
 (org-defkey org-mode-map "\C-c+"    'org-table-sum)
 (org-defkey org-mode-map "\C-c="    'org-table-eval-formula)
-(org-defkey org-mode-map "\C-c'"    'org-table-edit-formulas)
+(org-defkey org-mode-map "\C-c'"    'org-edit-special)
 (org-defkey org-mode-map "\C-c`"    'org-table-edit-field)
 (org-defkey org-mode-map "\C-c|"    'org-table-create-or-convert-from-region)
 (org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
@@ -11780,7 +12489,7 @@
 (org-defkey org-mode-map "\C-c:"    'org-toggle-fixed-width-section)
 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
 
-(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-cut-special)
+(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-mark-entry-for-agenda-action)
 (org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
 (org-defkey org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
 (org-defkey org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
@@ -11937,9 +12646,10 @@
   (interactive "P")
   (cond
    ((org-at-table-p) (call-interactively 'org-table-previous-field))
-   (arg (message  "Content view to level: ")
-	(org-content (prefix-numeric-value arg))
-	(setq org-cycle-global-status 'overview))
+   ((integerp arg)
+    (message "Content view to level: %d" arg)
+    (org-content (prefix-numeric-value arg))
+    (setq org-cycle-global-status 'overview))
    (t (call-interactively 'org-global-cycle))))
 
 (defun org-shiftmetaleft ()
@@ -12135,6 +12845,23 @@
       (org-table-paste-rectangle)
     (org-paste-subtree arg)))
 
+(defun org-edit-special ()
+  "Call a special editor for the stuff at point.
+When at a table, call the formula editor with `org-table-edit-formulas'.
+When at the first line of an src example, call `org-edit-src-code'.
+When in an #+include line, visit the include file.  Otherwise call
+`ffap' to visit the file at point."
+  (interactive)
+  (cond
+   ((org-at-table-p)
+    (call-interactively 'org-table-edit-formulas))
+   ((save-excursion
+      (beginning-of-line 1)
+      (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
+    (find-file (org-trim (match-string 1))))
+   ((org-edit-src-code))
+   (t (call-interactively 'ffap))))
+
 (defun org-ctrl-c-ctrl-c (&optional arg)
   "Set tags in headline, or update according to changed information at point.
 
@@ -12216,15 +12943,18 @@
 	  (if (org-at-table-p)
 	      (org-call-with-arg 'org-table-recalculate t))))
        (t
-	(call-interactively 'org-mode-restart))))
+;	(org-set-regexps-and-options)
+;	(org-restart-font-lock)
+	(let ((org-inhibit-startup t)) (org-mode-restart))
+	(message "Local setup has been refreshed"))))
      (t (error "C-c C-c can do nothing useful at this location.")))))
 
 (defun org-mode-restart ()
   "Restart Org-mode, to scan again for special lines.
 Also updates the keyword regular expressions."
   (interactive)
-  (let ((org-inhibit-startup t)) (org-mode))
-  (message "Org-mode restarted to refresh keyword and special line setup"))
+  (org-mode)
+  (message "Org-mode restarted"))
 
 (defun org-kill-note-or-show-branches ()
   "If this is a Note buffer, abort storing the note.  Else call `show-branches'."
@@ -12261,7 +12991,7 @@
 
 (defun org-ctrl-c-star ()
   "Compute table, or change heading status of lines.
-Calls `org-table-recalculate' or `org-toggle-region-headlines',
+Calls `org-table-recalculate' or `org-toggle-region-headings',
 depending on context.  This will also turn a plain list item or a normal
 line into a subheading."
   (interactive)
@@ -12412,7 +13142,7 @@
     ("Calculate"
      ["Set Column Formula" org-table-eval-formula (org-at-table-p)]
      ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="]
-     ["Edit Formulas" org-table-edit-formulas (org-at-table-p)]
+     ["Edit Formulas" org-edit-special (org-at-table-p)]
      "--"
      ["Recalculate line" org-table-recalculate (org-at-table-p)]
      ["Recalculate all" (lambda () (interactive) (org-table-recalculate '(4))) :active (org-at-table-p) :keys "C-u C-c *"]
@@ -12477,7 +13207,8 @@
      ["Convert to odd levels" org-convert-to-odd-levels t]
      ["Convert to odd/even levels" org-convert-to-oddeven-levels t])
     ("Editing"
-     ["Emphasis..." org-emphasize t])
+     ["Emphasis..." org-emphasize t]
+     ["Edit Source Example" org-edit-special t])
     ("Archive"
      ["Toggle ARCHIVE tag" org-toggle-archive-tag t]
 ;     ["Check and Tag Children" (org-toggle-archive-tag (4))
@@ -12633,13 +13364,15 @@
 
 ;;;; Documentation
 
+;;;###autoload
 (defun org-require-autoloaded-modules ()
   (interactive)
   (mapc 'require
 	'(org-agenda org-archive org-clock org-colview
-		     org-exp org-export-latex org-publish
+		     org-exp org-id org-export-latex org-publish
 		     org-remember org-table)))
 
+;;;###autoload
 (defun org-customize ()
   "Call the customize function with org as argument."
   (interactive)
@@ -12671,6 +13404,41 @@
 
 ;;; Generally useful functions
 
+(defun org-display-warning (message) ;; Copied from Emacs-Muse
+  "Display the given MESSAGE as a warning."
+  (if (fboundp 'display-warning)
+      (display-warning 'org message
+                       (if (featurep 'xemacs)
+                           'warning
+                         :warning))
+    (let ((buf (get-buffer-create "*Org warnings*")))
+      (with-current-buffer buf
+        (goto-char (point-max))
+        (insert "Warning (Org): " message)
+        (unless (bolp)
+          (newline)))
+      (display-buffer buf)
+      (sit-for 0))))
+
+(defun org-goto-marker-or-bmk (marker &optional bookmark)
+  "Go to MARKER, widen if necesary.  When marker is not live, try BOOKMARK."
+  (if (and marker (marker-buffer marker)
+	   (buffer-live-p (marker-buffer marker)))
+      (progn
+	(switch-to-buffer (marker-buffer marker))
+	(if (or (> marker (point-max)) (< marker (point-min)))
+	    (widen))
+	(goto-char marker))
+    (if bookmark
+	(bookmark-jump bookmark)
+      (error "Cannot find location"))))
+
+(defun org-quote-csv-field (s)
+  "Quote field for inclusion in CSV material."
+  (if (string-match "[\",]" s)
+      (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")
+    s))
+
 (defun org-plist-delete (plist property)
   "Delete PROPERTY from PLIST.
 This is in contrast to merely setting it to 0."
@@ -12708,6 +13476,12 @@
       (setq l (- l (get-text-property b 'org-dwidth-n s))))
     l))
 
+(defun org-base-buffer (buffer)
+  "Return the base buffer of BUFFER, if it has one.  Else return the buffer."
+  (if (not buffer)
+      buffer
+    (or (buffer-base-buffer buffer)
+	buffer)))
 
 (defun org-trim (s)
   "Remove whitespace at beginning and end of string."
@@ -13083,6 +13857,37 @@
   (save-match-data
     (string-match (org-image-file-name-regexp) file)))
 
+(defun org-get-cursor-date ()
+  "Return the date at cursor in as a time.
+This works in the calendar and in the agenda, anywhere else it just
+returns the current time."
+  (let (date day defd)
+    (cond
+     ((eq major-mode 'calendar-mode)
+      (setq date (calendar-cursor-to-date)
+	    defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
+     ((eq major-mode 'org-agenda-mode)
+      (setq day (get-text-property (point) 'day))
+      (if day
+	  (setq date (calendar-gregorian-from-absolute day)
+		defd (encode-time 0 0 0 (nth 1 date) (nth 0 date)
+				  (nth 2 date))))))
+    (or defd (current-time))))
+
+(defvar org-agenda-action-marker (make-marker)
+  "Marker pointing to the entry for the next agenda action.")
+
+(defun org-mark-entry-for-agenda-action ()
+  "Mark the current entry as target of an agenda action.
+Agenda actions are actions executed from the agenda with the key `k',
+which make use of the date at the cursor."
+  (interactive)
+  (move-marker org-agenda-action-marker
+	       (save-excursion (org-back-to-heading t) (point))
+	       (current-buffer))
+  (message
+   "Entry marked for action; press `k' at desired date in agenda or calendar"))
+
 ;;; Paragraph filling stuff.
 ;; We want this to be just right, so use the full arsenal.
 
@@ -13103,17 +13908,21 @@
 	(beginning-of-line 0))
       (cond
        ((looking-at "\\*+[ \t]+")
-	(goto-char (match-end 0))
-	(setq column (current-column)))
+	(if (not org-adapt-indentation)
+	    (setq column 0)
+	  (goto-char (match-end 0))
+	  (setq column (current-column))))
        ((org-in-item-p)
 	(org-beginning-of-item)
 ;	(looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
-	(looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\)?")
+	(looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?")
 	(setq bpos (match-beginning 1) tpos (match-end 0)
 	      bcol (progn (goto-char bpos) (current-column))
 	      tcol (progn (goto-char tpos) (current-column))
 	      bullet (match-string 1)
 	      bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
+	(if (> tcol (+ bcol org-description-max-indent))
+	    (setq tcol (+ bcol 5)))
 	(if (not itemp)
 	    (setq column tcol)
 	  (goto-char pos)
@@ -13197,6 +14006,13 @@
 work correctly."
   (cond ((looking-at "#[ \t]+")
 	 (match-string 0))
+	((looking-at "[ \t]*\\([-*+] .*? :: \\)")
+	 (save-excursion
+	   (if (> (match-end 1) (+ (match-beginning 1)
+				   org-description-max-indent))
+	       (goto-char (+ (match-beginning 1) 5))
+	     (goto-char (match-end 0)))
+	   (make-string (current-column) ?\ )))
 	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] \\)?")
 	 (save-excursion
 	   (goto-char (match-end 0))
@@ -13259,7 +14075,7 @@
 first attempt, and only move to after the tags when the cursor is already
 beyond the end of the headline."
   (interactive "P")
-  (let ((pos (point)))
+  (let ((pos (point)) refpos)
     (beginning-of-line 1)
     (if (bobp)
 	nil
@@ -13271,16 +14087,18 @@
 	(forward-char 1)))
     (when org-special-ctrl-a/e
       (cond
-       ((and (looking-at org-todo-line-regexp)
+       ((and (looking-at org-complex-heading-regexp)
 	     (= (char-after (match-end 1)) ?\ ))
+	(setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
+			  (point-at-eol)))
 	(goto-char
 	 (if (eq org-special-ctrl-a/e t)
-	     (cond ((> pos (match-beginning 3)) (match-beginning 3))
-		   ((= pos (point)) (match-beginning 3))
+	     (cond ((> pos refpos) refpos)
+		   ((= pos (point)) refpos)
 		   (t (point)))
 	   (cond ((> pos (point)) (point))
 		 ((not (eq last-command this-command)) (point))
-		 (t (match-beginning 3))))))
+		 (t refpos)))))
        ((org-at-item-p)
 	(goto-char
 	 (if (eq org-special-ctrl-a/e t)
@@ -13289,7 +14107,9 @@
 		   (t (point)))
 	   (cond ((> pos (point)) (point))
 		 ((not (eq last-command this-command)) (point))
-		 (t (match-end 4))))))))))
+		 (t (match-end 4))))))))
+    (org-no-warnings
+     (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
 
 (defun org-end-of-line (&optional arg)
   "Go to the end of the line.
@@ -13311,7 +14131,10 @@
 	    (if (or (< pos (match-end 0)) (not (eq this-command last-command)))
 		(goto-char (match-end 0))
 	      (goto-char (match-beginning 1))))
-	(end-of-line arg)))))
+	(end-of-line arg))))
+  (org-no-warnings
+   (and (featurep 'xemacs) (setq zmacs-region-stays t))))
+
 
 (define-key org-mode-map "\C-a" 'org-beginning-of-line)
 (define-key org-mode-map "\C-e" 'org-end-of-line)
@@ -13688,6 +14511,6 @@
 (run-hooks 'org-load-hook)
 
 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
+
 ;;; org.el ends here
 
-