]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge Org 7.8.03
authorBastien Guerry <bastien1@free.fr>
Tue, 3 Jan 2012 17:27:21 +0000 (18:27 +0100)
committerBastien Guerry <bastien1@free.fr>
Tue, 3 Jan 2012 17:27:21 +0000 (18:27 +0100)
116 files changed:
doc/misc/ChangeLog
doc/misc/org.texi
etc/ChangeLog
etc/org/COPYRIGHT-AND-LICENSE [new file with mode: 0644]
etc/org/OrgOdtContentTemplate.xml [new file with mode: 0644]
etc/org/OrgOdtStyles.xml [new file with mode: 0644]
etc/refcards/orgcard.pdf
etc/refcards/orgcard.tex
lisp/org/ChangeLog
lisp/org/ob-C.el
lisp/org/ob-R.el
lisp/org/ob-asymptote.el
lisp/org/ob-awk.el
lisp/org/ob-calc.el
lisp/org/ob-clojure.el
lisp/org/ob-comint.el
lisp/org/ob-css.el
lisp/org/ob-ditaa.el
lisp/org/ob-dot.el
lisp/org/ob-emacs-lisp.el
lisp/org/ob-eval.el
lisp/org/ob-exp.el
lisp/org/ob-fortran.el [new file with mode: 0644]
lisp/org/ob-gnuplot.el
lisp/org/ob-haskell.el
lisp/org/ob-java.el
lisp/org/ob-js.el
lisp/org/ob-keys.el
lisp/org/ob-latex.el
lisp/org/ob-ledger.el
lisp/org/ob-lilypond.el
lisp/org/ob-lisp.el
lisp/org/ob-lob.el
lisp/org/ob-matlab.el
lisp/org/ob-maxima.el
lisp/org/ob-mscgen.el
lisp/org/ob-ocaml.el
lisp/org/ob-octave.el
lisp/org/ob-org.el
lisp/org/ob-perl.el
lisp/org/ob-picolisp.el [new file with mode: 0644]
lisp/org/ob-plantuml.el
lisp/org/ob-python.el
lisp/org/ob-ref.el
lisp/org/ob-ruby.el
lisp/org/ob-sass.el
lisp/org/ob-scheme.el
lisp/org/ob-screen.el
lisp/org/ob-sh.el
lisp/org/ob-shen.el [new file with mode: 0644]
lisp/org/ob-sql.el
lisp/org/ob-sqlite.el
lisp/org/ob-table.el
lisp/org/ob-tangle.el
lisp/org/ob.el
lisp/org/org-agenda.el
lisp/org/org-archive.el
lisp/org/org-ascii.el
lisp/org/org-attach.el
lisp/org/org-bbdb.el
lisp/org/org-beamer.el
lisp/org/org-bibtex.el
lisp/org/org-capture.el
lisp/org/org-clock.el
lisp/org/org-colview.el
lisp/org/org-compat.el
lisp/org/org-crypt.el
lisp/org/org-ctags.el
lisp/org/org-datetree.el
lisp/org/org-docbook.el
lisp/org/org-docview.el
lisp/org/org-entities.el
lisp/org/org-eshell.el [new file with mode: 0644]
lisp/org/org-exp-blocks.el
lisp/org/org-exp.el
lisp/org/org-faces.el
lisp/org/org-feed.el
lisp/org/org-footnote.el
lisp/org/org-freemind.el
lisp/org/org-gnus.el
lisp/org/org-habit.el
lisp/org/org-html.el
lisp/org/org-icalendar.el
lisp/org/org-id.el
lisp/org/org-indent.el
lisp/org/org-info.el
lisp/org/org-inlinetask.el
lisp/org/org-irc.el
lisp/org/org-jsinfo.el
lisp/org/org-latex.el
lisp/org/org-list.el
lisp/org/org-lparse.el [new file with mode: 0644]
lisp/org/org-mac-message.el
lisp/org/org-macs.el
lisp/org/org-mew.el
lisp/org/org-mhe.el
lisp/org/org-mks.el
lisp/org/org-mobile.el
lisp/org/org-mouse.el
lisp/org/org-odt.el [new file with mode: 0644]
lisp/org/org-pcomplete.el
lisp/org/org-plot.el
lisp/org/org-protocol.el
lisp/org/org-publish.el
lisp/org/org-remember.el
lisp/org/org-rmail.el
lisp/org/org-special-blocks.el
lisp/org/org-src.el
lisp/org/org-table.el
lisp/org/org-taskjuggler.el
lisp/org/org-timer.el
lisp/org/org-vm.el
lisp/org/org-w3m.el
lisp/org/org-wl.el
lisp/org/org-xoxo.el
lisp/org/org.el

index 3b0e5251d5e13b8ad65628b4dc4ed863ce25acd9..30c4b01d3fa44db9478b24bbe920f3fbbdaf7450 100644 (file)
@@ -1,3 +1,157 @@
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * org.texi (Noweb reference syntax): Adding documentation of
+       the `*org-babel-use-quick-and-dirty-noweb-expansion*'
+       variable.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Plain lists): Split the table to fix the display
+       of items.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Plain lists): Fix misplaced explanation.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Plain lists, Agenda files): Add index entries.
+
+2012-01-03  Julian Gehring  <julian.gehring@googlemail.com>
+
+       * org.texi: Use "Org mode" instead of alternatives like
+       "Org-mode" or "org-mode".
+
+2012-01-03  Bernt Hansen  <bernt@norang.ca>
+
+       * org.texi (Agenda commands): Document
+       `org-clock-report-include-clocking-task'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Checkboxes): Document the new behavior of `C-u C-c
+       C-c' on checkboxes.
+
+2012-01-03  Julian Gehring  <julian.gehring@googlemail.com>
+
+       * org.texi: End sentences with two spaces.
+
+2012-01-03  Michael Brand  <michael.ch.brand@gmail.com>
+
+       * org.texi (External links): Document the link types file+sys
+       and file+emacs, slightly narrow used page width.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * org.texi (colnames): Note that colnames behavior may differ
+       across languages.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Weekly/daily agenda, Agenda commands): Fix typos.
+
+2012-01-03  Thomas Dye  <dk@poto.westell.com>
+
+       * org.texi: Augmented discussion of babel property
+       inheritance.  Put footnote outside sentence ending period.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.texi (eval): Documenting the full range of :eval header
+       argument values.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.texi (eval): Documentation of the new :eval option.
+
+2012-01-03  Thomas Dye  <dk@poto.local>
+
+       * org.texi: Add accumulated properties.
+
+2012-01-03  Thomas Dye  <dk@poto.local>
+
+       * org.texi: Documented no spaces in name=assign, another
+       correction to :var table.
+
+2012-01-03  Thomas Dye  <dk@poto.local>
+
+       * org.texi: Changed DATA to NAME in Working With Source Code
+       section.
+
+2012-01-03  Tom Dye  <tsd@tsdye.com>
+
+       * org.texi: Minor change to :var table.
+
+2012-01-03  Tom Dye  <tsd@tsdye.com>
+
+       * org.texi: More changes to :var table (some examples were wrong).
+
+2012-01-03  Tom Dye  <tsd@tsdye.com>
+
+       * org.texi: Cleaned up :var table.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Timestamps, Weekly/daily agenda)
+       (Weekly/daily agenda): Add @cindex for "appointment".
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.texi (Literal examples): A new link to the template for
+       inserting empty code blocks.
+       (Structure of code blocks): A new link to the template for
+       inserting empty code blocks.
+
+2012-01-03  Rafael Laboissiere  <rafael@laboissiere.net>  (tiny change)
+
+       * org.texi (External links): Add footnote on how the behavior
+       of the text search in Org files are controled by the variable
+       `org-link-search-must-match-exact-headline'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.texi (Buffer-wide header arguments): Update
+       documentation to reflect removal of #+PROPERTIES.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.texi (The clock table): Mention that ACHIVED trees
+       contribute to the clock table.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+       * org.texi (Conflicts): Better yasnippet config info.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>  (tiny change)
+
+       * org.texi (Selective export): Explicitely mention the default
+       values for `org-export-select-tags',
+       `org-export-exclude-tags'.
+
+2012-01-03  Tom Dye  <tsd@tsdye.com>
+
+       * org.texi: Added a line to specify that header arguments are
+       lowercase.
+
+2012-01-03  Tom Dye  <tsd@tsdye.com>
+
+       * org.texi: :var requires default value when declared.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Handling links): Add a note about the
+       `org-link-frame-setup' option.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.texi (Exporting Agenda Views, Extracting agenda
+       information): Fix command line syntax, quote symbol parameter
+       values.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.texi (Exporting Agenda Views): Fix command line syntax.
+
 2011-12-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        * gnus.texi (Mail Source Customization, Mail Back End Variables):
index adc9cf0b139ff28b0c9caa420b31c6f4617a9658..6d9a6566d9f847003a042f71db38adc7e6ea2664 100644 (file)
@@ -4,8 +4,8 @@
 @setfilename ../../info/org
 @settitle The Org Manual
 
-@set VERSION 7.7
-@set DATE July 2011
+@set VERSION 7.8.03
+@set DATE January 2012
 
 @c Use proper quote and backtick for code sections in PDF output
 @c Cf. Texinfo manual 14.2
@@ -36,7 +36,7 @@
 
 @c orgkey{key}                        A key item
 @c orgcmd{key,cmd}                    Key with command name
-@c xorgcmd{key,command}               Key with command name as @itemx
+@c xorgcmd{key,cmmand}                Key with command name as @itemx
 @c orgcmdnki{key,cmd}                 Like orgcmd, but do not index the key
 @c orgcmdtkc{text,key,cmd}            Like orgcmd,special text instead of key
 @c orgcmdkkc{key1,key2,cmd}           Two keys with one command name, use "or"
@@ -296,7 +296,7 @@ license to the document, as described in section 6 of the license.
 
 @subtitle Release @value{VERSION}
 @author by Carsten Dominik
-with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, and Thomas Dye
+with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, Thomas Dye and Jambunathan K.
 
 @c The following two commands start the copyright page.
 @page
@@ -382,7 +382,7 @@ The spreadsheet
 * Column formulas::             Formulas valid for an entire column
 * Editing and debugging formulas::  Fixing formulas
 * Updating the table::          Recomputing all dependent fields
-* Advanced features::           Field names, parameters and automatic recalc
+* Advanced features::           Field and column names, parameters and automatic recalc
 
 Hyperlinks
 
@@ -433,7 +433,7 @@ Tags
 Properties and columns
 
 * Property syntax::             How properties are spelled out
-* Special properties::          Access to other Org-mode features
+* Special properties::          Access to other Org mode features
 * Property searches::           Matching property values
 * Property inheritance::        Passing values down the tree
 * Column view::                 Tabular viewing and editing
@@ -462,7 +462,7 @@ Dates and times
 
 Creating timestamps
 
-* The date/time prompt::        How Org-mode helps you entering date and time
+* The date/time prompt::        How Org mode helps you entering date and time
 * Custom time format::          Making dates look different
 
 Deadlines and scheduling
@@ -541,7 +541,7 @@ Markup for rich export
 * Include files::               Include additional files into a document
 * Index entries::               Making an index
 * Macro replacement::           Use macros to create complex output
-* Embedded LaTeX::              LaTeX can be freely used inside Org documents
+* Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
 
 Structural markup elements
 
@@ -560,8 +560,8 @@ Embedded @LaTeX{}
 
 * Special symbols::             Greek letters and other symbols
 * Subscripts and superscripts::  Simple syntax for raising/lowering text
-* LaTeX fragments::             Complex formulas made easy
-* Previewing LaTeX fragments::  What will this snippet look like?
+* @LaTeX{} fragments::             Complex formulas made easy
+* Previewing @LaTeX{} fragments::  What will this snippet look like?
 * CDLaTeX mode::                Speed up entering of formulas
 
 Exporting
@@ -571,9 +571,9 @@ Exporting
 * The export dispatcher::       How to access exporter commands
 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
 * HTML export::                 Exporting to HTML
-* LaTeX and PDF export::        Exporting to @LaTeX{}, and processing to PDF
+* @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
 * DocBook export::              Exporting to DocBook
-* OpenDocumentText export::     Exporting to OpenDocumentText
+* OpenDocument Text export::    Exporting to OpenDocument Text
 * TaskJuggler export::          Exporting to TaskJuggler
 * Freemind export::             Exporting to Freemind mind maps
 * XOXO export::                 Exporting to XOXO
@@ -583,7 +583,7 @@ HTML export
 
 * HTML Export commands::        How to invoke HTML export
 * HTML preamble and postamble::  How to insert a preamble and a postamble
-* Quoting HTML tags::           Using direct HTML in Org-mode
+* Quoting HTML tags::           Using direct HTML in Org mode
 * Links in HTML export::        How links will be interpreted and formatted
 * Tables in HTML export::       How to modify the formatting of tables
 * Images in HTML export::       How to insert figures into HTML output
@@ -594,11 +594,11 @@ HTML export
 
 @LaTeX{} and PDF export
 
-* LaTeX/PDF export commands::   Which key invokes which commands
+* @LaTeX{}/PDF export commands::
 * Header and sectioning::       Setting up the export file structure
-* Quoting LaTeX code::          Incorporating literal @LaTeX{} code
-* Tables in LaTeX export::      Options for exporting tables to @LaTeX{}
-* Images in LaTeX export::      How to insert figures into @LaTeX{} output
+* Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
+* Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
+* Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
 * Beamer class export::         Turning the file into a presentation
 
 DocBook export
@@ -610,15 +610,30 @@ DocBook export
 * Images in DocBook export::    How to insert figures into DocBook output
 * Special characters::          How to handle special characters
 
-OpenDocument export
+OpenDocument Text export
 
-* OpenDocumentText export commands::    How to invoke OpenDocumentText export
-* Applying Custom Styles::      How to apply custom styles to the output
-* Converting to Other formats:: How to convert to formats like doc, docx etc
-* Links in OpenDocumentText export::  How links will be interpreted and formatted
-* Tables in OpenDocumentText export::    How Tables are handled
-* Images in OpenDocumentText export::    How to insert figures
-* Additional Documentation::          How to handle special characters
+* Pre-requisites for @acronym{ODT} export::  What packages @acronym{ODT} exporter relies on
+* @acronym{ODT} export commands::  How to invoke @acronym{ODT} export
+* Applying custom styles::      How to apply custom styles to the output
+* Links in @acronym{ODT} export::  How links will be interpreted and formatted
+* Tables in @acronym{ODT} export::  How Tables are exported
+* Images in @acronym{ODT} export::  How to insert images
+* Math formatting in @acronym{ODT} export::  How @LaTeX{} fragments are formatted
+* Literal examples in @acronym{ODT} export::  How source and example blocks are formatted
+* Advanced topics in @acronym{ODT} export::  Read this if you are a power user
+
+Math formatting in @acronym{ODT} export
+
+* Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
+* Working with MathML or OpenDocument formula files::  How to embed equations in native format
+
+Advanced topics in @acronym{ODT} export
+
+* Exporting and converting to other formats::  How to produce @samp{pdf} and other formats
+* Working with OpenDocument style files::  Explore the internals
+* Creating one-off styles::     How to produce custom highlighting etc
+* Customizing tables in @acronym{ODT} export::  How to define and use Table templates
+* Validating OpenDocument XML::  How to debug corrupt OpenDocument files
 
 Publishing
 
@@ -649,12 +664,12 @@ Working with source code
 * Editing source code::         Language major-mode editing
 * Exporting code blocks::       Export contents and/or results
 * Extracting source code::      Create pure source code files
-* Evaluating code blocks::      Place results of evaluation in the Org-mode buffer
+* Evaluating code blocks::      Place results of evaluation in the Org mode buffer
 * Library of Babel::            Use and contribute to a library of useful code blocks
 * Languages::                   List of supported code block languages
 * Header arguments::            Configure code block functionality
 * Results of evaluation::       How evaluation results are handled
-* Noweb reference syntax::      Literate programming in Org-mode
+* Noweb reference syntax::      Literate programming in Org mode
 * Key bindings and useful functions::  Work quickly with code blocks
 * Batch execution::             Call functions from the command line
 
@@ -668,7 +683,7 @@ Using header arguments
 * System-wide header arguments::  Set global default values
 * Language-specific header arguments::  Set default values by language
 * Buffer-wide header arguments::  Set default values for a specific buffer
-* Header arguments in Org-mode properties::  Set default values for a buffer or heading
+* Header arguments in Org mode properties::  Set default values for a buffer or heading
 * Code block specific header arguments::  The most common way to set values
 * Header arguments in function calls::  The most specific level
 
@@ -736,7 +751,7 @@ Hacking
 Tables and lists in arbitrary syntax
 
 * Radio tables::                Sending and receiving radio tables
-* A LaTeX example::             Step by step, almost a tutorial
+* A @LaTeX{} example::          Step by step, almost a tutorial
 * Translator functions::        Copy and modify
 * Radio lists::                 Doing the same for lists
 
@@ -898,7 +913,7 @@ make install-info
 
 Then add the following line to @file{.emacs}.  It is needed so that
 Emacs can autoload functions that are located in files not immediately loaded
-when Org-mode starts.
+when Org mode starts.
 @lisp
 (require 'org-install)
 @end lisp
@@ -934,9 +949,9 @@ liking.
 (global-set-key "\C-cb" 'org-iswitchb)
 @end lisp
 
-@cindex Org-mode, turning on
+@cindex Org mode, turning on
 With this setup, all files with extension @samp{.org} will be put
-into Org-mode.  As an alternative, make the first line of a file look
+into Org mode.  As an alternative, make the first line of a file look
 like this:
 
 @example
@@ -944,7 +959,7 @@ MY PROJECTS    -*- mode: org; -*-
 @end example
 
 @vindex org-insert-mode-line-in-empty-file
-@noindent which will select Org-mode for this buffer no matter what
+@noindent which will select Org mode for this buffer no matter what
 the file's name is.  See also the variable
 @code{org-insert-mode-line-in-empty-file}.
 
@@ -987,6 +1002,36 @@ version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
 that you only need to add your description.  If you re not sending the Email
 from within Emacs, please copy and paste the content into your Email program.
 
+Sometimes you might face a problem due to an error in your Emacs or Org mode
+setup.  Before reporting a bug, it is very helpful to start Emacs with minimal
+customisations and reproduce the problem.  Doing so often helps you determine
+if the problem is with your customisation or with Org mode itself.  You can
+start a typical minimal session with a command like the example below.
+
+@example
+$ emacs -Q -l /path/to/minimal-org.el
+@end example
+
+However if you are using Org mode as distributed with Emacs, a minimal setup
+is not necessary.  In that case it is sufficient to start Emacs as @code{emacs
+-Q}.  The @code{minimal-org.el} setup file can have contents as shown below.
+
+@example
+;;; Minimal setup to load latest `org-mode'
+
+;; activate debugging
+(setq debug-on-error t
+      debug-on-signal nil
+      debug-on-quit nil)
+
+;; add latest org-mode to load path
+(add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
+(add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp"))
+
+;; activate org
+(require 'org-install)
+@end example
+
 If an error occurs, a backtrace can be very useful (see below on how to
 create one).  Often a small example file helps, along with clear information
 about:
@@ -1009,7 +1054,7 @@ error occurred.  Here is how to produce a useful backtrace:
 
 @enumerate
 @item
-Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
+Reload uncompiled versions of all Org mode Lisp files.  The backtrace
 contains much more information if it is produced with uncompiled code.
 To do this, use
 @example
@@ -1196,8 +1241,8 @@ Reveal context around point, showing the current entry, the following heading
 and the hierarchy above.  Useful for working near a location that has been
 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
 (@pxref{Agenda commands}).  With a prefix argument show, on each
-level, all sibling headings.  With double prefix arg, also show the entire
-subtree of the parent.
+level, all sibling headings.  With a double prefix argument, also show the 
+entire subtree of the parent.
 @orgcmd{C-c C-k,show-branches}
 Expose all the headings of the subtree, CONTENT view for just one subtree.
 @orgcmd{C-c C-x b,org-tree-to-indirect-buffer}
@@ -1430,7 +1475,7 @@ functionality.
 @vindex org-show-following-heading
 @vindex org-show-siblings
 @vindex org-show-entry-below
-An important feature of Org-mode is the ability to construct @emph{sparse
+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
@@ -1439,7 +1484,7 @@ variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
 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
+Org mode contains several commands creating such trees, all these
 commands can be accessed through a dispatcher:
 
 @table @asis
@@ -1597,14 +1642,18 @@ to disable them individually.
 
 @table @asis
 @orgcmd{@key{TAB},org-cycle}
+@cindex cycling, in plain lists
 @vindex org-cycle-include-plain-lists
 Items can be folded just like headline levels.  Normally this works only if
 the cursor is on a plain list item.  For more details, see the variable
 @code{org-cycle-include-plain-lists}.  If this variable is set to
 @code{integrate}, plain list items will be treated like low-level
-headlines.  The level of an item is then given by the
-indentation of the bullet/number.  Items are always subordinate to real
-headlines, however; the hierarchies remain completely separated.
+headlines.  The level of an item is then given by the indentation of the
+bullet/number.  Items are always subordinate to real headlines, however; the
+hierarchies remain completely separated.  In a new item with no text yet, the
+first @key{TAB} demotes the item to become a child of the previous
+one.  Subsequent @key{TAB}s move the item to meaningful levels in the list
+and eventually get it back to its initial position.
 @orgcmd{M-@key{RET},org-insert-heading}
 @vindex org-M-RET-may-split-line
 @vindex org-list-automatic-rules
@@ -1615,17 +1664,15 @@ new item@footnote{If you do not want the item to be split, customize the
 variable @code{org-M-RET-may-split-line}.}.  If this command is executed
 @emph{before item's body}, the new item is created @emph{before} the current
 one.
+@end table
+
+@table @kbd
 @kindex M-S-@key{RET}
-@item M-S-@key{RET}
+@item M-S-RET
 Insert a new item with a checkbox (@pxref{Checkboxes}).
-@orgcmd{@key{TAB},org-cycle}
-In a new item with no text yet, the first @key{TAB} demotes the item to
-become a child of the previous one.  Subsequent @key{TAB}s move the item to
-meaningful levels in the list and eventually get it back to its initial
-position.
 @kindex S-@key{down}
-@item S-@key{up}
-@itemx S-@key{down}
+@item S-up
+@itemx S-down
 @cindex shift-selection-mode
 @vindex org-support-shift-select
 @vindex org-list-use-circular-motion
@@ -1637,21 +1684,21 @@ jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
 similar effect.
 @kindex M-@key{up}
 @kindex M-@key{down}
-@item M-@key{up}
-@itemx M-@key{down}
+@item M-up
+@itemx M-down
 Move the item including subitems up/down@footnote{See
 @code{org-liste-use-circular-motion} for a cyclic behavior.} (swap with
 previous/next item of same indentation).  If the list is ordered, renumbering
 is automatic.
 @kindex M-@key{left}
 @kindex M-@key{right}
-@item M-@key{left}
-@itemx M-@key{right}
+@item M-left
+@itemx M-right
 Decrease/increase the indentation of an item, leaving children alone.
 @kindex M-S-@key{left}
 @kindex M-S-@key{right}
-@item M-S-@key{left}
-@itemx M-S-@key{right}
+@item M-S-left
+@itemx M-S-right
 Decrease/increase the indentation of the item, including subitems.
 Initially, the item tree is selected based on current indentation.  When
 these commands are executed several times in direct succession, the initially
@@ -1694,7 +1741,7 @@ Turn the whole plain list into a subtree of the current heading.  Checkboxes
 (resp. checked).
 @kindex S-@key{left}
 @kindex S-@key{right}
-@item S-@key{left}/@key{right}
+@item S-left/right
 @vindex org-support-shift-select
 This command also cycles bullet styles when the cursor in on the bullet or
 anywhere in an item line, details depending on
@@ -1713,7 +1760,7 @@ numerically, alphabetically, by time, or by custom function.
 
 @vindex org-drawers
 Sometimes you want to keep information associated with an entry, but you
-normally don't want to see it.  For this, Org-mode has @emph{drawers}.
+normally don't want to see it.  For this, Org mode has @emph{drawers}.
 Drawers need to be configured with the variable
 @code{org-drawers}@footnote{You can define drawers on a per-file basis
 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
@@ -1731,7 +1778,7 @@ look like this:
 Visibility cycling (@pxref{Visibility cycling}) on the headline will 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 the @code{PROPERTIES} drawer for
+press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
 storing properties (@pxref{Properties and Columns}), and you can also arrange
 for state change notes (@pxref{Tracking TODO state changes}) and clock times
 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.  If you
@@ -1748,7 +1795,7 @@ Add a time-stamped note to the LOGBOOK drawer.
 
 @vindex org-hide-block-startup
 @cindex blocks, folding
-Org-mode uses begin...end blocks for various purposes from including source
+Org mode uses begin...end blocks for various purposes from including source
 code examples (@pxref{Literal examples}) to capturing time logging
 information (@pxref{Clocking work time}).  These blocks can be folded and
 unfolded by pressing TAB in the begin line.  You can also get all blocks
@@ -1766,8 +1813,8 @@ or on a per-file basis by using
 @section Footnotes
 @cindex footnotes
 
-Org-mode supports the creation of footnotes.  In contrast to the
-@file{footnote.el} package, Org-mode's footnotes are designed for work on a
+Org mode supports the creation of footnotes.  In contrast to the
+@file{footnote.el} package, Org mode's footnotes are designed for work on a
 larger document, not only for one-off documents like emails.  The basic
 syntax is similar to the one used by @file{footnote.el}, i.e.@: a footnote is
 defined in a paragraph that is started by a footnote marker in square
@@ -1781,11 +1828,11 @@ The Org homepage[fn:1] now looks a lot better than it used to.
 [fn:1] The link is: http://orgmode.org
 @end example
 
-Org-mode extends the number-based syntax to @emph{named} footnotes and
+Org mode extends the number-based syntax to @emph{named} footnotes and
 optional inline definition.  Using plain numbers as markers (as
 @file{footnote.el} does) is supported for backward compatibility, but not
 encouraged because of possible conflicts with @LaTeX{} snippets (@pxref{Embedded
-LaTeX}).  Here are the valid references:
+@LaTeX{}}).  Here are the valid references:
 
 @table @code
 @item [1]
@@ -1875,7 +1922,7 @@ you can use the usual commands to follow these links.
 @cindex Orgstruct mode
 @cindex minor mode for structure editing
 
-If you like the intuitive way the Org-mode structure editing and list
+If you like the intuitive way the Org mode structure editing and list
 formatting works, you might want to use these commands in other modes like
 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
@@ -2276,7 +2323,7 @@ formula, moving these references by arrow keys
 * Column formulas::             Formulas valid for an entire column
 * Editing and debugging formulas::  Fixing formulas
 * Updating the table::          Recomputing all dependent fields
-* Advanced features::           Field names, parameters and automatic recalc
+* Advanced features::           Field and column names, parameters and automatic recalc
 @end menu
 
 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
@@ -2833,9 +2880,11 @@ dependencies.
 @node Advanced features,  , Updating the table, The spreadsheet
 @subsection Advanced features
 
-If you want the recalculation of fields to happen automatically, or if
-you want to be able to assign @i{names} to fields and columns, you need
-to reserve the first column of the table for special marking characters.
+If you want the recalculation of fields to happen automatically, or if you
+want to be able to assign @i{names}@footnote{Such names must start by an
+alphabetic character and use only alphanumeric/underscore characters.} to
+fields and columns, you need to reserve the first column of the table for
+special marking characters.
 
 @table @kbd
 @orgcmd{C-#,org-table-rotate-recalc-marks}
@@ -3005,7 +3054,7 @@ When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
 flat mapping rather than a @code{3d} slope.
 
 @item timefmt
-Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
+Specify format of Org mode timestamps as they will be parsed by Gnuplot.
 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
 
 @item script
@@ -3168,11 +3217,19 @@ file:papers/last.pdf                      @r{file, relative path}
 ./papers/last.pdf                         @r{same as above}
 file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
 /myself@@some.where:papers/last.pdf        @r{same as above}
-file:sometextfile::NNN                    @r{file with line number to jump to}
+file:sometextfile::NNN                    @r{file, jump to line number}
 file:projects.org                         @r{another Org file}
-file:projects.org::some words             @r{text search in Org file}
+file:projects.org::some words             @r{text search in Org file}@footnote{
+The actual behavior of the search will depend on the value of
+the variable @code{org-link-search-must-match-exact-headline}.  If its value
+is nil, then a fuzzy text search will be done.  If it is t, then only the
+exact headline will be matched.  If the value is @code{'query-to-create},
+then an exact headline will be searched; if it is not found, then the user
+will be queried to create it.}
 file:projects.org::*task title            @r{heading search in Org file}
-docview:papers/last.pdf::NNN              @r{open file in doc-view mode at page NNN}
+file+sys:/path/to/file                    @r{open via OS, like double-click}
+file+emacs:/path/to/file                  @r{force opening by Emacs}
+docview:papers/last.pdf::NNN              @r{open in doc-view mode at page}
 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
 news:comp.emacs                           @r{Usenet link}
 mailto:adent@@galaxy.net                   @r{Mail link}
@@ -3189,7 +3246,7 @@ gnus:group                                @r{Gnus group link}
 gnus:group#id                             @r{Gnus article link}
 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
 irc:/irc.com/#emacs/bob                   @r{IRC link}
-info:org#External%20links                 @r{Info node link (with encoded space)}
+info:org#External links                   @r{Info node link}
 shell:ls *.org                            @r{A shell command}
 elisp:org-agenda                          @r{Interactive Elisp command}
 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
@@ -3235,7 +3292,7 @@ create a link.  The link will be stored for later insertion into an Org
 buffer (see below).  What kind of link will be created depends on the current
 buffer:
 
-@b{Org-mode buffers}@*
+@b{Org mode buffers}@*
 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
 to the target.  Otherwise it points to the current headline, which will also
 be the description@footnote{If the headline contains a timestamp, it will be
@@ -3338,6 +3395,7 @@ link and description parts of the link.
 @cindex following links
 @orgcmd{C-c C-o,org-open-at-point}
 @vindex org-file-apps
+@vindex org-link-frame-setup
 Open link at point.  This will launch a web browser for URLs (using
 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
 the corresponding links, and execute the command in a shell link.  When the
@@ -3351,7 +3409,9 @@ Classification of files is based on file extension only.  See option
 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
 If the cursor is on a headline, but not on a link, offer all links in the
-headline and entry text.
+headline and entry text.  If you want to setup the frame configuration for
+following links, customize @code{org-link-frame-setup}.
+
 @orgkey @key{RET}
 @vindex org-return-follows-link
 When @code{org-return-follows-link} is set, @kbd{@key{RET}} will also follow
@@ -3525,7 +3585,7 @@ Link to a heading with a @code{CUSTOM_ID} property
 @item /regexp/
 Do a regular expression search for @code{regexp}.  This uses the Emacs
 command @code{occur} to list all matches in a separate window.  If the
-target file is in Org-mode, @code{org-occur} is used to create a
+target file is in Org mode, @code{org-occur} is used to create a
 sparse tree with the matches.
 @c If the target file is a directory,
 @c @code{grep} will be used to search all files in the directory.
@@ -3564,7 +3624,7 @@ an implementation example.  See the file @file{org-bibtex.el}.
 @chapter TODO items
 @cindex TODO items
 
-Org-mode does not maintain TODO lists as separate documents@footnote{Of
+Org mode does not maintain TODO lists as separate documents@footnote{Of
 course, you can make a document that contains only long lists of TODO items,
 but this is not required.}.  Instead, TODO items are an integral part of the
 notes file, because TODO items usually come up while taking notes!  With Org
@@ -3573,7 +3633,7 @@ information is not duplicated, and the entire context from which the TODO
 item emerged is always present.
 
 Of course, this technique for managing TODO items scatters them
-throughout your notes file.  Org-mode compensates for this by providing
+throughout your notes file.  Org mode compensates for this by providing
 methods to give you an overview of all the things that you have to do.
 
 @menu
@@ -3659,7 +3719,7 @@ option @code{org-todo-state-tags-triggers} for details.
 
 @vindex org-todo-keywords
 By default, marked TODO entries have one of only two states: TODO and
-DONE.  Org-mode allows you to classify TODO items in more complex ways
+DONE.  Org mode allows you to classify TODO items in more complex ways
 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
 special setup, the TODO keyword system can work differently in different
 files.
@@ -3684,7 +3744,7 @@ TODO items in particular (@pxref{Tags}).
 
 You can use TODO keywords to indicate different @emph{sequential} states
 in the process of working on an item, for example@footnote{Changing
-this variable only becomes effective after restarting Org-mode in a
+this variable only becomes effective after restarting Org mode in a
 buffer.}:
 
 @lisp
@@ -3727,7 +3787,7 @@ be set up like this:
 
 In this case, different keywords do not indicate a sequence, but rather
 different types.  So the normal work flow would be to assign a task to a
-person, and later to mark it DONE.  Org-mode supports this style by adapting
+person, and later to mark it DONE.  Org mode supports this style by adapting
 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
 @kbd{t} command in the timeline and agenda buffers.}.  When used several
 times in succession, it will still cycle through all names, in order to first
@@ -3758,7 +3818,7 @@ like this:
         (sequence "|" "CANCELED")))
 @end lisp
 
-The keywords should all be different, this helps Org-mode to keep track
+The keywords should all be different, this helps Org mode to keep track
 of which subsequence should be used for a given entry.  In this setup,
 @kbd{C-c C-t} only operates within a subsequence, so it switches from
 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
@@ -3855,9 +3915,9 @@ Remember that the keywords after the vertical bar (or the last keyword
 if no bar is there) must always mean that the item is DONE (although you
 may use a different word).  After changing one of these lines, use
 @kbd{C-c C-c} with the cursor still in the line to make the changes
-known to Org-mode@footnote{Org-mode parses these lines only when
-Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
-cursor in a line starting with @samp{#+} is simply restarting Org-mode
+known to Org mode@footnote{Org mode parses these lines only when
+Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
+cursor in a line starting with @samp{#+} is simply restarting Org mode
 for the current buffer.}.
 
 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
@@ -3867,7 +3927,7 @@ for the current buffer.}.
 @vindex org-todo @r{(face)}
 @vindex org-done @r{(face)}
 @vindex org-todo-keyword-faces
-Org-mode highlights TODO keywords with special faces: @code{org-todo}
+Org mode highlights TODO keywords with special faces: @code{org-todo}
 for keywords indicating that an item still has to be acted upon, and
 @code{org-done} for keywords indicating that an item is finished.  If
 you are using more than 2 different states, you might want to use
@@ -3883,7 +3943,7 @@ special faces for some of them.  This can be done using the variable
 @end lisp
 
 While using a list with face properties as shown for CANCELED @emph{should}
-work, this does not always seem to be the case.  If necessary, define a
+work, this does not aways seem to be the case.  If necessary, define a
 special face and use that.  A string is interpreted as a color.  The variable
 @code{org-faces-easy-properties} determines if that color is interpreted as a
 foreground or a background color.
@@ -3955,7 +4015,7 @@ module @file{org-depend.el}.
 @cindex progress logging
 @cindex logging, of progress
 
-Org-mode can automatically record a timestamp and possibly a note when
+Org mode can automatically record a timestamp and possibly a note when
 you mark a TODO item as DONE, or even each time you change the state of
 a TODO item.  This system is highly configurable, settings can be on a
 per-keyword basis and can be localized to a file or even a subtree.  For
@@ -4019,21 +4079,25 @@ behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
 also overrule the setting of this variable for a subtree by setting a
 @code{LOG_INTO_DRAWER} property.
 
-Since it is normally too much to record a note for every state, Org-mode
+Since it is normally too much to record a note for every state, Org mode
 expects configuration on a per-keyword basis for this.  This is achieved by
-adding special markers @samp{!} (for a timestamp) and @samp{@@} (for a note)
-in parentheses after each keyword.  For example, with the setting
+adding special markers @samp{!} (for a timestamp) or @samp{@@} (for a note
+with timestamp) in parentheses after each keyword.  For example, with the
+setting
 
 @lisp
 (setq org-todo-keywords
   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
 @end lisp
 
+To record a timestamp without a note for TODO keywords configured with
+@samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
+
 @noindent
 @vindex org-log-done
 you not only define global TODO keywords and fast access keys, but also
 request that a time is recorded when the entry is set to
-DONE@footnote{It is possible that Org-mode will record two timestamps
+DONE@footnote{It is possible that Org mode will record two timestamps
 when you are using both @code{org-log-done} and state change logging.
 However, it will never prompt for two notes---if you have configured
 both, the state change recording note will take precedence and cancel
@@ -4182,7 +4246,7 @@ which should only be done in certain contexts, for example.
 @section Priorities
 @cindex priorities
 
-If you use Org-mode extensively, you may end up with enough TODO items that
+If you use Org mode extensively, you may end up with enough TODO items that
 it starts to make sense to prioritize them.  Prioritizing can be done by
 placing a @emph{priority cookie} into the headline of a TODO item, like this
 
@@ -4192,11 +4256,11 @@ placing a @emph{priority cookie} into the headline of a TODO item, like this
 
 @noindent
 @vindex org-priority-faces
-By default, Org-mode supports three priorities: @samp{A}, @samp{B}, and
+By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie is
 treated just like priority @samp{B}.  Priorities make a difference only for
 sorting in the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they
-have no inherent meaning to Org-mode.  The cookies can be highlighted with
+have no inherent meaning to Org mode.  The cookies can be highlighted with
 special faces by customizing the variable @code{org-priority-faces}.
 
 Priorities can be attached to any outline node; they do not need to be TODO
@@ -4363,9 +4427,11 @@ off a box while there are unchecked boxes above it.
 
 @table @kbd
 @orgcmd{C-c C-c,org-toggle-checkbox}
-Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
-double prefix argument, set it to @samp{[-]}, which is considered to be an
-intermediate state.
+Toggle checkbox status or (with prefix arg) checkbox presence at point.  
+With a single prefix argument, add an empty checkbox or remove the current
+one@footnote{`C-u C-c C-c' on the @emph{first} item of a list with no checkbox
+will add checkboxes to the rest of the list.}.  With a double prefix argument, set it to @samp{[-]}, which is
+considered to be an intermediate state.
 @orgcmd{C-c C-x C-b,org-toggle-checkbox}
 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
 double prefix argument, set it to @samp{[-]}, which is considered to be an
@@ -4410,7 +4476,7 @@ hand, use this command to get things back into sync.
 @cindex sparse tree, tag based
 
 An excellent way to implement labels and contexts for cross-correlating
-information is to assign @i{tags} to headlines.  Org-mode has extensive
+information is to assign @i{tags} to headlines.  Org mode has extensive
 support for tags.
 
 @vindex org-tag-faces
@@ -4489,7 +4555,7 @@ also a special command for inserting tags:
 @orgcmd{C-c C-q,org-set-tags-command}
 @cindex completion, of tags
 @vindex org-tags-column
-Enter new tags for the current headline.  Org-mode will either offer
+Enter new tags for the current headline.  Org mode will either offer
 completion or a special single-key interface for setting tags, see
 below.  After pressing @key{RET}, the tags will be inserted and aligned
 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
@@ -4532,7 +4598,7 @@ by adding a STARTUP option line to that file:
 #+STARTUP: noptag
 @end example
 
-By default Org-mode uses the standard minibuffer completion facilities for
+By default Org mode uses the standard minibuffer completion facilities for
 entering tags.  However, it also implements another, quicker, tag selection
 method called @emph{fast tag selection}.  This allows you to select and
 deselect tags with just a single key press.  For this to work well you should
@@ -4691,25 +4757,26 @@ and properties.  For a complete description with many examples, see
 @chapter Properties and columns
 @cindex properties
 
-Properties are a set of key-value pairs associated with an entry.  There
-are two main applications for properties in Org-mode.  First, properties
-are like tags, but with a value.  Second, you can use properties to
-implement (very basic) database capabilities in an Org buffer.  For
-an example of the first application, imagine maintaining a file where
+A property is a key-value pair associated with an entry.  Properties can be
+set so they are associated with a single entry, with every entry in a tree,
+or with every entry in an Org mode file.
+
+There are two main applications for properties in Org mode.  First,
+properties are like tags, but with a value.  Imagine maintaining a file where
 you document bugs and plan releases for a piece of software.  Instead of
-using tags like @code{:release_1:}, @code{:release_2:}, one can use a
+using tags like @code{:release_1:}, @code{:release_2:}, you can use a
 property, say @code{:Release:}, that in different subtrees has different
-values, such as @code{1.0} or @code{2.0}.  For an example of the second
-application of properties, imagine keeping track of your music CDs,
-where properties could be things such as the album, artist, date of
-release, number of tracks, and so on.
+values, such as @code{1.0} or @code{2.0}.  Second, you can use properties to
+implement (very basic) database capabilities in an Org buffer.  Imagine
+keeping track of your music CDs, where properties could be things such as the
+album, artist, date of release, number of tracks, and so on.
 
 Properties can be conveniently edited and viewed in column view
 (@pxref{Column view}).
 
 @menu
 * Property syntax::             How properties are spelled out
-* Special properties::          Access to other Org-mode features
+* Special properties::          Access to other Org mode features
 * Property searches::           Matching property values
 * Property inheritance::        Passing values down the tree
 * Column view::                 Tabular viewing and editing
@@ -4721,7 +4788,8 @@ Properties can be conveniently edited and viewed in column view
 @cindex property syntax
 @cindex drawer, for properties
 
-Properties are key-value pairs.  They need to be inserted into a special
+Properties are key-value pairs.  When they are associated with a single entry
+or with a tree they need to be inserted into a special
 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
 is specified on a single line, with the key (surrounded by colons)
 first, and the value after it.  Here is an example:
@@ -4739,6 +4807,10 @@ first, and the value after it.  Here is an example:
     :END:
 @end example
 
+Depending on the value of @code{org-use-property-inheritance}, a property set
+this way will either be associated with a single entry, or the sub-tree
+defined by the entry, see @ref{Property inheritance}.
+
 You may define the allowed values for a particular property @samp{:Xyz:}
 by setting a property @samp{:Xyz_ALL:}.  This special property is
 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
@@ -4763,6 +4835,37 @@ file, use a line like
 #+PROPERTY: NDisks_ALL 1 2 3 4
 @end example
 
+If you want to add to the value of an existing property, append a @code{+} to
+the property name.  The following results in the property @code{var} having
+the value ``foo=1 bar=2''.
+@cindex property, +
+@example
+#+PROPERTY: var  foo=1
+#+PROPERTY: var+ bar=2
+@end example
+
+It is also possible to add to the values of inherited properties.  The
+following results in the @code{genres} property having the value ``Classic
+Baroque'' under the @code{Goldberg Variations} subtree.
+@cindex property, +
+@example
+* CD collection
+** Classic
+    :PROPERTIES:
+    :GENRES: Classic
+    :END:
+*** Goldberg Variations
+    :PROPERTIES:
+    :Title:     Goldberg Variations
+    :Composer:  J.S. Bach
+    :Artist:    Glen Gould
+    :Publisher: Deutsche Grammophon
+    :NDisks:    1
+    :GENRES+:   Baroque
+    :END:
+@end example
+Note that a property can only have one entry per Drawer.
+
 @vindex org-global-properties
 Property values set with the global variable
 @code{org-global-properties} can be inherited by all entries in all
@@ -4803,7 +4906,7 @@ nearest column format definition.
 @section Special properties
 @cindex properties, special
 
-Special properties provide an alternative access method to Org-mode features,
+Special properties provide an alternative access method to Org mode features,
 like the TODO state or the priority of an entry, discussed in the previous
 chapters.  This interface exists so that you can include these states in a
 column view (@pxref{Column view}), or to use them in queries.  The following
@@ -4885,9 +4988,9 @@ a regular expression and matched against the property values.
 @cindex inheritance, of properties
 
 @vindex org-use-property-inheritance
-The outline structure of Org-mode documents lends itself to an
+The outline structure of Org mode documents lends itself to an
 inheritance model of properties: if the parent in a tree has a certain
-property, the children can inherit this property.  Org-mode does not
+property, the children can inherit this property.  Org mode does not
 turn this on by default, because it can slow down property searches
 significantly and is often not needed.  However, if you find inheritance
 useful, you can turn it on by setting the variable
@@ -4898,7 +5001,7 @@ inherited properties.  If a property has the value @samp{nil}, this is
 interpreted as an explicit undefine of the property, so that inheritance
 search will stop at this value and return @code{nil}.
 
-Org-mode has a few properties for which inheritance is hard-coded, at
+Org mode has a few properties for which inheritance is hard-coded, at
 least for the special applications for which they are used:
 
 @cindex property, COLUMNS
@@ -4929,7 +5032,7 @@ subtree (@pxref{Tracking TODO state changes}).
 A great way to view and edit properties in an outline tree is
 @emph{column view}.  In column view, each outline node is turned into a
 table row.  Columns in this table provide access to properties of the
-entries.  Org-mode implements columns by overlaying a tabular structure
+entries.  Org mode implements columns by overlaying a tabular structure
 over the headline of each item.  While the headlines have been turned
 into a table row, you can still change the visibility of the outline
 tree.  For example, you get a compact table by switching to CONTENTS
@@ -5231,9 +5334,9 @@ property API}.
 
 To assist project planning, TODO items can be labeled with a date and/or
 a time.  The specially formatted string carrying the date and time
-information is called a @emph{timestamp} in Org-mode.  This may be a
+information is called a @emph{timestamp} in Org mode.  This may be a
 little confusing because timestamp is often used as indicating when
-something was created or last changed.  However, in Org-mode this term
+something was created or last changed.  However, in Org mode this term
 is used in a much wider sense.
 
 @menu
@@ -5256,17 +5359,20 @@ is used in a much wider sense.
 @cindex scheduling
 
 A timestamp is a specification of a date (possibly with a time or a range of
-times) in a special format, either @samp{<2003-09-16 Tue>} or
-@samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
-12:00-12:30>}@footnote{This is inspired by the standard ISO 8601 date/time
-format.  To use an alternative format, see @ref{Custom time format}.}.  A
-timestamp can appear anywhere in the headline or body of an Org tree entry.
-Its presence causes entries to be shown on specific dates in the agenda
-(@pxref{Weekly/daily agenda}).  We distinguish:
+times) in a special format, either @samp{<2003-09-16 Tue>}@footnote{In this
+simplest form, the day name is optional when you type the date yourself.
+However, any dates inserted or modified by Org will add that day name, for
+reading convenience.} or @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16
+Tue 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601
+date/time format.  To use an alternative format, see @ref{Custom time
+format}.}.  A timestamp can appear anywhere in the headline or body of an Org
+tree entry.  Its presence causes entries to be shown on specific dates in the
+agenda (@pxref{Weekly/daily agenda}).  We distinguish:
 
 @table @var
 @item Plain timestamp; Event; Appointment
 @cindex timestamp
+@cindex appointment
 A simple timestamp just assigns a date/time to an item.  This is just
 like writing down an appointment or event in a paper agenda.  In the
 timeline and agenda displays, the headline of an entry associated with a
@@ -5289,7 +5395,7 @@ following will show up in the agenda every Wednesday:
 @end example
 
 @item Diary-style sexp entries
-For more complex date specifications, Org-mode supports using the special
+For more complex date specifications, Org mode supports using the special
 sexp diary entries implemented in the Emacs calendar/diary
 package@footnote{When working with the standard diary sexp functions, you
 need to be very careful with the order of the arguments.  That order depend
@@ -5297,7 +5403,7 @@ evilly on the variable @code{calendar-date-style} (or, for older Emacs
 versions, @code{european-calendar-style}).  For example, to specify a date
 December 12, 2005, the call might look like @code{(diary-date 12 1 2005)} or
 @code{(diary-date 1 12 2005)} or @code{(diary-date 2005 12 1)}, depending on
-the settings.  This has been the source of much confusion.  Org-mode users
+the settings.  This has been the source of much confusion.  Org mode users
 can resort to special versions of these functions like @code{org-date} or
 @code{org-anniversary}.  These work just like the corresponding @code{diary-}
 functions, but with stable ISO order of arguments (year, month, day) wherever
@@ -5338,7 +5444,7 @@ angular ones.  These timestamps are inactive in the sense that they do
 @cindex creating timestamps
 @cindex timestamps, creating
 
-For Org-mode to recognize timestamps, they need to be in the specific
+For Org mode to recognize timestamps, they need to be in the specific
 format.  All commands listed below produce timestamps in the correct
 format.
 
@@ -5362,6 +5468,9 @@ Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
 contains date and time.  The default time can be rounded to multiples of 5
 minutes, see the option @code{org-time-stamp-rounding-minutes}.
 @c
+@orgkey{C-c C-c}
+Normalize timestamp, insert/fix day name if missing or wrong.
+@c
 @orgcmd{C-c <,org-date-from-calendar}
 Insert a timestamp corresponding to the cursor date in the Calendar.
 @c
@@ -5397,7 +5506,7 @@ the following column).
 
 
 @menu
-* The date/time prompt::        How Org-mode helps you entering date and time
+* The date/time prompt::        How Org mode helps you entering date and time
 * Custom time format::          Making dates look different
 @end menu
 
@@ -5407,17 +5516,17 @@ the following column).
 @cindex time, reading in minibuffer
 
 @vindex org-read-date-prefer-future
-When Org-mode prompts for a date/time, the default is shown in default
+When Org mode prompts for a date/time, the default is shown in default
 date/time format, and the prompt therefore seems to ask for a specific
 format.  But it will in fact accept any string containing some date and/or
 time information, and it is really smart about interpreting your input.  You
 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
-copied from an email message.  Org-mode will find whatever information is in
+copied from an email message.  Org mode will find whatever information is in
 there and derive anything you have not specified from the @emph{default date
 and time}.  The default is usually the current date and time, but when
 modifying an existing timestamp, or when entering the second stamp of a
 range, it is taken from the stamp in the buffer.  When filling in
-information, Org-mode assumes that most of the time you will want to enter a
+information, Org mode assumes that most of the time you will want to enter a
 date in the future: if you omit the month/year and the given day/month is
 @i{before} today, it will assume that you mean a future date@footnote{See the
 variable @code{org-read-date-prefer-future}.  You may set that variable to
@@ -5426,7 +5535,7 @@ tomorrow.}.  If the date has been automatically shifted into the future, the
 time prompt will show this with @samp{(=>F).}
 
 For example, let's assume that today is @b{June 13, 2006}.  Here is how
-various inputs will be interpreted, the items filled in by Org-mode are
+various inputs will be interpreted, the items filled in by Org mode are
 in @b{bold}.
 
 @example
@@ -5536,7 +5645,7 @@ minibuffer@footnote{If you find this distracting, turn the display of with
 
 @vindex org-display-custom-times
 @vindex org-time-stamp-custom-formats
-Org-mode uses the standard ISO notation for dates and times as it is
+Org mode uses the standard ISO notation for dates and times as it is
 defined in ISO 8601.  If you cannot get used to this and require another
 representation of date and time to keep you happy, you can get it by
 customizing the variables @code{org-display-custom-times} and
@@ -5548,7 +5657,7 @@ Toggle the display of custom formats for dates and times.
 @end table
 
 @noindent
-Org-mode needs the default format for scanning, so the custom date/time
+Org mode needs the default format for scanning, so the custom date/time
 format does not @emph{replace} the default format---instead it is put
 @emph{over} the default format using text properties.  This has the
 following consequences:
@@ -5625,23 +5734,23 @@ the task will automatically be forwarded until completed.
 @end example
 
 @noindent
-@b{Important:} Scheduling an item in Org-mode should @i{not} be
+@b{Important:} Scheduling an item in Org mode should @i{not} be
 understood in the same way that we understand @i{scheduling a meeting}.
 Setting a date for a meeting is just a simple appointment, you should
 mark this entry with a simple plain timestamp, to get this item shown
 on the date where it applies.  This is a frequent misunderstanding by
-Org users.  In Org-mode, @i{scheduling} means setting a date when you
+Org users.  In Org mode, @i{scheduling} means setting a date when you
 want to start working on an action item.
 @end table
 
 You may use timestamps with repeaters in scheduling and deadline
-entries.  Org-mode will issue early and late warnings based on the
+entries.  Org mode will issue early and late warnings based on the
 assumption that the timestamp represents the @i{nearest instance} of
 the repeater.  However, the use of diary sexp entries like
 @c
 @code{<%%(org-float t 42)>}
 @c
-in scheduling and deadline timestamps is limited.  Org-mode does not
+in scheduling and deadline timestamps is limited.  Org mode does not
 know enough about the internals of each sexp function to issue early and
 late warnings.  However, it will show the item on each day where the
 sexp entry matches.
@@ -5714,7 +5823,7 @@ to the previous week before any current timestamp.
 @cindex tasks, repeated
 @cindex repeated tasks
 
-Some tasks need to be repeated again and again.  Org-mode helps to
+Some tasks need to be repeated again and again.  Org mode helps to
 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
 or plain timestamp.  In the following example
 @example
@@ -5734,7 +5843,7 @@ over-due, so it is important to be able to mark such an entry as completed
 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
 keyword DONE, it will no longer produce entries in the agenda.  The problem
 with this is, however, that then also the @emph{next} instance of the
-repeated entry will not be active.  Org-mode deals with this in the following
+repeated entry will not be active.  Org mode deals with this in the following
 way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
 shift the base date of the repeating timestamp by the repeater interval, and
 immediately set the entry state back to TODO@footnote{In fact, the target
@@ -5767,7 +5876,7 @@ task, this may not be the best way to handle it.  For example, if you
 forgot to call your father for 3 weeks, it does not make sense to call
 him 3 times in a single day to make up for it.  Finally, there are tasks
 like changing batteries which should always repeat a certain time
-@i{after} the last time you did it.  For these tasks, Org-mode has
+@i{after} the last time you did it.  For these tasks, Org mode has
 special repeaters  @samp{++} and @samp{.+}.  For example:
 
 @example
@@ -5796,7 +5905,7 @@ created for this purpose, it is described in @ref{Structure editing}.
 @cindex clocking time
 @cindex time clocking
 
-Org-mode allows you to clock the time you spend on specific tasks in a
+Org mode allows you to clock the time you spend on specific tasks in a
 project.  When you start working on an item, you can start the clock.
 When you stop working on that task, or when you mark the task done, the
 clock is stopped and the corresponding time interval is recorded.  It
@@ -5915,10 +6024,11 @@ formatted as one or several Org tables.
 @table @kbd
 @orgcmd{C-c C-x C-r,org-clock-report}
 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
-report as an Org-mode table into the current file.  When the cursor is
+report as an Org mode table into the current file.  When the cursor is
 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.
+update it.  The clock table always includes also trees with
+@code{:ARCHIVE:} tag.
 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
 Update dynamic block at point.  The cursor needs to be in the
 @code{#+BEGIN} line of the dynamic block.
@@ -6215,8 +6325,8 @@ not started at exactly the right moment.
 @kindex C-c C-x ;
 @kindex ;
 
-Calling @code{org-timer-set-timer} from an Org-mode buffer runs a countdown
-timer.  Use @kbd{;} from agenda buffers, @key{C-c C-x ;} everywhere else.
+Calling @code{org-timer-set-timer} from an Org mode buffer runs a countdown
+timer.  Use @kbd{;} from agenda buffers, @key{C-c C-x ;} everwhere else.
 
 @code{org-timer-set-timer} prompts the user for a duration and displays a
 countdown timer in the modeline.  @code{org-timer-default-timer} sets the
@@ -6249,7 +6359,7 @@ trees to an archive file keeps the system compact and fast.
 
 Org's method for capturing new items is heavily inspired by John Wiegley
 excellent remember package.  Up to version 6.36 Org used a special setup
-for @file{remember.el}.  @file{org-remember.el} is still part of Org-mode for
+for @file{remember.el}.  @file{org-remember.el} is still part of Org mode for
 backward compatibility with existing setups.  You can find the documentation
 for org-remember at @url{http://orgmode.org/org-remember.pdf}.
 
@@ -6393,7 +6503,7 @@ like this:
 @node Template elements, Template expansion, Capture templates, Capture templates
 @subsubsection Template elements
 
-Now let's look at the elements of a template definition.  Each entry in
+Now lets look at the elements of a template definition.  Each entry in
 @code{org-capture-templates} is a list with the following items:
 
 @table @var
@@ -6418,8 +6528,8 @@ selection.
 The type of entry, a symbol.  Valid values are:
 @table @code
 @item entry
-An Org-mode node, with a headline.  Will be filed as the child of the target
-entry or as a top-level entry.  The target file should be an Org-mode file.
+An Org mode node, with a headline.  Will be filed as the child of the target
+entry or as a top-level entry.  The target file should be an Org mode file.
 @item item
 A plain list item, placed in the first plain  list at the target
 location.  Again the target file should be an Org file.
@@ -6436,7 +6546,7 @@ Text to be inserted as it is.
 
 @item target
 @vindex org-default-notes-file
-Specification of where the captured item should be placed.  In Org-mode
+Specification of where the captured item should be placed.  In Org mode
 files, targets usually define a node.  Entries will become children of this
 node.  Other types will be added to the table or list in the body of this
 node.  Most target specifications contain a file name.  If that file name is
@@ -6536,7 +6646,7 @@ buffer again after capture is completed.
 
 In the template itself, special @kbd{%}-escapes@footnote{If you need one of
 these sequences literally, escape the @kbd{%} with a backslash.}  allow
-dynamic insertion of content. The templates are expanded in the order given here:
+dynamic insertion of content.  The templates are expanded in the order given here:
 
 @smallexample
 %[@var{file}]     @r{insert the contents of the file given by @var{file}.}
@@ -7032,6 +7142,7 @@ the front.  With a prefix argument, file is added/moved to the end.
 @orgcmd{C-c ],org-remove-file}
 Remove current file from the list of agenda files.
 @kindex C-,
+@cindex cycling, of agenda files
 @orgcmd{C-',org-cycle-agenda-files}
 @itemx C-,
 Cycle through agenda file list, visiting one file after the other.
@@ -7187,7 +7298,7 @@ anniversaries, lunar phases, sunrise/set, recurrent appointments
 Org.  It can be very useful to combine output from Org with
 the diary.
 
-In order to include entries from the Emacs diary into Org-mode's
+In order to include entries from the Emacs diary into Org mode's
 agenda, you only need to customize the variable
 
 @lisp
@@ -7196,7 +7307,7 @@ agenda, you only need to customize the variable
 
 @noindent After that, everything will happen automatically.  All diary
 entries including holidays, anniversaries, etc., will be included in the
-agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
+agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
 @key{RET} can be used from the agenda buffer to jump to the diary
 file in order to edit existing diary entries.  The @kbd{i} command to
 insert new entries for the current date works in the agenda buffer, as
@@ -7207,7 +7318,7 @@ between calendar and agenda.
 
 If you are using the diary only for sexp entries and holidays, it is
 faster to not use the above setting, but instead to copy or even move
-the entries into an Org file.  Org-mode evaluates diary-style sexp
+the entries into an Org file.  Org mode evaluates diary-style sexp
 entries, and does it faster because there is no overhead for first
 creating the diary display.  Note that the sexp entries must start at
 the left margin, no whitespace is allowed before them.  For example,
@@ -7253,7 +7364,7 @@ followed by a space and the class of the anniversary (@samp{birthday} or
 1973-06-22
 06-22
 1955-08-02 wedding
-2008-04-14 %s released version 6.01 of org-mode, %d years ago
+2008-04-14 %s released version 6.01 of org mode, %d years ago
 @end example
 
 After a change to BBDB, or for the first agenda display during an Emacs
@@ -7265,6 +7376,8 @@ in an Org or Diary file.
 @subsubheading Appointment reminders
 @cindex @file{appt.el}
 @cindex appointment reminders
+@cindex appointment
+@cindex reminders
 
 Org can interact with Emacs appointments notification facility.  To add all
 the appointments of your agenda files, use the command
@@ -7466,7 +7579,7 @@ other properties will slow down the search.  However, once you have paid the
 price by accessing one property, testing additional properties is cheap
 again.
 
-You can configure Org-mode to use property inheritance during a search, but
+You can configure Org mode to use property inheritance during a search, but
 beware that this can slow down searches considerably.  See @ref{Property
 inheritance}, for details.
 
@@ -7499,7 +7612,7 @@ Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
 @cindex timeline, single file
 @cindex time-sorted view
 
-The timeline summarizes all time-stamped items from a single Org-mode
+The timeline summarizes all time-stamped items from a single Org mode
 file in a @emph{time-sorted view}.  The main purpose of this command is
 to give an overview over events in a project.
 
@@ -7520,7 +7633,7 @@ The commands available in the timeline buffer are listed in
 @cindex text search
 @cindex searching, for text
 
-This agenda view is a general text search facility for Org-mode entries.
+This agenda view is a general text search facility for Org mode entries.
 It is particularly useful to find notes.
 
 @table @kbd
@@ -7552,7 +7665,7 @@ If you are following a system like David Allen's GTD to organize your
 work, one of the ``duties'' you have is a regular review to make sure
 that all projects move along.  A @emph{stuck} project is a project that
 has no defined next actions, so it will never show up in the TODO lists
-Org-mode produces.  During the review, you need to identify such
+Org mode produces.  During the review, you need to identify such
 projects and define next actions for them.
 
 @table @kbd
@@ -7570,7 +7683,7 @@ work for you.  The built-in default assumes that all your projects are
 level-2 headlines, and that a project is not stuck if it has at least
 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
 
-Let's assume that you, in your own way of using Org-mode, identify
+Let's assume that you, in your own way of using Org mode, identify
 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
 indicate a project that should not be considered yet.  Let's further
 assume that the TODO keyword DONE marks finished projects, and that NEXT
@@ -7598,7 +7711,7 @@ will still be searched for stuck projects.
 
 @vindex org-agenda-prefix-format
 @vindex org-agenda-tags-column
-Before displaying items in an agenda view, Org-mode visually prepares the
+Before displaying items in an agenda view, Org mode visually prepares the
 items and sorts them.  Each item occupies a single line.  The line starts
 with a @emph{prefix} that contains the @emph{category} (@pxref{Categories})
 of the item and other important information.  You can customize in which
@@ -7651,7 +7764,7 @@ You can set up icons for category by customizing the
 @subsection Time-of-day specifications
 @cindex time-of-day specification
 
-Org-mode checks each agenda item for a time-of-day specification.  The
+Org mode checks each agenda item for a time-of-day specification.  The
 time can be part of the timestamp that triggered inclusion into the
 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
 ranges can be specified with two timestamps, like
@@ -7663,7 +7776,7 @@ plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
 specifications in diary entries are recognized as well.
 
-For agenda display, Org-mode extracts the time and displays it in a
+For agenda display, Org mode extracts the time and displays it in a
 standard 24 hour format as part of the prefix.  The example times in
 the previous paragraphs would end up in the agenda like this:
 
@@ -7861,6 +7974,7 @@ press @kbd{v a} again.
 @c
 @orgcmdkskc{v R,R,org-agenda-clockreport-mode}
 @vindex org-agenda-start-with-clockreport-mode
+@vindex org-clock-report-include-clocking-task
 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
 always show a table with the clocked times for the timespan and file scope
 covered by the current agenda view.  The initial setting for this mode in new
@@ -7868,7 +7982,8 @@ agenda buffers can be set with the variable
 @code{org-agenda-start-with-clockreport-mode}.  By using a prefix argument
 when toggling this mode (i.e.@: @kbd{C-u R}), the clock table will not show
 contributions from entries that are hidden by agenda filtering@footnote{Only
-tags filtering will be respected here, effort filtering is ignored.}.
+tags filtering will be respected here, effort filtering is ignored.}.  See
+also the variable @code{org-clock-report-include-clocking-task}.
 @c
 @orgkey{v c}
 @vindex org-agenda-clock-consistency-checks
@@ -7921,18 +8036,27 @@ Remove the restriction lock on the agenda, if it is currently restricted to a
 file or subtree (@pxref{Agenda files}).
 
 @tsubheading{Secondary filtering and query editing}
-@cindex filtering, by tag and effort, in agenda
+@cindex filtering, by tag category and effort, in agenda
 @cindex tag filtering, in agenda
+@cindex category filtering, in agenda
 @cindex effort filtering, in agenda
 @cindex query editing, in agenda
 
+@orgcmd{<,org-agenda-filter-by-category}
+@vindex org-agenda-category-filter-preset
+
+Filter the current agenda view with respect to the category of the item at
+point.  Pressing @code{<} another time will remove this filter.  You can add
+a filter preset through the option @code{org-agenda-category-filter-preset}
+(see below.)
+
 @orgcmd{/,org-agenda-filter-by-tag}
-@vindex org-agenda-filter-preset
+@vindex org-agenda-tag-filter-preset
 Filter the current agenda view with respect to a tag and/or effort estimates.
 The difference between this and a custom agenda command is that filtering is
 very fast, so that you can switch quickly between different filters without
 having to recreate the agenda.@footnote{Custom commands can preset a filter by
-binding the variable @code{org-agenda-filter-preset} as an option.  This
+binding the variable @code{org-agenda-tag-filter-preset} as an option.  This
 filter will then be applied to the view and persist as a basic filter through
 refreshes and more secondary filtering.  The filter is a global property of
 the entire agenda view---in a block agenda, you should only set this in the
@@ -8076,7 +8200,7 @@ agenda, change a tag for all headings in the region.
 @kindex ,
 @item ,
 Set the priority for the current item (@command{org-agenda-priority}).
-Org-mode prompts for the priority character.  If you reply with @key{SPC},
+Org mode prompts for the priority character.  If you reply with @key{SPC},
 the priority cookie is removed from the entry.
 @c
 @orgcmd{P,org-agenda-show-priority}
@@ -8122,13 +8246,15 @@ command.
 @c
 @orgcmd{S-@key{right},org-agenda-do-date-later}
 Change the timestamp associated with the current line by one day into the
-future.  With a numeric prefix argument, change it by that many days.  For
-example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
-@kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
-command, it will continue to change hours even without the prefix arg.  With
-a double @kbd{C-u C-u} prefix, do the same for changing minutes.  The stamp
-is changed in the original Org file, but the change is not directly reflected
-in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
+future.  If the date is in the past, the first call to this command will move
+it to today.@*
+With a numeric prefix argument, change it by that many days.  For example,
+@kbd{3 6 5 S-@key{right}} will change it by a year.  With a @kbd{C-u} prefix,
+change the time by one hour.  If you immediately repeat the command, it will
+continue to change hours even without the prefix arg.  With a double @kbd{C-u
+C-u} prefix, do the same for changing minutes.@*
+The stamp is changed in the original Org file, but the change is not directly
+reflected in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
 @c
 @orgcmd{S-@key{left},org-agenda-do-date-earlier}
 Change the timestamp associated with the current line by one day
@@ -8213,7 +8339,7 @@ f  @r{Apply a function to marked entries.}
 Open the Emacs calendar and move to the date at the agenda cursor.
 @c
 @orgcmd{c,org-calendar-goto-agenda}
-When in the calendar, compute and show the Org-mode agenda for the
+When in the calendar, compute and show the Org mode agenda for the
 date at the cursor.
 @c
 @cindex diary entries, creating from agenda
@@ -8226,8 +8352,8 @@ file@footnote{This file is parsed for the agenda when
 command in the calendar.  The diary file will pop up in another window, where
 you can add the entry.
 
-If you configure @code{org-agenda-diary-file} to point to an Org-mode file,
-Org will create entries (in org-mode syntax) in that file instead.  Most
+If you configure @code{org-agenda-diary-file} to point to an Org mode file,
+Org will create entries (in Org mode syntax) in that file instead.  Most
 entries will be stored in a date-based outline tree that will later make it
 easy to archive appointments from previous months/years.  The tree will be
 built under an entry with a @code{DATE_TREE} property, or else with years as
@@ -8262,7 +8388,7 @@ This is a globally available command, and also available in the agenda menu.
 @vindex org-agenda-exporter-settings
 Write the agenda view to a file.  Depending on the extension of the selected
 file name, the view will be exported as HTML (extension @file{.html} or
-@file{.htm}), PostScript (extension @file{.ps}), PDF (extension @file{.pdf}),
+@file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
 and plain text (any other extension).  When called with a @kbd{C-u} prefix
 argument, immediately open the newly created file.  Use the variable
 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
@@ -8403,7 +8529,7 @@ command @kbd{C-c a o} provides a similar view for office tasks.
 @cindex options, for custom agenda views
 
 @vindex org-agenda-custom-commands
-Org-mode contains a number of variables regulating agenda construction
+Org mode contains a number of variables regulating agenda construction
 and display.  The global variables define the behavior for all agenda
 commands, including the custom commands.  However, if you want to change
 some settings just for a single custom view, you can do so.  Setting
@@ -8475,11 +8601,11 @@ yourself.
 @cindex agenda views, exporting
 
 If you are away from your computer, it can be very useful to have a printed
-version of some agenda views to carry around.  Org-mode can export custom
+version of some agenda views to carry around.  Org mode can export custom
 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
-@file{htmlize.el}.}, PostScript, PDF@footnote{To create PDF output, the
+@file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
-a PDF file will also create the PostScript file.}, and iCalendar files.  If
+a PDF file will also create the postscript file.}, and iCalendar files.  If
 you want to do this only occasionally, use the command
 
 @table @kbd
@@ -8489,7 +8615,7 @@ you want to do this only occasionally, use the command
 @vindex org-agenda-exporter-settings
 Write the agenda view to a file.  Depending on the extension of the selected
 file name, the view will be exported as HTML (extension @file{.html} or
-@file{.htm}), PostScript (extension @file{.ps}), iCalendar (extension
+@file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
 @file{.ics}), or plain text (any other extension).  Use the variable
 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
 for @file{htmlize} to be used during export, for example
@@ -8539,10 +8665,10 @@ or absolute.
 @end lisp
 
 The extension of the file name determines the type of export.  If it is
-@file{.html}, Org-mode will use the @file{htmlize.el} package to convert
+@file{.html}, Org mode will use the @file{htmlize.el} package to convert
 the buffer to HTML and save it to this file name.  If the extension is
 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
-PostScript output.  If the extension is @file{.ics}, iCalendar export is
+Postscript output.  If the extension is @file{.ics}, iCalendar export is
 run export over all files that were used to construct the agenda, and
 limit the export to entries listed in the agenda.  Any other
 extension produces a plain ASCII file.
@@ -8573,7 +8699,7 @@ set options for the export commands.  For example:
 @end lisp
 
 @noindent
-This command sets two options for the PostScript exporter, to make it
+This command sets two options for the Postscript exporter, to make it
 print in two columns in landscape format---the resulting page can be cut
 in two and then used in a paper agenda.  The remaining settings modify
 the agenda prefix to omit category and scheduling information, and
@@ -8586,14 +8712,14 @@ in @code{org-agenda-custom-commands} take precedence.
 @noindent
 From the command line you may also use
 @example
-emacs -f org-batch-store-agenda-views -kill
+emacs -eval (org-batch-store-agenda-views) -kill
 @end example
 @noindent
 or, if you need to modify some parameters@footnote{Quoting depends on the
 system you use, please check the FAQ for examples.}
 @example
 emacs -eval '(org-batch-store-agenda-views                      \
-              org-agenda-span month                             \
+              org-agenda-span (quote month)                     \
               org-agenda-start-day "2007-11-01"                 \
               org-agenda-include-diary nil                      \
               org-agenda-files (quote ("~/org/project.org")))'  \
@@ -8668,11 +8794,11 @@ the agenda).
 @node Markup, Exporting, Agenda Views, Top
 @chapter Markup for rich export
 
-When exporting Org-mode documents, the exporter tries to reflect the
+When exporting Org mode documents, the exporter tries to reflect the
 structure of the document as accurately as possible in the backend.  Since
 export targets like HTML, @LaTeX{}, or DocBook allow much richer formatting,
-Org-mode has rules on how to prepare text for rich export.  This section
-summarizes the markup rules used in an Org-mode buffer.
+Org mode has rules on how to prepare text for rich export.  This section
+summarizes the markup rules used in an Org mode buffer.
 
 @menu
 * Structural markup elements::  The basic structure as seen by the exporter
@@ -8681,7 +8807,7 @@ summarizes the markup rules used in an Org-mode buffer.
 * Include files::               Include additional files into a document
 * Index entries::               Making an index
 * Macro replacement::           Use macros to create complex output
-* Embedded LaTeX::              LaTeX can be freely used inside Org documents
+* Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
 @end menu
 
 @node Structural markup elements, Images and tables, Markup, Markup
@@ -8764,7 +8890,7 @@ the table of contents entirely, by configuring the variable
 @cindex text before first headline, markup rules
 @cindex #+TEXT
 
-Org-mode normally exports the text before the first headline, and even uses
+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, @LaTeX{}, or DocBook code, use the special
 constructs described below in the sections for the individual exporters.
@@ -8818,7 +8944,7 @@ can use this construct, which can also be used to format poetry.
 
 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:
+can include quotations in Org mode documents like this:
 
 @cindex #+BEGIN_QUOTE
 @example
@@ -8858,7 +8984,7 @@ multiple footnotes side by side.
 @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
+in the code and verbatim string is not processed for Org mode specific
 syntax; it is exported verbatim.
 
 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
@@ -8892,8 +9018,8 @@ Toggle the COMMENT keyword at the beginning of an entry.
 @cindex tables, markup rules
 @cindex #+CAPTION
 @cindex #+LABEL
-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,
+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.  You can use the following lines somewhere before the table to assign
 a caption and a label for cross references, and in the text you can refer to
@@ -8963,16 +9089,16 @@ 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{This works automatically for
 the HTML backend (it requires version 1.34 of the @file{htmlize.el} package,
-which is distributed with Org).  Fontified code chunks in LaTeX can be
+which is distributed with Org).  Fontified code chunks in @LaTeX{} can be
 achieved using either the listings or the
 @url{http://code.google.com/p/minted, minted,} package.  To use listings, turn
 on the variable @code{org-export-latex-listings} and ensure that the listings
-package is included by the LaTeX header (e.g.@: by configuring
+package is included by the @LaTeX{} header (e.g.@: by configuring
 @code{org-export-latex-packages-alist}).  See the listings documentation for
 configuration options, including obtaining colored output.  For minted it is
 necessary to install the program @url{http://pygments.org, pygments}, in
 addition to setting @code{org-export-latex-minted}, ensuring that the minted
-package is included by the LaTeX header, and ensuring that the
+package is included by the @LaTeX{} header, and ensuring that the
 @code{-shell-escape} option is passed to @file{pdflatex} (see
 @code{org-latex-to-pdf-process}).  See the documentation of the variables
 @code{org-export-latex-listings} and @code{org-export-latex-minted} for
@@ -8980,7 +9106,8 @@ further details.}.  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@footnote{Code in @samp{src} blocks may also be evaluated either
 interactively or on export.  See @pxref{Working With Source Code} for more
-information on evaluating code blocks.}:
+information on evaluating code blocks.}, see @ref{Easy Templates} for
+shortcuts to easily insert code blocks.
 @cindex #+BEGIN_SRC
 
 @example
@@ -9004,7 +9131,7 @@ cool.
 You can also add a @code{-r} switch which @i{removes} the labels from the
 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
 labels in the source code while using line numbers for the links, which might
-be useful to explain those in an org-mode example code.}.  With the @code{-n}
+be useful to explain those in an Org mode example code.}.  With the @code{-n}
 switch, links to these references will be labeled by the line numbers from
 the code listing, otherwise links will use the labels with no parentheses.
 Here is an example:
@@ -9070,11 +9197,11 @@ include your @file{.emacs} file, you could use:
 The optional second and third parameter are the markup (e.g.@: @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
+given, the text will be assumed to be in Org mode format and will be
 processed normally.  The include line will also allow additional keyword
 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
 first line and for each following line, @code{:minlevel} in order to get
-org-mode content demoted to a specified level, as well as any options
+Org mode content demoted to a specified level, as well as any options
 accepted by the selected markup.  For example, to include a file as an item,
 use
 
@@ -9117,7 +9244,7 @@ an index} for more information.
 
 
 
-@node Macro replacement, Embedded LaTeX, Index entries, Markup
+@node Macro replacement, Embedded @LaTeX{}, Index entries, Markup
 @section Macro replacement
 @cindex macro replacement, during export
 @cindex #+MACRO
@@ -9142,7 +9269,7 @@ Macro expansion takes place during export, and some people use it to
 construct complex HTML code.
 
 
-@node Embedded LaTeX,  , Macro replacement, Markup
+@node Embedded @LaTeX{},  , Macro replacement, Markup
 @section Embedded @LaTeX{}
 @cindex @TeX{} interpretation
 @cindex @LaTeX{} interpretation
@@ -9152,7 +9279,7 @@ include scientific notes, which often require mathematical symbols and the
 occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on
 Donald E. Knuth's @TeX{} system.  Many of the features described here as
 ``@LaTeX{}'' are really from @TeX{}, but for simplicity I am blurring this
-distinction.}  is widely used to typeset scientific documents.  Org-mode
+distinction.}  is widely used to typeset scientific documents.  Org mode
 supports embedding @LaTeX{} code into its files, because many academics are
 used to writing and reading @LaTeX{} source code, and because it can be
 readily processed to produce pretty output for a number of export backends.
@@ -9160,12 +9287,12 @@ readily processed to produce pretty output for a number of export backends.
 @menu
 * Special symbols::             Greek letters and other symbols
 * Subscripts and superscripts::  Simple syntax for raising/lowering text
-* LaTeX fragments::             Complex formulas made easy
-* Previewing LaTeX fragments::  What will this snippet look like?
+* @LaTeX{} fragments::             Complex formulas made easy
+* Previewing @LaTeX{} fragments::  What will this snippet look like?
 * CDLaTeX mode::                Speed up entering of formulas
 @end menu
 
-@node Special symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
+@node Special symbols, Subscripts and superscripts, Embedded @LaTeX{}, Embedded @LaTeX{}
 @subsection Special symbols
 @cindex math symbols
 @cindex special symbols
@@ -9178,7 +9305,7 @@ You can use @LaTeX{} macros to insert special symbols like @samp{\alpha} to
 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
 for these macros is available, just type @samp{\} and maybe a few letters,
 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
-code, Org-mode allows these macros to be present without surrounding math
+code, Org mode allows these macros to be present without surrounding math
 delimiters, for example:
 
 @example
@@ -9212,7 +9339,7 @@ buffer content which remains plain ASCII, but it overlays the UTF-8 character
 for display purposes only.
 @end table
 
-@node Subscripts and superscripts, LaTeX fragments, Special symbols, Embedded LaTeX
+@node Subscripts and superscripts, @LaTeX{} fragments, Special symbols, Embedded @LaTeX{}
 @subsection Subscripts and superscripts
 @cindex subscript
 @cindex superscript
@@ -9250,13 +9377,13 @@ In addition to showing entities as UTF-8 characters, this command will also
 format sub- and superscripts in a WYSIWYM way.
 @end table
 
-@node LaTeX fragments, Previewing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
+@node @LaTeX{} fragments, Previewing @LaTeX{} fragments, Subscripts and superscripts, Embedded @LaTeX{}
 @subsection @LaTeX{} fragments
 @cindex @LaTeX{} fragments
 
 @vindex org-format-latex-header
 Going beyond symbols and sub- and superscripts, a full formula language is
-needed.  Org-mode can contain @LaTeX{} math fragments, and it supports ways
+needed.  Org mode can contain @LaTeX{} math fragments, and it supports ways
 to process these for several export backends.  When exporting to @LaTeX{},
 the code is obviously left as it is.  When exporting to HTML, Org invokes the
 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
@@ -9309,10 +9436,10 @@ can configure the option @code{org-format-latex-options} to deselect the
 ones you do not wish to have interpreted by the @LaTeX{} converter.
 
 @vindex org-export-with-LaTeX-fragments
-LaTeX processing can be configured with the variable
+@LaTeX{} processing can be configured with the variable
 @code{org-export-with-LaTeX-fragments}.  The default setting is @code{t}
 which means @file{MathJax} for HTML, and no processing for DocBook, ASCII and
-LaTeX backends.  You can also set this variable on a per-file basis using one
+@LaTeX{} backends.  You can also set this variable on a per-file basis using one
 of these lines:
 
 @example
@@ -9322,9 +9449,9 @@ of these lines:
 #+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
 @end example
 
-@node Previewing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
-@subsection Previewing LaTeX fragments
-@cindex LaTeX fragments, preview
+@node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} fragments, Embedded @LaTeX{}
+@subsection Previewing @LaTeX{} fragments
+@cindex @LaTeX{} fragments, preview
 
 If you have @file{dvipng} installed, @LaTeX{} fragments can be processed to
 produce preview images of the typeset expressions:
@@ -9349,18 +9476,18 @@ some aspects of the preview.  In particular, the @code{:scale} (and for HTML
 export, @code{:html-scale}) property can be used to adjust the size of the
 preview images.
 
-@node CDLaTeX mode,  , Previewing LaTeX fragments, Embedded LaTeX
-@subsection Using CDLa@TeX{} to enter math
-@cindex CDLa@TeX{}
+@node CDLaTeX mode,  , Previewing @LaTeX{} fragments, Embedded @LaTeX{}
+@subsection Using CD@LaTeX{} to enter math
+@cindex CD@LaTeX{}
 
-CDLa@TeX{} mode is a minor mode that is normally used in combination with a
+CD@LaTeX{} mode is a minor mode that is normally used in combination with a
 major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
-environments and math templates.  Inside Org-mode, you can make use of
-some of the features of CDLa@TeX{} mode.  You need to install
+environments and math templates.  Inside Org mode, you can make use of
+some of the features of CD@LaTeX{} mode.  You need to install
 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
-Don't use CDLa@TeX{} mode itself under Org-mode, but use the light
-version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
+Don't use CD@LaTeX{} mode itself under Org mode, but use the light
+version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
 Org files with
 
@@ -9369,7 +9496,7 @@ Org files with
 @end lisp
 
 When this mode is enabled, the following features are present (for more
-details see the documentation of CDLa@TeX{} mode):
+details see the documentation of CD@LaTeX{} mode):
 @itemize @bullet
 @kindex C-c @{
 @item
@@ -9377,7 +9504,7 @@ Environment templates can be inserted with @kbd{C-c @{}.
 @item
 @kindex @key{TAB}
 The @key{TAB} key will do template expansion if the cursor is inside a
-@LaTeX{} fragment@footnote{Org-mode has a method to test if the cursor is
+@LaTeX{} fragment@footnote{Org mode has a method to test if the cursor is
 inside such a fragment, see the documentation of the function
 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
@@ -9414,20 +9541,20 @@ is normal.
 @chapter Exporting
 @cindex exporting
 
-Org-mode documents can be exported into a variety of other formats.  For
+Org mode documents can be exported into a variety of other formats.  For
 printing and sharing of notes, ASCII export produces a readable and simple
 version of an Org file.  HTML export allows you to publish a notes file on
 the web, while the XOXO format provides a solid base for exchange with a
-broad range of other applications.  @LaTeX{} export lets you use Org-mode and
+broad range of other applications.  @LaTeX{} export lets you use Org mode and
 its structured editing functions to easily create @LaTeX{} files.  DocBook
 export makes it possible to convert Org files to many other formats using
-DocBook tools.  OpenDocumentText export allows seamless collaboration across
-organizational boundaries.  For project management you can create gantt and
-resource charts by using TaskJuggler export.  To incorporate entries with
-associated times like deadlines or appointments into a desktop calendar
-program like iCal, Org-mode can also produce extracts in the iCalendar
-format.  Currently Org-mode only supports export, not import of these
-different formats.
+DocBook tools.  OpenDocument Text(@acronym{ODT}) export allows seamless
+colloboration across organizational boundaries.  For project management you
+can create gantt and resource charts by using TaskJuggler export.  To
+incorporate entries with associated times like deadlines or appointments into
+a desktop calendar program like iCal, Org mode can also produce extracts in
+the iCalendar format.  Currently Org mode only supports export, not import of
+these different formats.
 
 Org supports export of selected regions when @code{transient-mark-mode} is
 enabled (default in Emacs 23).
@@ -9438,9 +9565,9 @@ enabled (default in Emacs 23).
 * The export dispatcher::       How to access exporter commands
 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
 * HTML export::                 Exporting to HTML
-* LaTeX and PDF export::        Exporting to @LaTeX{}, and processing to PDF
+* @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
 * DocBook export::              Exporting to DocBook
-* OpenDocumentText export::     Exporting to OpenDocumentText
+* OpenDocument Text export::    Exporting to OpenDocument Text
 * TaskJuggler export::          Exporting to TaskJuggler
 * Freemind export::             Exporting to Freemind mind maps
 * XOXO export::                 Exporting to XOXO
@@ -9456,7 +9583,8 @@ enabled (default in Emacs 23).
 @cindex org-export-with-tasks
 You may use tags to select the parts of a document that should be exported,
 or to exclude parts from export.  This behavior is governed by two variables:
-@code{org-export-select-tags} and @code{org-export-exclude-tags}.
+@code{org-export-select-tags} and @code{org-export-exclude-tags},
+respectively defaulting to @code{'(:export:)} and @code{'(:noexport:)}.
 
 @enumerate
 @item
@@ -9517,10 +9645,11 @@ Insert template with export options, see example below.
 @vindex user-full-name
 @vindex user-mail-address
 @vindex org-export-default-language
+@vindex org-export-date-timestamp-format
 @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, or a format string for @code{format-time-string}
+#+DATE:        a date, an Org timestamp@footnote{@code{org-export-date-timestamp-format} defines how this timestamp will be exported.}, or a format string for @code{format-time-string}
 #+EMAIL:       his/her email address (default from @code{user-mail-address})
 #+DESCRIPTION: the page description, e.g.@: for the XHTML meta tag
 #+KEYWORDS:    the page keywords, e.g.@: for the XHTML meta tag
@@ -9528,19 +9657,19 @@ Insert template with export options, see example below.
 #+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 ...
-#+BIND:        lisp-var lisp-val, e.g.@:: org-export-latex-low-levels itemize
+#+BIND:        lisp-var lisp-val, e.g.@:: @code{org-export-latex-low-levels itemize}
                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
 #+LINK_UP:     the ``up'' link of an exported page
 #+LINK_HOME:   the ``home'' link of an exported page
-#+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
+#+LATEX_HEADER: extra line(s) for the @LaTeX{} header, like \usepackage@{xyz@}
 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
 #+XSLT:        the XSLT stylesheet used by DocBook exporter to generate FO file
 @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
+The @code{#+OPTIONS} line is a compact@footnote{If you want to configure many options
+this way, you can use several @code{#+OPTIONS} lines.} form to specify export
 settings.  Here you can:
 @cindex headline levels
 @cindex section-numbers
@@ -9642,7 +9771,7 @@ not set, or force processing in the current Emacs process if set.
 @cindex Latin-1 export
 @cindex UTF-8 export
 
-ASCII export produces a simple and very readable version of an Org-mode
+ASCII export produces a simple and very readable version of an Org mode
 file, containing only plain ASCII.  Latin-1 and UTF-8 export augment the file
 with special characters and symbols available in these encodings.
 
@@ -9697,18 +9826,18 @@ Links will be exported in a footnote-like style, with the descriptive part in
 the text and the link in a note before the next heading.  See the variable
 @code{org-export-ascii-links-to-notes} for details and other options.
 
-@node HTML export, LaTeX and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
+@node HTML export, @LaTeX{} and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
 @section HTML export
 @cindex HTML export
 
-Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
+Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
 HTML formatting, in ways similar to John Gruber's @emph{markdown}
 language, but with additional support for tables.
 
 @menu
 * HTML Export commands::        How to invoke HTML export
 * HTML preamble and postamble::  How to insert a preamble and a postamble
-* Quoting HTML tags::           Using direct HTML in Org-mode
+* Quoting HTML tags::           Using direct HTML in Org mode
 * Links in HTML export::        How links will be interpreted and formatted
 * Tables in HTML export::       How to modify the formatting of tables
 * Images in HTML export::       How to insert figures into HTML output
@@ -9746,11 +9875,11 @@ the region.  This is good for cut-and-paste operations.
 @item C-c C-e v h/b/H/R
 Export only the visible part of the document.
 @item M-x org-export-region-as-html
-Convert the region to HTML under the assumption that it was Org-mode
+Convert the region to HTML under the assumption that it was Org mode
 syntax before.  This is a global command that can be invoked in any
 buffer.
 @item M-x org-replace-region-by-HTML
-Replace the active region (assumed to be in Org-mode syntax) by HTML
+Replace the active region (assumed to be in Org mode syntax) by HTML
 code.
 @end table
 
@@ -9852,7 +9981,7 @@ and @code{style} attributes for a link:
 
 @cindex #+ATTR_HTML
 @example
-#+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
+#+ATTR_HTML: title="The Org mode homepage" style="color:red;"
 [[http://orgmode.org]]
 @end example
 
@@ -9861,7 +9990,7 @@ and @code{style} attributes for a link:
 @cindex tables, in HTML
 @vindex org-export-html-table-tag
 
-Org-mode tables are exported to HTML using the table tag defined in
+Org mode tables are exported to HTML using the table tag defined in
 @code{org-export-html-table-tag}.  The default setting makes tables without
 cell borders and frame.  If you would like to change this for individual
 tables, place something like the following before the table:
@@ -9870,7 +9999,7 @@ tables, place something like the following before the table:
 @cindex #+ATTR_HTML
 @example
 #+CAPTION: This is a table with lines around and between cells
-#+ATTR_HTML: border="2" rules="all" frame="all"
+#+ATTR_HTML: border="2" rules="all" frame="border"
 @end example
 
 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
@@ -9915,11 +10044,11 @@ You could use @code{http} addresses just as well.
 @cindex MathJax
 @cindex dvipng
 
-@LaTeX{} math snippets (@pxref{LaTeX fragments}) can be displayed in two
+@LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
 different ways on HTML pages.  The default is to use the
 @uref{http://www.mathjax.org, MathJax system} which should work out of the
 box with Org mode installation because @code{http://orgmode.org} serves
-@file{MathJax} for Org-mode users for small applications and for testing
+@file{MathJax} for Org mode users for small applications and for testing
 purposes.  @b{If you plan to use this regularly or on pages with significant
 page views, you should install@footnote{Installation instructions can be
 found on the MathJax website, see
@@ -9985,7 +10114,7 @@ addition to any of the standard classes like for headlines, tables, etc.
 @example
 p.author            @r{author information, including email}
 p.date              @r{publishing date}
-p.creator           @r{creator info, about org-mode version}
+p.creator           @r{creator info, about org mode version}
 .title              @r{document title}
 .todo               @r{TODO keywords, all not-done states}
 .done               @r{the DONE keywords, all states that count as done}
@@ -10111,16 +10240,16 @@ You can choose default values for these options by customizing the variable
 @code{org-infojs-options}.  If you always want to apply the script to your
 pages, configure the variable @code{org-export-html-use-infojs}.
 
-@node LaTeX and PDF export, DocBook export, HTML export, Exporting
+@node @LaTeX{} and PDF export, DocBook export, HTML export, Exporting
 @section @LaTeX{} and PDF export
 @cindex @LaTeX{} export
 @cindex PDF export
 @cindex Guerry, Bastien
 
-Org-mode contains a @LaTeX{} exporter written by Bastien Guerry.  With
-further processing@footnote{The default LaTeX output is designed for
-processing with pdftex or latex.  It includes packages that are not
-compatible with xetex and possibly luatex.  See the variables
+Org mode contains a @LaTeX{} exporter written by Bastien Guerry.  With
+further processing@footnote{The default @LaTeX{} output is designed for
+processing with @code{pdftex} or @LaTeX{}.  It includes packages that are not
+compatible with @code{xetex} and possibly @code{luatex}.  See the variables
 @code{org-export-latex-default-packages-alist} and
 @code{org-export-latex-packages-alist}.}, this backend is also used to
 produce PDF output.  Since the @LaTeX{} output uses @file{hyperref} to
@@ -10130,15 +10259,15 @@ structured in order to be correctly exported: respect the hierarchy of
 sections.
 
 @menu
-* LaTeX/PDF export commands::   Which key invokes which commands
+* @LaTeX{}/PDF export commands::
 * Header and sectioning::       Setting up the export file structure
-* Quoting LaTeX code::          Incorporating literal @LaTeX{} code
-* Tables in LaTeX export::      Options for exporting tables to @LaTeX{}
-* Images in LaTeX export::      How to insert figures into @LaTeX{} output
+* Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
+* Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
+* Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
 * Beamer class export::         Turning the file into a presentation
 @end menu
 
-@node LaTeX/PDF export commands, Header and sectioning, LaTeX and PDF export, LaTeX and PDF export
+@node @LaTeX{}/PDF export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export
 @subsection @LaTeX{} export commands
 
 @cindex region, active
@@ -10160,11 +10289,11 @@ Export to a temporary buffer.  Do not create a file.
 @item C-c C-e v l/L
 Export only the visible part of the document.
 @item M-x org-export-region-as-latex
-Convert the region to @LaTeX{} under the assumption that it was Org-mode
+Convert the region to @LaTeX{} under the assumption that it was Org mode
 syntax before.  This is a global command that can be invoked in any
 buffer.
 @item M-x org-replace-region-by-latex
-Replace the active region (assumed to be in Org-mode syntax) by @LaTeX{}
+Replace the active region (assumed to be in Org mode syntax) by @LaTeX{}
 code.
 @orgcmd{C-c C-e p,org-export-as-pdf}
 Export as @LaTeX{} and then process to PDF.
@@ -10190,13 +10319,13 @@ with a numeric prefix argument.  For example,
 @noindent
 creates two levels of headings and does the rest as items.
 
-@node Header and sectioning, Quoting LaTeX code, LaTeX/PDF export commands, LaTeX and PDF export
+@node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{}/PDF export commands, @LaTeX{} and PDF export
 @subsection Header and sectioning structure
 @cindex @LaTeX{} class
 @cindex @LaTeX{} sectioning structure
 @cindex @LaTeX{} header
-@cindex header, for LaTeX files
-@cindex sectioning structure, for LaTeX export
+@cindex header, for @LaTeX{} files
+@cindex sectioning structure, for @LaTeX{} export
 
 By default, the @LaTeX{} output uses the class @code{article}.
 
@@ -10224,10 +10353,10 @@ can also use @code{#+LATEX_HEADER: \usepackage@{xyz@}} to add lines to the
 header.  See the docstring of @code{org-export-latex-classes} for more
 information.
 
-@node Quoting LaTeX code, Tables in LaTeX export, Header and sectioning, LaTeX and PDF export
+@node Quoting @LaTeX{} code, Tables in @LaTeX{} export, Header and sectioning, @LaTeX{} and PDF export
 @subsection Quoting @LaTeX{} code
 
-Embedded @LaTeX{} as described in @ref{Embedded LaTeX}, will be correctly
+Embedded @LaTeX{} as described in @ref{Embedded @LaTeX{}}, will be correctly
 inserted into the @LaTeX{} file.  This includes simple macros like
 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
 you can add special code that should only be present in @LaTeX{} export with
@@ -10236,7 +10365,7 @@ the following constructs:
 @cindex #+LaTeX
 @cindex #+BEGIN_LaTeX
 @example
-#+LaTeX: Literal LaTeX code for export
+#+LaTeX: Literal @LaTeX{} code for export
 @end example
 
 @noindent or
@@ -10249,7 +10378,7 @@ All lines between these markers are exported literally
 @end example
 
 
-@node Tables in LaTeX export, Images in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
+@node Tables in @LaTeX{} export, Images in @LaTeX{} export, Quoting @LaTeX{} code, @LaTeX{} and PDF export
 @subsection Tables in @LaTeX{} export
 @cindex tables, in @LaTeX{} export
 
@@ -10286,7 +10415,7 @@ or to specify a multicolumn table with @code{tabulary}
 | ..... | ..... |
 @end example
 
-@node Images in LaTeX export, Beamer class export, Tables in LaTeX export, LaTeX and PDF export
+@node Images in @LaTeX{} export, Beamer class export, Tables in @LaTeX{} export, @LaTeX{} and PDF export
 @subsection Images in @LaTeX{} export
 @cindex images, inline in @LaTeX{}
 @cindex inlining images in @LaTeX{}
@@ -10337,14 +10466,14 @@ will export the image wrapped in a @code{figure*} environment.
 If you need references to a label created in this way, write
 @samp{\ref@{fig:SED-HR4049@}} just like in @LaTeX{}.
 
-@node Beamer class export,  , Images in LaTeX export, LaTeX and PDF export
+@node Beamer class export,  , Images in @LaTeX{} export, @LaTeX{} and PDF export
 @subsection Beamer class export
 
-The LaTeX class @file{beamer} allows production of high quality presentations
-using LaTeX and pdf processing.  Org-mode has special support for turning an
-Org-mode file or tree into a @file{beamer} presentation.
+The @LaTeX{} class @file{beamer} allows production of high quality presentations
+using @LaTeX{} and pdf processing.  Org mode has special support for turning an
+Org mode file or tree into a @file{beamer} presentation.
 
-When the LaTeX class for the current buffer (as set with @code{#+LaTeX_CLASS:
+When the @LaTeX{} class for the current buffer (as set with @code{#+LaTeX_CLASS:
 beamer}) or subtree (set with a @code{LaTeX_CLASS} property) is
 @code{beamer}, a special export mode will turn the file or tree into a beamer
 presentation.  Any tree with not-too-deep level nesting should in principle be
@@ -10464,7 +10593,7 @@ Here is a simple example Org document that is intended for beamer export.
 
 For more information, see the documentation on Worg.
 
-@node DocBook export, OpenDocumentText export, LaTeX and PDF export, Exporting
+@node DocBook export, OpenDocument Text export, @LaTeX{} and PDF export, Exporting
 @section DocBook export
 @cindex DocBook export
 @cindex PDF export
@@ -10620,7 +10749,7 @@ set:
 @cindex #+LABEL
 @cindex #+ATTR_DOCBOOK
 @example
-#+CAPTION:    The logo of Org-mode
+#+CAPTION:    The logo of Org mode
 #+LABEL:      unicorn-svg
 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
 [[./img/org-mode-unicorn.svg]]
@@ -10663,39 +10792,46 @@ special characters included in XHTML entities:
 
 @c begin opendocument
 
-@node OpenDocumentText export, TaskJuggler export, DocBook export, Exporting
-@section OpenDocumentText export
-@cindex OpenDocumentText export
+@node OpenDocument Text export, TaskJuggler export, DocBook export, Exporting
+@section OpenDocument Text export
 @cindex K, Jambunathan
-
-Org-mode 7.6 supports export to OpenDocumentText format using
-@file{org-odt.el} module contributed by Jambunathan K.  This module can be
-enabled in one of the following ways based on your mode of installation.
-
-@enumerate
-@item
-If you have downloaded the Org from the Web, either as a distribution
-@file{.zip} or @file{.tar} file, or as a Git archive, enable the @code{odt}
-option in variable @code{org-modules}.
-@item
-If you are using Org that comes bundled with Emacs, then you can install the
-OpenDocumentText exporter using the package manager.  To do this, customize
-the variable @code{package-archives} to include
-@uref{http://orgmode.org/pkg/releases/} as one of the package archives.
-@end enumerate
+@cindex ODT
+@cindex OpenDocument
+@cindex export, OpenDocument
+@cindex LibreOffice
+@cindex org-odt.el
+@cindex org-modules
+
+Orgmode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
+(@acronym{ODT}) format using the @file{org-odt.el} module.  Documents created
+by this exporter use the @cite{OpenDocument-v1.2
+specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
+Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
+are compatible with LibreOffice 3.4.
 
 @menu
-* OpenDocumentText export commands::How to invoke OpenDocumentText export
-* Applying Custom Styles::      How to apply custom styles to the output
-* Converting to Other formats:: How to convert to formats like doc, docx etc
-* Links in OpenDocumentText export::  How links will be interpreted and formatted
-* Tables in OpenDocumentText export::    Tables are exported as HTML tables
-* Images in OpenDocumentText export::    How to insert figures into DocBook output
-* Additional Documentation::    Where to find more information
+* Pre-requisites for @acronym{ODT} export::  What packages @acronym{ODT} exporter relies on
+* @acronym{ODT} export commands::  How to invoke @acronym{ODT} export
+* Applying custom styles::      How to apply custom styles to the output
+* Links in @acronym{ODT} export::  How links will be interpreted and formatted
+* Tables in @acronym{ODT} export::  How Tables are exported
+* Images in @acronym{ODT} export::  How to insert images
+* Math formatting in @acronym{ODT} export::  How @LaTeX{} fragments are formatted
+* Literal examples in @acronym{ODT} export::  How source and example blocks are formatted
+* Advanced topics in @acronym{ODT} export::  Read this if you are a power user
 @end menu
 
-@node OpenDocumentText export commands, Applying Custom Styles, OpenDocumentText export, OpenDocumentText export
-@subsection OpenDocumentText export commands
+@node Pre-requisites for @acronym{ODT} export, @acronym{ODT} export commands, OpenDocument Text export, OpenDocument Text export
+@subsection Pre-requisites for @acronym{ODT} export
+@cindex zip
+The @acronym{ODT} exporter relies on the @file{zip} program to create the final
+output.  Check the availability of this program before proceeding further.
+
+@node @acronym{ODT} export commands, Applying custom styles, Pre-requisites for @acronym{ODT} export, OpenDocument Text export
+@subsection @acronym{ODT} export commands
+
+@subsubheading Exporting to @acronym{ODT}
+@anchor{x-export-to-odt}
 
 @cindex region, active
 @cindex active region
@@ -10703,113 +10839,791 @@ the variable @code{package-archives} to include
 @table @kbd
 @orgcmd{C-c C-e o,org-export-as-odt}
 @cindex property EXPORT_FILE_NAME
-Export as OpenDocumentText file.  For an Org file, @file{myfile.org}, the
-OpenDocumentText file will be @file{myfile.odt}.  The file will be
-overwritten without warning.  If there is an active region@footnote{This
-requires @code{transient-mark-mode} to be turned on}, 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.
+
+Export as OpenDocument Text file.
+@vindex org-export-odt-preferred-output-format
+If @code{org-export-odt-preferred-output-format} is specified, automatically
+convert the exported file to that format.
+@xref{x-export-to-other-formats,,Automatically exporting to other formats}.
+
+For an Org file @file{myfile.org}, the @acronym{ODT} file will be
+@file{myfile.odt}.  The file will be overwritten without warning.  If there
+is an active region,@footnote{This requires @code{transient-mark-mode} to be
+turned on} 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.
+
 @orgcmd{C-c C-e O,org-export-as-odt-and-open}
-Export as OpenDocumentText file and open the resulting file.
+Export as OpenDocument Text file and open the resulting file.
+@vindex org-export-odt-preferred-output-format
+If @code{org-export-odt-preferred-output-format} is specified, open the
+converted file instead.
+@xref{x-export-to-other-formats,,Automatically exporting to other formats}.
 @end table
 
-@node Applying Custom Styles, Converting to Other formats, OpenDocumentText export commands, OpenDocumentText export
-@subsection Applying Custom Styles
+@subsubheading Automatically exporting to other formats
+@anchor{x-export-to-other-formats}
+@vindex org-export-odt-preferred-output-format
+Very often, you will find yourself exporting to @acronym{ODT} format, only to
+immediately save the exported document to a different format like @samp{pdf}.
+In such cases, you will find it convenient to configure a converter
+(@pxref{Exporting and converting to other formats}) and specify your
+preferred output format by customizing the variable
+@code{org-export-odt-preferred-output-format}.  This way, the export commands
+(@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to also export to
+the preferred format.
+
+@node Applying custom styles, Links in @acronym{ODT} export, @acronym{ODT} export commands, OpenDocument Text export
+@subsection Applying custom styles
 @cindex styles, custom
 @cindex template, custom
 
-@vindex org-export-odt-styles-file
+The @acronym{ODT} exporter ships with a set of OpenDocument styles
+(@pxref{Working with OpenDocument style files}) that ensure a well-formatted
+output.  These factory styles, however, may not cater to your specific
+tastes.  To customize the output, you can either modify the above styles
+files directly, or generate the required styles using an application like
+LibreOffice.  The latter method is suitable for expert and non-expert
+users alike, and is described here.
 
-OpenDocumentExporter ships with a custom @file{styles.xml} for formatting of
-the exported file.  To customize the output to suit your needs you can use
-one of the following methods:
+@subsubsection Applying custom styles - the easy way
 
 @enumerate
 @item
-Customize the variable @code{org-export-odt-styles-file} to point to either a
-@file{styles.xml} file, a OpenDocument Text Template file @code{.ott} or a
-combination of Text or Template Document together with a set of member files.
-Use the first two options if the styles.xml has no references to additional
-set of files and use the last option if the @file{styles.xml} references
-additional files like header and footer images.
+Create a sample @file{example.org} file with the below settings and export it
+to @acronym{ODT} format.
+
+@example
+#+OPTIONS: H:10 num:t
+@end example
+
+@item
+Open the above @file{example.odt} using LibreOffice.  Use the @file{Stylist}
+to locate the target styles - these typically have the @samp{Org} prefix -
+and modify those to your taste.  Save the modified file either as an
+OpenDocument Text (@file{.odt}) or OpenDocument Template (@file{.ott}) file.
+
 @item
-Use an external tool like unoconv to apply custom templates.
+@cindex #+ODT_STYLES_FILE
+@vindex org-export-odt-styles-file
+Customize the variable @code{org-export-odt-styles-file} and point it to the
+newly created file.  For additional configuration options
+@pxref{x-overriding-factory-styles,,Overriding factory styles}.
+
+If you would like to choose a style on a per-file basis, you can use the
+@code{#+ODT_STYLES_FILE} option.  A typical setting will look like
+
+@example
+#+ODT_STYLES_FILE: "/path/to/example.ott"
+@end example
+
+or
+
+@example
+#+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
+@end example
+
 @end enumerate
 
-For best results, it is necessary that the style names used by
-OpenDocumentText exporter match that used in the @file{styles.xml}.
+@subsubsection Using third-party styles and templates
+
+You can use third-party styles and templates for customizing your output.
+This will produce the desired output only if the template provides all
+style names that the @samp{ODT} exporter relies on.  Unless this condition is
+met, the output is going to be less than satisfactory.  So it is highly
+recommended that you only work with templates that are directly derived from
+the factory settings.
+
+@node Links in @acronym{ODT} export, Tables in @acronym{ODT} export, Applying custom styles, OpenDocument Text export
+@subsection Links in @acronym{ODT} export
+@cindex tables, in DocBook export
+
+The @acronym{ODT} exporter creates cross-references (aka bookmarks) for
+internal links.  It creates Internet-style links for all other links.
+
+@node Tables in @acronym{ODT} export, Images in @acronym{ODT} export, Links in @acronym{ODT} export, OpenDocument Text export
+@subsection Tables in @acronym{ODT} export
+@cindex tables, in DocBook export
 
-@node Converting to Other formats, Links in OpenDocumentText export, Applying Custom Styles, OpenDocumentText export
-@subsection Converting to Other formats
+Export of native Org mode tables (@pxref{Tables}) and simple @file{table.el}
+tables is supported.  However, export of complex @file{table.el} tables -
+tables that have column or row spans - is not supported.  Such tables are
+stripped from the exported document.
 
+By default, a table is exported with top and bottom frames and with
+rules separating row and column groups (@pxref{Column groups}).  If the table
+specifies alignment and relative width for its columns (@pxref{Column width
+and alignment}) then these are honored on export.@footnote{The column widths
+are interpreted as weighted ratios with the default weight being 1}
+
+@cindex #+ATTR_ODT
+If you are not satisfied with the default formatting of tables, you can
+create custom table styles and associate them with a table using
+the @code{#+ATTR_ODT} line.  @xref{Customizing tables in @acronym{ODT} export}.
+
+@node Images in @acronym{ODT} export, Math formatting in @acronym{ODT} export, Tables in @acronym{ODT} export, OpenDocument Text export
+@subsection Images in @acronym{ODT} export
+@cindex images, embedding in @acronym{ODT}
+@cindex embedding images in @acronym{ODT}
+
+@subsubheading Embedding images
+You can embed images within the exported document by providing a link to the
+desired image file with no link description.  For example, to embed
+@samp{img.png} do either of the following:
+
+@example
+[[file:img.png]]
+@end example
+
+@example
+[[./img.png]]
+@end example
+
+@subsubheading Embedding clickable images
+You can create clickable images by providing a link whose description is a
+link to an image file.  For example, to embed a image
+@file{org-mode-unicorn.png} which when clicked jumps to
+@uref{http://Orgmode.org} website, do the following
+
+@example
+[[http://orgmode.org][./org-mode-unicorn.png]]
+@end example
+
+@subsubheading Sizing and scaling of embedded images
+
+You can control the size and scale of the embedded images using the
+@code{#+ATTR_ODT} attribute.
+
+@vindex org-export-odt-pixels-per-inch
+Note that the exporter specifies the desired size of the image in the final
+document in units of centimetres.  In order to scale the embedded images, the
+exporter needs to compute the size of the image.  This is done by retrieving
+the image size in pixels and converting the pixel units to centimetres using
+@code{org-export-odt-pixels-per-inch}.  The default value of this variable is
+set to @code{display-pixels-per-inch}.  You can tweak this variable to
+achieve the best results.
+
+The examples below illustrate the various possibilities.
+
+@table @asis
+
+@item Explicitly size the image
+To embed @file{img.png} as a 10 cm x 10 cm image, do the following:
+
+@example
+#+ATTR_ODT: :width 10 :height 10
+[[./img.png]]
+@end example
+
+@item Scale the image
+To embed @file{img.png} at half its size, do the following:
+
+@example
+#+ATTR_ODT: :scale 0.5
+[[./img.png]]
+@end example
+
+@item Scale the image to a specific width
+To embed @file{img.png} with a width of 10 cm while retaining the original
+height:width ratio, do the following:
+
+@example
+#+ATTR_ODT: :width 10
+[[./img.png]]
+@end example
+
+@item Scale the image to a specific height
+To embed @file{img.png} with a height of 10 cm while retaining the original
+height:width ratio, do the following
+
+@example
+#+ATTR_ODT: :height 10
+[[./img.png]]
+@end example
+@end table
+
+@node Math formatting in @acronym{ODT} export, Literal examples in @acronym{ODT} export, Images in @acronym{ODT} export, OpenDocument Text export
+@subsection Math formatting in @acronym{ODT} export
+
+The @acronym{ODT} exporter has special support for handling math.
+
+@menu
+* Working with @LaTeX{} math snippets::  How to embed @LaTeX{} math fragments
+* Working with MathML or OpenDocument formula files::  How to embed equations in native format
+@end menu
+
+@node Working with @LaTeX{} math snippets, Working with MathML or OpenDocument formula files, Math formatting in @acronym{ODT} export, Math formatting in @acronym{ODT} export
+@subsubsection Working with @LaTeX{} math snippets
+
+@LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be embedded in the ODT
+document in one of the following ways:
+
+@cindex MathML
+@enumerate
+@item MathML
+
+This option is activated on a per-file basis with
+
+@example
+#+OPTIONS: LaTeX:t
+@end example
+
+With this option, @LaTeX{} fragments are first converted into MathML
+fragments using an external @LaTeX{}-to-MathML converter program.  The
+resulting MathML fragments are then embedded as an OpenDocument Formula in
+the exported document.
+
+@vindex org-latex-to-mathml-convert-command
+@vindex org-latex-to-mathml-jar-file
+
+You can specify the @LaTeX{}-to-MathML converter by customizing the variables
+@code{org-latex-to-mathml-convert-command} and
+@code{org-latex-to-mathml-jar-file}.
+
+If you prefer to use @file{MathToWeb}@footnote{See
+@uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}} as your
+converter, you can configure the above variables as shown below.
+
+@lisp
+(setq org-latex-to-mathml-convert-command
+      "java -jar %j -unicode -force -df %o %I"
+      org-latex-to-mathml-jar-file
+      "/path/to/mathtoweb.jar")
+@end lisp
+
+You can use the following commands to quickly verify the reliability of
+the @LaTeX{}-to-MathML converter.
+
+@table @kbd
+
+@item M-x org-export-as-odf
+Convert a @LaTeX{} math snippet to OpenDocument formula (@file{.odf}) file.
+
+@item M-x org-export-as-odf-and-open
+Convert a @LaTeX{} math snippet to OpenDocument formula (@file{.odf}) file and
+open the formula file with the system-registered application.
+@end table
+
+@cindex dvipng
+@item PNG images
+
+This option is activated on a per-file basis with
+
+@example
+#+OPTIONS: LaTeX:dvipng
+@end example
+
+With this option, @LaTeX{} fragments are processed into PNG images and the
+resulting images are embedded in the exported document.  This method requires
+that the @file{dvipng} program be available on your system.
+@end enumerate
+
+@node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in @acronym{ODT} export
+@subsubsection Working with MathML or OpenDocument formula files
+
+For various reasons, you may find embedding @LaTeX{} math snippets in an
+@acronym{ODT} document less than reliable.  In that case, you can embed a
+math equation by linking to its MathML(@file{.mml}) source or its
+OpenDocument formula (@file{.odf}) file as shown below:
+
+@example
+[[./equation.mml]]
+@end example
+
+or
+
+@example
+[[./equation.odf]]
+@end example
+
+@node Literal examples in @acronym{ODT} export, Advanced topics in @acronym{ODT} export, Math formatting in @acronym{ODT} export, OpenDocument Text export
+@subsection Literal examples in @acronym{ODT} export
+
+Export of literal examples (@pxref{Literal examples}) with full fontification
+is supported.  This feature is enabled by default and is activated
+automatically if an enhanced version of @file{htmlfontify.el} is available in
+the @code{load-path}.@footnote{The @file{htmlfontify.el} that ships with
+standard Emacs <= 24.1 has no support for @acronym{ODT} fontification.  A
+copy of the proposed version is available as an attachment to
+@url{http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;filename=htmlfontify.el;att=9;bug=9914,
+Emacs Bug #9914}.}
+
+@vindex org-export-odt-fontify-srcblocks
+
+The character styles used for fontification of the literal blocks are
+auto-generated by the exporter in conjunction with @file{htmlfontify.el}
+library and need not be included in the default @file{styles.xml} file.
+These auto-generated styles have the @samp{OrgSrc} prefix and inherit their color
+based on the face used by Emacs @code{font-lock} library.
+
+@vindex org-export-odt-create-custom-styles-for-srcblocks
+If you prefer to use your own custom styles for fontification and disable
+their auto-generation altogether, you can do so by customizing the variable
+@code{org-export-odt-create-custom-styles-for-srcblocks}.
+
+You can turn off fontification support for literal examples by customizing
+the variable @code{org-export-odt-fontify-srcblocks}.
+
+
+@node Advanced topics in @acronym{ODT} export,  , Literal examples in @acronym{ODT} export, OpenDocument Text export
+@subsection Advanced topics in @acronym{ODT} export
+
+If you rely heavily on @acronym{ODT} export, you may want to exploit the full
+set of features that the exporter offers.  This section describes features
+that would be of interest to power users.
+
+@menu
+* Exporting and converting to other formats::  How to produce @samp{pdf} and other formats
+* Working with OpenDocument style files::  Explore the internals
+* Creating one-off styles::     How to produce custom highlighting etc
+* Customizing tables in @acronym{ODT} export::  How to define and use Table templates
+* Validating OpenDocument XML::  How to debug corrupt OpenDocument files
+@end menu
+
+@node Exporting and converting to other formats, Working with OpenDocument style files, Advanced topics in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
+@subsubsection Exporting and converting to other formats
 @cindex convert
 @cindex doc, docx
 
-@vindex org-export-odt-styles-file
-
-Often times there is a need to convert OpenDocumentText files to other
-formats like doc, docx or pdf.  You can accomplish this by one of the
-following methods:
+The @acronym{ODT} exporter adds support for exporting Org outlines to formats
+that are not supported natively by Org.  It also adds support to convert
+document from one format to another.  To use these features, you need to
+configure a command-line converter.  Once a command-line converter is
+configured you can use it to extend the list of formats to which Org can
+export.  @xref{x-export-to-other-formats,,Automatically exporting to other
+formats}.  You can also use it to perform one-off document conversion as
+detailed below.
 
+@vindex org-export-odt-convert
 @table @kbd
-@item M-x org-lparse
-Export the outline first to one of the native formats (like OpenDocumentText)
-and immediately post-process it to other formats using an external converter.
 
-@item M-x org-lparse-convert
-Export an existing document to other formats using an external converter.
+@item M-x org-export-odt-convert
+Convert an existing document from one format to another as determined by the
+variable @code{org-export-odt-convert-capabilities}
+(@pxref{x-odt-converter-capabilities,,Configure converter
+capabilities}).  @strong{Please note} that you can use this command to even
+convert documents that are produced outside of Org and in other formats than
+@acronym{ODT} format.
 @end table
 
-You can choose the converter used for conversion by customizing the variable
-@code{org-lparse-convert-process}.
+@subsubheading Pre-configured converters
 
-@node Links in OpenDocumentText export, Tables in OpenDocumentText export, Converting to Other formats, OpenDocumentText export
-@subsection Links in OpenDocumentText export
-@cindex tables, in DocBook export
+@cindex converter
+The @acronym{ODT} exporter supports two converters out of the box:
 
-OpenDocumentExporter creates cross-references (aka bookmarks) for links that
-are destined locally.  It creates internet style links for all other links.
+@enumerate
 
-@node Tables in OpenDocumentText export, Images in OpenDocumentText export, Links in OpenDocumentText export, OpenDocumentText export
-@subsection Tables in OpenDocumentText export
-@cindex tables, in DocBook export
+@cindex @file{unoconv}
+@item @file{unoconv}
 
-Export of @file{table.el} tables with row or column spanning is not
-supported.  Such tables are stripped from the exported document.
+This converter is available as an installable package in your favorite
+distribution.
 
-@node Images in OpenDocumentText export, Additional Documentation, Tables in OpenDocumentText export, OpenDocumentText export
-@subsection Images in OpenDocumentText export
-@cindex images, embedding in OpenDocumentText
-@cindex embedding images in OpenDocumentText
+@cindex @file{BasicODConverter}
+@item @file{BasicODConverter}
 
-OpenDocumentText exporter can embed images within the exported document.  To
-embed images, provide a link to the desired image file with no link
-description.  For example, the following links @samp{[[file:img.jpg]]} or
-@samp{[[./img.jpg]]}, will result in embedding of @samp{img.jpg} in the
-exported file.
+@vindex org-odt-data-dir
+This converter is distributed as a LibreOffice extension and can be found in
+your Org distribution.  See the subdirectory pointed to by the variable
+@code{org-odt-data-dir}.
 
-The exporter can also embed scaled and explicitly sized images within the
-exported document.  The markup of the scale and size specifications has not
-been standardized yet and is hence conveniently skipped in this document.
+@end enumerate
+
+@subsubheading Installing a new converter
+If you prefer to use a converter other than the two mentioned above, then you
+may have to do additional configuration.  You can proceed as follows:
+
+@enumerate
+@item Register the converter
+
+@vindex org-export-odt-convert-processes
+Name your converter and add it to the list of known converters by customizing
+the variable @code{org-export-odt-convert-processes}.  Also specify how the
+converter can be invoked via command-line to effect the conversion.
+
+@item Configure its capabilities
+@vindex org-export-odt-convert-capabilities
 
-The exporter can also make an image the clickable part of a link.  To create
-clickable images, provide a link whose description is a link to an image
-file.  For example, the following link
-@samp{[[http://orgmode.org][./img.jpg]]}, will result in a clickable image
-that links to @uref{http://Orgmode.org} website.
+@anchor{x-odt-converter-capabilities}
 
-@node Additional Documentation, , Images in OpenDocumentText export, OpenDocumentText export
-@subsection Additional documentation
+Specify the set of formats the converter can handle by customizing the
+variable @code{org-export-odt-convert-capabilities}.  Use the default value
+for this variable as a guide for configuring your converter.  As suggested by
+the default setting, you can specify the full set of formats supported by the
+converter and not limit yourself to specifying formats that are related to
+just the OpenDocument Text format.
+
+@item Choose the converter
+
+@vindex org-export-odt-convert-process
+Select the newly added converter as the preferred one by customizing the
+variable @code{org-export-odt-convert-process}.
+@end enumerate
+
+@node Working with OpenDocument style files, Creating one-off styles, Exporting and converting to other formats, Advanced topics in @acronym{ODT} export
+@subsubsection Working with OpenDocument style files
+@cindex styles, custom
+@cindex template, custom
 
-The OpenDocumentText exporter is still in development.  For up to date
-information, please follow Org mailing list @email{emacs-orgmode@@gnu.org}
-closely.
+This section explores the internals of the @acronym{ODT} exporter and the
+means by which it produces styled documents.  Read this section if you are
+interested in exploring the automatic and custom OpenDocument styles used by
+the exporter.
+
+@anchor{x-factory-styles}
+@subsubheading Factory styles
+
+The @acronym{ODT} exporter relies on two files for generating its output.
+These files are bundled with the distribution under the directory pointed to
+by the variable @code{org-odt-styles-dir}.  The two files are:
+
+@itemize
+@anchor{x-orgodtstyles-xml}
+@item
+@file{OrgOdtStyles.xml}
+
+This file contributes to the @file{styles.xml} file of the final @samp{ODT}
+document.  This file gets modified for the following purposes:
+@enumerate
+
+@item
+To control outline numbering based on user settings.
+
+@item
+To add styles generated by @file{htmlfontify.el} for fontification of code
+blocks.
+@end enumerate
+
+@anchor{x-orgodtcontenttemplate-xml}
+@item
+@file{OrgOdtContentTemplate.xml}
+
+This file contributes to the @file{content.xml} file of the final @samp{ODT}
+document.  The contents of the Org outline are inserted between the
+@samp{<office:text>}@dots{}@samp{</office:text>} elements of this file.
+
+Apart from serving as a template file for the final @file{content.xml}, the
+file serves the following purposes:
+@enumerate
+
+@item
+It contains automatic styles for formatting of tables which are referenced by
+the exporter.
+
+@item
+It contains @samp{<text:sequence-decl>}@dots{}@samp{</text:sequence-decl>}
+elements that control how various entities - tables, images, equations etc -
+are numbered.
+@end enumerate
+@end itemize
+
+@anchor{x-overriding-factory-styles}
+@subsubheading Overriding factory styles
+The following two variables control the location from which the @acronym{ODT}
+exporter picks up the custom styles and content template files.  You can
+customize these variables to override the factory styles used by the
+exporter.
+
+@itemize
+@anchor{x-org-export-odt-styles-file}
+@item
+@code{org-export-odt-styles-file}
+
+Use this variable to specify the @file{styles.xml} that will be used in the
+final output.  You can specify one of the following values:
+
+@enumerate
+@item A @file{styles.xml} file
+
+Use this file instead of the default @file{styles.xml}
+
+@item A @file{.odt} or @file{.ott} file
+
+Use the @file{styles.xml} contained in the specified OpenDocument Text or
+Template file
+
+@item A @file{.odt} or @file{.ott} file and a subset of files contained within them
+
+Use the @file{styles.xml} contained in the specified OpenDocument Text or
+Template file.  Additionally extract the specified member files and embed
+those within the final @samp{ODT} document.
+
+Use this option if the @file{styles.xml} file references additional files
+like header and footer images.
+
+@item @code{nil}
+
+Use the default @file{styles.xml}
+@end enumerate
+
+@anchor{x-org-export-odt-content-template-file}
+@item
+@code{org-export-odt-content-template-file}
+
+Use this variable to specify the blank @file{content.xml} that will be used
+in the final output.
+@end itemize
+
+@node Creating one-off styles, Customizing tables in @acronym{ODT} export, Working with OpenDocument style files, Advanced topics in @acronym{ODT} export
+@subsubsection Creating one-off styles
+
+There are times when you would want one-off formatting in the exported
+document.  You can achieve this by embedding raw OpenDocument XML in the Org
+file.  The use of this feature is better illustrated with couple of examples.
+
+@enumerate
+@item Embedding ODT tags as part of regular text
+
+You can include simple OpenDocument tags by prefixing them with
+@samp{@@}.  For example, to highlight a region of text do the following:
+
+@example
+@@<text:span text:style-name="Highlight">This is a
+highlighted text@@</text:span>.  But this is a
+regular text.
+@end example
+
+@strong{Hint:} To see the above example in action, edit your
+@file{styles.xml}(@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
+custom @samp{Highlight} style as shown below.
+
+@example
+<style:style style:name="Highlight" style:family="text">
+  <style:text-properties fo:background-color="#ff0000"/>
+</style:style>
+@end example
+
+@item Embedding a one-line OpenDocument XML
+
+You can add a simple OpenDocument one-liner using the @code{#+ODT:}
+directive.  For example, to force a page break do the following:
+
+@example
+#+ODT: <text:p text:style-name="PageBreak"/>
+@end example
+
+@strong{Hint:} To see the above example in action, edit your
+@file{styles.xml}(@pxref{x-orgodtstyles-xml,,Factory styles}) and add a
+custom @samp{PageBreak} style as shown below.
+
+@example
+<style:style style:name="PageBreak" style:family="paragraph"
+            style:parent-style-name="Text_20_body">
+  <style:paragraph-properties fo:break-before="page"/>
+</style:style>
+@end example
+
+@item Embedding a block of OpenDocument XML
+
+You can add a large block of OpenDocument XML using the
+@code{#+BEGIN_ODT}@dots{}@code{#+END_ODT} construct.
+
+For example, to create a one-off paragraph that uses bold text, do the
+following:
+
+@example
+#+BEGIN_ODT
+<text:p text:style-name="Text_20_body_20_bold">
+This paragraph is specially formatted and uses bold text.
+</text:p>
+#+END_ODT
+@end example
+
+@end enumerate
+
+@node Customizing tables in @acronym{ODT} export, Validating OpenDocument XML, Creating one-off styles, Advanced topics in @acronym{ODT} export
+@subsubsection Customizing tables in @acronym{ODT} export
+@cindex tables, in ODT export
+
+@cindex #+ATTR_ODT
+You can override the default formatting of the table by specifying a custom
+table style with the @code{#+ATTR_ODT} line.  For a discussion on default
+formatting of tables @pxref{Tables in @acronym{ODT} export}.
+
+This feature closely mimics the way table templates are defined in the
+OpenDocument-v1.2
+specification.@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
+OpenDocument-v1.2 Specification}}
+
+
+
+@subsubheading Custom table styles - an illustration
+
+To have a quick preview of this feature, install the below setting and export
+the table that follows.
+
+@lisp
+(setq org-export-odt-table-styles
+      (append org-export-odt-table-styles
+             '(("TableWithHeaderRowAndColumn" "Custom"
+                ((use-first-row-styles . t)
+                 (use-first-column-styles . t)))
+               ("TableWithFirstRowandLastRow" "Custom"
+                ((use-first-row-styles . t)
+                 (use-last-row-styles . t))))))
+@end lisp
+
+@example
+#+ATTR_ODT: TableWithHeaderRowAndColumn
+| Name  | Phone | Age |
+| Peter |  1234 |  17 |
+| Anna  |  4321 |  25 |
+@end example
+
+In the above example, you used a template named @samp{Custom} and installed
+two table styles with the names @samp{TableWithHeaderRowAndColumn} and
+@samp{TableWithFirstRowandLastRow}.  (@strong{Important:} The OpenDocument
+styles needed for producing the above template have been pre-defined for you.
+These styles are available under the section marked @samp{Custom Table
+Template} in @file{OrgOdtContentTemplate.xml}
+(@pxref{x-orgodtcontenttemplate-xml,,Factory styles}).  If you need
+additional templates you have to define these styles yourselves.
+
+@subsubheading Custom table styles - the nitty-gritty
+To use this feature proceed as follows:
+
+@enumerate
+@item
+Create a table template@footnote{See the @code{<table:table-template>}
+element of the OpenDocument-v1.2 specification}
+
+A table template is nothing but a set of @samp{table-cell} and
+@samp{paragraph} styles for each of the following table cell categories:
+
+@itemize @minus
+@item Body
+@item First column
+@item Last column
+@item First row
+@item Last row
+@item Even row
+@item Odd row
+@item Even column
+@item Odd Column
+@end itemize
+
+The names for the above styles must be chosen based on the name of the table
+template using a well-defined convention.
+
+The naming convention is better illustrated with an example.  For a table
+template with the name @samp{Custom}, the needed style names are listed in
+the following table.
+
+@multitable  {Table cell type} {CustomEvenColumnTableCell} {CustomEvenColumnTableParagraph}
+@headitem Table cell type
+@tab @code{table-cell} style
+@tab @code{paragraph} style
+@item
+@tab
+@tab
+@item Body
+@tab @samp{CustomTableCell}
+@tab @samp{CustomTableParagraph}
+@item First column
+@tab @samp{CustomFirstColumnTableCell}
+@tab @samp{CustomFirstColumnTableParagraph}
+@item Last column
+@tab @samp{CustomLastColumnTableCell}
+@tab @samp{CustomLastColumnTableParagraph}
+@item First row
+@tab @samp{CustomFirstRowTableCell}
+@tab @samp{CustomFirstRowTableParagraph}
+@item Last row
+@tab @samp{CustomLastRowTableCell}
+@tab @samp{CustomLastRowTableParagraph}
+@item Even row
+@tab @samp{CustomEvenRowTableCell}
+@tab @samp{CustomEvenRowTableParagraph}
+@item Odd row
+@tab @samp{CustomOddRowTableCell}
+@tab @samp{CustomOddRowTableParagraph}
+@item Even column
+@tab @samp{CustomEvenColumnTableCell}
+@tab @samp{CustomEvenColumnTableParagraph}
+@item Odd column
+@tab @samp{CustomOddColumnTableCell}
+@tab @samp{CustomOddColumnTableParagraph}
+@end multitable
+
+To create a table template with the name @samp{Custom}, define the above
+styles in the
+@code{<office:automatic-styles>}...@code{</office:automatic-styles>} element
+of the content template file (@pxref{x-orgodtcontenttemplate-xml,,Factory
+styles}).
+
+@item
+Define a table style@footnote{See the attributes @code{table:template-name},
+@code{table:use-first-row-styles}, @code{table:use-last-row-styles},
+@code{table:use-first-column-styles}, @code{table:use-last-column-styles},
+@code{table:use-banding-rows-styles}, and
+@code{table:use-banding-column-styles} of the @code{<table:table>} element in
+the OpenDocument-v1.2 specification}
+
+@vindex org-export-odt-table-styles
+To define a table style, create an entry for the style in the variable
+@code{org-export-odt-table-styles} and specify the following:
+
+@itemize @minus
+@item the name of the table template created in step (1)
+@item the set of cell styles in that template that are to be activated
+@end itemize
+
+For example, the entry below defines two different table styles
+@samp{TableWithHeaderRowsAndColumns} and @samp{TableWithHeaderColumns} based
+on the same template @samp{Custom}.  The styles achieve their intended effect
+by selectively activating the individual cell styles in that template.
+
+@lisp
+(setq org-export-odt-table-styles
+      (append org-export-odt-table-styles
+             '(("TableWithHeaderRowAndColumn" "Custom"
+                ((use-first-row-styles . t)
+                 (use-first-column-styles . t)))
+               ("TableWithFirstRowandLastRow" "Custom"
+                ((use-first-row-styles . t)
+                 (use-last-row-styles . t))))))
+@end lisp
+
+@item
+Associate a table with the table style
+
+To do this, specify the table style created in step (2) as part of
+the @code{ATTR_ODT} line as shown below.
+
+@example
+#+ATTR_ODT: TableWithHeaderRowAndColumn
+| Name  | Phone | Age |
+| Peter |  1234 |  17 |
+| Anna  |  4321 |  25 |
+@end example
+@end enumerate
+
+@node Validating OpenDocument XML,  , Customizing tables in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
+@subsubsection Validating OpenDocument XML
+
+Occasionally, you will discover that the document created by the
+@acronym{ODT} exporter cannot be opened by your favorite application.  One of
+the common reasons for this is that the @file{.odt} file is corrupt.  In such
+cases, you may want to validate the document against the OpenDocument RELAX
+NG Compact Syntax (RNC) schema.
+
+For de-compressing the @file{.odt} file@footnote{@file{.odt} files are
+nothing but @samp{zip} archives}: @inforef{File Archives,,emacs}.  For
+general help with validation (and schema-sensitive editing) of XML files:
+@inforef{Introduction,,nxml-mode}.
+
+@vindex org-export-odt-schema-dir
+If you have ready access to OpenDocument @file{.rnc} files and the needed
+schema-locating rules in a single folder, you can customize the variable
+@code{org-export-odt-schema-dir} to point to that directory.  The
+@acronym{ODT} exporter will take care of updating the
+@code{rng-schema-locating-files} for you.
 
 @c end opendocument
 
-@node  TaskJuggler export, Freemind export, OpenDocumentText export, Exporting
+@node  TaskJuggler export, Freemind export, OpenDocument Text export, Exporting
 @section TaskJuggler export
 @cindex TaskJuggler export
 @cindex Project management
@@ -10820,7 +11634,7 @@ resource assignments based on the project outline and the constraints that
 you have provided.
 
 The TaskJuggler exporter is a bit different from other exporters, such as the
-HTML and LaTeX exporters for example, in that it does not export all the
+@code{HTML} and @LaTeX{} exporters for example, in that it does not export all the
 nodes of a document or strictly follow the order of the nodes in the
 document.
 
@@ -10842,7 +11656,7 @@ Export as TaskJuggler file and then open the file with TaskJugglerUI.
 @subsection Tasks
 
 @vindex org-export-taskjuggler-project-tag
-Create your tasks as you usually do with Org-mode.  Assign efforts to each
+Create your tasks as you usually do with Org mode.  Assign efforts to each
 task using properties (it is easiest to do this in the column view).  You
 should end up with something similar to the example by Peter Jones in
 @url{http://www.contextualdevelopment.com/static/artifacts/articles/2008/project-planning/project-planning.org}.
@@ -10954,9 +11768,9 @@ file will be @file{myfile.mm}.
 @section XOXO export
 @cindex XOXO export
 
-Org-mode contains an exporter that produces XOXO-style output.
+Org mode contains an exporter that produces XOXO-style output.
 Currently, this exporter only handles the general outline structure and
-does not interpret any additional Org-mode features.
+does not interpret any additional Org mode features.
 
 @table @kbd
 @orgcmd{C-c C-e x,org-export-as-xoxo}
@@ -10975,10 +11789,10 @@ Export only the visible part of the document.
 @vindex org-icalendar-use-scheduled
 @vindex org-icalendar-categories
 @vindex org-icalendar-alarm-time
-Some people use Org-mode for keeping track of projects, but still prefer a
+Some people use Org mode for keeping track of projects, but still prefer a
 standard calendar application for anniversaries and appointments.  In this
 case it can be useful to show deadlines and other time-stamped items in Org
-files in the calendar application.  Org-mode can export calendar information
+files in the calendar application.  Org mode can export calendar information
 in the standard iCalendar format.  If you also want to have TODO entries
 included in the export, configure the variable
 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
@@ -11422,7 +12236,7 @@ Defaults to @code{nil}.
 @subsection Generating an index
 @cindex index, in a publishing project
 
-Org-mode can generate an index across the files of a publishing project.
+Org mode can generate an index across the files of a publishing project.
 
 @multitable @columnfractions 0.25 0.75
 @item @code{:makeindex}
@@ -11442,7 +12256,7 @@ a title, style information, etc.
 
 For those people already utilizing third party sync tools such as
 @command{rsync} or @command{unison}, it might be preferable not to use the built in
-@i{remote} publishing facilities of Org-mode which rely heavily on
+@i{remote} publishing facilities of Org mode which rely heavily on
 Tramp.  Tramp, while very useful and powerful, tends not to be
 so efficient for multiple file transfer and has been known to cause problems
 under heavy usage.
@@ -11581,7 +12395,7 @@ This may be necessary in particular if files include other files via
 @cindex Davison, Dan
 @cindex source code, working with
 
-Source code can be included in Org-mode documents using a @samp{src} block,
+Source code can be included in Org mode documents using a @samp{src} block,
 e.g.@:
 
 @example
@@ -11592,26 +12406,26 @@ e.g.@:
 #+END_SRC
 @end example
 
-Org-mode provides a number of features for working with live source code,
+Org mode provides a number of features for working with live source code,
 including editing of code blocks in their native major-mode, evaluation of
 code blocks, converting code blocks into source files (known as @dfn{tangling}
 in literate programming), and exporting code blocks and their
 results in several formats.  This functionality was contributed by Eric
 Schulte and Dan Davison, and was originally named Org-babel.
 
-The following sections describe Org-mode's code block handling facilities.
+The following sections describe Org mode's code block handling facilities.
 
 @menu
 * Structure of code blocks::    Code block syntax described
 * Editing source code::         Language major-mode editing
 * Exporting code blocks::       Export contents and/or results
 * Extracting source code::      Create pure source code files
-* Evaluating code blocks::      Place results of evaluation in the Org-mode buffer
+* Evaluating code blocks::      Place results of evaluation in the Org mode buffer
 * Library of Babel::            Use and contribute to a library of useful code blocks
 * Languages::                   List of supported code block languages
 * Header arguments::            Configure code block functionality
 * Results of evaluation::       How evaluation results are handled
-* Noweb reference syntax::      Literate programming in Org-mode
+* Noweb reference syntax::      Literate programming in Org mode
 * Key bindings and useful functions::  Work quickly with code blocks
 * Batch execution::             Call functions from the command line
 @end menu
@@ -11623,18 +12437,26 @@ The following sections describe Org-mode's code block handling facilities.
 @section Structure of code blocks
 @cindex code block, structure
 @cindex source code, block structure
+@cindex #+NAME
+@cindex #+BEGIN_SRC
 
-The structure of code blocks is as follows:
+Live code blocks can be specified with a @samp{src} block or
+inline.@footnote{Note that @samp{src} blocks may be inserted using Org mode's
+@ref{Easy Templates} system}  The structure of a @samp{src} block is
 
 @example
-#+srcname: <name>
-#+begin_src <language> <switches> <header arguments>
+#+NAME: <name>
+#+BEGIN_SRC <language> <switches> <header arguments>
   <body>
-#+end_src
+#+END_SRC
 @end example
 
-Switches and header arguments are optional.  Code can also be embedded in text
-inline using
+The @code{#+NAME:} line is optional, and can be used to name the code
+block.  Live code blocks require that a language be specified on the
+@code{#+BEGIN_SRC} line.  Switches and header arguments are optional.
+@cindex source code, inline
+
+Live code blocks can also be specified inline using
 
 @example
 src_<language>@{<body>@}
@@ -11647,26 +12469,30 @@ src_<language>[<header arguments>]@{<body>@}
 @end example
 
 @table @code
-@item <name>
-This name is associated with the code block.  This is similar to the
-@samp{#+tblname} lines that can be used to name tables in Org-mode files.
-Referencing the name of a code block makes it possible to evaluate the
-block from other places in the file, other files, or from Org-mode table
-formulas (see @ref{The spreadsheet}).  Names are assumed to be unique by
-evaluation functions and the behavior of multiple blocks of the same name is
+@item <#+NAME: name>
+This line associates a name with the code block.  This is similar to the
+@code{#+TBLNAME: NAME} lines that can be used to name tables in Org mode
+files.  Referencing the name of a code block makes it possible to evaluate
+the block from other places in the file, from other files, or from Org mode
+table formulas (see @ref{The spreadsheet}).  Names are assumed to be unique
+and the behavior of Org mode when two or more blocks share the same name is
 undefined.
+@cindex #+NAME
 @item <language>
-The language of the code in the block.
+The language of the code in the block (see @ref{Languages}).
+@cindex source code, language
 @item <switches>
-Optional switches controlling exportation of the code block (see switches discussion in
+Optional switches control code block export (see the discussion of switches in
 @ref{Literal examples})
+@cindex source code, switches
 @item <header arguments>
 Optional header arguments control many aspects of evaluation, export and
-tangling of code blocks.  See the @ref{Header arguments}.
+tangling of code blocks (see @ref{Header arguments}).
 Header arguments can also be set on a per-buffer or per-subtree
 basis using properties.
+@item source code, header arguments
 @item <body>
-The source code.
+Source code in the specified language.
 @end table
 
 @comment  node-name,  next,  previous,  up
@@ -11715,12 +12541,12 @@ variable @code{org-src-fontify-natively}.
 @cindex code block, exporting
 @cindex source code, exporting
 
-It is possible to export the @emph{contents} of code blocks, the
-@emph{results} of code block evaluation, @emph{neither}, or @emph{both}.  For
-most languages, the default exports the contents of code blocks.  However, for
-some languages (e.g.@: @code{ditaa}) the default exports the results of code
-block evaluation.  For information on exporting code block bodies, see
-@ref{Literal examples}.
+It is possible to export the @emph{code} of code blocks, the @emph{results}
+of code block evaluation, @emph{both} the code and the results of code block
+evaluation, or @emph{none}.  For most languages, the default exports code.
+However, for some languages (e.g.@: @code{ditaa}) the default exports the
+results of code block evaluation.  For information on exporting code block
+bodies, see @ref{Literal examples}.
 
 The @code{:exports} header argument can be used to specify export
 behavior:
@@ -11732,7 +12558,7 @@ The default in most languages.  The body of the code block is exported, as
 described in @ref{Literal examples}.
 @item :exports results
 The code block will be evaluated and the results will be placed in the
-Org-mode buffer for export, either updating previous results of the code
+Org mode buffer for export, either updating previous results of the code
 block located anywhere in the buffer or, if no previous results exist,
 placing the results immediately after the code block.  The body of the code
 block will not be exported.
@@ -11745,8 +12571,8 @@ Neither the code block nor its results will be exported.
 It is possible to inhibit the evaluation of code blocks during export.
 Setting the @code{org-export-babel-evaluate} variable to @code{nil} will
 ensure that no code blocks are evaluated as part of the export process.  This
-can be useful in situations where potentially untrusted Org-mode files are
-exported in an automated fashion, for example when Org-mode is used as the
+can be useful in situations where potentially untrusted Org mode files are
+exported in an automated fashion, for example when Org mode is used as the
 markup language for a wiki.
 
 @comment  node-name,  next,  previous,  up
@@ -11798,14 +12624,15 @@ of tangled code files.
 @cindex source code, evaluating
 
 Code blocks can be evaluated@footnote{Whenever code is evaluated there is a
-potential for that code to do harm.  Org-mode provides a number of safeguards
-to ensure that it only evaluates code with explicit confirmation from the
-user.  For information on these safeguards (and on how to disable them) see
-@ref{Code evaluation security}.} and the results placed in the Org-mode
-buffer.  By default, evaluation is only turned on for @code{emacs-lisp} code
-blocks, however support exists for evaluating blocks in many languages.  See
-@ref{Languages} for a list of supported languages.  See @ref{Structure of
-code blocks} for information on the syntax used to define a code block.
+potential for that code to do harm.  Org mode provides safeguards to ensure
+that code is only evaluated after explicit confirmation from the user.  For
+information on these safeguards (and on how to disable them) see @ref{Code
+evaluation security}.} and the results of evaluation optionally placed in the
+Org mode buffer.  By default, the evaluation facility is only enabled for
+Lisp code blocks specified as @code{emacs-lisp}. However, souce code blocks
+in many languages can be evaluated within Org mode (see @ref{Languages} for a
+list of supported languages and @ref{Structure of code blocks} for
+information on the syntax used to define a code block).
 
 @kindex C-c C-c
 There are a number of ways to evaluate code blocks.  The simplest is to press
@@ -11813,64 +12640,52 @@ There are a number of ways to evaluate code blocks.  The simplest is to press
 @code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
 @code{org-babel-execute-src-block} function to evaluate the block and insert
-its results into the Org-mode buffer.
+its results into the Org mode buffer.
+@cindex #+CALL
 
 It is also possible to evaluate named code blocks from anywhere in an
-Org-mode buffer or an Org-mode table.  @code{#+call} (or synonymously
-@code{#+function} or @code{#+lob}) lines can be used to remotely execute code
-blocks located in the current Org-mode buffer or in the ``Library of Babel''
-(see @ref{Library of Babel}).  These lines use the following syntax to place
-a call on a line by itself.
+Org mode buffer or an Org mode table. Live code blocks located in the current
+Org mode buffer or in the ``Library of Babel'' (see @ref{Library of Babel})
+can be executed.  Named code blocks can be executed with a separate
+@code{#+CALL:} line or inline within a block of text.
+
+The syntax of the @code{#+CALL:} line is
 
 @example
-#+call: <name>(<arguments>)
-#+call: <name>[<header args>](<arguments>) <header args>
+#+CALL: <name>(<arguments>)
+#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
 @end example
 
-The following syntax can be used to place these calls within a block of
-prose.
+The syntax for inline evaluation of named code blocks is
 
 @example
-...prose... call_<name>(<arguments>) ...prose...
-...prose... call_<name>[<header args>](<arguments>)[<header args>] ...prose...
+... call_<name>(<arguments>) ...
+... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
 @end example
 
 @table @code
 @item <name>
-The name of the code block to be evaluated.
+The name of the code block to be evaluated (see @ref{Structure of code blocks}).
 @item <arguments>
 Arguments specified in this section will be passed to the code block.  These
-arguments should relate to @code{:var} header arguments in the called code
-block expressed using standard function call syntax.  For example if the
-original code block named @code{double} has the header argument @code{:var
-n=2}, then the call line passing the number four to that block would be
-written as @code{#+call: double(n=2)}.
-@item <header args>
-Header arguments can be placed either inside the call to the code block or at
-the end of the line as shown below.
-
-@example
-#+call: code_bloc_name[XXXX](arguments) YYYY
-@end example
-
-Header arguments located in these two locations are treated differently.
-
-@table @code
-@item XXXX
-Those placed in the @code{XXXX} location are passed through and applied to
-the code block being called.  These header arguments affect how the code
-block is evaluated, for example @code{[:results output]} will collect the
-results from @code{STDOUT} of the called code block.
-@item YYYY
-Those placed in the @code{YYYY} location are applied to the call line and do
-not affect the code block being called.  These header arguments affect how
-the results are incorporated into the Org-mode buffer when the call line is
-evaluated, and how the call line is exported.  For example @code{:results
-org} at the end of the call line will insert the results of the call line
-inside of an Org-mode block.
-@end table
-
-For more examples of passing header arguments to @code{#+call:} lines see
+arguments use standard function call syntax, rather than
+header argument syntax.  For example, a @code{#+CALL:} line that passes the
+number four to a code block named @code{double}, which declares the header
+argument @code{:var n=2}, would be written as @code{#+CALL: double(n=4)}.
+@item <inside header arguments>
+Inside header arguments are passed through and applied to the named code
+block.  These arguments use header argument syntax rather than standard
+function call syntax.  Inside header arguments affect how the code block is
+evaluated.  For example, @code{[:results output]} will collect the results of
+everything printed to @code{STDOUT} during execution of the code block.
+@item <end header arguments>
+End header arguments are applied to the calling instance and do not affect
+evaluation of the named code block.  They affect how the results are
+incorporated into the Org mode buffer and how the call line is exported.  For
+example, @code{:results html} will insert the results of the call line
+evaluation in the Org buffer, wrapped in a @code{BEGIN_HTML:} block.
+
+For more examples of passing header arguments to @code{#+CALL:} lines see
 @ref{Header arguments in function calls}.
 @end table
 
@@ -11880,18 +12695,22 @@ For more examples of passing header arguments to @code{#+call:} lines see
 @cindex source code, library
 @cindex code block, library
 
-The ``Library of Babel'' is a library of code blocks
-that can be called from any Org-mode file.  The library is housed in an
-Org-mode file located in the @samp{contrib} directory of Org-mode.
-Org-mode users can deposit functions they believe to be generally
-useful in the library.
+The ``Library of Babel'' consists of code blocks that can be called from any
+Org mode file.  Code blocks defined in the ``Library of Babel'' can be called
+remotely as if they were in the current Org mode buffer (see @ref{Evaluating
+code blocks} for information on the syntax of remote code block evaluation).
+
+
+The central repository of code blocks in the ``Library of Babel'' is housed
+in an Org mode file located in the @samp{contrib} directory of Org mode.
+
+Users can add code blocks they believe to be generally useful to their
+``Library of Babel.''  The code blocks can be stored in any Org mode file and
+then loaded into the library with @code{org-babel-lob-ingest}.
 
-Code blocks defined in the ``Library of Babel'' can be called remotely as if
-they were in the current Org-mode buffer (see @ref{Evaluating code blocks}
-for information on the syntax of remote code block evaluation).
 
 @kindex C-c C-v i
-Code blocks located in any Org-mode file can be loaded into the ``Library of
+Code blocks located in any Org mode file can be loaded into the ``Library of
 Babel'' with the @code{org-babel-lob-ingest} function, bound to @kbd{C-c C-v
 i}.
 
@@ -11916,7 +12735,7 @@ Code blocks in the following languages are supported.
 @item Ledger @tab ledger @tab Lisp @tab lisp
 @item Lilypond @tab lilypond @tab MATLAB @tab matlab
 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
-@item Octave @tab octave @tab Org-mode @tab org
+@item Octave @tab octave @tab Org mode @tab org
 @item Oz @tab oz @tab Perl @tab perl
 @item Plantuml @tab plantuml @tab Python @tab python
 @item R @tab R @tab Ruby @tab ruby
@@ -11980,7 +12799,7 @@ specific (and having higher priority) than the last.
 * System-wide header arguments::  Set global default values
 * Language-specific header arguments::  Set default values by language
 * Buffer-wide header arguments::  Set default values for a specific buffer
-* Header arguments in Org-mode properties::  Set default values for a buffer or heading
+* Header arguments in Org mode properties::  Set default values for a buffer or heading
 * Code block specific header arguments::  The most common way to set values
 * Header arguments in function calls::  The most specific level
 @end menu
@@ -12031,12 +12850,11 @@ Each language can define its own set of default header arguments.  See the
 language-specific documentation available online at
 @uref{http://orgmode.org/worg/org-contrib/babel}.
 
-@node Buffer-wide header arguments, Header arguments in Org-mode properties, Language-specific header arguments, Using header arguments
+@node Buffer-wide header arguments, Header arguments in Org mode properties, Language-specific header arguments, Using header arguments
 @subsubheading Buffer-wide header arguments
-Buffer-wide header arguments may be specified through the use of a special
-line placed anywhere in an Org-mode file.  The line consists of the
-@code{#+BABEL:} keyword followed by a series of header arguments which may be
-specified using the standard header argument syntax.
+Buffer-wide header arguments may be specified as properties through the use
+of @code{#+PROPERTY:} lines placed anywhere in an Org mode file (see
+@ref{Property syntax}).
 
 For example the following would set @code{session} to @code{*R*}, and
 @code{results} to @code{silent} for every code block in the buffer, ensuring
@@ -12044,24 +12862,27 @@ that all execution took place in the same session, and no results would be
 inserted into the buffer.
 
 @example
-#+BABEL: :session *R* :results silent
+#+PROPERTY: session *R*
+#+PROPERTY: results silent
 @end example
 
-@node Header arguments in Org-mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
-@subsubheading Header arguments in Org-mode properties
+@node Header arguments in Org mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
+@subsubheading Header arguments in Org mode properties
 
-Header arguments are also read from Org-mode properties (see @ref{Property
+Header arguments are also read from Org mode properties (see @ref{Property
 syntax}), which can be set on a buffer-wide or per-heading basis.  An example
 of setting a header argument for all code blocks in a buffer is
 
 @example
-#+property: tangle yes
+#+PROPERTY: tangle yes
 @end example
 
+@vindex org-use-property-inheritance
 When properties are used to set default header arguments, they are looked up
-with inheritance, so the value of the @code{:cache} header argument will default
-to @code{yes} in all code blocks in the subtree rooted at the following
-heading:
+with inheritance, regardless of the value of
+@code{org-use-property-inheritance}.  In the following example the value of
+the @code{:cache} header argument will default to @code{yes} in all code
+blocks in the subtree rooted at the following heading:
 
 @example
 * outline header
@@ -12075,45 +12896,47 @@ heading:
 Properties defined in this way override the properties set in
 @code{org-babel-default-header-args}.  It is convenient to use the
 @code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
-in Org-mode documents.
+in Org mode documents.
 
-@node Code block specific header arguments, Header arguments in function calls, Header arguments in Org-mode properties, Using header arguments
+@node Code block specific header arguments, Header arguments in function calls, Header arguments in Org mode properties, Using header arguments
 @subsubheading Code block specific header arguments
 
 The most common way to assign values to header arguments is at the
 code block level.  This can be done by listing a sequence of header
-arguments and their values as part of the @code{#+begin_src} line.
+arguments and their values as part of the @code{#+BEGIN_SRC} line.
 Properties set in this way override both the values of
 @code{org-babel-default-header-args} and header arguments specified as
 properties.  In the following example, the @code{:results} header argument
 is set to @code{silent}, meaning the results of execution will not be
 inserted in the buffer, and the @code{:exports} header argument is set to
 @code{code}, meaning only the body of the code block will be
-preserved on export to HTML or LaTeX.
+preserved on export to HTML or @LaTeX{}.
 
 @example
-#+source: factorial
-#+begin_src haskell :results silent :exports code :var n=0
+#+NAME: factorial
+#+BEGIN_SRC haskell :results silent :exports code :var n=0
 fac 0 = 1
 fac n = n * fac (n-1)
-#+end_src
+#+END_SRC
 @end example
-Similarly, it is possible to set header arguments for inline code blocks:
+Similarly, it is possible to set header arguments for inline code blocks
 
 @example
 src_haskell[:exports both]@{fac 5@}
 @end example
 
-Code block header arguments can span multiple lines using =#+header:= or
-=#+headers:= lines preceding a code block or nested in between the name and
-body of a named code block.
+Code block header arguments can span multiple lines using @code{#+HEADER:} or
+@code{#+HEADERS:} lines preceding a code block or nested between the
+@code{#+NAME:} line and the @code{#+BEGIN_SRC} line of a named code block.
+@cindex #+HEADER:
+@cindex #+HEADERS:
 
 Multi-line header arguments on an un-named code block:
 @example
- #+headers: :var data1=1
- #+begin_src emacs-lisp :var data2=2
+ #+HEADERS: :var data1=1
+ #+BEGIN_SRC emacs-lisp :var data2=2
    (message "data1:%S, data2:%S" data1 data2)
- #+end_src
+ #+END_SRC
 
  #+results:
  : data1:1, data2:2
@@ -12121,11 +12944,11 @@ Multi-line header arguments on an un-named code block:
 
 Multi-line header arguments on a named code block:
 @example
-   #+source: named-block
-   #+header: :var data=2
-   #+begin_src emacs-lisp
+   #+NAME: named-block
+   #+HEADER: :var data=2
+   #+BEGIN_SRC emacs-lisp
      (message "data:%S" data)
-   #+end_src
+   #+END_SRC
 
    #+results: named-block
    : data:2
@@ -12136,25 +12959,26 @@ Multi-line header arguments on a named code block:
 @subsubheading Header arguments in function calls
 
 At the most specific level, header arguments for ``Library of Babel'' or
-function call lines can be set as shown in the two examples below.  For more
-information on the structure of @code{#+call:} lines see @ref{Evaluating code
+@code{#+CALL:} lines can be set as shown in the two examples below.  For more
+information on the structure of @code{#+CALL:} lines see @ref{Evaluating code
 blocks}.
 
 The following will apply the @code{:exports results} header argument to the
-evaluation of the @code{#+call:} line.
+evaluation of the @code{#+CALL:} line.
 @example
-#+call: factorial(n=5) :exports results
+#+CALL: factorial(n=5) :exports results
 @end example
 
 The following will apply the @code{:session special} header argument to the
 evaluation of the @code{factorial} code block.
 @example
-#+call: factorial[:session special](n=5)
+#+CALL: factorial[:session special](n=5)
 @end example
 
 @node Specific header arguments,  , Using header arguments, Header arguments
 @subsection Specific header arguments
-The following header arguments are defined:
+Header arguments consist of an initial colon followed by the name of the
+argument in lowercase letters.  The following header arguments are defined:
 
 @menu
 * var::                         Pass arguments to code blocks
@@ -12193,13 +13017,18 @@ Additional header arguments are defined on a language-specific basis, see
 The @code{:var} header argument is used to pass arguments to code blocks.
 The specifics of how arguments are included in a code block vary by language;
 these are addressed in the language-specific documentation.  However, the
-syntax used to specify arguments is the same across all languages.  The
-values passed to arguments can be literal values, values from org-mode tables
-and literal example blocks, the results of other code blocks, or Emacs Lisp
-code---see the ``Emacs Lisp evaluation of variables'' heading below.
+syntax used to specify arguments is the same across all languages.  In every
+case, variables require a default value when they are declared.
+
+The values passed to arguments can either be literal values, references, or
+Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}). References
+include anything in the Org mode file that takes a @code{#+NAME:},
+@code{#+TBLNAME:}, or @code{#+RESULTS:} line.  This includes tables, lists,
+@code{#+BEGIN_EXAMPLE} blocks, other code blocks, and the results of other
+code blocks.
 
-These values can be indexed in a manner similar to arrays---see the
-``indexable variable values'' heading below.
+Argument values can be indexed in a manner similar to arrays (see @ref{var,
+Indexable variable values}).
 
 The following syntax is used to pass arguments to code blocks using the
 @code{:var} header argument.
@@ -12208,76 +13037,122 @@ The following syntax is used to pass arguments to code blocks using the
 :var name=assign
 @end example
 
-where @code{assign} can take one of the following forms
+The argument, @code{assign}, can either be a literal value, such as a string
+@samp{"string"} or a number @samp{9}, or a reference to a table, a list, a
+literal example, another code block (with or without arguments), or the
+results of evaluating another code block.
 
-@itemize @bullet
-@item literal value
-either a string @code{"string"} or a number @code{9}.
-@item reference
-a table name:
+Here are examples of passing values by reference:
+
+@table @dfn
 
+@item table
+an Org mode table named with either a @code{#+NAME:} or @code{#+TBLNAME:} line
 @example
-#+tblname: example-table
+#+TBLNAME: example-table
 | 1 |
 | 2 |
 | 3 |
 | 4 |
 
-#+source: table-length
-#+begin_src emacs-lisp :var table=example-table
+#+NAME: table-length
+#+BEGIN_SRC emacs-lisp :var table=example-table
 (length table)
-#+end_src
+#+END_SRC
 
 #+results: table-length
 : 4
 @end example
 
-a code block name, as assigned by @code{#+srcname:}, followed by
-parentheses:
+@item list
+a simple list named with a @code{#+NAME:} line (note that nesting is not
+carried through to the source code block)
 
 @example
-#+begin_src emacs-lisp :var length=table-length()
+#+NAME: example-list
+  - simple
+    - not
+    - nested
+  - list
+
+#+BEGIN_SRC emacs-lisp :var x=example-list
+  (print x)
+#+END_SRC
+
+#+results:
+| simple | list |
+@end example
+
+@item code block without arguments
+a code block name (from the example above), as assigned by @code{#+NAME:},
+optionally followed by parentheses
+
+@example
+#+BEGIN_SRC emacs-lisp :var length=table-length()
 (* 2 length)
-#+end_src
+#+END_SRC
 
 #+results:
 : 8
 @end example
 
-In addition, an argument can be passed to the code block referenced
-by @code{:var}.  The argument is passed within the parentheses following the
-code block name:
+@item code block with arguments
+a code block name, as assigned by @code{#+NAME:}, followed by parentheses and
+optional arguments passed within the parentheses following the
+code block name using standard function call syntax
 
 @example
-#+source: double
-#+begin_src emacs-lisp :var input=8
+#+NAME: double
+#+BEGIN_SRC emacs-lisp :var input=8
 (* 2 input)
-#+end_src
+#+END_SRC
 
 #+results: double
 : 16
 
-#+source: squared
-#+begin_src emacs-lisp :var input=double(input=1)
+#+NAME: squared
+#+BEGIN_SRC emacs-lisp :var input=double(input=1)
 (* input input)
-#+end_src
+#+END_SRC
 
 #+results: squared
 : 4
 @end example
-@end itemize
+
+@item literal example
+a literal example block named with a @code{#+NAME:} line
+
+@example
+#+NAME: literal-example
+#+BEGIN_EXAMPLE
+A literal example
+on two lines
+#+END_EXAMPLE
+
+#+NAME: read-literal-example
+#+BEGIN_SRC emacs-lisp :var x=literal-example
+  (concatenate 'string x " for you.")
+#+END_SRC
+
+#+results: read-literal-example
+: A literal example
+: on two lines for you.
+
+@end example
+
+@end table
 
 @subsubheading Alternate argument syntax
 It is also possible to specify arguments in a potentially more natural way
-using the @code{#+source:} line of a code block.  As in the following
-example arguments can be packed inside of parenthesis, separated by commas,
+using the @code{#+NAME:} line of a code block.  As in the following
+example, arguments can be packed inside of parentheses, separated by commas,
 following the source name.
 
 @example
-#+source: double(input=0, x=2)
-#+begin_src emacs-lisp
+#+NAME: double(input=0, x=2)
+#+BEGIN_SRC emacs-lisp
 (* 2 (+ input x))
-#+end_src
+#+END_SRC
 @end example
 
 @subsubheading Indexable variable values
@@ -12291,15 +13166,15 @@ following example assigns the last cell of the first row the table
 @code{example-table} to the variable @code{data}:
 
 @example
-#+results: example-table
+#+NAME: example-table
 | 1 | a |
 | 2 | b |
 | 3 | c |
 | 4 | d |
 
-#+begin_src emacs-lisp :var data=example-table[0,-1]
+#+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
   data
-#+end_src
+#+END_SRC
 
 #+results:
 : a
@@ -12311,16 +13186,16 @@ example the following assigns the middle three rows of @code{example-table}
 to @code{data}.
 
 @example
-#+results: example-table
+#+NAME: example-table
 | 1 | a |
 | 2 | b |
 | 3 | c |
 | 4 | d |
 | 5 | 3 |
 
-#+begin_src emacs-lisp :var data=example-table[1:3]
+#+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
   data
-#+end_src
+#+END_SRC
 
 #+results:
 | 2 | b |
@@ -12334,15 +13209,15 @@ interpreted to mean the entire range and as such are equivalent to
 column is referenced.
 
 @example
-#+results: example-table
+#+NAME: example-table
 | 1 | a |
 | 2 | b |
 | 3 | c |
 | 4 | d |
 
-#+begin_src emacs-lisp :var data=example-table[,0]
+#+BEGIN_SRC emacs-lisp :var data=example-table[,0]
   data
-#+end_src
+#+END_SRC
 
 #+results:
 | 1 | 2 | 3 | 4 |
@@ -12353,16 +13228,16 @@ Any number of dimensions can be indexed.  Dimensions are separated from one
 another by commas, as shown in the following example.
 
 @example
-#+source: 3D
-#+begin_src emacs-lisp
+#+NAME: 3D
+#+BEGIN_SRC emacs-lisp
   '(((1  2  3)  (4  5  6)  (7  8  9))
     ((10 11 12) (13 14 15) (16 17 18))
     ((19 20 21) (22 23 24) (25 26 27)))
-#+end_src
+#+END_SRC
 
-#+begin_src emacs-lisp :var data=3D[1,,1]
+#+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
   data
-#+end_src
+#+END_SRC
 
 #+results:
 | 11 | 14 | 17 |
@@ -12371,31 +13246,31 @@ another by commas, as shown in the following example.
 @subsubheading Emacs Lisp evaluation of variables
 
 Emacs lisp code can be used to initialize variable values.  When a variable
-value starts with @code{(}, @code{[}, @code{'} or @code{`} it will be evaluated as
-Emacs Lisp and the result of the evaluation will be assigned as the variable
-value.  The following example demonstrates use of this evaluation to reliably
-pass the file-name of the org-mode buffer to a code block---note that
-evaluation of header arguments is guaranteed to take place in the original
-org-mode file, while there is no such guarantee for evaluation of the code
-block body.
+value starts with @code{(}, @code{[}, @code{'} or @code{`} it will be
+evaluated as Emacs Lisp and the result of the evaluation will be assigned as
+the variable value.  The following example demonstrates use of this
+evaluation to reliably pass the file-name of the Org mode buffer to a code
+block---note that evaluation of header arguments is guaranteed to take place
+in the original Org mode file, while there is no such guarantee for
+evaluation of the code block body.
 
 @example
-#+begin_src sh :var filename=(buffer-file-name) :exports both
+#+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
   wc -w $filename
-#+end_src
+#+END_SRC
 @end example
 
 Note that values read from tables and lists will not be evaluated as
 Emacs Lisp, as shown in the following example.
 
 @example
-#+results: table
+#+NAME: table
 | (a b c) |
 
-#+headers: :var data=table[0,0]
-#+begin_src perl
+#+HEADERS: :var data=table[0,0]
+#+BEGIN_SRC perl
   $data
-#+end_src
+#+END_SRC
 
 #+results:
 : (a b c)
@@ -12414,7 +13289,7 @@ from the code block
 @item
 @b{type} header arguments specify what type of result the code block will
 return---which has implications for how they will be inserted into the
-Org-mode buffer
+Org mode buffer
 @item
 @b{handling} header arguments specify how the results of evaluating the code
 block should be handled.
@@ -12445,28 +13320,28 @@ table or scalar depending on their value.
 
 @itemize @bullet
 @item @code{table}, @code{vector}
-The results should be interpreted as an Org-mode table.  If a single value is
+The results should be interpreted as an Org mode table.  If a single value is
 returned, it will be converted into a table with one row and one column.
 E.g., @code{:results value table}.
 @item @code{list}
-The results should be interpreted as an Org-mode list.  If a single scalar
+The results should be interpreted as an Org mode list.  If a single scalar
 value is returned it will be converted into a list with only one element.
 @item @code{scalar}, @code{verbatim}
 The results should be interpreted literally---they will not be
-converted into a table.  The results will be inserted into the Org-mode
+converted into a table.  The results will be inserted into the Org mode
 buffer as quoted text.  E.g., @code{:results value verbatim}.
 @item @code{file}
 The results will be interpreted as the path to a file, and will be inserted
-into the Org-mode buffer as a file link.  E.g., @code{:results value file}.
+into the Org mode buffer as a file link.  E.g., @code{:results value file}.
 @item @code{raw}, @code{org}
-The results are interpreted as raw Org-mode code and are inserted directly
+The results are interpreted as raw Org mode code and are inserted directly
 into the buffer.  If the results look like a table they will be aligned as
-such by Org-mode.  E.g., @code{:results value raw}.
+such by Org mode.  E.g., @code{:results value raw}.
 @item @code{html}
 Results are assumed to be HTML and will be enclosed in a @code{begin_html}
 block.  E.g., @code{:results value html}.
 @item @code{latex}
-Results assumed to be LaTeX and are enclosed in a @code{begin_latex} block.
+Results assumed to be @LaTeX{} and are enclosed in a @code{begin_latex} block.
 E.g., @code{:results value latex}.
 @item @code{code}
 Result are assumed to be parsable code and are enclosed in a code block.
@@ -12488,10 +13363,10 @@ results once they are collected.
 @itemize @bullet
 @item @code{silent}
 The results will be echoed in the minibuffer but will not be inserted into
-the Org-mode buffer.  E.g., @code{:results output silent}.
+the Org mode buffer.  E.g., @code{:results output silent}.
 @item @code{replace}
 The default value.  Any existing results will be removed, and the new results
-will be inserted into the Org-mode buffer in their place.  E.g.,
+will be inserted into the Org mode buffer in their place.  E.g.,
 @code{:results output replace}.
 @item @code{append}
 If there are pre-existing results of the code block then the new results will
@@ -12507,9 +13382,9 @@ inserted as with @code{replace}.
 @subsubsection @code{:file}
 
 The header argument @code{:file} is used to specify an external file in which
-to save code block results.  After code block evaluation an Org-mode style
+to save code block results.  After code block evaluation an Org mode style
 @code{[[file:]]} link (see @ref{Link format}) to the file will be inserted
-into the Org-mode buffer.  Some languages including R, gnuplot, dot, and
+into the Org mode buffer.  Some languages including R, gnuplot, dot, and
 ditaa provide special handling of the @code{:file} header argument
 automatically wrapping the code block body in the boilerplate code required
 to save output to the specified file.  This is often useful for saving
@@ -12538,9 +13413,9 @@ In other words, if you want your plot to go into a folder called @file{Work}
 in your home directory, you could use
 
 @example
-#+begin_src R :file myplot.png :dir ~/Work
+#+BEGIN_SRC R :file myplot.png :dir ~/Work
 matplot(matrix(rnorm(100), 10), type="l")
-#+end_src
+#+END_SRC
 @end example
 
 @subsubheading Remote execution
@@ -12548,14 +13423,14 @@ A directory on a remote machine can be specified using tramp file syntax, in
 which case the code will be evaluated on the remote machine.  An example is
 
 @example
-#+begin_src R :file plot.png :dir /dand@@yakuba.princeton.edu:
+#+BEGIN_SRC R :file plot.png :dir /dand@@yakuba.princeton.edu:
 plot(1:10, main=system("hostname", intern=TRUE))
-#+end_src
+#+END_SRC
 @end example
 
-Text results will be returned to the local Org-mode buffer as usual, and file
+Text results will be returned to the local Org mode buffer as usual, and file
 output will be created on the remote machine with relative paths interpreted
-relative to the remote directory.  An Org-mode link to the remote file will be
+relative to the remote directory.  An Org mode link to the remote file will be
 created.
 
 So, in the above example a plot will be created on the remote machine,
@@ -12581,7 +13456,7 @@ currently made to alter the directory associated with an existing session.
 @code{:dir} should typically not be used to create files during export with
 @code{:exports results} or @code{:exports both}.  The reason is that, in order
 to retain portability of exported material between machines, during export
-links inserted into the buffer will *not* be expanded against @code{default
+links inserted into the buffer will @emph{not} be expanded against @code{default
 directory}.  Therefore, if @code{default-directory} is altered using
 @code{:dir}, it is probable that the file will be created in a location to
 which the link does not point.
@@ -12591,7 +13466,7 @@ which the link does not point.
 @subsubsection @code{:exports}
 
 The @code{:exports} header argument specifies what should be included in HTML
-or LaTeX exports of the Org-mode file.
+or @LaTeX{} exports of the Org mode file.
 
 @itemize @bullet
 @item @code{code}
@@ -12616,14 +13491,14 @@ block should be included in tangled extraction of source code files.
 @itemize @bullet
 @item @code{tangle}
 The code block is exported to a source code file named after the full path
-(including the directory) and file name (w/o extension) of the Org-mode file.
+(including the directory) and file name (w/o extension) of the Org mode file.
 E.g., @code{:tangle yes}.
 @item @code{no}
 The default.  The code block is not exported to a source code file.
 E.g., @code{:tangle no}.
 @item other
 Any other string passed to the @code{:tangle} header argument is interpreted
-as a path (directory and file name relative to the directory of the Org-mode
+as a path (directory and file name relative to the directory of the Org mode
 file) to which the block will be exported.  E.g., @code{:tangle path}.
 @end itemize
 
@@ -12650,7 +13525,7 @@ original Org file from which the code was tangled.
 @item @code{yes}
 A synonym for ``link'' to maintain backwards compatibility.
 @item @code{org}
-Include text from the org-mode file as a comment.
+Include text from the Org mode file as a comment.
 
 The text is picked from the leading context of the tangled code and is
 limited by the nearest headline or source block as the case may be.
@@ -12751,37 +13626,39 @@ concatenated together to form the replacement text.
 
 By setting this header argument at the sub-tree or file level, simple code
 block concatenation may be achieved.  For example, when tangling the
-following Org-mode file, the bodies of code blocks will be concatenated into
-the resulting pure code file.
+following Org mode file, the bodies of code blocks will be concatenated into
+the resulting pure code file@footnote{(The example needs property inheritance
+to be turned on for the @code{noweb-ref} property, see @ref{Property
+inheritance}).}.
 
 @example
- #+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh
+ #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
    <<fullest-disk>>
- #+end_src
+ #+END_SRC
  * the mount point of the fullest disk
    :PROPERTIES:
    :noweb-ref: fullest-disk
    :END:
 
  ** query all mounted disks
- #+begin_src sh
+ #+BEGIN_SRC sh
    df \
- #+end_src
+ #+END_SRC
 
  ** strip the header row
- #+begin_src sh
+ #+BEGIN_SRC sh
    |sed '1d' \
- #+end_src
+ #+END_SRC
 
  ** sort by the percent full
- #+begin_src sh
+ #+BEGIN_SRC sh
    |awk '@{print $5 " " $6@}'|sort -n |tail -1 \
- #+end_src
+ #+END_SRC
 
  ** extract the mount point
- #+begin_src sh
+ #+BEGIN_SRC sh
    |awk '@{print $2@}'
- #+end_src
+ #+END_SRC
 @end example
 
 @node cache, sep, noweb-ref, Specific header arguments
@@ -12811,18 +13688,18 @@ invalidated and the code block is re-run.  In the following example,
 changed since it was last run.
 
 @example
- #+srcname: random
- #+begin_src R :cache yes
+ #+NAME: random
+ #+BEGIN_SRC R :cache yes
  runif(1)
- #+end_src
+ #+END_SRC
 
  #+results[a2a72cd647ad44515fab62e144796432793d68e1]: random
  0.4659510825295
 
- #+srcname: caller
- #+begin_src emacs-lisp :var x=random :cache yes
+ #+NAME: caller
+ #+BEGIN_SRC emacs-lisp :var x=random :cache yes
  x
- #+end_src
+ #+END_SRC
 
  #+results[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
  0.254227238707244
@@ -12832,7 +13709,7 @@ changed since it was last run.
 @subsubsection @code{:sep}
 
 The @code{:sep} header argument can be used to control the delimiter used
-when writing tabular results out to files external to Org-mode.  This is used
+when writing tabular results out to files external to Org mode.  This is used
 either when opening tabular results of a code block by calling the
 @code{org-open-at-point} function bound to @kbd{C-c C-o} on the code block,
 or when writing code block results to an external file (see @ref{file})
@@ -12856,17 +13733,17 @@ variable and raises an error.  Setting @code{:hlines no} or relying on the
 default value yields the following results.
 
 @example
-#+tblname: many-cols
+#+TBLNAME: many-cols
 | a | b | c |
 |---+---+---|
 | d | e | f |
 |---+---+---|
 | g | h | i |
 
-#+source: echo-table
-#+begin_src python :var tab=many-cols
+#+NAME: echo-table
+#+BEGIN_SRC python :var tab=many-cols
   return tab
-#+end_src
+#+END_SRC
 
 #+results: echo-table
 | a | b | c |
@@ -12878,17 +13755,17 @@ default value yields the following results.
 Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
 
 @example
-#+tblname: many-cols
+#+TBLNAME: many-cols
 | a | b | c |
 |---+---+---|
 | d | e | f |
 |---+---+---|
 | g | h | i |
 
-#+source: echo-table
-#+begin_src python :var tab=many-cols :hlines yes
+#+NAME: echo-table
+#+BEGIN_SRC python :var tab=many-cols :hlines yes
   return tab
-#+end_src
+#+END_SRC
 
 #+results: echo-table
 | a | b | c |
@@ -12904,6 +13781,10 @@ Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
 
 The @code{:colnames} header argument accepts the values @code{yes},
 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
+Note that the behavior of the @code{:colnames} header argument may differ
+across languages.  For example Emacs Lisp code blocks ignore the
+@code{:colnames} header argument entirely given the ease with which tables
+with column names may be handled directly in Emacs Lisp.
 
 @itemize @bullet
 @item @code{nil}
@@ -12913,16 +13794,16 @@ names will be removed from the table before
 processing, then reapplied to the results.
 
 @example
-#+tblname: less-cols
+#+TBLNAME: less-cols
 | a |
 |---|
 | b |
 | c |
 
-#+srcname: echo-table-again
-#+begin_src python :var tab=less-cols
+#+NAME: echo-table-again
+#+BEGIN_SRC python :var tab=less-cols
   return [[val + '*' for val in row] for row in tab]
-#+end_src
+#+END_SRC
 
 #+results: echo-table-again
 | a  |
@@ -12958,14 +13839,14 @@ The first column of the table is removed from the table before processing,
 and is then reapplied to the results.
 
 @example
-#+tblname: with-rownames
+#+TBLNAME: with-rownames
 | one | 1 | 2 | 3 | 4 |  5 |
 | two | 6 | 7 | 8 | 9 | 10 |
 
-#+srcname: echo-table-once-again
-#+begin_src python :var tab=with-rownames :rownames yes
+#+NAME: echo-table-once-again
+#+BEGIN_SRC python :var tab=with-rownames :rownames yes
   return [[val + 10 for val in row] for row in tab]
-#+end_src
+#+END_SRC
 
 #+results: echo-table-once-again
 | one | 11 | 12 | 13 | 14 | 15 |
@@ -12988,12 +13869,23 @@ permissions of the tangled file are set to make it executable.
 @node eval,  , shebang, Specific header arguments
 @subsubsection @code{:eval}
 The @code{:eval} header argument can be used to limit the evaluation of
-specific code blocks.  @code{:eval} accepts two arguments ``never'' and
-``query''.  @code{:eval never} will ensure that a code block is never
-evaluated, this can be useful for protecting against the evaluation of
-dangerous code blocks.  @code{:eval query} will require a query for every
-execution of a code block regardless of the value of the
-@code{org-confirm-babel-evaluate} variable.
+specific code blocks.  The @code{:eval} header argument can be useful for
+protecting against the evaluation of dangerous code blocks or to ensure that
+evaluation will require a query regardless of the value of the
+@code{org-confirm-babel-evaluate} variable.  The possible values of
+@code{:eval} and their effects are shown below.
+
+@table @code
+@item never or no
+The code block will not be evaluated under any circumstances.
+@item query
+Evaluation of the code block will require a query.
+@item never-export or no-export
+The code block will not be evaluated during export but may still be called
+interactively.
+@item query-export
+Evaluation of the code block during export will require a query.
+@end table
 
 If this header argument is not set then evaluation is determined by the value
 of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation
@@ -13016,7 +13908,7 @@ of the possible results header arguments see @ref{results}.
 @end multitable
 
 Note: With @code{:results value}, the result in both @code{:session} and
-non-session is returned to Org-mode as a table (a one- or two-dimensional
+non-session is returned to Org mode as a table (a one- or two-dimensional
 vector of strings or numbers) when appropriate.
 
 @subsection Non-session
@@ -13062,26 +13954,26 @@ were passed to a non-interactive interpreter running as an external
 process.  For example, compare the following two blocks:
 
 @example
-#+begin_src python :results output
+#+BEGIN_SRC python :results output
  print "hello"
  2
  print "bye"
-#+end_src
+#+END_SRC
 
-#+resname:
+#+results:
 : hello
 : bye
 @end example
 
 In non-session mode, the `2' is not printed and does not appear.
 @example
-#+begin_src python :results output :session
+#+BEGIN_SRC python :results output :session
  print "hello"
  2
  print "bye"
-#+end_src
+#+END_SRC
 
-#+resname:
+#+results:
 : hello
 : 2
 : bye
@@ -13109,7 +14001,8 @@ When a code block is tangled or evaluated, whether or not ``noweb''
 references are expanded depends upon the value of the @code{:noweb} header
 argument.  If @code{:noweb yes}, then a Noweb reference is expanded before
 evaluation.  If @code{:noweb no}, the default, then the reference is not
-expanded before evaluation.
+expanded before evaluation.  See the @ref{noweb-ref} header argument for
+a more flexible way to resolve noweb references.
 
 Note: the default value, @code{:noweb no}, was chosen to ensure that
 correct code is not broken in a language, such as Ruby, where
@@ -13117,11 +14010,17 @@ correct code is not broken in a language, such as Ruby, where
 syntactically valid in languages that you use, then please consider setting
 the default value.
 
+Note: if noweb tangling is slow in large Org-mode files consider setting the
+@code{*org-babel-use-quick-and-dirty-noweb-expansion*} variable to true.
+This will result in faster noweb reference resolution at the expense of not
+correctly resolving inherited values of the @code{:noweb-ref} header
+argument.
+
 @node Key bindings and useful functions, Batch execution, Noweb reference syntax, Working With Source Code
 @section Key bindings and useful functions
 @cindex code block, key bindings
 
-Many common Org-mode key sequences are re-bound depending on
+Many common Org mode key sequences are re-bound depending on
 the context.
 
 Within a code block, the following key bindings
@@ -13138,7 +14037,7 @@ are active:
 @item @kbd{M-@key{down}}  @tab @code{org-babel-pop-to-session}
 @end multitable
 
-In an Org-mode buffer, the following key bindings are active:
+In an Org mode buffer, the following key bindings are active:
 
 @multitable @columnfractions 0.45 0.55
 @kindex C-c C-v a
@@ -13255,7 +14154,7 @@ emacs -Q --batch -l $ORGINSTALL \
 @cindex tag completion
 @cindex link abbreviations, completion of
 
-Emacs would not be Emacs without completion, and Org-mode uses it whenever it
+Emacs would not be Emacs without completion, and Org mode uses it whenever it
 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
 some of the completion prompts, you can specify your preference by setting at
 most one of the variables @code{org-completion-use-iswitchb}
@@ -13290,7 +14189,7 @@ buffer.
 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
 @item
 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
-@samp{OPTIONS} which set file-specific options for Org-mode.  When the
+@samp{OPTIONS} which set file-specific options for Org mode.  When the
 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
 will insert example settings for this keyword.
 @item
@@ -13306,7 +14205,7 @@ Elsewhere, complete dictionary words using Ispell.
 @cindex template insertion
 @cindex insertion, of templates
 
-Org-mode supports insertion of empty structural elements (like
+Org mode supports insertion of empty structural elements (like
 @code{#+BEGIN_SRC} and @code{#+END_SRC} pairs) with just a few key
 strokes.  This is achieved through a native template expansion mechanism.
 Note that Emacs has several other template mechanisms which could be used in
@@ -13438,7 +14337,7 @@ lines into the buffer (@pxref{In-buffer settings}).
 @cindex in-buffer settings
 @cindex special keywords
 
-Org-mode uses special lines in the buffer to define settings on a
+Org mode uses special lines in the buffer to define settings on a
 per-file basis.  These lines start with a @samp{#+} followed by a
 keyword, a colon, and then individual words defining a setting.  Several
 setting words can be in the same line, but you can also have multiple
@@ -13497,14 +14396,14 @@ 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
+(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 particular, the file can be
-any other Org-mode file with internal setup.  You can visit the file the
+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:
 @cindex #+STARTUP:
-This line sets options to be used at startup of Org-mode, when an
+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 initial visibility of the outline
@@ -13527,7 +14426,7 @@ showeverything   @r{show even drawer contents}
 @cindex @code{indent}, STARTUP keyword
 @cindex @code{noindent}, STARTUP keyword
 Dynamic virtual indentation is controlled by the variable
-@code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
+@code{org-startup-indented}@footnote{Emacs 23 and Org mode 6.29 are required}
 @example
 indent     @r{start with @code{org-indent-mode} turned on}
 noindent   @r{start with @code{org-indent-mode} turned off}
@@ -13748,6 +14647,8 @@ ordered list.
 @item
 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
 block is updated.
+@item
+If the cursor is at a timestamp, fix the day name in the timestamp.
 @end itemize
 
 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
@@ -13956,11 +14857,11 @@ setup.  See the installation instructions in the file
 @item @file{cdlatex.el} by Carsten Dominik
 @cindex @file{cdlatex.el}
 @cindex Dominik, Carsten
-Org-mode can make use of the CDLa@TeX{} package to efficiently enter
+Org mode can make use of the CD@LaTeX{} package to efficiently enter
 @LaTeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
 @cindex @file{imenu.el}
-Imenu allows menu access to an index of items in a file.  Org-mode
+Imenu allows menu access to an index of items in a file.  Org mode
 supports Imenu---all you need to do to get the index is the following:
 @lisp
 (add-hook 'org-mode-hook
@@ -13977,7 +14878,7 @@ Org used to use this package for capture, but no longer does.
 @cindex @file{speedbar.el}
 @cindex Ludlam, Eric M.
 Speedbar is a package that creates a special frame displaying files and
-index items in files.  Org-mode supports Speedbar and allows you to
+index items in files.  Org mode supports Speedbar and allows you to
 drill into Org files directly from the Speedbar.  It also allows you to
 restrict the scope of agenda commands to a file or a subtree by using
 the command @kbd{<} in the Speedbar frame.
@@ -13991,8 +14892,8 @@ the command @kbd{<} in the Speedbar frame.
 Complex ASCII tables with automatic line wrapping, column- and row-spanning,
 and alignment can be created using the Emacs table package by Takaaki Ota
 (@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
-Org-mode will recognize these tables and export them properly.  Because of
-interference with other Org-mode functionality, you unfortunately cannot edit
+Org mode will recognize these tables and export them properly.  Because of
+interference with other Org mode functionality, you unfortunately cannot edit
 these tables directly in the buffer.  Instead, you need to use the command
 @kbd{C-c '} to edit them, similar to source code snippets.
 
@@ -14002,7 +14903,7 @@ Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
 @c
 @orgcmd{C-c ~,org-table-create-with-table.el}
 Insert a @file{table.el} table.  If there is already a table at point, this
-command converts it between the @file{table.el} format and the Org-mode
+command converts it between the @file{table.el} format and the Org mode
 format.  See the documentation string of the command
 @code{org-convert-table} for the restrictions under which this is
 possible.
@@ -14011,13 +14912,13 @@ possible.
 @item @file{footnote.el} by Steven L. Baur
 @cindex @file{footnote.el}
 @cindex Baur, Steven L.
-Org-mode recognizes numerical footnotes as provided by this package.
-However, Org-mode also has its own footnote support (@pxref{Footnotes}),
+Org mode recognizes numerical footnotes as provided by this package.
+However, Org mode also has its own footnote support (@pxref{Footnotes}),
 which makes using @file{footnote.el} unnecessary.
 @end table
 
 @node Conflicts,  , Cooperation, Interaction
-@subsection Packages that lead to conflicts with Org-mode
+@subsection Packages that lead to conflicts with Org mode
 
 @table @asis
 
@@ -14029,7 +14930,7 @@ This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
 special contexts don't do anything, but you can customize the variable
-@code{org-support-shift-select}.  Org-mode then tries to accommodate shift
+@code{org-support-shift-select}.  Org mode then tries to accommodate shift
 selection by (i) using it outside of the special contexts where special
 commands apply, and by (ii) extending an existing active region even if the
 cursor moves across a special context.
@@ -14044,7 +14945,7 @@ region.  In fact, Emacs 23 has this built-in in the form of
 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
 23, you probably don't want to use another package for this purpose.  However,
 if you prefer to leave these keys to a different package while working in
-Org-mode, configure the variable @code{org-replace-disputed-keys}.  When set,
+Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
 Org will move the following key bindings in Org files, and in the agenda
 buffer (but not during date selection).
 
@@ -14069,7 +14970,7 @@ fixed this problem:
 (add-hook 'org-mode-hook
           (lambda ()
             (org-set-local 'yas/trigger-key [tab])
-            (define-key yas/keymap [tab] 'yas/next-field-group)))
+            (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
 @end lisp
 
 The latest version of yasnippet doesn't play well with Org mode.  If the
@@ -14096,7 +14997,7 @@ Then, tell Org mode what to do with the new function:
 @cindex @file{windmove.el}
 This package also uses the @kbd{S-<cursor>} keys, so everything written
 in the paragraph above about CUA mode also applies here.  If you want make
-the windmove function active in locations where Org-mode does not have
+the windmove function active in locations where Org mode does not have
 special functionality on @kbd{S-@key{cursor}}, add this to your
 configuration:
 
@@ -14112,7 +15013,7 @@ configuration:
 @cindex @file{viper.el}
 @kindex C-c /
 Viper uses @kbd{C-c /} and therefore makes this key not access the
-corresponding Org-mode command @code{org-sparse-tree}.  You need to find
+corresponding Org mode command @code{org-sparse-tree}.  You need to find
 another key for this command, or override the key in
 @code{viper-vi-global-user-map} with
 
@@ -14197,7 +15098,7 @@ maintained by the Worg project and can be found at
 
 A large number of add-on packages have been written by various authors.
 These packages are not part of Emacs, but they are distributed as contributed
-packages with the separate release available at the Org-mode home page at
+packages with the separate release available at the Org mode home page at
 @uref{http://orgmode.org}.  The list of contributed packages, along with
 documentation about each package, is maintained by the Worg project at
 @uref{http://orgmode.org/worg/org-contrib/}.
@@ -14321,7 +15222,7 @@ Add-ons can tap into this functionality by providing a function that detects
 special context for that add-on and executes functionality appropriate for
 the context.  Here is an example from Dan Davison's @file{org-R.el} which
 allows you to evaluate commands based on the @file{R} programming language
-@footnote{@file{org-R.el} has been replaced by the org-mode functionality
+@footnote{@file{org-R.el} has been replaced by the Org mode functionality
 described in @ref{Working With Source Code} and is now obsolete.}.  For this
 package, special contexts are lines that start with @code{#+R:} or
 @code{#+RR:}.
@@ -14374,12 +15275,12 @@ can use Org's facilities to edit and structure lists by turning
 
 @menu
 * Radio tables::                Sending and receiving radio tables
-* A LaTeX example::             Step by step, almost a tutorial
+* A @LaTeX{} example::          Step by step, almost a tutorial
 * Translator functions::        Copy and modify
 * Radio lists::                 Doing the same for lists
 @end menu
 
-@node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
+@node Radio tables, A @LaTeX{} example, Tables in arbitrary syntax, Tables in arbitrary syntax
 @subsection Radio tables
 @cindex radio tables
 
@@ -14447,7 +15348,7 @@ makes this comment-toggling very easy, in particular if you bind it to a
 key.
 @end itemize
 
-@node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
+@node A @LaTeX{} example, Translator functions, Radio tables, Tables in arbitrary syntax
 @subsection A @LaTeX{} example of radio tables
 @cindex @LaTeX{}, and Orgtbl mode
 
@@ -14557,7 +15458,7 @@ applied.  Similar to @code{fmt}, functions of two arguments can be
 supplied instead of strings.
 @end table
 
-@node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
+@node Translator functions, Radio lists, A @LaTeX{} example, Tables in arbitrary syntax
 @subsection Translator functions
 @cindex HTML, and Orgtbl mode
 @cindex translator function
@@ -14877,7 +15778,7 @@ You may also modify parameters on the fly like this:
 @example
 emacs -batch -l ~/.emacs                                      \
    -eval '(org-batch-agenda "a"                               \
-            org-agenda-span month                             \
+            org-agenda-span (quote month)                     \
             org-agenda-include-diary nil                      \
             org-agenda-files (quote ("~/org/project.org")))'  \
    | lpr
@@ -15139,7 +16040,7 @@ The following example counts the number of entries with TODO keyword
 
 @uref{http://mobileorg.ncogni.to/, MobileOrg} is an application for the
 @i{iPhone/iPod Touch} series of devices, developed by Richard Moreland.
-@i{MobileOrg} offers offline viewing and capture support for an Org-mode
+@i{MobileOrg} offers offline viewing and capture support for an Org mode
 system rooted on a ``real'' computer.  It does also allow you to record
 changes to existing entries.  Android users should check out
 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
@@ -15168,7 +16069,7 @@ in-buffer settings, but it will understand the logistics of TODO state
 
 MobileOrg needs to interact with Emacs through a directory on a server.  If you
 are using a public server, you should consider to encrypt the files that are
-uploaded to the server.  This can be done with Org-mode 7.02 and with
+uploaded to the server.  This can be done with Org mode 7.02 and with
 @i{MobileOrg 1.5} (iPhone version), and you need an @file{openssl}
 installation on your system.  To turn on encryption, set a password in
 @i{MobileOrg} and, on the Emacs side, configure the variable
@@ -15191,7 +16092,7 @@ Emacs about it:
 (setq org-mobile-directory "~/Dropbox/MobileOrg")
 @end lisp
 
-Org-mode has commands to put files for @i{MobileOrg} into that directory,
+Org mode has commands to put files for @i{MobileOrg} into that directory,
 and to read captured notes from there.
 
 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
@@ -15204,7 +16105,7 @@ can be included by customizing @code{org-mobile-files}.  File names will be
 staged with paths relative to @code{org-directory}, so all files should be
 inside this directory.  The push operation also creates a special Org file
 @file{agendas.org} with all custom agenda view defined by the
-user@footnote{While creating the agendas, Org-mode will force ID properties
+user@footnote{While creating the agendas, Org mode will force ID properties
 on all referenced entries, so that these entries can be uniquely identified
 if @i{MobileOrg} flags them for further action.  If you do not want to get
 these properties in so many entries, you can set the variable
@@ -15305,7 +16206,7 @@ Before I get to this list, a few special mentions are in order:
 @table @i
 @item Bastien Guerry
 Bastien has written a large number of extensions to Org (most of them
-integrated into the core by now), including the LaTeX exporter and the plain
+integrated into the core by now), including the @LaTeX{} exporter and the plain
 list parser.  His support during the early days, when he basically acted as
 co-maintainer, was central to the success of this project.  Bastien also
 invented Worg, helped establishing the Web presence of Org, and sponsors
@@ -15340,13 +16241,13 @@ know what I am missing here!
 @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.
+Org mode website.
 @item
 @i{Alex Bochannek} provided a patch for rounding timestamps.
 @item
 @i{Jan Böcker} wrote @file{org-docview.el}.
 @item
-@i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
+@i{Brad Bozarth} showed how to pull RSS feed data into Org mode files.
 @item
 @i{Tom Breton} wrote @file{org-choose.el}.
 @item
@@ -15522,7 +16423,7 @@ tweaks and features.
 extension system, added support for mairix, and proposed the mapping API.
 @item
 @i{Ulf Stegemann} created the table to translate special symbols to HTML,
-LaTeX, UTF-8, Latin-1 and ASCII.
+@LaTeX{}, UTF-8, Latin-1 and ASCII.
 @item
 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
 with links transformation to Org syntax.
@@ -15530,10 +16431,10 @@ with links transformation to Org syntax.
 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
 chapter about publishing.
 @item
-@i{Jambunathan K} contributed the OpenDocumentText exporter.
+@i{Jambunathan K} contributed the @acronym{ODT} exporter.
 @item
-@i{Sebastien Vauban} reported many issues with LaTeX and BEAMER export and
-enabled source code highlighting in Gnus.
+@i{Sebastien Vauban} reported many issues with @LaTeX{} and BEAMER export and
+enabled source code highlighling in Gnus.
 @item
 @i{Stefan Vollmar} organized a video-recorded talk at the
 Max-Planck-Institute for Neurology.  He also inspired the creation of a
index 758025c6c3e41ed32ba29dd7bd24437142e9d700..f7c37b2465412e2a32ae5f8973303b1dcc5da054 100644 (file)
@@ -1,3 +1,17 @@
+2012-01-03  Bastien Guerry  <bzg@altern.org>
+
+       * org/COPYRIGHT-AND-LICENSE: New file.
+
+       * org/OrgOdtContentTemplate.xml: New file.
+
+       * org/OrgOdtStyles.xml: New file.
+
+       * org/: New directory.
+
+2012-01-03  Julian Gehring  <julian.gehring@googlemail.com>
+
+       * refcards/orgcard.tex: Correct one markup in the "Timestamps" section.
+
 2011-12-10  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * NEWS: Mention auth-source twice in connection with smtpmail to
diff --git a/etc/org/COPYRIGHT-AND-LICENSE b/etc/org/COPYRIGHT-AND-LICENSE
new file mode 100644 (file)
index 0000000..e4438bb
--- /dev/null
@@ -0,0 +1,36 @@
+OrgOdtContentTemplate.xml --- Aux XML file (Org-mode's OpenDocument export)
+OrgOdtStyles.xml         --- Aux XML file (Org-mode's OpenDocument export)
+
+Copyright (C) 2010-2011 Free Software Foundation, Inc.
+
+Author: Jambunathan K <kjambunathan at gmail dot com>
+Keywords: outlines, hypermedia, calendar, wp
+Homepage: http://orgmode.org
+
+These file are not (yet) part of GNU Emacs.
+However, it is distributed under the same license.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+Commentary:
+
+Above files are part of Org-mode's OpenDocument export module.
+
+OrgOdtContentTemplate.xml provides a template within which the content
+of an exported document is enclosed.  This file contributes to
+"content.xml" file within an exported document and acts as a
+repository of automatic styles.
+
+OrgOdtStyles.xml contributes to "styles.xml" file within an exported
+document and acts as a repository of custom styles.
diff --git a/etc/org/OrgOdtContentTemplate.xml b/etc/org/OrgOdtContentTemplate.xml
new file mode 100644 (file)
index 0000000..f4982f6
--- /dev/null
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-content
+    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
+    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
+    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
+    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
+    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
+    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
+    xmlns:xlink="http://www.w3.org/1999/xlink"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
+    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
+    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
+    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
+    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
+    xmlns:math="http://www.w3.org/1998/Math/MathML"
+    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
+    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
+    xmlns:ooo="http://openoffice.org/2004/office"
+    xmlns:ooow="http://openoffice.org/2004/writer"
+    xmlns:oooc="http://openoffice.org/2004/calc"
+    xmlns:dom="http://www.w3.org/2001/xml-events"
+    xmlns:xforms="http://www.w3.org/2002/xforms"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:rpt="http://openoffice.org/2005/report"
+    xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
+    xmlns:xodt="http://www.w3.org/1999/xodt"
+    xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"    office:version="1.2">
+  <!-- scripts -->
+  <office:scripts/>
+
+  <!-- font face declarations -->
+  <office:font-face-decls>
+    <style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/>
+    <style:font-face style:name="courier" svg:font-family="courier, monospace"/>
+    <style:font-face style:name="Arial Unicode MS" svg:font-family="&apos;Arial Unicode MS&apos;" style:font-pitch="variable"/>
+    <style:font-face style:name="HG Mincho Light J" svg:font-family="&apos;HG Mincho Light J&apos;" style:font-pitch="variable"/>
+    <style:font-face style:name="Thorndale" svg:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>
+    <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/>
+    <style:font-face style:name="Albany" svg:font-family="Albany" style:font-family-generic="swiss" style:font-pitch="variable"/>
+    <style:font-face style:name="SimSun" svg:font-family="SimSun" style:font-family-generic="system" style:font-pitch="variable"/>
+    <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/>
+  </office:font-face-decls>
+
+  <!-- automatic styles -->
+  <office:automatic-styles>
+    <style:style style:name="OrgTable" style:family="table">
+      <style:table-properties style:rel-width="90%" fo:margin-top="0cm" fo:margin-bottom="0.20cm" table:align="center"/>
+    </style:style>
+
+    <style:style style:name="OrgTableColumn" style:family="table-column">
+      <style:table-column-properties style:rel-column-width="1*"/>
+    </style:style>
+
+    <style:style style:name="OrgTblCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="top" fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellL" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellT" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTL" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="none" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellB" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellBL" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellBR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellBLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTB" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTBL" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTBR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="none" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+    <style:style style:name="OrgTblCellTBLR" style:family="table-cell" style:parent-style-name="OrgTblCell">
+      <style:table-cell-properties fo:padding="0.159cm" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000"/>
+    </style:style>
+
+    <!-- BEGIN: Table styles for numbered equations -->
+    <style:style style:name="OrgEquation" style:family="table">
+      <style:table-properties style:rel-width="100%" fo:margin-top="0cm" fo:margin-bottom="0.20cm" table:align="center"/>
+    </style:style>
+    <style:style style:name="OrgEquationTableColumn" style:family="table-column">
+      <style:table-column-properties style:rel-column-width="1*"/>
+    </style:style>
+    <style:style style:name="OrgFirstEquationFirstColumnTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="middle" fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgEquationLastColumnTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="middle" fo:padding="0.159cm" fo:border-top="none" fo:border-bottom="none" fo:border-left="none" fo:border-right="none"/>
+    </style:style>
+    <style:style style:name="OrgEquationFirstColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+    </style:style>
+    <style:style style:name="OrgEquationLastColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
+    </style:style>
+    <!-- END: Table styles for numbered equations -->
+
+    <!-- BEGIN: Custom Table Template -->
+    <style:style style:name="Custom" style:family="table">
+      <style:table-properties style:rel-width="80%" table:align="center"/>
+    </style:style>
+
+    <style:style style:name="CustomColumn" style:family="table-column">
+      <style:table-column-properties style:rel-column-width="1*"/>
+    </style:style>
+
+    <!-- Table Paragraph Styles -->
+    <style:style style:name="CustomTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+      <style:text-properties fo:color="#000000" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
+    </style:style>
+
+    <style:style style:name="CustomLastRowTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+      <style:text-properties fo:color="#000000" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
+    </style:style>
+
+    <style:style style:name="CustomLastColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+      <style:text-properties fo:color="#000000" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
+    </style:style>
+
+    <style:style style:name="CustomFirstRowTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+      <style:text-properties fo:color="#ffffff" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
+    </style:style>
+
+    <style:style style:name="CustomFirstColumnTableParagraph" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+      <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+      <style:text-properties fo:color="#ffffff" style:text-outline="false" style:text-line-through-style="none" style:font-name="Times New Roman" fo:font-size="12pt" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:font-size-asian="12pt" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-size-complex="12pt" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-overline-style="none" style:text-overline-color="font-color"/>
+    </style:style>
+
+    <!-- Table Cell Styles -->
+    <style:style style:name="CustomTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="top" fo:background-color="#ffffff" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
+       <style:background-image/>
+      </style:table-cell-properties>
+    </style:style>
+
+    <style:style style:name="CustomFirstRowTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="top" fo:background-color="#000080" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
+       <style:background-image/>
+      </style:table-cell-properties>
+    </style:style>
+
+    <style:style style:name="CustomLastRowTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="top" fo:background-color="#cccccc" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
+       <style:background-image/>
+      </style:table-cell-properties>
+    </style:style>
+
+    <style:style style:name="CustomFirstColumnTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="top" fo:background-color="#4d4d4d" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
+       <style:background-image/>
+      </style:table-cell-properties>
+    </style:style>
+
+    <style:style style:name="CustomLastColumnTableCell" style:family="table-cell">
+      <style:table-cell-properties style:vertical-align="top" fo:background-color="#cccccc" fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000">
+       <style:background-image/>
+      </style:table-cell-properties>
+    </style:style>
+
+    <!-- END: Custom Table Template -->
+
+  </office:automatic-styles>
+
+  <office:body>
+    <office:text>
+      <text:sequence-decls>
+       <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
+       <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+       <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+       <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+       <text:sequence-decl text:display-outline-level="0" text:name="Equation"/>
+       <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+      </text:sequence-decls>
+    </office:text>
+  </office:body>
+</office:document-content>
diff --git a/etc/org/OrgOdtStyles.xml b/etc/org/OrgOdtStyles.xml
new file mode 100644 (file)
index 0000000..762d56a
--- /dev/null
@@ -0,0 +1,731 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2">
+ <office:font-face-decls>
+  <style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/>
+  <style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/>
+  <style:font-face style:name="Courier New" svg:font-family="&apos;Courier New&apos;" style:font-family-generic="modern" style:font-pitch="fixed"/>
+  <style:font-face style:name="NSimSun" svg:font-family="NSimSun" style:font-family-generic="modern" style:font-pitch="fixed"/>
+  <style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/>
+  <style:font-face style:name="SimSun" svg:font-family="SimSun" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="graphic">
+   <style:graphic-properties draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
+   <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+   <style:text-properties style:use-window-font-color="true" fo:font-size="12pt" fo:language="en" fo:country="GB" style:letter-kerning="true" style:font-size-asian="12pt" style:language-asian="zh" style:country-asian="CN" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/>
+  </style:default-style>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
+   <style:text-properties style:use-window-font-color="true" style:font-name="Times New Roman" fo:font-size="12pt" fo:language="en" fo:country="GB" style:letter-kerning="true" style:font-name-asian="SimSun" style:font-size-asian="12pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Tahoma" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+  </style:default-style>
+  <style:default-style style:family="table">
+   <style:table-properties table:border-model="collapsing"/>
+  </style:default-style>
+  <style:default-style style:family="table-row">
+   <style:table-row-properties fo:keep-together="auto"/>
+  </style:default-style>
+
+  <!-- Outline numbering -->
+  <text:outline-style style:name="OrgOutline">
+   <text:outline-level-style text:level="1" style:num-suffix=". " style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-0.762cm" fo:margin-left="0.762cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="2" style:num-suffix=". " style:num-format="1" text:display-levels="2">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.016cm" fo:margin-left="1.016cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="3" style:num-suffix=". " style:num-format="1" text:display-levels="3">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.27cm" fo:margin-left="1.27cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="4" style:num-suffix=". " style:num-format="1" text:display-levels="4">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.524cm" fo:margin-left="1.524cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="5" style:num-suffix=". " style:num-format="1" text:display-levels="5">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-1.778cm" fo:margin-left="1.778cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="6" style:num-suffix=". " style:num-format="1" text:display-levels="6">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.032cm" fo:margin-left="2.032cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="7" style:num-suffix=". " style:num-format="1" text:display-levels="7">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.286cm" fo:margin-left="2.286cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="8" style:num-suffix=". " style:num-format="1" text:display-levels="8">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.54cm" fo:margin-left="2.54cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="9" style:num-suffix=". " style:num-format="1" text:display-levels="9">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-2.794cm" fo:margin-left="2.794cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="10" style:num-suffix=". " style:num-format="1" text:display-levels="10">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="nothing" fo:text-indent="-3.048cm" fo:margin-left="3.048cm"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+  </text:outline-style>
+
+  <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+  <style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text">
+   <style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/>
+   <style:text-properties style:font-name="Arial" fo:font-size="14pt" style:font-name-asian="SimSun" style:font-size-asian="14pt" style:font-name-complex="Tahoma" style:font-size-complex="14pt"/>
+  </style:style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm"/>
+  </style:style>
+  <style:style style:name="List" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="list">
+   <style:text-properties style:font-name-complex="Tahoma1"/>
+  </style:style>
+  <style:style style:name="Caption" style:family="paragraph" style:parent-style-name="Standard" style:class="extra">
+   <style:paragraph-properties fo:margin-top="0.212cm" fo:margin-bottom="0.212cm" text:number-lines="false" text:line-number="0"/>
+   <style:text-properties fo:font-size="12pt" fo:font-style="italic" style:font-size-asian="12pt" style:font-style-asian="italic" style:font-name-complex="Tahoma1" style:font-size-complex="12pt" style:font-style-complex="italic"/>
+  </style:style>
+  <style:style style:name="Index" style:family="paragraph" style:parent-style-name="Standard" style:class="index">
+   <style:paragraph-properties text:number-lines="false" text:line-number="0"/>
+   <style:text-properties style:font-name-complex="Tahoma1"/>
+  </style:style>
+  <style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="1" style:class="text">
+   <style:text-properties fo:font-size="115%" fo:font-weight="bold" style:font-size-asian="115%" style:font-weight-asian="bold" style:font-size-complex="115%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_2" style:display-name="Heading 2" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="2" style:class="text">
+   <style:text-properties fo:font-size="14pt" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="14pt" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-style-complex="italic" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_3" style:display-name="Heading 3" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="3" style:class="text">
+   <style:text-properties fo:font-size="14pt" fo:font-weight="bold" style:font-size-asian="14pt" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_4" style:display-name="Heading 4" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="4" style:class="text">
+   <style:text-properties fo:font-size="85%" fo:font-style="italic" fo:font-weight="bold" style:font-size-asian="85%" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-size-complex="85%" style:font-style-complex="italic" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_5" style:display-name="Heading 5" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="5" style:class="text">
+   <style:text-properties fo:font-size="85%" fo:font-weight="bold" style:font-size-asian="85%" style:font-weight-asian="bold" style:font-size-complex="85%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_6" style:display-name="Heading 6" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="6" style:class="text">
+   <style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_7" style:display-name="Heading 7" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="7" style:class="text">
+   <style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_8" style:display-name="Heading 8" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="8" style:class="text">
+   <style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_9" style:display-name="Heading 9" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="9" style:class="text">
+   <style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_10" style:display-name="Heading 10" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="10" style:class="text">
+   <style:text-properties fo:font-size="75%" fo:font-weight="bold" style:font-size-asian="75%" style:font-weight-asian="bold" style:font-size-complex="75%" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Heading_20_1.title" style:display-name="Heading 1.title" style:family="paragraph" style:parent-style-name="Heading_20_1">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Title" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Subtitle" style:class="chapter">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+   <style:text-properties fo:font-size="18pt" fo:font-weight="bold" style:font-size-asian="18pt" style:font-weight-asian="bold" style:font-size-complex="18pt" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="OrgTitle" style:family="paragraph" style:parent-style-name="Title">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
+   <style:text-properties fo:font-size="24pt"/>
+  </style:style>
+  <style:style style:name="Subtitle" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:class="chapter">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+   <style:text-properties fo:font-size="14pt" fo:font-style="italic" style:font-size-asian="14pt" style:font-style-asian="italic" style:font-size-complex="14pt" style:font-style-complex="italic"/>
+  </style:style>
+  <style:style style:name="OrgSubtitle" style:family="paragraph" style:parent-style-name="Subtitle">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
+   <style:text-properties fo:font-size="20pt"/>
+  </style:style>
+  <style:style style:name="Text_20_body_20_indent" style:display-name="Text body indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
+   <style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
+  </style:style>
+  <style:style style:name="List_20_Indent" style:display-name="List Indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
+   <style:paragraph-properties fo:margin-left="5.001cm" fo:margin-right="0cm" fo:text-indent="-4.5cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="0cm"/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="First_20_line_20_indent" style:display-name="First line indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
+   <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0.499cm" style:auto-text-indent="false"/>
+  </style:style>
+  <style:style style:name="Hanging_20_indent" style:display-name="Hanging indent" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text">
+   <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="0cm" fo:text-indent="-0.499cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="0cm"/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Salutation" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties text:number-lines="false" text:line-number="0"/>
+  </style:style>
+  <style:style style:name="Contents_20_Heading" style:display-name="Contents Heading" style:family="paragraph" style:parent-style-name="Heading" style:class="index">
+   <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/>
+   <style:text-properties fo:font-size="16pt" fo:font-weight="bold" style:font-size-asian="16pt" style:font-weight-asian="bold" style:font-size-complex="16pt" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Contents_20_1" style:display-name="Contents 1" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="17cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_2" style:display-name="Contents 2" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="16.501cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_3" style:display-name="Contents 3" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="0.998cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="16.002cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_4" style:display-name="Contents 4" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="1.498cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="15.503cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_5" style:display-name="Contents 5" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="1.997cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="15.004cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_6" style:display-name="Contents 6" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="2.496cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="14.504cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_7" style:display-name="Contents 7" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="2.995cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="14.005cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_8" style:display-name="Contents 8" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="3.494cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="13.506cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_9" style:display-name="Contents 9" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="3.993cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="13.007cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Contents_20_10" style:display-name="Contents 10" style:family="paragraph" style:parent-style-name="Index" style:class="index">
+   <style:paragraph-properties fo:margin-left="4.493cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
+    <style:tab-stops>
+     <style:tab-stop style:position="12.508cm" style:type="right" style:leader-style="dotted" style:leader-text="."/>
+    </style:tab-stops>
+   </style:paragraph-properties>
+  </style:style>
+  <style:style style:name="Quotations" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
+   <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
+  </style:style>
+  <style:style style:name="Preformatted_20_Text" style:display-name="Preformatted Text" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
+   <style:text-properties style:font-name="Courier New" fo:font-size="10pt" style:font-name-asian="NSimSun" style:font-size-asian="10pt" style:font-name-complex="Courier New" style:font-size-complex="10pt"/>
+  </style:style>
+  <style:style style:name="OrgVerse" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+   <style:paragraph-properties fo:background-color="#c0c0c0" fo:padding="0.049cm" fo:border="0.018cm solid #000000" style:shadow="none">
+    <style:background-image/>
+   </style:paragraph-properties>
+  </style:style>
+
+  <style:style style:name="OrgFixedWidthBlock" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+   <style:paragraph-properties fo:background-color="#c0c0c0" fo:padding="0.049cm" fo:border="0.018cm solid #000000" style:shadow="none">
+    <style:background-image/>
+   </style:paragraph-properties>
+  </style:style>
+
+  <style:style style:name="OrgFixedWidthBlockLastLine" style:family="paragraph" style:parent-style-name="OrgFixedWidthBlock">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm"/>
+  </style:style>
+
+  <style:style style:name="OrgSrcBlockLastLine" style:family="paragraph" style:parent-style-name="OrgSrcBlock">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm"/>
+  </style:style>
+
+  <style:style style:name="OrgCenter" style:family="paragraph" style:parent-style-name="Text_20_body">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="OrgTableContents" style:family="paragraph" style:parent-style-name="Text_20_body"/>
+  <style:style style:name="OrgTableHeading" style:family="paragraph" style:parent-style-name="OrgTableContents" style:class="extra">
+    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false" text:number-lines="false" text:line-number="0"/>
+    <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
+  </style:style>
+
+  <style:style style:name="OrgTableHeadingLeft" style:family="paragraph" style:parent-style-name="OrgTableHeading">
+    <style:paragraph-properties fo:text-align="left" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="OrgTableHeadingRight" style:family="paragraph" style:parent-style-name="OrgTableHeading">
+    <style:paragraph-properties fo:text-align="right" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="OrgTableHeadingCenter" style:family="paragraph" style:parent-style-name="OrgTableHeading">
+    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
+
+  <style:style style:name="OrgTableContentsLeft" style:family="paragraph" style:parent-style-name="OrgTableContents">
+    <style:paragraph-properties fo:text-align="left" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="OrgTableContentsRight" style:family="paragraph" style:parent-style-name="OrgTableContents">
+    <style:paragraph-properties fo:text-align="right" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="OrgTableContentsCenter" style:family="paragraph" style:parent-style-name="OrgTableContents">
+    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Text_20_body_20_bold" style:display-name="Text body bold" style:family="paragraph" style:parent-style-name="Text_20_body" style:next-style-name="Text_20_body">
+   <style:text-properties fo:font-weight="bold"/>
+  </style:style>
+  <style:style style:name="Footnote" style:family="paragraph" style:parent-style-name="Standard" style:class="extra">
+   <style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="-0.499cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/>
+   <style:text-properties fo:font-size="10pt" style:font-size-asian="10pt" style:font-size-complex="10pt"/>
+  </style:style>
+  <style:style style:name="Figure" style:family="paragraph" style:parent-style-name="Caption"/>
+  <style:style style:name="Illustration_20_Index_20_Heading" style:display-name="Illustration Index Heading" style:family="paragraph" style:parent-style-name="Heading" style:class="index">
+   <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" text:number-lines="false" text:line-number="0"/>
+   <style:text-properties fo:font-size="16pt" fo:font-weight="bold" style:font-size-asian="16pt" style:font-weight-asian="bold" style:font-size-complex="16pt" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="Table" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
+  <style:style style:name="Horizontal_20_Line" style:display-name="Horizontal Line" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="html">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.499cm" style:border-line-width-bottom="0.002cm 0.035cm 0.002cm" fo:padding="0cm" fo:border-left="none" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.039cm double #808080" text:number-lines="false" text:line-number="0" style:join-border="false"/>
+   <style:text-properties fo:font-size="6pt" style:font-size-asian="6pt" style:font-size-complex="6pt"/>
+  </style:style>
+  <style:style style:name="Emphasis" style:family="text">
+   <style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/>
+  </style:style>
+  <style:style style:name="Underline" style:family="text">
+   <style:text-properties style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" fo:background-color="transparent"/>
+  </style:style>
+  <style:style style:name="Strikethrough" style:family="text">
+   <style:text-properties style:text-line-through-style="solid"/>
+  </style:style>
+  <style:style style:name="Source_20_Text" style:display-name="Source Text" style:family="text">
+   <style:text-properties style:font-name="Courier New" fo:background-color="transparent" style:font-name-asian="NSimSun" style:font-name-complex="Courier New"/>
+  </style:style>
+  <style:style style:name="Citation" style:family="text">
+   <style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/>
+  </style:style>
+  <style:style style:name="Example" style:family="text">
+   <style:text-properties style:font-name="Courier New" fo:background-color="transparent" style:font-name-asian="NSimSun" style:font-name-complex="Courier New"/>
+  </style:style>
+  <style:style style:name="OrgCode" style:family="text" style:parent-style-name="Source_20_Text"/>
+
+  <!-- BEGIN: Org Agenda Styles -->
+  <style:style style:name="OrgTodo" style:family="text">
+   <style:text-properties fo:color="#ff0000"/>
+  </style:style>
+  <style:style style:name="OrgDone" style:family="text">
+   <style:text-properties fo:color="#008000"/>
+  </style:style>
+  <style:style style:name="OrgTag" style:family="text">
+   <style:text-properties fo:background-color="#add8e6"/>
+  </style:style>
+  <style:style style:name="OrgTimestamp" style:family="text">
+   <style:text-properties fo:color="#bebebe"/>
+  </style:style>
+  <style:style style:name="OrgTimestampKeyword" style:family="text">
+   <style:text-properties fo:color="#5f9ea0"/>
+  </style:style>
+  <style:style style:name="OrgTimestampWrapper" style:family="text"/>
+  <style:style style:name="OrgTarget" style:family="text"/>
+  <!-- END: Org Agenda Styles -->
+
+  <style:style style:name="Bold" style:family="text">
+   <style:text-properties fo:font-weight="bold"/>
+  </style:style>
+  <style:style style:name="Numbering_20_Symbols" style:display-name="Numbering Symbols" style:family="text"/>
+  <style:style style:name="Footnote_20_Symbol" style:display-name="Footnote Symbol" style:family="text"/>
+  <style:style style:name="Footnote_20_anchor" style:display-name="Footnote anchor" style:family="text">
+   <style:text-properties style:text-position="super 58%"/>
+  </style:style>
+  <style:style style:name="OrgSuperscript" style:family="text">
+   <style:text-properties style:text-position="super 58%"/>
+  </style:style>
+  <style:style style:name="OrgSubscript" style:family="text">
+   <style:text-properties style:text-position="sub 58%"/>
+  </style:style>
+  <style:style style:name="Internet_20_link" style:display-name="Internet link" style:family="text">
+   <style:text-properties fo:color="#000080" fo:language="zxx" fo:country="none" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" style:language-asian="zxx" style:country-asian="none" style:language-complex="zxx" style:country-complex="none"/>
+  </style:style>
+  <style:style style:name="Graphics" style:family="graphic">
+   <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
+  </style:style>
+  <style:style style:name="Frame" style:family="graphic">
+   <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" fo:margin-top="0.201cm" fo:margin-bottom="0.201cm" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0.15cm" fo:border="0.002cm solid #000000"/>
+  </style:style>
+
+  <!-- Simple Images   -->
+  <style:style style:name="OrgDisplayImage" style:family="graphic" style:parent-style-name="Graphics">
+   <style:graphic-properties text:anchor-type="paragraph" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
+  </style:style>
+
+  <style:style style:name="OrgPageImage" style:family="graphic" style:parent-style-name="Graphics">
+   <style:graphic-properties text:anchor-type="page" fo:margin-top="0.21cm" fo:margin-bottom="0.21cm" style:vertical-pos="middle" style:vertical-rel="page" style:horizontal-pos="center" style:horizontal-rel="page" fo:background-color="transparent" style:background-transparency="100%" style:shadow="none" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard">
+    <style:background-image/>
+   </style:graphic-properties>
+  </style:style>
+
+  <!-- Captioned Images  -->
+  <style:style style:name="OrgCaptionedImage" style:family="graphic" style:parent-style-name="Graphics">
+   <style:graphic-properties style:rel-width="100%" text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" style:vertical-rel="paragraph-content" style:horizontal-pos="from-left" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none" style:shadow="none"/>
+  </style:style>
+
+  <style:style style:name="OrgImageCaptionFrame" style:family="graphic" style:parent-style-name="Frame">
+   <style:graphic-properties text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0cm" fo:border="none"/>
+  </style:style>
+
+  <style:style style:name="OrgPageImageCaptionFrame" style:family="graphic" style:parent-style-name="Frame">
+   <style:graphic-properties text:anchor-type="paragraph" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.21cm" fo:margin-bottom="0.21cm" style:wrap="none" style:vertical-pos="middle" style:vertical-rel="page" style:horizontal-pos="center" style:horizontal-rel="page" fo:background-color="transparent" style:background-transparency="100%" fo:padding="0cm" fo:border="none" style:shadow="none">
+    <style:background-image/>
+   </style:graphic-properties>
+  </style:style>
+
+  <!-- Inlined Images -->
+  <style:style style:name="OrgInlineImage" style:family="graphic" style:parent-style-name="Graphics">
+   <style:graphic-properties text:anchor-type="as-char" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
+  </style:style>
+
+  <!-- Inline Formula -->
+  <style:style style:name="OrgFormula" style:family="graphic">
+    <style:graphic-properties text:anchor-type="as-char" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" style:vertical-pos="middle" style:vertical-rel="text" style:shadow="none"/>
+  </style:style>
+
+  <style:style style:name="OrgInlineFormula" style:family="graphic" style:parent-style-name="Formula">
+    <style:graphic-properties text:anchor-type="as-char" fo:margin-left="0.201cm" fo:margin-right="0.201cm" style:vertical-pos="middle" style:vertical-rel="text"/>
+  </style:style>
+
+  <style:style style:name="OrgInlineFormula" style:family="graphic" style:parent-style-name="Formula">
+    <style:graphic-properties style:vertical-pos="middle" style:vertical-rel="text" draw:ole-draw-aspect="1"/>
+  </style:style>
+
+  <style:style style:name="OrgDisplayFormula" style:family="graphic" style:parent-style-name="OrgFormula">
+    <style:graphic-properties style:vertical-pos="middle" style:vertical-rel="text" style:horizontal-pos="from-left" style:horizontal-rel="paragraph-content" draw:ole-draw-aspect="1"/>
+  </style:style>
+
+  <style:style style:name="OrgFormulaCaptionFrame" style:family="graphic" style:parent-style-name="Frame">
+    <style:graphic-properties fo:margin-top="0cm" fo:margin-bottom="0cm" style:vertical-pos="middle" style:vertical-rel="text" style:horizontal-pos="from-left" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none"/>
+  </style:style>
+
+  <style:style style:name="OrgCaptionedFormula" style:family="graphic" style:parent-style-name="OrgFormula">
+    <style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:run-through="foreground" style:wrap="none" style:vertical-pos="from-top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none" style:shadow="none" draw:ole-draw-aspect="1"/>
+  </style:style>
+
+  <!-- Inline Tasks -->
+  <style:style style:name="OrgInlineTaskHeading" style:family="paragraph" style:parent-style-name="Caption" style:next-style-name="Text_20_body">
+   <style:text-properties style:font-name="Arial1" fo:font-style="normal" fo:font-weight="bold"/>
+  </style:style>
+  <style:style style:name="OrgInlineTaskFrame" style:family="graphic" style:parent-style-name="Frame">
+   <style:graphic-properties svg:x="0cm" svg:y="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:background-color="#ffffcc" style:background-transparency="0%" fo:padding="0.15cm" fo:border="0.26pt solid #000000" style:shadow="none">
+    <style:background-image/>
+   </style:graphic-properties>
+  </style:style>
+
+  <text:list-style style:name="Numbering_20_1" style:display-name="Numbering 1">
+   <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.499cm" fo:text-indent="-0.499cm" fo:margin-left="0.499cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1cm" fo:text-indent="-0.499cm" fo:margin-left="1cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.499cm" fo:text-indent="-0.499cm" fo:margin-left="1.499cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="4" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.499cm" fo:margin-left="2cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="5" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.499cm" fo:text-indent="-0.499cm" fo:margin-left="2.499cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="6" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3cm" fo:text-indent="-0.499cm" fo:margin-left="3cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="7" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5cm" fo:text-indent="-0.499cm" fo:margin-left="3.5cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="8" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.499cm" fo:margin-left="4.001cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="9" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5cm" fo:text-indent="-0.499cm" fo:margin-left="4.5cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="10" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.001cm" fo:text-indent="-0.499cm" fo:margin-left="5.001cm"/>
+    </style:list-level-properties>
+   </text:list-level-style-number>
+  </text:list-style>
+  <text:list-style style:name="List_20_1" style:display-name="List 1">
+   <text:list-level-style-bullet text:level="1" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.4cm" fo:text-indent="-0.4cm" fo:margin-left="0.4cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="2" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.801cm" fo:text-indent="-0.4cm" fo:margin-left="0.801cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="3" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.199cm" fo:text-indent="-0.4cm" fo:margin-left="1.199cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="4" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.6cm" fo:text-indent="-0.4cm" fo:margin-left="1.6cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="5" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.4cm" fo:margin-left="2cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="6" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.401cm" fo:text-indent="-0.4cm" fo:margin-left="2.401cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="7" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.799cm" fo:text-indent="-0.4cm" fo:margin-left="2.799cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="8" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.2cm" fo:text-indent="-0.4cm" fo:margin-left="3.2cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="9" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.6cm" fo:text-indent="-0.4cm" fo:margin-left="3.6cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="10" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+    <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.4cm" fo:margin-left="4.001cm"/>
+    </style:list-level-properties>
+    <style:text-properties style:font-name="OpenSymbol"/>
+   </text:list-level-style-bullet>
+  </text:list-style>
+
+  <!-- Numbered List -->
+  <text:list-style style:name="OrgNumberedList">
+   <text:list-level-style-number text:level="1" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="2" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="3" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="4" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="5" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="6" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="7" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="8" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="9" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="10" style:num-suffix="." style:num-format="1">
+    <style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+  </text:list-style>
+
+  <!-- Bulleted List -->
+  <text:list-style style:name="OrgBulletedList">
+   <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+   <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
+    <style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm"/>
+    <style:text-properties fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
+   </text:list-level-style-bullet>
+  </text:list-style>
+
+  <!-- Description List -->
+  <text:list-style style:name="OrgDescriptionList">
+   <text:list-level-style-number text:level="1" style:num-format="">
+    <style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="2" style:num-format="">
+    <style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="3" style:num-format="">
+    <style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="4" style:num-format="">
+    <style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="5" style:num-format="">
+    <style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="6" style:num-format="">
+    <style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="7" style:num-format="">
+    <style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="8" style:num-format="">
+    <style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="9" style:num-format="">
+    <style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="10" style:num-format="">
+    <style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm"/>
+   </text:list-level-style-number>
+  </text:list-style>
+
+  <text:list-style style:name="OrgSrcBlockNumberedLine">
+   <text:list-level-style-number text:level="1" style:num-format="1">
+    <style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="2" style:num-format="1">
+    <style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="3" style:num-format="1">
+    <style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="4" style:num-format="1">
+    <style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="5" style:num-format="1">
+    <style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="6" style:num-format="1">
+    <style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="7" style:num-format="1">
+    <style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="8" style:num-format="1">
+    <style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="9" style:num-format="1">
+    <style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="10" style:num-format="1">
+    <style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+  </text:list-style>
+
+  <text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_20_Symbol" text:citation-body-style-name="Footnote_20_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
+  <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/>
+  <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
+ </office:styles>
+ <office:automatic-styles>
+  <style:page-layout style:name="Mpm1">
+   <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style/>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="Mpm1"/>
+ </office:master-styles>
+</office:document-styles>
index 71f216156f3afaf62224b53efe1697fc8d912a28..92df030d4d2082a5808db70ae68008edf8319143 100644 (file)
Binary files a/etc/refcards/orgcard.pdf and b/etc/refcards/orgcard.pdf differ
index 1579a31b8d56e7998d1cec7002a3193e009e6092..d49cd1e6252a9e0bc7d6a164d00bcbac793b57cb 100644 (file)
@@ -1,5 +1,5 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{7.7}
+\def\orgversionnumber{7.8.02}
 \def\versionyear{2011}          % latest update
 \def\year{2011}                 % latest copyright year
 
@@ -445,6 +445,7 @@ formula, \kbd{:=} a field formula.
 \key{execute code block at point}{C-c C-c}
 \key{open results of code block at point}{C-c C-o}
 \key{check code block at point for errors}{C-c C-v c}
+\key{insert a header argument with completion}{C-c C-v j}
 \key{view expanded body of code block at point}{C-c C-v v}
 \key{view information about code block at point}{C-c C-v I}
 \key{go to named code block}{C-c C-v g}
@@ -460,7 +461,7 @@ formula, \kbd{:=} a field formula.
 \key{tangle code blocks in supplied file}{C-c C-v f}
 \key{ingest all code blocks in supplied file into the Library of Babel}{C-c C-v i}
 \key{switch to the session of the current code block}{C-c C-v z}
-\key{load expanded body of the current code block into a session}{C-c C-v l}
+\key{load the current code block into a session}{C-c C-v l}
 \key{view sha1 hash of the current code block}{C-c C-v a}
 
 \section{Completion}
@@ -525,7 +526,7 @@ after  ``{\tt :}'', and dictionary words elsewhere.
 \section{Timestamps}
 
 \key{prompt for date and insert timestamp}{C-c .}
-\key{like \kbd{C-c} . but insert date and time format}{C-u C-c .}
+\key{like \kbd{C-c .} but insert date and time format}{C-u C-c .}
 \key{like \kbd{C-c .} but make stamp inactive}{C-c !} % FIXME
 \key{insert DEADLINE timestamp}{C-c C-d}
 \key{insert SCHEDULED timestamp}{C-c C-s}
@@ -673,7 +674,7 @@ never exported.
 
 \section{Notes}
 [1] This is only a suggestion for a binding of this command.  Choose
-your own key as shown under INSTALLATION.
+your own key as shown under ACTIVATION.
 
 [2] Keybinding affected by {\tt org-support-shift-select} and also
  {\tt org-replace-disputed-keys}.
@@ -686,4 +687,3 @@ your own key as shown under INSTALLATION.
 % compile-command: "tex refcard"
 % End:
 
-
index ac328d1091044af424e843f4e1560e42ded1dbb2..6f0d0bedd9f94b4f1d094b9e5e015bffe82df9e7 100644 (file)
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-ctrl-c-ctrl-c): Preserve symmetry when adding
+       and removing checkboxes with `C-u C-c C-c' on the first item
+       of a list.  Also, don't reinitialize checkboxes that are
+       already ticked.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-ts-regexp0, org-ts-regexp1): Also match a time
+       value with only one digit for the hours.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-batch-agenda, org-batch-agenda-csv):
+       Remove deleted function `org-encode-for-stdout'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-show-context): Complete docstring.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-filter-by-tag): Use
+       `read-char-exclusive' instead of `read-char'.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+       * org-clock.el (org-clock-in, org-clock-find-position): Remove
+       erraneous space in regexp.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-expand-noweb-references): Rather than using
+       a pure regexp solution to resolve noweb references, actually
+       check the information of every code block in the buffer.  This
+       will cause a slowdown in noweb reference expansion, but is
+       necessary for correct behavior.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-map-continue-from): Fix typo in docstring.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-property-re): Also match cumulating properties
+       like ":prop+:".
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-exp-blocks.el (org-export-blocks-preprocess): Fix regexp for
+       matching the end of a block.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-open-at-point): Escape link path for http:,
+       https:, ftp:, news:, and doi: links only if the path contains
+       space or non-ascii character.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-refile-get-targets): Ignore headlines without a
+       true headline.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-map-call-lines): Moved this file from
+       ob-lob.el into ob.el to ease dependency pains.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-publish.el (org-publish-index-generate-theindex): Use
+       theindex.inc for storing index entries, and theindex.org for
+       including theindex.inc.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-publish.el (org-publish-index-generate-theindex): Create
+       proper file target for index entries in subdirectories.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-protocol.el (org-protocol-check-filename-for-protocol):
+       Fix spelling mistake.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-export-odt-default-org-styles-alist): Add styles
+       for title and subtitle.
+       (org-odt-format-toc): New.
+       (org-odt-format-preamble): New.  Users can redefine this to
+       customize what goes before the document body.  Currently it
+       outputs title, author and email, date and toc.
+       (org-odt-begin-document-body): Use `org-odt-format-preamble'.
+       (org-odt-format-date): Renamed from
+       `org-odt-iso-date-from-org-timestamp'.  Also added an
+       additional param for format string.
+       (org-odt-begin-annotation, org-odt-update-meta-file): Use
+       `org-odt-format-date'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-at-drawer-p): New function.
+       (org-end-of-line): Use it.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (*org-babel-use-quick-and-dirty-noweb-expansion*):
+       Controls the method in which noweb references are expanded.
+       (org-babel-expand-noweb-references): Bring back the option for
+       regexp-based noweb expansion.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-ts-regexp0, org-ts-regexp1): Also match a time value
+       with only one digit for the hours.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-ctrl-c-ctrl-c): Don't make `C-c C-c' special
+       when ticking the checkbox of the first item.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-list-write-struct): Add an optional
+       argument for structure changes happening outside the function.
+
+       * org.el (org-ctrl-c-ctrl-c): Now, `C-u C-c C-c' on the first
+       item of a sub-list should toggle check-box presence of every
+       item in the same sub-list.  Also fix check-box insertion on a
+       single item.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-filter-preset): New alias.
+       (org-agenda-filter-by-category): New command.
+       (org-agenda-mode-map): Add the new command.
+       (org-agenda-custom-commands-local-options): Add category
+       filter preset.
+       (org-agenda-mark-filtered-text): Mark both tag and filter
+       overlays.
+       (org-agenda-category-filter-preset): New variable.
+       (org-finalize-agenda, org-agenda-redo)
+       (org-agenda-filter-make-matcher, org-agenda-filter-apply): Handle
+       both category and tag filters.
+       (org-agenda-filter-show-all-tag): Rename from
+       `org-agenda-filter-by-tag-show-all'.
+       (org-agenda-filter-show-all-cat): New function.
+       (org-agenda-set-mode-name): Show the category filter in the
+       modeline.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-bbdb.el (org-bbdb-old): New variable.
+       (org-bbdb-store-link, org-bbdb-open): Check for
+       `org-bbdb-old'.
+       (org-bbdb-open-old, org-bbdb-open-new): New functions.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-batch-agenda, org-batch-agenda-csv):
+       Remove deleted function `org-encode-for-stdout'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-check-dates-range): New command.
+       (org-sparse-tree): Use it.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-write): Rename from
+       `org-write-agenda'.
+       (org-agenda-mode-map, org-agenda-menu)
+       (org-batch-store-agenda-views): Use new name
+       `org-agenda-write'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-loop-over-headlines-in-active-region): Fix
+       docstring.
+       (org-todo, org-deadline, org-schedule): Honor the 'start-level
+       value of `org-loop-over-headlines-in-active-region'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-archive.el (org-archive-subtree)
+       (org-archive-to-archive-sibling, org-toggle-archive-tag):
+       Bugfix: use 'region-start-level.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-show-context): Complete docstring.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-filter-by-tag): Use
+       `read-char-exclusive' instead of `read-char'.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-scan-tags): Make sure `org-map-continue-from' is
+       nil at each match.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+       * org-clock.el (org-clock-in, org-clock-find-position): Remove
+       erraneous space in regexp.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-odt-lib-dir): Add docstring.
+       (org-odt-data-dir): New variable.  Use this variable to
+       control the locations from which the ODT exporter picks the
+       OpenDocument styles and schema files from.  Set this variable
+       explicitly only if the in-built heuristics for locating the
+       above files fails.
+       (org-odt-styles-dir-list, org-odt-schema-dir-list): New
+       variables.  Pay specific attention to (eval-when-compile ...)
+       form through which Makefile's $(datadir) - contained in
+       `org-odt-data-dir' - gets compiled in as a "hard coded"
+       constant.
+       (org-odt-styles-dir, org-export-odt-schema-dir): Add messages to
+       aid debugging.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-archive.el (org-archive-subtree)
+       (org-archive-to-archive-sibling, org-toggle-archive-tag)
+       (org-archive-set-tag): Handle the 'start-level value for
+       `org-loop-over-headlines-in-active-region'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-scan-tags): New parameter `start-level' to scan only
+       through headlines of that level.
+       (org-map-entries): New allowed value `region-start-level' for
+       the `scope' parameter, to allow scanning through headlines of
+       the same level than the first headline in the region.
+       (org-loop-over-headlines-in-active-region): New allowed value
+       'start-level.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-archive.el (org-archive-subtree)
+       (org-archive-to-archive-sibling, org-archive-set-tag)
+       (org-toggle-archive-tag): Allow to loop over the active region by
+       using `org-loop-over-headlines-in-active-region'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-todo): Allow to loop over the active region by
+       using `org-loop-over-headlines-in-active-region'.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-expand-noweb-references): Rather than using
+       a pure regexp solution to resolve noweb references, actually
+       check the information of every code block in the buffer.  This
+       will cause a slowdown in noweb reference expansion, but is
+       necessary for correct behavior.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-map-continue-from): Fix typo in docstring.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-write-buffer-name): New variable.
+       (org-write-agenda): Use it.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-exp.el (org-export-date-timestamp-format): New option to
+       define the way a timestamp in #+DATE will be exported.
+       (org-infile-export-plist): Use the new option.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-drill.el (org-drill-leech-method, org-drill-scope)
+       (org-drill-spaced-repetition-algorithm): Fix wrong :type spec.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-property-re): Also match cumulating properties
+       like ":prop+:".
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-odt-styles-dir): Assume that the styles
+       files are located under `data-directory' of Emacs distribution
+       as etc/org/OrgOdtStyles.xml and
+       etc/org/OrgOdtContentTemplate.xml.  Also update docstring.
+       (org-export-odt-schema-dir): Update docstring.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-odt-format-preamble): Honor following user
+       options: author, timestamp and email.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-exp-blocks.el (org-export-blocks-preprocess): Fix regexp
+       for matching the end of a block.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-eshell.el: New file.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-open-at-point): Escape link path for http:,
+       https:, ftp:, news:, and doi: links only if the path contains
+       space or non-ascii character.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-beamer.el (org-beamer-fragile-re): Also recognize
+       \lstinline and \verb as commands that make a frame fragile.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-refile-get-targets): Ignore headlines without a
+       true headline.
+
+2012-01-03  Litvinov Sergey  <slitvinov@gmail.com>
+
+       * ob-octave.el: add graphical output to png file
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-map-call-lines): Moved this file from
+       ob-lob.el into ob.el to ease dependency pains.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-publish.el (org-publish-index-generate-theindex): Use
+       theindex.inc for storing index entries, and theindex.org for
+       including theindex.inc.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-publish.el (org-publish-index-generate-theindex): Create
+       proper file target for index entries in subdirectories.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-protocol.el (org-protocol-check-filename-for-protocol):
+       Fix spelling mistake.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-export-odt-default-org-styles-alist): Add
+       styles for title and subtitle.
+       (org-odt-format-toc): New.
+       (org-odt-format-preamble): New.  Users can redefine this to
+       customize what goes before the document body.  Currently it
+       outputs title, author and email, date and toc.
+       (org-odt-begin-document-body): Use `org-odt-format-preamble'.
+       (org-odt-format-date): Renamed from
+       `org-odt-iso-date-from-org-timestamp'.  Also added an
+       additional param for format string.
+       (org-odt-begin-annotation, org-odt-update-meta-file): Use
+       `org-odt-format-date'.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob-ref.el (org-babel-ref-split-args): Now uses
+       `org-babel-balanced-split'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-export-html-preamble)
+       (org-export-html-postamble): Fix docstrings.
+       (org-export-as-html): Insert the string used by a custom
+       function for `org-export-html-pre/postamble'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-block-regexp)
+       (org-heading-keyword-regexp-format)
+       (org-heading-keyword-maybe-regexp-format): Move up to keep the
+       byte-compiler happy.
+
+2012-01-03  Dave Abrahams  <dave@boostpro.com>  (tiny change)
+
+       * org-agenda.el (org-agenda-do-tree-to-indirect-buffer): New
+       function.
+       (org-agenda-tree-to-indirect-buffer): Use the new function.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-export-as-html): Fix bug when inserting the
+       output of a custom function for the pre/postamble.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-odt-format-source-code-or-example): Try
+       loading htmlfontify safely.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-odt.el (require): Require htmlfontify.el only if
+       emacs-version is greater than 23.2.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-faces.el (org-agenda-calendar-event)
+       (org-agenda-calendar-sexp): Use the default face.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-expand-noweb-references): Fixed regexp.
+
+2012-01-03  Michael Brand  <michael.ch.brand@gmail.com>
+
+       * org.el Key bindings: remap the Outline functions from
+       `outline-mode-prefix-map' where possible.
+
+2012-01-03  Christian Moe  <mail@christianmoe.com>  (tiny change)
+
+       * org-html.el (org-export-as-html): Apply
+       `org-export-html-get-todo-kwd-class-name' to the class
+       attribute of the todo-keyword span tag, not to its text
+       content.
+
+2012-01-03  Sebastien Vauban  <sva@mygooglest.com>
+
+       * org-agenda.el (org-agenda-get-timestamps)
+       (org-agenda-get-sexps): Use face for highlighting "calendar"
+       events.
+
+2012-01-03  Peter Münster  <pmlists@free.fr>  (tiny change)
+
+       * org.el (org-add-planning-info): Treat absolute time too.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-table.el (org-table-transpose-table-at-point): Don't use
+       Ì€remove-if-not'.
+
+2012-01-03  Dave Abrahams  <dave@boostpro.com>  (tiny change)
+
+       * org-clock.el (org-clock-out-if-current): Check the clock
+       buffer is existing.
+
+2012-01-03  Bernt Hansen  <bernt@norang.ca>
+
+       * org-clock.el (org-clock-out-if-current): Fix marker in no
+       buffer error for task state change in an indirect buffer.
+
+2012-01-03  Michael Brand  <michael.ch.brand@gmail.com>
+
+       * org.el (org-offer-links-in-entry): Make list when assigning
+       a single link.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-expand-noweb-references): Rather than
+       collect the info from *every* block in the current buffer,
+       simply regexp search for those blocks which appear to match
+       the continued source name.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob.el (org-babel-insert-result): Do not examplize wrapped
+       scalar results, simply wrap them.
+       (org-babel-result-end): Find the end of results wrapped in a
+       RESULTS drawer.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-todo-yesterday): When called from the agenda,
+       use `org-agenda-todo-yesterday' instead.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-table.el (org-table-transpose-table-at-point): New command.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-export-html-headline-anchor-format): New
+       option.
+       (org-html-level-start): Use the new option.
+
+2012-01-03  Rob Giardina  <rob@giardina.us>  (tiny change)
+
+       * org-agenda.el (org-agenda-with-point-at-orig-entry): Small
+       bugfix.
+
+2012-01-03  Christian Moe  <mail@christianmoe.com>  (tiny change)
+
+       * org-special-blocks.el
+       (org-special-blocks-convert-html-special-cookies): Close
+       paragraph before opening or closing the <div>, and open
+       paragraph after. Also changed newline placement to be the same
+       as for other blocks.
+
+2012-01-03  Roberto Huelga  <rhuelga@gmail.com>
+
+       * org-clock.el (org-program-exists): Make the function
+       compatible with darwin systems.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-exp.el (org-export-normalize-links): Mark bracket links
+       before normalization to avoid erroneous normalization of
+       bracket link parts.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-odt.el (org-odt-data-dir): Removed.
+       (org-odt-styles-dir, org-export-odt-schema-dir): New
+       variables.
+
+       * org-odt.el: New file.
+
+       * org-lparse: New file.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-capture.el (org-capture-set-target-location): Set the
+       capture default time also to the prompt time.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-exp.el (org-export-res/src-name-cleanup): Remove #+name
+       and #+results lines during preprocess.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob-picolisp.el (ob-comint): Required.
+       (comint): Required.
+       (cl): Required.
+       (run-picolisp): Declared.
+       (org-babel-execute:picolisp): Capture free variable, and replace
+       function from cl-extra with core function.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * ob-picolisp.el: New file.
+
+       * org.el (org-babel-load-languages): Add Pico Lisp to the list
+       of supported code block languages.
+
+2012-01-03  Eric Schulte  <eric.schulte@gmx.com>
+
+       * org-bibtex.el (org-bibtex): Now catches bibtex errors and
+       directs the user to the location of the error.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-dim-blocked-tasks): Fix typo.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * ob.el (org-babel-execute-src-block): Fix typo.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-freemind.el (org-freemind-write-mm-buffer): Fix typo.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-link-unescape, org-link-unescape-compound): Fix
+       two typos in docstrings.
+
+2012-01-03  Thomas Dye  <dk@poto.local>
+
+       * ob-R.el: Added tikzDevice support.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-clone-subtree-with-time-shift): Remove clocking
+       information and empty drawers when preparing a clone.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el: Don't add `org-exp-res/src-name-cleanup' to
+       `org-export-blocks-postblock-hook'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-hide-result-toggle): Skip over header
+       argument lines when toggling named code block visibility.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-exp.el (org-export-grab-title-from-buffer): Don't
+       license to kill text inside blocks when getting a title.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-confirm-evaluate): Adding support for new
+       range of :eval header arguments.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-confirm-evaluate): Inhibit evaluation
+       during export when eval is set to "non-export".
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-ref.el (org-babel-update-intermediate): New custom
+       variable.
+       (org-babel-ref-resolve): Optionally update the in-buffer results
+       of code blocks which are evaluated to resolve references.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-join-splits-near-ch): Rejoins a list of a
+       split string when a character appears on either side of the
+       split.
+       (org-babel-parse-multiple-vars): Rejoin splits around "=" signs.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.el (org-reduce): Added a less functional Org-mode copy of
+       the cl reduce function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-fontify-meta-lines-and-blocks-1): Recognize
+       "name" as a valid keyword that can preceed a block.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el (org-babel-exp-lob-one-liners): Don't limit
+       in-verbatim check to inline code blocks, do lob code blocks as
+       well.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-todo): Interpret 0 prefix arg as note inhibitor.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-named-src-block-regexp-for-name): Ensure
+       that partial names are not matched.
+       (org-babel-named-data-regexp-for-name): Ensure that partial names
+       are not matched.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-ref.el (org-babel-ref-resolve): Search for named code
+       blocks before named data.
+
+       * ob.el (org-babel-named-data-regexp-for-name): New function for
+       finding named data.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-insert-result): Gracefully handle results
+       which are neither lists nor strings.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-ref.el (org-babel-ref-resolve): Don't change location when
+       looking at the contents.
+
+2012-01-03  Milan Zamazal  <pdm@zamazal.org>
+
+       * org.el (org-set-outline-overlay-data): Use
+       outline-flag-region to make a region invisible.  This ensures
+       all necessary actions, especially adding
+       isearch-open-invisible property, are applied.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-lob.el (org-babel-in-example-or-verbatim): Fix
+       compilation warning.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-find-named-result): Downcase "name" before
+       comparison.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-lisp.el (org-babel-execute:lisp): Fixed typo.
+       (org-babel-lisp-vector-to-list): Fixed typo.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el (org-babel-in-example-or-verbatim): Some valid
+       execution contexts (e.g., call lines) look like commented
+       lines.
+
+       * ob.el (org-babel-get-src-block-info): Empty match string doesn't
+       count.
+       (org-babel-process-params): Always process parameters, even if
+       you don't to table splitting.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el (org-exp-res/src-name-cleanup): Updated Documentation.
+
+       * ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
+       regular expression.
+       (org-babel-inline-lob-one-liner-regexp): Updated regular
+       expression.
+
+       * ob-ref.el (org-babel-ref-resolve): Notice when something that
+       looks like a data results may actually be a code block.
+
+       * ob-table.el: Updated documentation.
+
+       * ob.el (org-babel-src-name-regexp): Simplified regexp.
+       (org-babel-get-src-block-info): Updated match strings.
+       (org-babel-data-names): Simplified acceptable names.
+       (org-babel-find-named-block): Indentation.
+       (org-babel-find-named-result): Updated to not return a code block
+       as a result.
+
+       * org.el (org-fontify-meta-lines-and-blocks-1): Removing
+       references to old syntactic elements.
+       (org-additional-option-like-keywords): Removing references to
+       old syntactic elements.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-agenda-get-todos): Swap calls to `org-trim'
+       and `buffer-substring'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-agenda.el (org-agenda-get-todos): Prevent an error when
+       encountering tasks with only the TODO keyword.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-try-cdlatex-tab): Don't try to expand a LaTeX
+       environment when at an item or an headline, but allow LaTeX
+       fragments.
+       (org-cycle): Try to call `cdlatex-tab' before cycling item's or
+       headline's visibility, in order to catch LaTeX fragments within.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-exp-blocks.el (org-export-blocks-preprocess): Require a
+       newline and spaces before a code block.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-lob.el (org-babel-map-call-lines): Allow mapping of code
+       over all call lines in a buffer.
+
+       * ob.el (org-babel-execute-buffer): Execute call lines when
+       executing an entire buffer.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-process-params): Don't disassemble tables
+       twice.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-clock.el (org-clock-in, org-clock-find-position): Make space
+       after date optional.
+
+       * org.el (org-set-regexps-and-options)
+       (org-ts-regexp, org-ts-regexp-both, org-ts-regexp1)
+       (org-ctrl-c-ctrl-c): Make `C-c C-c' on date fix the time stamp.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-lob.el (org-babel-lob-execute-maybe): Don't execute a call
+       inside a verbatim block.
+
+       * ob-exp.el (org-babel-in-example-or-verbatim): Check for example
+       blocks.
+
+2012-01-03  Litvinov Sergey  <slitvinov@gmail.com>
+
+       * ob-maxima.el (org-babel-tangle-lang-exts): Maxima extension.
+       (org-babel-maxima-expand): Add input variables and graphic output.
+       (org-babel-execute:maxima): Add input variables and graphic output.
+       (org-babel-maxima-var-to-maxima): Add input variables and graphic
+       output.
+       (org-babel-maxima-graphical-output-file): Add input variables and
+       graphic output.
+       (org-babel-maxima-elisp-to-maxima): Add input variables and graphic
+       output.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-fortran.el: New file.  Adding support for Fortran code blocks.
+       * org.el (org-babel-load-languages): Adding fortran to this list.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-new): Cannot insert an inline
+       footnote at beginning of line anymore.
+       (org-footnote-at-reference-p): Don't recognize inline footnotes at
+       beginning of line.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-set-font-lock-defaults): Fix small error in matching
+       group that prevented fontification of keywords like
+       org-comment-string and stars in headlines.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-catch-invisible-edits): New option.
+       (org-self-insert-command, org-delete-backward-char)
+       (org-delete-char): Call `org-check-before-invisible-edit'.
+       (org-check-before-invisible-edit): New function.
+
+2012-01-03  Suvayu Ali  <fatkasuvayu+linux@gmail.com>
+
+       * org-exp.el (org-solidify-link-text): Respect
+       org-export-with-tags when forming the export title during subtree
+       export.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-heading-regexp, org-heading-keyword-regexp-format)
+       (org-heading-keyword-maybe-regexp-format): Globalize variables so
+       they are accessible even in buffers not in Org mode.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-insert-link): Don't use default-description if a
+       `org-make-link-description-function' is defined.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.el (org-set-regexps-and-options): Use property blocks for
+       multi-line properties.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-self-insert-command): Don't throw an error when
+       editing takes place at the first point of the buffer.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-self-insert-command): Unfold invisible region at
+       point or right before point when editing.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-faces.el (org-agenda-filter-tags): Use the 'modeline face as
+       default.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-html-expand): Prevent a nil value for STRING to
+       return an error, just return nil.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-latex.el (org-export-latex-set-initial-vars): Allow "/"
+       character in the #+LaTeX_CLASS option.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-at-reference-p)
+       (org-footnote-at-definition-p): Don't store text-properties of
+       footnote definitions.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-export-as-html): Convert special characters in
+       meta tag "author", "date", "keyword" and "description".
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-capture.el (org-capture-before-finalize-hook): Docstring
+       improvement: mention that the buffer is widened when this hook is
+       run.
+
+2012-01-03  Sebastien Vauban  <sva@mygooglest.com>
+
+       * org-html.el (org-export-as-html): Make sure the div for preamble
+       is not inserted when the preamble is empty.
+
+2012-01-03  Sebastien Vauban  <sva@mygooglest.com>
+
+       * org-agenda.el (org-agenda-set-mode-name): Highlight tags used
+       for filtering (shown in the mode-line).
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-parse-multiple-vars): Trimming excess white
+       space from split variables.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-link-search): Add an optional argument preventing
+       function from revealing context around match.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (calendar-check-holidays): Declare function.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-return): Fix bug when matching the face property
+       before following a link.
+
+2012-01-03  Matt Lundin  <mdl@imapmail.org>
+
+       * org-agenda.el: (org-class): Fix holidays symbol in
+       org-class.  This was resulting in an "Bad sexp..." warning.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-scan-tags): Also remember
+       `org-complex-heading-regexp' in a property.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-latex.el (org-export-as-latex): Turn off auto-insert and set
+       TeX-master to t when creating new TeX buffers.
+
+       * org-docbook.el (org-export-as-docbook): Turn off auto-insert
+       when creating new buffers.
+
+       * org-html.el (org-export-as-html): Turn off auto-insert
+       when creating new buffers.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-table.el (org-table-formula-handle-first/last-rc): Do not
+       expand pointers to first/last row/column that are inside a call to
+       `remote'.
+       (org-table-get-remote-range): Expand pointers to first/last
+       row/column.
+
+2012-01-03  Michael Sperber  <sperber@deinprogramm.de>  (tiny change)
+
+       * org-capture.el (org-capture-get-indirect-buffer): Fix XEmacs
+       compatibility issue when creating an indirect buffer.
+
+2012-01-03  Christophe Rhodes  <csr21@cantab.net>
+
+       * org-exp.el (org-infile-export-plist): Handle LATEX_CLASS_OPTIONS
+       the same way than LATEX_CLASS.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-return): Check the presence of the 'org-link face
+       even in contexts where there is more than one face.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-sql.el (org-babel-header-arg-names:sql): Sql specific header
+       argument names which should be inherited.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-in-block-p): Return matched name of block, if
+       any.  It can be useful when a list of block names is provided as
+       an argument.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-docbook.el (org-export-as-docbook): Fix regexp.
+
+       * org-html.el (org-export-as-html): Fix regexp.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-class): Allow holidays to be skipped.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-shen.el (org-babel-execute:shen): Fix two compilation errors.
+
+2012-01-03  Peter Münster  <pmrb@free.fr>  (tiny change)
+
+       * org-agenda.el (org-agenda-to-appt): Make sure filter-items are
+       strings before calling `string-match'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-at-reference-p)
+       (org-footnote-at-definition-p): Remove text-properties from label.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-export-as-html): Add a "title" meta tag.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-to-appt): Allow to refine the scope of
+       entries to pass to `org-agenda-get-day-entries' and allow to
+       filter out entries using a function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-agenda.el: Fix small display bug.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-set-regexps-and-options): Fix small bug introduced
+       by commit dfcb6faef11a2439b56b18a6289803361d402130.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-agenda.el (org-search-view): Simplify regexp.
+       (org-agenda-get-todos): Use new format string.
+
+       * org-archive.el (org-archive-all-done): Simplify regexp.
+
+       * org-ascii.el (org-export-as-ascii): More accurate regexp.
+
+       * org-colview.el (org-columns-capture-view): Use new format string
+       and new string.
+
+       * org-docbook.el (org-export-as-docbook): More accurate
+       regexp.  Also use new regexp to match generic headlines.
+
+       * org-exp.el (org-export-protect-quoted-subtrees): More accurate
+       regexp.  Also use new regexp to match generic headlines.
+
+       * org-html.el (org-export-as-html): More accurate regexp.  Also
+       use new regexp to match generic headlines.
+
+       * org-mouse.el (org-mouse-match-todo-keyword): Removed unused
+       and now erroneous function.
+
+       * org.el (org-heading-regexp, org-heading-keyword-regexp-format):
+       New variables.
+       (org-set-regexps-and-options): Create regexps according to the
+       following rule: use spaces only to separate elements from an headline,
+       while allowing mixed tabs and spaces for any indentation job.
+       (org-nl-done-regexp, org-looking-at-done-regexp): Removed variables.
+       (org-set-font-lock-defaults): Fontify again headlines with a keyword
+       and no other text.  Use new format strings.
+       (org-get-heading, org-toggle-comment, org-prepare-agenda-buffers)
+       (org-toggle-fixed-width-section): Use new format string.
+       (org-todo): More accurate regexps.
+       (org-point-at-end-of-empty-headline): Simplify regexp.
+       (org-insert-heading): Headline can sometimes be nil.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-agenda.el (org-agenda-bulk-action): Bind
+       `org-loop-over-headlines-in-active-region' to nil to avoid conflict
+       with bulk command.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-deadline, org-schedule): Skip invisible headlines when
+       mapping over headlines in active region.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-loop-over-headlines-in-active-region): New
+       customization variable.  Loop over headlines in active region.
+       (org-schedule, org-deadline): Apply to headlines in region depending
+       on new customization variable.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-map-entries): Immediately return if scope is 'region
+       but no region is active.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-map-entries): Extend scope 'region to include entire
+       body of last headline in active region.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-src.el (org-edit-src-code): Fix typo-bug.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-format-agenda-item, org-scan-tags): Rename
+       `org-format-agenda-item' to `org-agenda-format-item'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el: Replace `category-pos' by `org-category-pos' to
+       silent byte-compiler.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el: Declare external function `cdlatex-compute-tables'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-latex.el (org-export-latex-set-initial-vars): Fix problem
+       when matching #+LaTeX_CLASS.
+
+2012-01-03  Rafael Laboissiere  <rafael@laboissiere.net>  (tiny change)
+
+       * org.el (org-link-search-must-match-exact-headline): Fix typos.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-latex.el (org-export-latex-make-header): Add some hyperref
+       options.
+
+2012-01-03  Kai Tetzlaff  <kai.tetzlaff@web.de>  (tiny change)
+
+       * org-publish.el (org-publish-file): Added 'eval'ing the value of
+       the :publishing-directory property before using it as destination
+       of the publishing project.  This allows to construct the publish
+       destination directory dynamically at run-time using the return
+       value of a function.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-list-stuck-projects): Fix tiny bug.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-agenda-move-date-from-past-immediately-to-today):
+       New option.
+       (org-agenda-date-later): Improve the logical structure.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * ob-calc.el (featurep): Require calc-store.
+
+       * org-agenda.el (org-agenda-list-stuck-projects): Fix regexp
+       special handling.
+
+       * org-compat.el (fboundp): Support for XEmacs.
+
+       * org-exp.el (org-export): Protect XEmacs from `(redisplay)' call.
+
+       * org-footnote.el (org-footnote-re): Optimize macro processing.
+
+       * org.el (org-set-autofill-regexps): Xemacs compatibility.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-balanced-split): Balance both [] and ()
+       groupings.
+       (org-babel-parse-header-arguments): Be sure to replace removed ":"
+       characters.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-parse-header-arguments): Quick fix for a
+       tiny bug.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-params-from-properties): Now splits
+       multiple var arguments behind a single ":var".
+       (org-babel-balanced-split): Separated balanced splitting of
+       strings out into a new function.
+       (org-babel-parse-multiple-vars): Splits multiple var arguments
+       behind a single ":var".
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el: Remap `outline-promote' and `outline-demote' keys to
+       `org-promote-subtree' and `org-demote-subtree'.
+
+2012-01-03  Leo  <sdl.web@gmail.com>
+
+       * org-agenda.el (org-agenda-do-context-action): Check if marker is
+       valid before use.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+       * org-agenda.el (org-agenda-date-later): Fix shifting of date
+       ranges.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el: Removing `org-babel-params-from-buffer' and
+       #+PROPERTIES: entirely.
+
+       * ob-exp.el (org-babel-exp-src-block): Removing
+       `org-babel-params-from-buffer' and #+PROPERTIES: entirely.
+
+       * ob-lob.el (org-babel-lob-execute): Removing
+       `org-babel-params-from-buffer' and #+PROPERTIES: entirely.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-params-from-buffer): Removing #+BABEL:
+       lines in favor of general #+PROPERTIES: lines.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-sql.el (org-babel-execute:sql): Insert into a temporary
+       buffer.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-cdlatex-mode): Run `cdlatex-mode-hook' and
+       update the internal cdlatex tables.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-sql.el (org-babel-execute:sql): Respect literal-results
+       options.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-disassemble-tables): Fix multi-table bug in
+       code block colname and rowname handling.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-publish.el (org-publish-cache-file-needs-publishing):
+       Fix regexp to not inlcude newlines.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-ctrl-c-ctrl-c): Remove table overlays before
+       restart.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-fontify-entities): Match entities before
+       numbers, as in `\sim2'.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-agenda-date-later): Make pushing forward
+       a past date to jump immedialtely to today.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-exp.el (org-store-forced-table-alignment): Parse the
+       column cookie for both alignment and width
+       specification.  Store the resulting value in `org-col-cookies'
+       property.  Retire the previously used `org-forced-aligns'
+       property for consistency.  Renamed local variable `aligns' to
+       `cookies'.
+
+       * org-html.el (org-format-org-table-html): Use
+       `org-col-cookies'.  Renamed local variable forced-aligns to
+       col-cookies.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-latex-to-mathml-jar-file)
+       (org-latex-to-mathml-convert-command): New user-customizable
+       variables.
+       (org-format-latex-mathml-available-p, org-create-math-formula)
+       (org-format-latex-as-mathml): New functions.
+       (org-format-latex): Add a new local variable block-type that notes
+       the nature of the equation - inline or display.  Associate it's
+       value to `org-latex-src-embed-type' property of dvipng links.  Add
+       mathml as new processing type.
+
+2012-01-03  Sébastien Vauban  <wxhgmqzgwmuf@spammotel.com>
+
+       * org.el (org-refile): Add tree name to prompt.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-latex.el (org-export-latex-tables): Honor
+       `org-export-latex-table-caption-above'
+       (org-export-latex-table-caption-above): New option.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-insert-header-arg): Now including language
+       specific header arg values in insertion options.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-insert-header-arg): Fixed typo.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-exp.el (org-export-number-lines): Modified.  Add a new
+       parameter `preprocess' and use this for backend-agnostic
+       handling of literal examples.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-match-substring-regexp)
+       (org-match-substring-with-braces-regexp): Allow subscripts and
+       superscripts to start at beginning of line.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-common-header-args-w-values): New variable to
+       hold common header arguments and their default values.
+       (org-babel-header-arg-names): Redefined using the new common
+       header arg variable.
+       (org-babel-insert-header-arg): New function to help when inserting
+       header arguments.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-html.el (org-html-handle-links): Remove unnecessary
+       protection markers when publishing link in default format.
+
+2012-01-03  Pieter Praet  <pieter@praet.org>  (tiny change)
+
+       * org-crypt.el (org-crypt-check-auto-save): New function, see
+       next change.
+
+       * org-crypt.el (org-decrypt-entry): Break the auto-save-mode
+       check out into a separate function, and call it at a later
+       point, to assure it only runs when visiting an encrypted
+       entry.
+
+2012-01-03  John J Foerch  <jjfoerch@earthlink.net>  (tiny change)
+
+       * org.el (org-log-note-headings): Document new %d and %D
+       escapes.
+       (org-store-log-note): Implement new %d and %D escapes.
+
+2012-01-03  Dave Abrahams  <dave@boostpro.com>
+
+       * org-agenda.el (org-agenda-follow-indirect): New option.
+       (org-agenda-follow-mode): Call `org-agenda-do-context-action' fro
+       follow mode.
+       (org-agenda-do-context-action): Also do indirect follow mode
+       action.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-table.el (sbe): Fix typo in new sbe specification.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-table.el (sbe): If first variable is a string and not a
+       cons cell, then interpret it as a string of header arguments
+       to be passed to the code block.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-shen.el (shen-eval-defun): Declare external function.
+       (org-babel-execute:shen): Move requirement of inf-shen into
+       the function in which it is used to fix build error.
+
+       * ob-shen.el: New file.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+       * org.el (org-open-at-point): Make `org-open-at-point' only
+       ask once about creating a new headline.
+
+2012-01-03  Nick Dokos  <nicholas.dokos@hp.com>  (tiny change)
+
+       * org.el (org-refile-targets): Elaborated the documentation of
+       the variable as suggested by Dave Abrahams.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+       * org.el (org-align-tags-here): Allow tags to be placed right
+       after heading.
+       (org-tags-column): Document the meaning of tags column 0.
+
+2012-01-03  Niels Giesen  <niels.giesen@gmail.com>
+
+       * org-agenda.el (org-agenda-get-blocks): Show timestamp ranges
+       in agenda if start day is same as end day.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-refile-get-location): Ignore errors when
+       collection heading to be excluded.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-special-blocks.el
+       (org-special-blocks-convert-html-special-cookies): Avoid XHTML
+       strict problems by not enclosing special blocks in paragraph tags.
+
+2012-01-03  Bernt Hansen  <bernt@norang.ca>
+
+       * org-html.el (org-export-as-html): Check string-match
+       argument.
+       (org-html-handle-time-stamps): Check string-match argument.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el
+       (org-agenda-skip-additional-timestamps-same-entry): Change
+       default value.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-time-string-to-time):
+       (org-time-string-to-absolute): Add optional arguments BUFFER and
+       POS for error reporting.
+
+       * org-agenda.el (org-get-all-dates):
+       (org-agenda-get-timestamps, org-agenda-get-deadlines)
+       (org-agenda-get-scheduled, org-agenda-get-blocks): Call time
+       stamp parsing functions with information on where the
+       timestamp was taken from.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-tree-to-indirect-buffer): Run `org-cycle-hook'
+       after `show-all' in indirect buffer.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-list-parents-alist): When no parent is found
+       for an item, set it as the closest less indented item above.  If
+       none is found, make it a top level item.
+       (org-list-write-struct): Externalize code.
+       (org-list-struct-fix-item-end): New function.
+       (org-list-struct): Remove a now useless fix.
+
+       * org.el (org-ctrl-c-ctrl-c): Use new function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-end-of-line): When on an item, move point at the
+       end of the line, but before any hidden text.  Thus, it's still
+       possible to use commands, like `C-c C-c', acting at
+       items.  This is still disabled if `org-special-ctrl-a/e'
+       ignores `C-e'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-renumber-fn:N): Small refactoring.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-renumber-fn:N): Fix an
+       infloop.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-at-definition-p): Remove
+       useless `org-re'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-renumber-fn:N): Verify point
+       is at a real footnote reference or definition before
+       renumbering it.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-goto-definition): This patch
+       makes sure the function says when a definition has been
+       found.  Thus, moving from the reference to the definition
+       doesn't offer to create the latter again.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-create-definition):
+       Explicitely move point after tag, if it has just been
+       inserted.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-gnuplot.el (org-babel-execute:gnuplot): Don't quote file
+       names on Windows systems.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-create-definition): When the
+       tag is missing, it is created before any existing footnote, or
+       at end of buffer.  In the latter case, the marker pointing at
+       the position where the new footnote is going to be inserted
+       (at end of buffer) stays before the tag.  This patch makes
+       sure that the marker will be kept after the tag.
+
+2012-01-03  Eli Zaretskii  <eliz@gnu.org>
+
+       * org.el (org-mode): Force left-to-right paragraphs in Org
+       buffers.  For a related discussions, see
+       https://lists.gnu.org/archive/html/emacs-devel/2011-09/msg00349.html.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ob-asymptote.el (org-babel-asymptote-define-type): Silence
+       byte-compiler.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-R.el (org-babel-R-evaluate): Fix bug in R session
+       evaluation.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-bibtex.el (org-bibtex-type-property-name): Configurable
+       property name for bibtex entry types.
+       (org-bibtex-headline): Use new configurable property name.
+       (org-bibtex-check): Use new configurable property name.
+       (org-bibtex-create): Use new configurable property name.
+       (org-bibtex-write): Use new configurable property name.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.el (org-paste-subtree): Remove unnecessary `concat'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-paste-subtree): Remove useless (concat ...).
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-C.el (org-babel-C-var-to-C): Replacing usage of
+       characterp with integerp (which should work w/Emacs22).
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-at-definition-p): Context must
+       be valid at the beginning of line, not at point.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-tangle.el (org-babel-tangle-collect-blocks): Better
+       delimiting of Org-mode text preceding a code block.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-get-src-block-info): Fixing bug,
+       accidentally deleted variable values.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-tangle.el (org-babel-process-comment-text): Customizable
+       function to process comment text.
+       (org-babel-tangle-collect-blocks): Make use of new
+       customizable processing function.
+       (org-babel-spec-to-string): Call customizable function rather than
+       `org-babel-trim'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-R.el (org-babel-execute:R): Collect and pass along the
+       result-params.
+       (org-babel-R-evaluate): Accept result-params and if "scalar" or
+       "verbatim" don't process output.
+       (org-babel-R-evaluate-session): Accept result-params and if
+       "scalar" or "verbatim" don't process output.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-merge-params): Differentiate between result
+       types and wrappers.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-get-src-block-info): Check that
+       functional-syntax variables are initialized.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-check-src-block): Adding a note for a
+       future enhancement.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-exp.el (org-export): Restore point when exporting a subtree.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-parse-src-block-match): More robust to code
+       blocks with empty bodies.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-parse-src-block-match): Don't error on empty
+       code block body.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-open-at-point): Unescape plain link.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-html.el (org-html-handle-links): Remove unnecessary link
+       unescape.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-merge-params): Better error message for
+       unassigned variables.
+
+2012-01-03  Christian Egli  <christian.egli@alumni.ethz.ch>
+
+       * org-taskjuggler.el (org-export-as-taskjuggler): Clone the
+       buffer local variables to the temporary buffer before
+       exporting.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-exp.el (org-export-select-backend-specific-text): Only
+       remove commas on the front line of a code block.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-demarcate-block): Copy headers and indent to
+       column of point when a block is split.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-insert-result): Corrected file insertion
+       for inline results.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-in-valid-context-p): No
+       footnote in latex fragments.
+
+2012-01-03  Martin Rudalics  <rudalics@gmx.at>
+
+       * org-compat.el (org-pop-to-buffer-same-window): Remove LABEL
+       argument from `pop-to-buffer-same-window' call.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-R.el (org-babel-R-evaluate-session): Improve prompt
+       detection regexp.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-goto-end): Small
+       refactoring.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ob-asymptote.el (org-babel-asymptote-var-to-asymptote):
+       refactor code.
+       (org-babel-asymptote-table-to-array): Removed function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ob-asymptote.el (org-babel-asymptote-var-to-asymptote):
+       recognize non-nested lists as uni-dimensional arrays.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-params-from-properties): Don't check for
+       header arguments in properties with leading ":"s.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-goto-end): Correctly
+       detect the end of an inlinetask when the next one starts
+       immediately after the current one.  Also, return position of
+       point.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ob.el (org-babel-inline-src-block-regexp): Allow regexp to
+       start at bol.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ob-asymptote.el (org-babel-asymptote-define-type): Elisp
+       floats are asymptote reals.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ob-asymptote.el (org-babel-asymptote-table-to-array):
+       Require a new argument TYPE specifying the detected type of
+       array.  If it's a string array, make sure every element is
+       returned as a string. Also improve doc-string.
+       (org-babel-asymptote-var-to-asymptote): Fill new argument.  Small
+       refactoring.
+       (org-babel-asymptote-define-type): Rewrite to avoid stopping
+       search at first float found, as strings have precedence over
+       floats.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-normalize): Be sure to separate
+       the last footnote definition from the rest of the buffer.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-awk.el (org-babel-expand-body:awk): Allow for symbolic
+       variable names.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-latex-regexps): Allow matching latex fragments
+       of type "$" and "$1" at beginning of line.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-search-view, org-agenda-get-todos)
+       (org-agenda-get-deadlines, org-agenda-get-scheduled): Add
+       `category-pos' in let construct.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-get-definition): The function has
+       to widen buffer if definition has not been found in the current
+       narrowed part. Be sure to restore that restriction once the
+       definition is found.
+
+2012-01-03  Michal Sojka  <sojka@os.inf.tu-dresden.de>  (tiny change)
+
+       * org-icalendar.el (org-print-icalendar-entries): Make alarm
+       duration RFC5545 compliant.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-get-timestamps)
+       (org-agenda-get-sexps, org-agenda-get-progress): Correctly set
+       the `org-category-pos' property.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-export-html-divs): Improve docstring.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-table.el (org-table-fix-formulas): Throw error when
+       changing formula leads to an invalid formula.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-archive-location): Minor docstring fix.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-block-todo-from-checkboxes):
+       `org-list-search-forward' should be used when looking for an
+       item, as it filters out contexts where match couldn't be in a
+       list.  Also use a correct item regexp, taking into account
+       alphabetical ordered lists and counters.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-html.el (org-html-make-link): Minor fix to the
+       docstring.
+
+2012-01-03  Suvayu Ali  <fatkasuvayu+linux@gmail.com>  (tiny change)
+
+       * org-inlinetask.el (org-inlinetask): New customisable face
+       for inlinetasks
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-get-todos): Properly set
+       `category-pos'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-list-struct-apply-struct): Don't use
+       (copy-marker (point)) instead of (point-marker).
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-where-is-src-block-result): Don't try to
+       resolve variables when simply checking if we're inside of a
+       code block.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-refresh-category-properties): New text property
+       'org-category-position to point at the beginning of the
+       headline from which the category is set.
+
+2012-01-03  Matt Lundin  <mdl@imapmail.org>
+
+       * org.el (org-refile): Don't call `org-back-to-heading' with
+       goto argument.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-link-display-descriptive): Remove this option and
+       rely on the existing `org-descriptive-links' instead.
+       (org-toggle-link-display): Use `org-descriptive-links'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-ref.el (org-babel-ref-resolve): Allow matching of results
+       with tags after the result name.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-table.el (org-table-get-specials): Allow the use of the
+       underscore character in column names.
+       (org-table-get-specials): Allow the use of the underscore
+       character in field names.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-exp-blocks.el (org-export-blocks-preprocess): Explicitly
+       cleaning up markers.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el (org-babel-exp-inline-src-blocks): Save match data
+       around `org-babel-exp-do-export' which now searches in this case.
+       (org-babel-exp-results): Position the point in the inline source
+       block during export evaluation.
+
+       * ob.el (org-babel-insert-result): More readable code.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-exp-blocks.el (org-export-blocks-preprocess): Use the built
+       in function rather than the superfluous (and now removed)
+       org-specific function.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el (org-babel-exp-inline-src-blocks): Don't examplize
+       inline code blocks which are already escaped.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-exp-blocks.el (org-marker-from-point): Helper function to
+       create markers at specific points in source buffers.
+       (org-export-blocks-preprocess): Use markers instead of points
+       to delimit code blocks.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-list-separating-blank-lines-number): The
+       behaviour of `org-back-over-empty-lines' depends on the
+       associated value of `headline' in
+       `org-blank-before-new-entry', which is out of context in a
+       list.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-initialize-agent): When the current
+       buffer isn't being watched, resume initialization of other watched
+       buffers.  In that case, give hand to others idle timers or
+       processes more frequently.
+       (org-indent-agent-active-delay): Renamed from
+       `org-indent-agent-process-duration'.
+       (org-indent-agent-passive-delay): New variable.
+       (org-indent-agent-resume-delay): Change value.
+       (org-indent-initialize-buffer): Change argument name.
+       (org-indent-add-properties): Change argument name and type
+       expected. It must be a time value now.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-set-property): Bugfix.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-remove-result): Idempotent code block
+       evaluation and result removal.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-ruby.el (org-babel-ruby-initiate-session): No longer
+       require inf-ruby when no session evaluation takes place.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-prefix-format): Mention "%e" in
+       the docstring.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-agenda-custom-commands): Set a default
+       value for this command.
+
+2012-01-03  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-agenda.el (org-agenda-include-all-todo): Declare this option
+       as no longer working.
+       (org-timeline): Rename the include-all argument to dotodo.
+       (org-arg-loc): Renamed from` org-include-all-loc'.
+       (org-agenda-list): Rename the INCLUDE-ALL argument to ARG,
+       because its function has changed.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-fixup-indentation): Fix various small bugs.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-agent-timer)
+       (org-indent-agentized-buffers, org-indent-agent-resume-timer)
+       (org-indent-agent-process-duration)
+       (org-indent-agent-resume-delay): New variables.
+       (org-indent-initial-marker): More accurate doc-string.
+       (org-indent-initial-timer, org-indent-initial-resume-timer)
+       (org-indent-initial-process-duration)
+       (org-indent-initial-resume-delay)
+       (org-indent-initial-lock): Removed variables.
+       (org-indent-mode): Set up an agent to watch current buffer, or
+       add it to the list of already watched buffers.
+       (org-indent-initialize-agent): New function.
+       (org-indent-initialize-buffer): Now requires a mandatory
+       buffer argument.
+       (org-indent-add-properties): Reflect changes to variables. The resume
+       timer is now global.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-normalize): Refactor, and fix
+       some blank lines deletion.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-mode):
+       `org-indent-initial-resume-timer ' needs to be local.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-fixup-indentation): Correctly indent meta lines.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-set-line-properties): Add text
+       properties down to the beginning of the next line.
+       (org-indent-add-properties): When last position to add
+       properties to is at the beginning of a line, all that line
+       will have properties.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-initial-resume-timer): New variable.
+       (org-indent-initialize-buffer): Also resume after a small break.
+       (org-indent-add-properties): When in asynchronous mode,
+       proceed for 2 seconds, then take a break.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-set-line-properties): New function.
+       (org-indent-add-properties): Externalize worker function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-indent-buffer): Take into account
+       narrowing.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-modified-headline-flag): Renamed from
+       `org-indent-deleted-headline-flag'
+       (org-indent-notify-modified-headline): Renamed from
+       `org-indent-notify-deleted-headline'. Handle situations when
+       the stars of an headline are modified.
+       (org-indent-refresh-maybe): Remove case now handled by
+       previous function.
+       (org-indent-mode): Apply renames.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-inlinetask-first-star): New
+       variable.
+       (org-indent-add-properties): Set the first star of inline-tasks'
+       virtual indentation in `org-warning' face.
+
+       * org-inlinetask.el (org-inlinetask-insert-task): Create a new
+       inline-task slightly differently, so virtual indentation can
+       be applied normally.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-initial-marker)
+       (org-indent-initial-timer, org-indent-initial-lock): New
+       variables.
+       (org-indent-mode): At initialization, start an idle timer to indent
+       the whole buffer. When the user is asking for control, interrupt the
+       process, and resume at the same point when idle again.
+       (org-indent-initialize-buffer): New function.
+       (org-indent-add-properties): Throw an interrupt when indentation of
+       buffer is stopped during initialization.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-indent-buffer): Send more
+       appropriate messages.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-notify-deleted-headline)
+       (org-indent-refresh-maybe): Replace `org-indent-outline-re'
+       with `org-outline-regexp-bol'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-max-levels): Modify default value and
+       add comment.
+       (org-indent-add-properties): Pay attention to `org-indent-max'
+       and `org-indent-max-levels' values.
+       (org-indent-refresh-maybe): Refactor code to avoid an unnecessary
+       save excursion.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-table.el (org-table-align): Remove now useless hack.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-fix-section-after-idle-time): Remove
+       variable.
+       (org-indent-initialize): Remove timer.
+       (org-indent-add-properties): Refactor code.
+       (org-indent-refresh-subtree, org-indent-refresh-section)
+       (org-indent-refresh-buffer,org-indent-set-initial-properties): Remove
+       functions.
+       (org-indent-deleted-headline): New variable.
+       (org-indent-notify-deleted-headline,org-indent-refresh-maybe): New
+       functions.
+       (org-indent-mode): Insert new functions into a hook.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-indent.el (org-indent-mode): Completely refresh buffer
+       before starting org-indent-mode. Also set idle timer to refresh
+       only visible portion of buffer, and refresh the subtree instead of
+       section when promoting or demoting it.
+       (org-indent-add-properties): Rewrite function to proceed line by
+       line, as required by `wrap-prefix' specificity.
+       (org-indent-refresh-section,org-indent-refresh-subtree): Refactor.
+       (org-indent-refresh-view): New function.
+       (org-indent-refresh-to, org-indent-refresh-section): Removed
+       functions.
+
+       * org.el (org-unfontify-region): Do not remove prefix
+       properties when unfontifying a region.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-colview.el (org-columns-cleanup-item): Correctly remove
+       leading stars in items displayed in the agenda column view.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-colview.el (org-columns-display-here): Clean up items in
+       `org-agenda-mode' too.
+       (org-columns-cleanup-item): Take a new argument CPHR to allow
+       passing a complex heading regexp.  Rewrite to cleanup ITEM
+       correctly in `org-agenda-mode'.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-clock.el (org-duration-string-to-minutes)
+       (org-minutes-to-hh:mm-string, org-hh:mm-string-to-minutes): Move
+       from org.el.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-refile-active-region-within-subtree): New option to
+       allow refiling a region that is part of a subtree without
+       containing a subtree itself.  This default to `nil'.
+       (org-refile): Use the new option.  Put point at the beginning
+       of the region/subtree to be refiled, so that users understand
+       what will be refiled.  Also improve the prompt to tell whether
+       the user is refiling a region or a headline.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-properties-postprocess-alist): New option to allow
+       postprocessing the values of properties set through
+       `org-set-property'.
+       (org-set-property): Use this option.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-outline-regexp, org-outline-regexp-bol): Add a
+       docstring.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-archive.el (org-archive-to-archive-sibling): Use
+       `org-outline-regexp' instead of `outline-regexp'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-between-regexps-p): Searching up to pos may
+       match again beginning regexp.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-goto-definition): Don't send
+       erroneous message: suggested bindings might not be set outside
+       Org.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-normalize): Effectively remove
+       any footnote tag in non Org buffers, as detailled in the
+       docstring of `org-footnote-tag-for-non-org-mode-files'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-tag-for-non-org-mode-files):
+       notify the opportunity to set the variable to the empty string.
+       (org-footnote-normalize, org-footnote-create-definition):
+       Carefully check for inserted newlines and presence of the
+       footnote tag.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-at-definition-p): Re-use
+       `org-footnote-definition-re'.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-definition-re): Remove an
+       useless group.
+       (org-footnote-at-definition-p): Reflect removal of the group.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-set-regexps-and-options): Enforce white space
+       after todo keyword, as word boundary isn't sufficient (i.e. in
+       matches * TODO/this).
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-export-templates): Fixed
+       template for html so that the exported file is valid
+       xhtml.  Added template for odt.
+       (org-inlinetask-export-handler): Fix typo in the regexp that
+       trims content. Make sure that the content is flanked by
+       paragraph boundaries on either side.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-add-planning-info): Don't insert superfluous
+       space when updating timestamps.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-cmp-effort): Fix docstring.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-list-full-item-re): When an item has only a
+       bullet and no space after it, list structure would not be
+       recognized correctly.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-overview): Use `outline-regexp' instead of
+       `org-outline-regexp' so that global cycling using
+       `orgstruct-mode' works outside of Org buffers.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-table.el (org-table-eval-formula): Fix missing variable
+       in let construct.
+       (org-table-time-string-to-seconds): Fix missing variable in
+       let construct.
+
+2012-01-03  Michael Brand  <michael.ch.brand@gmail.com>
+
+       * org-agenda.el (org-agenda-get-deadlines): Fix dfrac for the
+       case of wdays being 0.  Don't pass wdays to
+       org-agenda-deadline-face, like before the old fix.
+       (org-agenda-deadline-face): Revert to old state that was without
+       wdays.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-latex.el (org-export-latex-fixed-width): Only add one
+       line break after exporting verbatim environments.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-mw.el (org-mw-export-lists): Fix list export.
+
+2012-01-03  Bastien Guerry  <bzg@gnu.org>
+
+       * org-list.el (org-list-item-trim-br): New function.
+       (org-list-to-generic): New parameter :nobr to use the new
+       function.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-paste-subtree): Fix wrong order of lines to move
+       before pasting.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-paste-subtree): Paste subtree above target
+       headline if point is at bol.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-toggle-checkbox): Don't clear lim-down
+       while used in the while loop.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-list.el (org-toggle-checkbox): Lim-down must be a
+       marker.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-activate-code): Correct regexp so ":.*" isn't
+       matched.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-macs.el (org-with-gensyms, org-called-interactively-p)
+       (with-silent-modifications, org-bound-and-true-p)
+       (org-unmodified, org-re, org-preserve-lc)
+       (org-without-partial-completion, org-with-point-at)
+       (org-no-warnings, org-if-unprotected, org-if-unprotected-1)
+       (org-if-unprotected-at, org-with-remote-undo)
+       (org-no-read-only, org-save-outline-visibility)
+       (org-with-wide-buffer, org-with-limited-levels)
+       (org-eval-in-environment): Provide edebug specifications.
+
+       * org-src.el (org-src-do-at-code-block): Dto.
+
+       * org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
+
+       * org-compat.el (org-xemacs-without-invisibility): Dto.
+
+       * org-clock.el (org-with-clock-position, org-with-clock): Dto.
+
+       * org-agenda.el (org-agenda-with-point-at-orig-entry)
+       (org-batch-agenda, org-batch-agenda-csv)
+       (org-batch-store-agenda-views): Dto.
+
+       * ob.el (org-babel-do-in-edit-buffer)
+       (org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
+
+       * ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
+
+       * ob-table.el (sbe): Dto.
+
+       * ob-exp.el (org-babel-exp-in-export-file): Dto.
+
+       * ob-comint.el (org-babel-comint-in-buffer)
+       (org-babel-comint-with-output): Dto.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-export-templates): Fix
+       docstring.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-insert-task): Error when
+       trying to nest inline tasks.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-activate-code, org-toggle-fixed-width-section)
+       (org-indent-line-function): Allow "[ \t]*:$" as a special case of
+       fixed-width section.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-paste-subtree): Don't eat headline when called
+       with point at existing headline.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-paste-subtree): Fix typo in variable name.
+
+2012-01-03  Jambunathan K  <kjambunathan@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-export-handler): Don't
+       export inline tasks if the current backend has provided no
+       entries in `org-inlinetask-export-templates'.
+
+2012-01-03  Valentin Wüstholz  <wuestholz@gmail.com>  (tiny change)
+
+       * org.el (org-indent-line-function): Made the way in which
+       example blocks are indented more flexible.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-agenda.el (org-batch-agenda-csv): Fix argument to append
+       when creating final parameter alist.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-agenda.el (org-batch-store-agenda-views): Use macro
+       `org-eval-in-environment'.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-agenda.el (org-batch-agenda, org-batch-agenda-csv): Use
+       `org-eval-in-environment.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-macs.el (org-make-parameter-alist): New function.  Turn
+       flat list of alternating symbol names and values into an alist
+       with symbol name in car and value in cdr.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-agenda.el (org-agenda-with-point-at-orig-entry): Use
+       macro `org-with-gensyms'.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-macs.el (org-substitute-posix-classes): New
+       function.  Substitute posix classes in regular expression.
+       (org-re): Use new function.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-macs.el (org-eval-in-environment): New macro.  Evaluate FORM
+       in ENVIRONMENT.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-macs.el (org-preserve-lc, org-with-point-at)
+       (org-with-remote-undo, org-save-outline-visibility): Use new
+       macro `org-with-gensyms'.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org-macs.el (org-with-gensyms): New macro.  Wrap let-binding
+       of SYMBOLS to new uninterned symbols around BODY.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-inlinetask.el (org-inlinetask-export-handler): Make sure
+       the task starts a paragraph or the HTML exporter will produce
+       an incorrect output.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-return): When filling happens, `newline' can
+       change match data, hence modifying the indent column.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-new): Only forbid non-inlined
+       footnotes at column 0, as only them can be confused with a
+       footnote definition.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-new): Use `ido' or `iswitchb'
+       when available when prompted for a label.  Also rename a local
+       variable to avoid confusion with an existing function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-label-history): Removed
+       variable
+       (org-footnote-new): Remove call to that variable.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-insert-heading): With `force-heading' non-nil,
+       inserting an heading before any headline, and just after a
+       list would return an error.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-sha1-hash): Removed use of `copy-seq'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org-bibtex.el (org-bibtex-get): Make the "FILE" property
+       non-special when resolving bibtex values.
+
+2012-01-03  David Maus  <dmaus@ictsoc.de>
+
+       * org.el (org-back-over-empty-lines): Don't move line upward
+       if point is at eob.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-in-valid-context-p): Check
+       `org-protected' property before allowing to match a footnote.
+       (org-footnote-at-reference-p): Remove an obsolete test.  It is now
+       done in the previous function.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-between-regexps-p): Previous name implied the
+       function was related to blocks, which isn't mandatory.
+       (org-narrow-to-block, org-in-block-p)
+       (org-indent-line-function): Applied the rename.
+
+       * ob-exp.el (org-babel-in-example-or-verbatim): Applied
+       rename.  Also removed a white space.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.el (org-in-regexps-block-p): Return an useful value when
+       point is between START-RE and END-RE. No incomplete block is
+       allowed anymore.  Add another optional argument to bound the
+       bottom part of the search.
+       (org-narrow-to-block, org-in-block-p): Apply modifications.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob.el (org-babel-src-block-regexp): If a code block has a
+       body, its last character must be a newline.
+
+2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org-footnote.el (org-footnote-next-reference-or-definition):
+       If no more footnote is found, be sure to go back to the
+       original position.  Otherwise, point might be left on a
+       footnote-like element that has been dished out.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-exp.el (org-babel-inline-src-block-regexp): Declare this
+       variable.
+
+       * ob.el (defvar): Wrap variable declaration in
+       `eval-when-compile'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-keys.el (org-babel-key-bindings): Bound to `C-c C-v k'.
+
+2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
+
+       * ob-java.el (org-babel-execute:java): Allow cmdline flags
+       during compilation and evaluation.
+
 2011-12-06  Juanma Barranquero  <lekktu@gmail.com>
 
        * ob.el (org-babel-expand-body:generic, org-babel-number-p):
index 4f8106cd66fbeadc2644e09c31947768378122eb..dccf6b2b0b36d743f92cd88db4735bab54188515 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -180,7 +179,7 @@ of the same value."
       (format "int %S = %S;" var val))
      ((floatp val)
       (format "double %S = %S;" var val))
-     ((or (characterp val))
+     ((or (integerp val))
       (format "char %S = '%S';" var val))
      ((stringp val)
       (format "char %S[%d] = \"%s\";"
index 2b0e6d5e16a5f7a2cb6419162cf73dd49b8c7cad..d8c3d6bbf5e6b65bbf773279fecf0acb89c26ab0 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Dan Davison
 ;; Keywords: literate programming, reproducible research, R, statistics
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -80,7 +79,8 @@
   "Execute a block of R code.
 This function is called by `org-babel-execute-src-block'."
   (save-excursion
-    (let* ((result-type (cdr (assoc :result-type params)))
+    (let* ((result-params (cdr (assoc :result-params params)))
+          (result-type (cdr (assoc :result-type params)))
            (session (org-babel-R-initiate-session
                     (cdr (assoc :session params)) params))
           (colnames-p (cdr (assoc :colnames params)))
@@ -89,7 +89,7 @@ This function is called by `org-babel-execute-src-block'."
           (full-body (org-babel-expand-body:R body params graphics-file))
           (result
            (org-babel-R-evaluate
-            session full-body result-type
+            session full-body result-type result-params
             (or (equal "yes" colnames-p)
                 (org-babel-pick-name
                  (cdr (assoc :colname-names params)) colnames-p))
@@ -197,6 +197,7 @@ current code buffer."
         '((:bmp . "bmp")
           (:jpg . "jpeg")
           (:jpeg . "jpeg")
+          (:tex . "tikz")
           (:tiff . "tiff")
           (:png . "png")
           (:svg . "svg")
@@ -214,7 +215,7 @@ current code buffer."
     (setq device (or (and device (cdr (assq (intern (concat ":" device))
                                            devices))) "png"))
     (setq filearg
-         (if (member device '("pdf" "postscript" "svg")) "file" "filename"))
+         (if (member device '("pdf" "postscript" "svg" "tikz")) "file" "filename"))
     (setq args (mapconcat
                (lambda (pair)
                  (if (member (car pair) allowed-args)
@@ -232,16 +233,16 @@ current code buffer."
 (defvar org-babel-R-write-object-command "{function(object,transfer.file){object;invisible(if(inherits(try({tfile<-tempfile();write.table(object,file=tfile,sep=\"\\t\",na=\"nil\",row.names=%s,col.names=%s,quote=FALSE);file.rename(tfile,transfer.file)},silent=TRUE),\"try-error\")){if(!file.exists(transfer.file))file.create(transfer.file)})}}(object=%s,transfer.file=\"%s\")")
 
 (defun org-babel-R-evaluate
-  (session body result-type column-names-p row-names-p)
+  (session body result-type result-params column-names-p row-names-p)
   "Evaluate R code in BODY."
   (if session
       (org-babel-R-evaluate-session
-       session body result-type column-names-p row-names-p)
+       session body result-type result-params column-names-p row-names-p)
     (org-babel-R-evaluate-external-process
-     body result-type column-names-p row-names-p)))
+     body result-type result-params column-names-p row-names-p)))
 
 (defun org-babel-R-evaluate-external-process
-  (body result-type column-names-p row-names-p)
+  (body result-type result-params column-names-p row-names-p)
   "Evaluate BODY in external R process.
 If RESULT-TYPE equals 'output then return standard output as a
 string. If RESULT-TYPE equals 'value then return the value of the
@@ -258,11 +259,17 @@ last statement in BODY, as elisp."
                               (format "{function ()\n{\n%s\n}}()" body)
                               (org-babel-process-file-name tmp-file 'noquote)))
        (org-babel-R-process-value-result
-       (org-babel-import-elisp-from-file tmp-file '(16)) column-names-p)))
+       (if (or (member "scalar" result-params)
+               (member "verbatim" result-params))
+           (with-temp-buffer
+             (insert-file-contents tmp-file)
+             (buffer-string))
+         (org-babel-import-elisp-from-file tmp-file '(16)))
+       column-names-p)))
     (output (org-babel-eval org-babel-R-command body))))
 
 (defun org-babel-R-evaluate-session
-  (session body result-type column-names-p row-names-p)
+  (session body result-type result-params column-names-p row-names-p)
   "Evaluate BODY in SESSION.
 If RESULT-TYPE equals 'output then return standard output as a
 string. If RESULT-TYPE equals 'value then return the value of the
@@ -284,7 +291,13 @@ last statement in BODY, as elisp."
                  "FALSE")
                ".Last.value" (org-babel-process-file-name tmp-file 'noquote)))
        (org-babel-R-process-value-result
-       (org-babel-import-elisp-from-file tmp-file '(16))  column-names-p)))
+       (if (or (member "scalar" result-params)
+               (member "verbatim" result-params))
+           (with-temp-buffer
+             (insert-file-contents tmp-file)
+             (buffer-string))
+         (org-babel-import-elisp-from-file tmp-file '(16)))
+       column-names-p)))
     (output
      (mapconcat
       #'org-babel-chomp
@@ -295,7 +308,7 @@ last statement in BODY, as elisp."
              (mapcar
               (lambda (line) ;; cleanup extra prompts left in output
                 (if (string-match
-                     "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
+                     "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
                     (substring line (match-end 1))
                   line))
               (org-babel-comint-with-output (session org-babel-R-eoe-output)
index 6bae3581cf4c4d114f816b9bd52d9dcaff9f1b65..5bd33f5086c33f6b7e64fe13ed5baacb1e51702f 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -98,9 +97,8 @@ Asymptote does not support sessions"
 The elisp value PAIR is converted into Asymptote code specifying
 a variable of the same value."
   (let ((var (car pair))
-        (val (if (symbolp (cdr pair))
-                 (symbol-name (cdr pair))
-               (cdr pair))))
+        (val (let ((v (cdr pair)))
+              (if (symbolp v) (symbol-name v) v))))
     (cond
      ((integerp val)
       (format "int %S=%S;" var val))
@@ -108,55 +106,42 @@ a variable of the same value."
       (format "real %S=%S;" var val))
      ((stringp val)
       (format "string %S=\"%s\";" var val))
+     ((and (listp val) (not (listp (car val))))
+      (let* ((type (org-babel-asymptote-define-type val))
+            (fmt (if (eq 'string type) "\"%s\"" "%s"))
+            (vect (mapconcat (lambda (e) (format fmt e)) val ", ")))
+       (format "%s[] %S={%s};" type var vect)))
      ((listp val)
-      (let* ((dimension-2-p (not (null (cdr val))))
-             (dim (if dimension-2-p "[][]" "[]"))
-             (type (org-babel-asymptote-define-type val))
-             (array (org-babel-asymptote-table-to-array
-                     val
-                     (if dimension-2-p '(:lstart "{" :lend "}," :llend "}")))))
-        (format "%S%s %S=%s;" type dim var array))))))
-
-(defun org-babel-asymptote-table-to-array (table params)
-  "Convert values of an elisp table into a string of an asymptote array.
-Empty cells are ignored."
-  (labels ((atom-to-string (table)
-                           (cond
-                            ((null table) '())
-                            ((not (listp (car table)))
-                             (cons (if (and (stringp (car table))
-                                            (not (string= (car table) "")))
-                                       (format "\"%s\"" (car table))
-                                     (format "%s" (car table)))
-                                   (atom-to-string (cdr table))))
-                            (t
-                             (cons (atom-to-string (car table))
-                                   (atom-to-string (cdr table))))))
-           ;; Remove any empty row
-           (fix-empty-lines (table)
-                            (delq nil (mapcar (lambda (l) (delq "" l)) table))))
-    (orgtbl-to-generic
-     (fix-empty-lines (atom-to-string table))
-     (org-combine-plists '(:hline nil :sep "," :tstart "{" :tend "}") params))))
+      (let* ((type (org-babel-asymptote-define-type val))
+            (fmt (if (eq 'string type) "\"%s\"" "%s"))
+             (array (mapconcat (lambda (row)
+                                (concat "{"
+                                        (mapconcat (lambda (e) (format fmt e))
+                                                   row ", ")
+                                        "}"))
+                              val ",")))
+        (format "%S[][] %S={%s};" type var array))))))
 
 (defun org-babel-asymptote-define-type (data)
   "Determine type of DATA.
-DATA is a list. Type symbol is returned as 'symbol. The type is
-usually the type of the first atom encountered, except for arrays
-of int, where every cell must be of int type."
-  (labels ((anything-but-int (el)
-                             (cond
-                              ((null el) nil)
-                              ((not (listp (car el)))
-                               (cond
-                                ((floatp (car el)) 'real)
-                                ((stringp (car el)) 'string)
-                                (t
-                                 (anything-but-int (cdr el)))))
-                              (t
-                               (or (anything-but-int (car el))
-                                   (anything-but-int (cdr el)))))))
-    (or (anything-but-int data) 'int)))
+
+DATA is a list.  Return type as a symbol.
+
+The type is `string' if any element in DATA is
+a string. Otherwise, it is either `real', if some elements are
+floats, or `int'."
+  (let* ((type 'int)
+        find-type                      ; for byte-compiler
+        (find-type
+         (function
+          (lambda (row)
+            (catch 'exit
+              (mapc (lambda (el)
+                      (cond ((listp el) (funcall find-type el))
+                            ((stringp el) (throw 'exit (setq type 'string)))
+                            ((floatp el) (setq type 'real))))
+                    row))))))
+    (funcall find-type data) type))
 
 (provide 'ob-asymptote)
 
index 66e07bf175c46854050f7baa5e76cd778981cef5..1ba0a356924bb1c93be8a44040e15b2af7d5214b 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -49,7 +48,7 @@
   "Expand BODY according to PARAMS, return the expanded body."
   (dolist (pair (mapcar #'cdr (org-babel-get-header params :var)))
     (setf body (replace-regexp-in-string
-                (regexp-quote (concat "$" (car pair))) (cdr pair) body)))
+                (regexp-quote (format "$%s" (car pair))) (cdr pair) body)))
   body)
 
 (defun org-babel-execute:awk (body params)
index 68694786729ce2823dfd15442ca60178dbacb8e5..0b0cfd4b1edb62382d5b5715c2c2593455b0edcf 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
 ;;; Code:
 (require 'ob)
 (require 'calc)
-(require 'calc-store)
-(unless (featurep 'xemacs) (require 'calc-trail))
+(unless (featurep 'xemacs)
+  (require 'calc-trail)
+  (require 'calc-store))
 (eval-when-compile (require 'ob-comint))
 
+(declare-function calc-store-into    "calc-store" (&optional var))
+(declare-function calc-recall        "calc-store" (&optional var))
+(declare-function math-evaluate-expr "calc-ext"   (x))
+
 (defvar org-babel-default-header-args:calc nil
   "Default arguments for evaluating an calc source block.")
 
index 090b60662f8fbacbf2466baffd060edf02b1de88..9ed13d69f568ba465c339e21427b024c47ecf8f9 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index efdac4d3818ccf8dfe9f1ceb19ec9b760fa46396..24af735746a78d58ab061754818115928228c5c1 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -54,6 +53,7 @@ executed inside the protection of `save-excursion' and
          (error "buffer %s doesn't exist or has no process" ,buffer))
        (set-buffer ,buffer)
        ,@body)))
+(def-edebug-spec org-babel-comint-in-buffer (form body))
 
 (defmacro org-babel-comint-with-output (meta &rest body)
   "Evaluate BODY in BUFFER and return process output.
@@ -115,6 +115,7 @@ or user `keyboard-quit' during execution of body."
                   string-buffer))
             (setq raw (substring string-buffer (match-end 0))))
         (split-string string-buffer comint-prompt-regexp)))))
+(def-edebug-spec org-babel-comint-with-output (form body))
 
 (defun org-babel-comint-input-command (buffer cmd)
   "Pass CMD to BUFFER.
index 7bc97f8290908427bcb8edaae856c4913e20d42f..a49595f05cd9b58a1680c5fd633da567ba743e92 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index db638f6ef9851eeb45dd5d0fced2d506446d8d28..0aba9a6e47e216a44a5e040f14fd8370ed0787ee 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index cc78ac5bf95af077a0951cc5226b1dbef8639594..1b18ffd3617d6ae1c06f8ff292af967881a4aadc 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 2eccf19b6d1ac31a544d3e45be2d99f3a3b348f8..c6d9d59c25dabc8ecdcb54a52f3c1c5ef0c9e7c2 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index e74be0b6e0284a728f0b912489d2fa8ffd960dca..02738c17b88bdabf56e36d702530c25993f84cd9 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 0fceb184c5e72df840a8bd9dbf6b000345df6d01..de3a4c85d88e3274b8583e19e30197a0424c195c 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -37,7 +36,6 @@
 (declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
 (add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks))
 (add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners))
-(add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup)
 
 (org-export-blocks-add-block '(src org-babel-exp-src-block nil))
 
@@ -74,6 +72,7 @@ process."
         (setq results ,@body))
        (set-buffer export-buffer)
        results)))
+(def-edebug-spec org-babel-exp-in-export-file (form body))
 
 (defun org-babel-exp-src-block (body &rest headers)
   "Process source block for export.
@@ -105,7 +104,6 @@ none ----- do not display either code or results upon export"
                  (org-babel-process-params
                   (org-babel-merge-params
                    org-babel-default-header-args
-                   (org-babel-params-from-buffer)
                    (org-babel-params-from-properties lang)
                    (if (boundp lang-headers) (eval lang-headers) nil)
                    raw-params))))
@@ -129,10 +127,10 @@ options and are taken from `org-babel-default-inline-header-args'."
     (while (and (< (point) end)
                 (re-search-forward org-babel-inline-src-block-regexp end t))
       (let* ((info (save-match-data (org-babel-parse-inline-src-block-match)))
-            (params (nth 2 info)) code-replacement)
+            (params (nth 2 info)))
        (save-match-data
          (goto-char (match-beginning 2))
-         (when (not (org-babel-in-example-or-verbatim))
+         (unless (org-babel-in-example-or-verbatim)
            ;; expand noweb references in the original file
            (setf (nth 1 info)
                  (if (and (cdr (assoc :noweb params))
@@ -140,39 +138,25 @@ options and are taken from `org-babel-default-inline-header-args'."
                      (org-babel-expand-noweb-references
                       info (get-file-buffer org-current-export-file))
                    (nth 1 info)))
-           (setq code-replacement (org-babel-exp-do-export info 'inline))))
-       (if code-replacement
-           (replace-match code-replacement nil nil nil 1)
-         (org-babel-examplize-region (match-beginning 1) (match-end 1))
-         (forward-char 2))))))
-
-(defun org-exp-res/src-name-cleanup ()
-  "Clean up #+results and #+srcname lines for export.
-This function should only be called after all block processing
-has taken place."
-  (interactive)
-  (save-excursion
-    (goto-char (point-min))
-    (while (org-re-search-forward-unprotected
-           (concat
-            "\\("org-babel-src-name-regexp"\\|"org-babel-result-regexp"\\)")
-           nil t)
-      (delete-region
-       (progn (beginning-of-line) (point))
-       (progn (end-of-line) (+ 1 (point)))))))
+           (let ((code-replacement (save-match-data
+                                     (org-babel-exp-do-export info 'inline))))
+             (if code-replacement
+                 (replace-match code-replacement nil nil nil 1)
+               (org-babel-examplize-region (match-beginning 1) (match-end 1))
+               (forward-char 2)))))))))
 
 (defun org-babel-in-example-or-verbatim ()
   "Return true if point is in example or verbatim code.
 Example and verbatim code include escaped portions of
 an org-mode buffer code that should be treated as normal
 org-mode text."
-  (or (org-in-indented-comment-line) 
-      (save-match-data
+  (or (save-match-data
        (save-excursion
          (goto-char (point-at-bol))
          (looking-at "[ \t]*:[ \t]")))
       (org-in-verbatim-emphasis)
-      (org-in-regexps-block-p "^[ \t]*#\\+begin_src" "^[ \t]*#\\+end_src")))
+      (org-in-block-p org-list-forbidden-blocks)
+      (org-between-regexps-p "^[ \t]*#\\+begin_src" "^[ \t]*#\\+end_src")))
 
 (defvar org-babel-default-lob-header-args)
 (defun org-babel-exp-lob-one-liners (start end)
@@ -183,8 +167,8 @@ options are taken from `org-babel-default-header-args'."
   (save-excursion
     (goto-char start)
     (while (and (< (point) end)
-               (re-search-forward org-babel-lob-one-liner-regexp nil t))
-      (unless (and (match-string 12) (org-babel-in-example-or-verbatim))
+               (re-search-forward org-babel-lob-one-liner-regexp end t))
+      (unless (org-babel-in-example-or-verbatim)
        (let* ((lob-info (org-babel-lob-get-info))
               (inlinep (match-string 11))
               (inline-start (match-end 11))
@@ -196,7 +180,6 @@ options are taken from `org-babel-default-header-args'."
                               (org-babel-merge-params
                                org-babel-default-header-args
                                org-babel-default-lob-header-args
-                               (org-babel-params-from-buffer)
                                (org-babel-params-from-properties)
                                (org-babel-parse-header-arguments
                                 (org-babel-clean-text-properties
@@ -232,7 +215,7 @@ The function respects the value of the :exports header argument."
 (defun org-babel-exp-code (info)
   "Return the original code block formatted for export."
   (org-fill-template
-   "#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC\n"
+   "#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC"
    `(("lang"  . ,(nth 0 info))
      ("flags" . ,((lambda (f) (when f (concat " " f))) (nth 3 info)))
      ("body"  . ,(nth 1 info)))))
@@ -258,7 +241,15 @@ inhibit insertion of results into the buffer."
                    (nth 2 info)
                    `((:results . ,(if silent "silent" "replace")))))))
          (cond
-          ((or (equal type 'block) (equal type 'inline))
+          ((equal type 'block)
+           (org-babel-execute-src-block nil info))
+          ((equal type 'inline)
+           ;; position the point on the inline source block allowing
+           ;; `org-babel-insert-result' to check that the block is
+           ;; inline
+           (re-search-backward "[ \f\t\n\r\v]" nil t)
+           (re-search-forward org-babel-inline-src-block-regexp nil t)
+           (re-search-backward "src_" nil t)
            (org-babel-execute-src-block nil info))
           ((equal type 'lob)
            (save-excursion
diff --git a/lisp/org/ob-fortran.el b/lisp/org/ob-fortran.el
new file mode 100644 (file)
index 0000000..b2c9790
--- /dev/null
@@ -0,0 +1,162 @@
+;;; ob-fortran.el --- org-babel functions for fortran
+
+;; Copyright (C) 2011 Sergey Litvinov, Eric Schulte
+
+;; Authors: Sergey Litvinov (based on ob-C.el by Eric Schulte), Eric Schulte
+;; Keywords: literate programming, reproducible research, fortran
+;; Homepage: http://orgmode.org
+;; Version: 7.8.02
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; Org-Babel support for evaluating fortran code.
+
+;;; Code:
+(require 'ob)
+(require 'ob-eval)
+(require 'cc-mode)
+
+(declare-function org-entry-get "org"
+                 (pom property &optional inherit literal-nil))
+
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("fortran" . "F90"))
+
+(defvar org-babel-default-header-args:fortran '())
+
+(defvar org-babel-fortran-compiler "gfortran"
+  "fortran command used to compile a fortran source code file into an
+  executable.")
+
+(defun org-babel-execute:fortran (body params)
+  "This function should only be called by `org-babel-execute:fortran'"
+  (let* ((tmp-src-file (org-babel-temp-file "fortran-src-" ".F90"))
+         (tmp-bin-file (org-babel-temp-file "fortran-bin-"))
+         (cmdline (cdr (assoc :cmdline params)))
+         (flags (cdr (assoc :flags params)))
+         (full-body (org-babel-expand-body:fortran body params))
+         (compile
+         (progn
+           (with-temp-file tmp-src-file (insert full-body))
+           (org-babel-eval
+            (format "%s -o %s %s %s"
+                    org-babel-fortran-compiler
+                    (org-babel-process-file-name tmp-bin-file)
+                    (mapconcat 'identity
+                               (if (listp flags) flags (list flags)) " ")
+                    (org-babel-process-file-name tmp-src-file)) ""))))
+    ((lambda (results)
+       (org-babel-reassemble-table
+       (if (member "vector" (cdr (assoc :result-params params)))
+           (let ((tmp-file (org-babel-temp-file "f-")))
+             (with-temp-file tmp-file (insert results))
+             (org-babel-import-elisp-from-file tmp-file))
+         (org-babel-read results))
+       (org-babel-pick-name
+        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+       (org-babel-pick-name
+        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
+     (org-babel-trim
+       (org-babel-eval
+       (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) "")))))
+
+(defun org-babel-expand-body:fortran (body params)
+  "Expand a block of fortran or fortran code with org-babel according to
+it's header arguments."
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+        (main-p (not (string= (cdr (assoc :main params)) "no")))
+        (includes (or (cdr (assoc :includes params))
+                      (org-babel-read (org-entry-get nil "includes" t))))
+        (defines (org-babel-read
+                  (or (cdr (assoc :defines params))
+                      (org-babel-read (org-entry-get nil "defines" t))))))
+     (mapconcat 'identity
+               (list
+                ;; includes
+                (mapconcat
+                 (lambda (inc) (format "#include %s" inc))
+                 (if (listp includes) includes (list includes)) "\n")
+                ;; defines
+                (mapconcat
+                 (lambda (inc) (format "#define %s" inc))
+                 (if (listp defines) defines (list defines)) "\n")
+                ;; body
+                (if main-p
+                    (org-babel-fortran-ensure-main-wrap
+                     (concat
+                      ;; variables
+                      (mapconcat 'org-babel-fortran-var-to-fortran vars "\n")
+                      body) params)
+                  body) "\n") "\n")))
+
+(defun org-babel-fortran-ensure-main-wrap (body params)
+  "Wrap body in a \"program ... end program\" block if none exists."
+  (if (string-match "^[ \t]*program[ \t]*.*" (capitalize body))
+       (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+        (if vars (error "cannot use :vars if 'program' statment is present"))
+        body)
+    (format "program main\n%s\nend program main\n" body)))
+
+(defun org-babel-prep-session:fortran (session params)
+  "This function does nothing as fortran is a compiled language with no
+support for sessions"
+  (error "fortran is a compiled languages -- no support for sessions"))
+
+(defun org-babel-load-session:fortran (session body params)
+  "This function does nothing as fortran is a compiled language with no
+support for sessions"
+  (error "fortran is a compiled languages -- no support for sessions"))
+
+;; helper functions
+
+(defun org-babel-fortran-var-to-fortran (pair)
+  "fortranonvert an elisp val into a string of fortran code specifying a var
+of the same value."
+  ;; TODO list support
+  (let ((var (car pair))
+        (val (cdr pair)))
+    (when (symbolp val)
+      (setq val (symbol-name val))
+      (when (= (length val) 1)
+        (setq val (string-to-char val))))
+    (cond
+     ((integerp val)
+      (format "integer, parameter  ::  %S = %S\n" var val))
+     ((floatp val)
+      (format "real, parameter ::  %S = %S\n" var val))
+     ((or (integerp val))
+      (format "character, parameter :: %S = '%S'\n" var val))
+     ((stringp val)
+      (format "character(len=%d), parameter ::  %S = '%s'\n"
+              (length val) var val))
+     ((listp val)
+      (format "real, parameter :: %S(%d) = %s\n"
+             var (length val) (ob-fortran-transform-list val)))
+     (t
+      (error (format "the type of parameter %s is not supported by ob-fortran"
+                    var))))))
+
+(defun ob-fortran-transform-list (val)
+  "Return a fortran representation of enclose syntactic lists."
+  (if (listp val)
+      (concat "(/" (mapconcat #'ob-fortran-transform-list val ", ") "/)")
+    (format "%S" val)))
+
+(provide 'ob-fortran)
+
+;;; ob-fortran.el ends here
index 9bf0433f9fcbfa2a3e568edaffb65f016b6ef536..c1e533a95ebb071ce55c1c729a131ce926ab1a12 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -149,7 +148,10 @@ This function is called by `org-babel-execute-src-block'."
                   (shell-command-to-string
                   (format
                    "gnuplot \"%s\""
-                   (org-babel-process-file-name script-file))))
+                   (org-babel-process-file-name
+                    script-file
+                    (if (member system-type '(cygwin windows-nt ms-dos))
+                        t nil)))))
             (message output))
         (with-temp-buffer
           (insert (concat body "\n"))
index 236dbba28f1ee53124556b8cd58528ba7b32a5eb..10fd363f135238b67f8181e5fd46494e984a8dc2 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -29,7 +28,7 @@
 ;; they can be run, but haskell code can also be run through an
 ;; interactive interpreter.
 ;;
-;; For now let's only allow evaluation using the haskell interpreter.
+;; For now lets only allow evaluation using the haskell interpreter.
 
 ;;; Requirements:
 
@@ -80,7 +79,7 @@
                    (cdr (member org-babel-haskell-eoe
                                 (reverse (mapcar #'org-babel-trim raw)))))))
     (org-babel-reassemble-table
-     (cond
+     (cond 
       ((equal result-type 'output)
        (mapconcat #'identity (reverse (cdr results)) "\n"))
       ((equal result-type 'value)
index 20824d4cb3023ab7d704a4aa9b85bdd2db44df46..bd02d30f0ab88befb524cb4fd29b84600b909e1b 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
                         "Can't compile a java block without a classname")))
         (packagename (file-name-directory classname))
         (src-file (concat classname ".java"))
+        (cmpflag (or (cdr (assoc :cmpflag params)) ""))
+        (cmdline (or (cdr (assoc :cmdline params)) ""))
         (full-body (org-babel-expand-body:generic body params))
         (compile
          (progn (with-temp-file src-file (insert full-body))
                 (org-babel-eval
-                 (concat org-babel-java-compiler " " src-file) ""))))
+                 (concat org-babel-java-compiler
+                         " " cmpflag " " src-file) ""))))
     ;; created package-name directories if missing
     (unless (or (not packagename) (file-exists-p packagename))
       (make-directory packagename 'parents))
@@ -65,7 +67,8 @@
         (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
        (org-babel-pick-name
         (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
-     (org-babel-eval (concat org-babel-java-command " " classname) ""))))
+     (org-babel-eval (concat org-babel-java-command
+                            " " cmdline " " classname) ""))))
 
 (provide 'ob-java)
 
index 9e6751c9525c002ca629c3d72eb0aa4e133fdca6..e4379a29acdf16123c10cc1a0410bcc3b29e2570 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, js
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index b56ba5cf01a68787704e4fd9f52d4e8d2bc2b6ff..4f320a0afc05a84a7b25b60edaf5370c6ff349f8 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -75,6 +74,8 @@ functions which are assigned key bindings, and see
     ("f" . org-babel-tangle-file)
     ("\C-c" . org-babel-check-src-block)
     ("c" . org-babel-check-src-block)
+    ("\C-j" . org-babel-insert-header-arg)
+    ("j" . org-babel-insert-header-arg)
     ("\C-l" . org-babel-load-in-session)
     ("l" . org-babel-load-in-session)
     ("\C-i" . org-babel-lob-ingest)
index 731d83096d841a342bb2dbbcbf581a3b6f2e556d..afd8e5f369384e6331d330f656b9e49b2c91b39c 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -73,6 +72,10 @@ This function is called by `org-babel-execute-src-block'."
       (let* ((out-file (cdr (assoc :file params)))
             (tex-file (org-babel-temp-file "latex-" ".tex"))
             (border (cdr (assoc :border params)))
+            (imagemagick (cdr (assoc :imagemagick params)))
+            (im-in-options (cdr (assoc :iminoptions params)))
+            (im-out-options (cdr (assoc :imoutoptions params)))
+            (pdfpng (cdr (assoc :pdfpng params)))
             (fit (or (cdr (assoc :fit params)) border))
             (height (and fit (cdr (assoc :pdfheight params))))
             (width (and fit (cdr (assoc :pdfwidth params))))
@@ -82,10 +85,10 @@ This function is called by `org-babel-execute-src-block'."
              (append (cdr (assoc :packages params))
                      org-export-latex-packages-alist)))
         (cond
-         ((string-match "\\.png$" out-file)
+         ((and (string-match "\\.png$" out-file) (not imagemagick))
           (org-create-formula-image
            body out-file org-format-latex-options in-buffer))
-         ((string-match "\\.pdf$" out-file)
+         ((or (string-match "\\.pdf$" out-file) imagemagick)
          (require 'org-latex)
          (with-temp-file tex-file
            (insert
@@ -119,13 +122,29 @@ This function is called by `org-babel-execute-src-block'."
               (concat "\n\\begin{document}\n" body "\n\\end{document}\n")))
            (org-export-latex-fix-inputenc))
           (when (file-exists-p out-file) (delete-file out-file))
-          (rename-file (org-babel-latex-tex-to-pdf tex-file) out-file))
+         (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
+           (cond
+            ((string-match "\\.pdf$" out-file)
+             (rename-file transient-pdf-file out-file))
+            (imagemagick
+             (convert-pdf
+              transient-pdf-file out-file im-in-options im-out-options)
+             (when (file-exists-p transient-pdf-file)
+               (delete-file transient-pdf-file))))))
          ((string-match "\\.\\([^\\.]+\\)$" out-file)
-          (error "can not create %s files, please specify a .png or .pdf file"
+          (error "can not create %s files, please specify a .png or .pdf file or try the :imagemagick header arguement"
                 (match-string 1 out-file))))
         nil) ;; signal that output has already been written to file
     body))
 
+
+(defun convert-pdf (pdffile out-file im-in-options im-out-options)
+  "Generate a file from a pdf file using imagemagick."
+  (let ((cmd (concat "convert " im-in-options " " pdffile " "
+                    im-out-options " " out-file)))
+    (message (concat "Converting pdffile file " cmd  "..."))
+    (shell-command cmd)))
+
 (defun org-babel-latex-tex-to-pdf (file)
   "Generate a pdf file according to the contents FILE.
 Extracted from `org-export-as-pdf' in org-latex.el."
index 4fe61451982cccb5137be05dd6cf5a5ab707476b..7556ca1917675fadde3d8f823a65bcabbc5f199e 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric S Fraga
 ;; Keywords: literate programming, reproducible research, accounting
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -30,7 +29,7 @@
 ;;
 ;; 1) there is no such thing as a "session" in ledger
 ;;
-;; 2) we are generally only going to return output from the ledger program
+;; 2) we are generally only going to return output from the leger program
 ;;
 ;; 3) we are adding the "cmdline" header argument
 ;;
index 23fc8f04c34ec9866f8dd26c9b7a3aa90ec0ec23..1f817adb4ecc06d881f3d390b63e582b1d84508e 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Martyn Jago
 ;; Keywords: babel language, literate programming
 ;; Homepage: https://github.com/mjago/ob-lilypond
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 4ff9c4076ecd8abbe191918241ac5eda99d14d36..31656c6e1134b98b754cdc70d34611e32e943e26 100644 (file)
@@ -7,7 +7,6 @@
 ;;     David T. O'Toole <dto@gnu.org>
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -79,7 +78,7 @@ current directory string."
       (if (member "output" (cdr (assoc :result-params params)))
          (car result)
        (condition-case nil
-           (read (org-bable-lisp-vector-to-list (cadr result)))
+           (read (org-babel-lisp-vector-to-list (cadr result)))
          (error (cadr result)))))
     (with-temp-buffer
       (insert (org-babel-expand-body:lisp body params))
@@ -97,7 +96,7 @@ current directory string."
    (org-babel-pick-name (cdr (assoc :rowname-names params))
                        (cdr (assoc :rownames params)))))
 
-(defun org-bable-lisp-vector-to-list (results)
+(defun org-babel-lisp-vector-to-list (results)
   ;; TODO: better would be to replace #(...) with [...]
   (replace-regexp-in-string "#(" "(" results))
 
index 5cb40a057f3e37b0840207de9ae656f092b129c3..181eee22b311758928067881b8cb2761e5cad20f 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -29,6 +28,8 @@
 (require 'ob)
 (require 'ob-table)
 
+(declare-function org-babel-in-example-or-verbatim "ob-exp" nil)
+
 (defvar org-babel-library-of-babel nil
   "Library of source-code blocks.
 This is an association list.  Populate the library by adding
@@ -62,24 +63,15 @@ To add files to this list use the `org-babel-lob-ingest' command."
             lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
     lob-ingest-count))
 
-(defconst org-babel-lob-call-aliases '("lob" "call")
-  "Aliases to call a source block function.
-If you change the value of this variable then your files may
-  become unusable by other org-babel users, and vice versa.")
-
 (defconst org-babel-block-lob-one-liner-regexp
   (concat
-   "^\\([ \t]*\\)#\\+\\(?:"
-   (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
-   "\\):[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
+   "^\\([ \t]*\\)#\\+call:[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
    "\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\(\\([^\n]*\\)\\)?")
   "Regexp to match non-inline calls to predefined source block functions.")
 
 (defconst org-babel-inline-lob-one-liner-regexp
   (concat
-   "\\([^\n]*\\)\\(?:"
-   (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
-   "\\)_\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
+   "\\([^\n]*\\)call_\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
    "\(\\([^\n]*\\)\)\\(\\[\\(.*?\\)\\]\\)?")
   "Regexp to match inline calls to predefined source block functions.")
 
@@ -89,6 +81,7 @@ If you change the value of this variable then your files may
   "Regexp to match calls to predefined source block functions.")
 
 ;; functions for executing lob one-liners
+
 ;;;###autoload
 (defun org-babel-lob-execute-maybe ()
   "Execute a Library of Babel source block, if appropriate.
@@ -96,7 +89,9 @@ Detect if this is context for a Library Of Babel source block and
 if so then run the appropriate source block from the Library."
   (interactive)
   (let ((info (org-babel-lob-get-info)))
-    (if (nth 0 info) (progn (org-babel-lob-execute info) t) nil)))
+    (if (and (nth 0 info) (not (org-babel-in-example-or-verbatim)))
+       (progn (org-babel-lob-execute info) t)
+      nil)))
 
 ;;;###autoload
 (defun org-babel-lob-get-info ()
@@ -126,7 +121,6 @@ if so then run the appropriate source block from the Library."
   (let ((params (org-babel-process-params
                 (org-babel-merge-params
                  org-babel-default-header-args
-                 (org-babel-params-from-buffer)
                  (org-babel-params-from-properties)
                  (org-babel-parse-header-arguments
                   (org-babel-clean-text-properties
index bb32c5a29f509f6f5d7674d93e6e5119f634be0f..479100a80c48594c99175adbd1f66541a82a6ab4 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 279ba6b928b5c9766a73e1bbd421fd3a91e4b493..f14cf550a71375493afc0ceec1ebed5241d7d85a 100644 (file)
@@ -6,7 +6,6 @@
 ;;        Eric Schulte
 ;; Keywords: literate programming, reproducible research, maxima
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
 ;;
 ;; 1) there is no such thing as a "session" in maxima
 ;;
-;; 2) we are generally only going to return output from maxima
-;;
-;; 3) we are adding the "cmdline" header argument
-;;
-;; 4) there are no variables
+;; 2) we are adding the "cmdline" header argument
 
 ;;; Code:
 (require 'ob)
 
+(defvar org-babel-tangle-lang-exts)
+(add-to-list 'org-babel-tangle-lang-exts '("maxima" . "max"))
+
 (defvar org-babel-default-header-args:maxima '())
 
 (defun org-babel-maxima-expand (body params)
   "Expand a block of Maxima code according to its header arguments."
-  body)
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+     (mapconcat 'identity
+               (list
+                ;; graphic output
+                (let ((graphic-file (org-babel-maxima-graphical-output-file params)))
+                  (if graphic-file
+                      (format
+                       "set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]);"
+                       graphic-file)
+                    ""))
+                ;; variables
+                (mapconcat 'org-babel-maxima-var-to-maxima vars "\n")
+                ;; body
+                body
+                "gnuplot_close ()$")
+               "\n")))
 
 (defun org-babel-execute:maxima (body params)
   "Execute a block of Maxima entries with org-babel.  This function is
 called by `org-babel-execute-src-block'."
   (message "executing Maxima source code block")
-  (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
-        (cmdline (cdr (assoc :cmdline params)))
-        (in-file (org-babel-temp-file "maxima-"))
-        (cmd (format "maxima --very-quiet -r 'batchload(%S)$' %s"
-                     in-file cmdline)))
-    (with-temp-file in-file (insert body))
-    (message cmd)
-    ((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
-       (mapconcat
-       #'identity
-       (delq nil
-             (mapcar (lambda (line)
-                       (unless (or (string-match "batch" line)
-                                   (string-match "^rat: replaced .*$" line)
-                                   (= 0 (length line)))
-                         line))
-                     (split-string raw "[\r\n]"))) "\n"))
-     (org-babel-eval cmd ""))))
+  (let ((result
+        (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
+               (cmdline (cdr (assoc :cmdline params)))
+               (in-file (org-babel-temp-file "maxima-" ".max"))
+               (cmd (format "maxima --very-quiet -r 'batchload(%S)$' %s"
+                            in-file cmdline)))
+          (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
+          (message cmd)
+          ((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
+             (mapconcat
+              #'identity
+              (delq nil
+                    (mapcar (lambda (line)
+                              (unless (or (string-match "batch" line)
+                                          (string-match "^rat: replaced .*$" line)
+                                          (= 0 (length line)))
+                                line))
+                            (split-string raw "[\r\n]"))) "\n"))
+           (org-babel-eval cmd "")))))
+    (if (org-babel-maxima-graphical-output-file params)
+       nil
+      (if (or (member "scalar" result-params)
+             (member "verbatim" result-params)
+             (member "output" result-params))
+         result
+       (let ((tmp-file (org-babel-temp-file "maxima-res-")))
+         (with-temp-file tmp-file (insert result))
+         (org-babel-import-elisp-from-file tmp-file))))))
+
 
 (defun org-babel-prep-session:maxima (session params)
   (error "Maxima does not support sessions"))
 
+(defun org-babel-maxima-var-to-maxima (pair)
+  "Convert an elisp val into a string of maxima code specifying a var
+of the same value."
+  (let ((var (car pair))
+        (val (cdr pair)))
+    (when (symbolp val)
+      (setq val (symbol-name val))
+      (when (= (length val) 1)
+        (setq val (string-to-char val))))
+      (format "%S: %s$" var
+             (org-babel-maxima-elisp-to-maxima val))))
+
+(defun org-babel-maxima-graphical-output-file (params)
+  "Name of file to which maxima should send graphical output."
+  (and (member "graphics" (cdr (assq :result-params params)))
+       (cdr (assq :file params))))
+
+(defun org-babel-maxima-elisp-to-maxima (val)
+  "Return a string of maxima code which evaluates to VAL."
+  (if (listp val)
+      (concat "[" (mapconcat #'org-babel-maxima-elisp-to-maxima val ", ") "]")
+    (format "%s" val)))
+
+
 (provide 'ob-maxima)
 
 
index dc800a875c692619e2cd88c6314b58284da7bd99..5e894717ddddc67e318ec9d9c8a6a877901c0abc 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Juan Pechiar
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 78d309b9e138f2b52db121e0b57e612c6d099d78..22ccc3b7ad52d7639a17b964fbcdeace8e34b432 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -29,7 +28,7 @@
 ;; they can be run, but ocaml code can also be run through an
 ;; interactive interpreter.
 ;;
-;; For now let's only allow evaluation using the ocaml interpreter.
+;; For now lets only allow evaluation using the ocaml interpreter.
 
 ;;; Requirements:
 
@@ -99,7 +98,7 @@
    (lambda (pair) (format "let %s = %s;;" (car pair)
                          (org-babel-ocaml-elisp-to-ocaml (cdr pair))))
    (mapcar #'cdr (org-babel-get-header params :var))))
-
+  
 (defun org-babel-ocaml-elisp-to-ocaml (val)
   "Return a string of ocaml code which evaluates to VAL."
   (if (listp val)
index 2003a6f18f702b16346a0f01e0d16096b572380b..7de1455b8206ac18f37084d4eb048faf0c1b38d6 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -87,13 +86,24 @@ end")
          (org-babel-expand-body:generic
           body params (org-babel-variable-assignments:octave params)))
         (result (org-babel-octave-evaluate
-                 session full-body result-type matlabp)))
-    (org-babel-reassemble-table
-     result
-     (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
-     (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+                 session
+                 (if (org-babel-octave-graphical-output-file params)
+                     (mapconcat 'identity
+                                (list
+                                 "set (0, \"defaultfigurevisible\", \"off\");"
+                                 full-body
+                                 (format "print -dpng %s" (org-babel-octave-graphical-output-file params)))
+                                "\n")
+                   full-body)
+                 result-type matlabp)))
+    (if (org-babel-octave-graphical-output-file params)
+       nil
+      (org-babel-reassemble-table
+       result
+       (org-babel-pick-name
+       (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+       (org-babel-pick-name
+       (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
 
 (defun org-babel-prep-session:matlab (session params)
   "Prepare SESSION according to PARAMS."
@@ -118,7 +128,11 @@ specifying a variable of the same value."
   (if (listp var)
       (concat "[" (mapconcat #'org-babel-octave-var-to-octave var
                             (if (listp (car var)) "; " ",")) "]")
-    (format "%s" (or var "nil"))))
+    (cond
+     ((stringp var)
+      (format "\'%s\'" var))
+     (t
+      (format "%s" var)))))
 
 (defun org-babel-prep-session:octave (session params &optional matlabp)
   "Prepare SESSION according to the header arguments specified in PARAMS."
@@ -256,6 +270,11 @@ This removes initial blank and comment lines and then calls
       (match-string 1 string)
     string))
 
+(defun org-babel-octave-graphical-output-file (params)
+  "Name of file to which maxima should send graphical output."
+  (and (member "graphics" (cdr (assq :result-params params)))
+       (cdr (assq :file params))))
+
 (provide 'ob-octave)
 
 
index 37256d015c7e99615ed92be34490a452eb19d57c..32820e55fa3aff4d4d0844493106c0c253923df5 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 13d7141373187bae312310f11fba270cbba2c2b9..12e6c17a764f8d2634a17122862571bf50dc0e9f 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/org/ob-picolisp.el b/lisp/org/ob-picolisp.el
new file mode 100644 (file)
index 0000000..75e3ae0
--- /dev/null
@@ -0,0 +1,192 @@
+;;; ob-picolisp.el --- org-babel functions for picolisp evaluation
+
+;; Copyright (C) 2010-2011  Free Software Foundation, Inc.
+
+;; Authors: Thorsten Jolitz and Eric Schulte
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library enables the use of PicoLisp in the multi-language
+;; programming framework Org-Babel. PicoLisp is a minimal yet
+;; fascinating lisp dialect and a highly productive application
+;; framework for web-based client-server applications on top of
+;; object-oriented databases. A good way to learn PicoLisp is to first
+;; read Paul Grahams essay "The hundred year language"
+;; (http://www.paulgraham.com/hundred.html) and then study the various
+;; documents and essays published in the PicoLisp wiki
+;; (http://picolisp.com/5000/-2.html). PicoLisp is included in some
+;; GNU/Linux Distributions, and can be downloaded here:
+;; http://software-lab.de/down.html. It ships with a picolisp-mode and
+;; a inferior-picolisp-mode for Emacs (to be found in the /lib/el/
+;; directory).
+
+;; Although it might seem more natural to use Emacs Lisp for most
+;; Lisp-based programming tasks inside Org-Mode, an Emacs library
+;; written in Emacs Lisp, PicoLisp has at least two outstanding
+;; features that make it a valuable addition to Org-Babel:
+
+;; PicoLisp _is_ an object-oriented database with a Prolog-based query
+;; language implemented in PicoLisp (Pilog). Database objects are
+;; first-class members of the language. 
+
+;; PicoLisp is an extremely productive framework for the development
+;; of interactive web-applications (on top of a database). 
+
+;;; Requirements:
+
+;;; Code:
+(require 'ob)
+(require 'ob-eval)
+(require 'ob-comint)
+(require 'comint)
+(eval-when-compile (require 'cl))
+
+(declare-function run-picolisp "ext:inferior-picolisp" (cmd))
+
+;; optionally define a file extension for this language
+(add-to-list 'org-babel-tangle-lang-exts '("picolisp" . "l"))
+
+;;; interferes with settings in org-babel buffer?
+;; optionally declare default header arguments for this language
+;; (defvar org-babel-default-header-args:picolisp
+;;   '((:colnames . "no"))
+;;   "Default arguments for evaluating a picolisp source block.")
+
+(defvar org-babel-picolisp-eoe "org-babel-picolisp-eoe"
+  "String to indicate that evaluation has completed.")
+
+(defcustom org-babel-picolisp-cmd "pil"
+  "Name of command used to evaluate picolisp blocks."
+  :group 'org-babel
+  :type 'string)
+
+(defun org-babel-expand-body:picolisp (body params &optional processed-params)
+  "Expand BODY according to PARAMS, return the expanded body."
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+        (result-params (cdr (assoc :result-params params)))
+        (print-level nil) (print-length nil))
+    (if (> (length vars) 0)
+        (concat "(prog (let ("
+                (mapconcat
+                 (lambda (var)
+                   (format "%S '%S)"
+                           (print (car var))
+                           (print (cdr var))))
+                 vars "\n      ")
+                " \n" body ") )")
+      body)))
+
+(defun org-babel-execute:picolisp (body params)
+  "Execute a block of Picolisp code with org-babel.  This function is
+ called by `org-babel-execute-src-block'"           
+  (message "executing Picolisp source code block")
+  (let* (
+        ;; name of the session or "none"
+        (session-name (cdr (assoc :session params)))
+        ;; set the session if the session variable is non-nil
+        (session (org-babel-picolisp-initiate-session session-name))
+        ;; either OUTPUT or VALUE which should behave as described above
+        (result-type (cdr (assoc :result-type params)))
+        (result-params (cdr (assoc :result-params params)))
+        ;; expand the body with `org-babel-expand-body:picolisp'
+        (full-body (org-babel-expand-body:picolisp body params))
+         ;; wrap body appropriately for the type of evaluation and results
+         (wrapped-body
+          (cond
+           ((or (member "code" result-params)
+                (member "pp" result-params))
+            (format "(pretty (out \"/dev/null\" %s))" full-body))
+           ((and (member "value" result-params) (not session))
+            (format "(print (out \"/dev/null\" %s))" full-body))
+           ((member "value" result-params)
+            (format "(out \"/dev/null\" %s)" full-body))
+           (t full-body))))
+    
+    ((lambda (result)
+       (if (or (member "verbatim" result-params)
+               (member "scalar" result-params)
+               (member "output" result-params)
+               (member "code" result-params)
+               (member "pp" result-params)
+               (= (length result) 0))
+           result
+         (read result)))
+     (if (not (string= session-name "none"))
+         ;; session based evaluation
+        (mapconcat ;; <- joins the list back together into a single string
+          #'identity
+          (butlast ;; <- remove the org-babel-picolisp-eoe line
+           (delq nil
+                 (mapcar
+                  (lambda (line)
+                    (org-babel-chomp ;; remove trailing newlines
+                     (when (> (length line) 0) ;; remove empty lines
+                      (cond
+                       ;; remove leading "-> " from return values
+                       ((and (>= (length line) 3)
+                             (string= "-> " (substring line 0 3)))
+                        (substring line 3))
+                       ;; remove trailing "-> <<return-value>>" on the
+                       ;; last line of output
+                       ((and (member "output" result-params)
+                             (string-match-p "->" line))
+                        (substring line 0 (string-match "->" line)))
+                       (t line)
+                       )
+                       ;; (if (and (>= (length line) 3) ;; remove leading "<- "
+                       ;;          (string= "-> " (substring line 0 3)))
+                       ;;     (substring line 3)
+                       ;;   line)
+                      )))
+                  ;; returns a list of the output of each evaluated expression
+                  (org-babel-comint-with-output (session org-babel-picolisp-eoe)
+                    (insert wrapped-body) (comint-send-input)
+                    (insert "'" org-babel-picolisp-eoe) (comint-send-input)))))
+          "\n")
+       ;; external evaluation
+       (let ((script-file (org-babel-temp-file "picolisp-script-")))
+        (with-temp-file script-file
+          (insert (concat wrapped-body "(bye)")))
+         (org-babel-eval
+          (format "%s %s"
+                  org-babel-picolisp-cmd
+                  (org-babel-process-file-name script-file))
+          ""))))))
+
+(defun org-babel-picolisp-initiate-session (&optional session-name)
+  "If there is not a current inferior-process-buffer in SESSION
+then create.  Return the initialized session."
+  (unless (string= session-name "none")
+    (require 'inferior-picolisp)
+    ;; provide a reasonable default session name
+    (let ((session (or session-name "*inferior-picolisp*")))
+      ;; check if we already have a live session by this name
+      (if (org-babel-comint-buffer-livep session)
+          (get-buffer session)
+        (save-window-excursion
+          (run-picolisp org-babel-picolisp-cmd)
+          (rename-buffer session-name)
+          (current-buffer))))))
+
+(provide 'ob-picolisp)
+
+
+
+;;; ob-picolisp.el ends here
index 9fa557275925f64c4dff02828d178a6f9e6bf7bc..9f60f583bb039e8e85f5d7fd21da7d4ebdd4777b 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Zhang Weize
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 5234d83eceec6e4f330c459ecd32d6fb3a0ba53d..c84b11d77f0b56c50851dee13698442b367c6195 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 1e14021a364ab4a8a7362cba0d37f724355f2eb7..304e47832530c96e3f9e74e0939816b3b60f561a 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
 (declare-function org-narrow-to-subtree "org" ())
 (declare-function org-id-find-id-in-file "org-id" (id file &optional markerp))
 (declare-function org-show-context "org" (&optional key))
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 (defvar org-babel-ref-split-regexp
   "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")
 
+(defvar org-babel-update-intermediate nil
+  "Update the in-buffer results of code blocks executed to resolve references.")
+
 (defun org-babel-ref-parse (assignment)
   "Parse a variable ASSIGNMENT in a header argument.
 If the right hand side of the assignment has a literal value
@@ -94,7 +98,7 @@ the variable."
               (m (when file (org-id-find-id-in-file id file 'marker))))
          (when (and file m)
            (message "file:%S" file)
-           (switch-to-buffer (marker-buffer m))
+           (org-pop-to-buffer-same-window (marker-buffer m))
            (goto-char m)
            (move-marker m nil)
            (org-show-context)
@@ -147,21 +151,19 @@ the variable."
       (save-restriction
        (widen)
        (goto-char (point-min))
-       (if (let* ((rx (regexp-quote ref))
-                  (res-rx (concat org-babel-result-regexp rx "[ \t]*$"))
-                  (src-rx (concat org-babel-src-name-regexp
-                                  rx "\\(\(.*\)\\)?" "[ \t]*$")))
+       (if (let ((src-rx (org-babel-named-src-block-regexp-for-name ref))
+                 (res-rx (org-babel-named-data-regexp-for-name ref)))
              ;; goto ref in the current buffer
-             (or (and (not args)
-                      (or (re-search-forward res-rx nil t)
-                          (re-search-backward res-rx nil t)))
-                 (re-search-forward src-rx nil t)
-                 (re-search-backward src-rx nil t)
-                 ;; check for local or global headlines by id
-                 (setq id (org-babel-ref-goto-headline-id ref))
-                 ;; check the Library of Babel
-                 (setq lob-info (cdr (assoc (intern ref)
-                                            org-babel-library-of-babel)))))
+             (or
+              ;; check for code blocks
+              (re-search-forward src-rx nil t)
+              ;; check for named data
+              (re-search-forward res-rx nil t)
+              ;; check for local or global headlines by id
+              (setq id (org-babel-ref-goto-headline-id ref))
+              ;; check the Library of Babel
+              (setq lob-info (cdr (assoc (intern ref)
+                                         org-babel-library-of-babel)))))
            (unless (or lob-info id) (goto-char (match-beginning 0)))
          ;; ;; TODO: allow searching for names in other buffers
          ;; (setq id-loc (org-id-find ref 'marker)
@@ -172,6 +174,12 @@ the variable."
        (cond
         (lob-info (setq type 'lob))
         (id (setq type 'id))
+        ((and (looking-at org-babel-src-name-regexp)
+              (save-excursion
+                (forward-line 1)
+                (or (looking-at org-babel-src-block-regexp)
+                    (looking-at org-babel-multi-line-header-regexp))))
+         (setq type 'source-block))
         (t (while (not (setq type (org-babel-ref-at-ref-p)))
              (forward-line 1)
              (beginning-of-line)
@@ -184,7 +192,9 @@ the variable."
                  (table        (org-babel-read-table))
                  (list         (org-babel-read-list))
                  (file         (org-babel-read-link))
-                 (source-block (org-babel-execute-src-block nil nil params))
+                 (source-block (org-babel-execute-src-block
+                                nil nil (if org-babel-update-intermediate
+                                            nil params)))
                  (lob          (org-babel-execute-src-block
                                 nil lob-info params))
                  (id           (org-babel-ref-headline-body)))))
@@ -234,20 +244,7 @@ to \"0:-1\"."
 
 (defun org-babel-ref-split-args (arg-string)
   "Split ARG-STRING into top-level arguments of balanced parenthesis."
-  (let ((index 0) (depth 0) (buffer "") holder return)
-    ;; crawl along string, splitting at any ","s which are on the top level
-    (while (< index (length arg-string))
-      (setq holder (substring arg-string index (+ 1 index)))
-      (setq buffer (concat buffer holder))
-      (setq index (+ 1 index))
-      (cond
-       ((string= holder ",")
-        (when (= depth 0)
-          (setq return (cons (substring buffer 0 -1) return))
-          (setq buffer "")))
-       ((or (string= holder "(") (string= holder "[")) (setq depth (+ depth 1)))
-       ((or (string= holder ")") (string= holder "]")) (setq depth (- depth 1)))))
-    (mapcar #'org-babel-trim (reverse (cons buffer return)))))
+  (mapcar #'org-babel-trim (org-babel-balanced-split arg-string 44)))
 
 (defvar org-bracket-link-regexp)
 (defun org-babel-ref-at-ref-p ()
index 02089b4a21413d512cad02adaa7c38d1bd80d91c..e48e372ebd0962222f0080a8901f7c3cbb1ad6c1 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -129,8 +128,8 @@ Emacs-lisp table, otherwise return the results as a string."
   "Initiate a ruby session.
 If there is not a current inferior-process-buffer in SESSION
 then create one.  Return the initialized session."
-  (require 'inf-ruby)
   (unless (string= session "none")
+    (require 'inf-ruby)
     (let ((session-buffer (save-window-excursion
                            (run-ruby nil session) (current-buffer))))
       (if (org-babel-comint-buffer-livep session-buffer)
index 162113ea5a8b612501c562ddf9e15287e8828c59..b687eeb9fe233e5a02d743401544fd337b3db70f 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 3e93a3a74f778bfce9f0e9971ce1a56ec7da132b..14198ba6a21656e3e46638c02109c0ae6529220d 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, scheme
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index 367d73f787a0157a87d22c204420e1ad39434361..2b1b25d407cc04a03297d155b0b85731d29334a3 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Benjamin Andresen
 ;; Keywords: literate programming, interactive shell
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index f46ba45770a31b2d794ba795b096bf7ba71576aa..ac0cf94726c9ea11e25b52c004fedfe8e1355c70 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/org/ob-shen.el b/lisp/org/ob-shen.el
new file mode 100644 (file)
index 0000000..ccf3030
--- /dev/null
@@ -0,0 +1,79 @@
+;;; ob-shen.el --- org-babel functions for Shen
+
+;; Copyright (C) 2010-2011 Free Software Foundation
+
+;; Author: Eric Schulte
+;; Keywords: literate programming, reproducible research, shen
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Currently this only works using session evaluation as there is no
+;; defined method for executing shen code outside of a session.
+
+;;; Requirements:
+
+;; - shen-mode and inf-shen will soon be available through the GNU
+;;   elpa, however in the interim they are available at
+;;   https://github.com/eschulte/shen-mode
+
+;;; Code:
+(require 'ob)
+
+(declare-function shen-eval-defun "ext:inf-shen" (&optional and-go))
+
+(defvar org-babel-default-header-args:shen '()
+  "Default header arguments for shen code blocks.")
+
+(defun org-babel-expand-body:shen (body params)
+  "Expand BODY according to PARAMS, return the expanded body."
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+    (if (> (length vars) 0)
+        (concat "(let "
+                (mapconcat (lambda (var)
+                            (format "%s %s" (car var)
+                                    (org-babel-shen-var-to-shen (cdr var))))
+                          vars " ")
+               body ")")
+      body)))
+
+(defun org-babel-shen-var-to-shen (var)
+  "Convert VAR into a shen variable."
+  (if (listp var)
+      (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var " ") "]")
+    (format "%S" var)))
+
+(defun org-babel-execute:shen (body params)
+  "Execute a block of Shen code with org-babel.
+This function is called by `org-babel-execute-src-block'"
+  (require 'inf-shen)
+  (let* ((result-type (cdr (assoc :result-type params)))
+        (result-params (cdr (assoc :result-params params)))
+         (full-body (org-babel-expand-body:shen body params)))
+    ((lambda (results)
+       (if (or (member 'scalar result-params)
+              (member 'verbatim result-params))
+          results
+        (condition-case nil (org-babel-script-escape results)
+          (error results))))
+     (with-temp-buffer
+       (insert full-body)
+       (call-interactively #'shen-eval-defun)))))
+
+(provide 'ob-shen)
+;;; ob-shen.el ends here
index 7a5c7c8a46a383e15211eb59b685056dd83d88c2..8e92635bc1fbf87492e09e406e1fbf04757ed108 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -32,7 +31,7 @@
 ;;
 ;; Also SQL evaluation generally takes place inside of a database.
 ;;
-;; For now let's just allow a generic ':cmdline' header argument.
+;; For now lets just allow a generic ':cmdline' header argument.
 ;;
 ;; TODO:
 ;;
@@ -40,7 +39,7 @@
 ;; - add more useful header arguments (user, passwd, database, etc...)
 ;; - support for more engines (currently only supports mysql)
 ;; - what's a reasonable way to drop table data into SQL?
-;;
+;; 
 
 ;;; Code:
 (require 'ob)
@@ -51,6 +50,9 @@
 
 (defvar org-babel-default-header-args:sql '())
 
+(defvar org-babel-header-arg-names:sql
+  '(engine out-file))
+
 (defun org-babel-expand-body:sql (body params)
   "Expand BODY according to the values of PARAMS."
   (org-babel-sql-expand-vars
@@ -85,31 +87,38 @@ This function is called by `org-babel-execute-src-block'."
       (insert (org-babel-expand-body:sql body params)))
     (message command)
     (shell-command command)
-    (with-temp-buffer
-      ;; need to figure out what the delimiter is for the header row
+    (if (or (member "scalar" result-params)
+           (member "verbatim" result-params)
+           (member "html" result-params)
+           (member "code" result-params)
+           (equal (point-min) (point-max)))
+       (with-temp-buffer
+         (progn (insert-file-contents-literally out-file) (buffer-string)))
       (with-temp-buffer
-        (insert-file-contents out-file)
-        (goto-char (point-min))
-        (when (re-search-forward "^\\(-+\\)[^-]" nil t)
-          (setq header-delim (match-string-no-properties 1)))
-        (goto-char (point-max))
-        (forward-char -1)
-        (while (looking-at "\n")
-          (delete-char 1)
-          (goto-char (point-max))
-          (forward-char -1))
-        (write-file out-file))
-      (org-table-import out-file '(16))
-      (org-babel-reassemble-table
-       (mapcar (lambda (x)
-                 (if (string= (car x) header-delim)
-                     'hline
-                   x))
-               (org-table-to-lisp))
-       (org-babel-pick-name (cdr (assoc :colname-names params))
-                           (cdr (assoc :colnames params)))
-       (org-babel-pick-name (cdr (assoc :rowname-names params))
-                           (cdr (assoc :rownames params)))))))
+       ;; need to figure out what the delimiter is for the header row
+       (with-temp-buffer
+         (insert-file-contents out-file)
+         (goto-char (point-min))
+         (when (re-search-forward "^\\(-+\\)[^-]" nil t)
+           (setq header-delim (match-string-no-properties 1)))
+         (goto-char (point-max))
+         (forward-char -1)
+         (while (looking-at "\n")
+           (delete-char 1)
+           (goto-char (point-max))
+           (forward-char -1))
+         (write-file out-file))
+       (org-table-import out-file '(16))
+       (org-babel-reassemble-table
+        (mapcar (lambda (x)
+                  (if (string= (car x) header-delim)
+                      'hline
+                    x))
+                (org-table-to-lisp))
+        (org-babel-pick-name (cdr (assoc :colname-names params))
+                             (cdr (assoc :colnames params)))
+        (org-babel-pick-name (cdr (assoc :rowname-names params))
+                             (cdr (assoc :rownames params))))))))
 
 (defun org-babel-sql-expand-vars (body vars)
   "Expand the variables held in VARS in BODY."
index c08c7f38e8a1ba22065a9daa54ef9c44a3d83e36..edd230e78c04460f7b1a5c359274b9fea8291de2 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
index ea253b2f048b24cb81fa53cb9db2642a97798591..15ebff94fcb3f422649cbf58cf79740a41b3721f 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -31,7 +30,7 @@
 ;;   (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
 ;; #+end_src
 
-;; #+srcname: fibbd
+;; #+name: fibbd
 ;; #+begin_src emacs-lisp :var n=2 :results silent
 ;; (fibbd n)
 ;; #+end_src
@@ -78,46 +77,60 @@ NOTE: by default string variable names are interpreted as
 references to source-code blocks, to force interpretation of a
 cell's value as a string, prefix the identifier with two \"$\"s
 rather than a single \"$\" (i.e. \"$$2\" instead of \"$2\" in the
-example above."
-  (let* (quote
-        (variables
-         (mapcar
-          (lambda (var)
-            ;; ensure that all cells prefixed with $'s are strings
-            (cons (car var)
-                  (delq nil (mapcar
-                             (lambda (el)
-                               (if (eq '$ el)
-                                   (setq quote t)
-                                 (prog1 (if quote
-                                            (format "\"%s\"" el)
-                                          (org-babel-clean-text-properties el))
-                                   (setq quote nil))))
-                             (cdr var)))))
-          variables)))
-    (unless (stringp source-block)
-      (setq source-block (symbol-name source-block)))
-    ((lambda (result)
-       (org-babel-trim (if (stringp result) result (format "%S" result))))
-     (if (and source-block (> (length source-block) 0))
-         (let ((params
-                (eval `(org-babel-parse-header-arguments
-                        (concat ":var results="
-                                ,source-block
-                                "("
-                                (mapconcat
-                                (lambda (var-spec)
-                                  (if (> (length (cdr var-spec)) 1)
-                                      (format "%S='%S"
-                                              (car var-spec)
-                                              (mapcar #'read (cdr var-spec)))
-                                    (format "%S=%s"
-                                            (car var-spec) (cadr var-spec))))
-                                ',variables ", ")
-                                ")")))))
-           (org-babel-execute-src-block
-            nil (list "emacs-lisp" "results" params) '((:results . "silent"))))
-       ""))))
+example above.
+
+NOTE: it is also possible to pass header arguments to the code
+block.  In this case a table cell should hold the string value of
+the header argument which can then be passed before all variables
+as shown in the example below.
+
+| 1 | 2 | :file nothing.png | nothing.png |
+#+TBLFM: @1$4='(sbe test-sbe $3 (x $1) (y $2))"
+  (let* ((header-args (if (stringp (car variables)) (car variables) ""))
+        (variables (if (stringp (car variables)) (cdr variables) variables)))
+    (let* (quote
+          (variables
+           (mapcar
+            (lambda (var)
+              ;; ensure that all cells prefixed with $'s are strings
+              (cons (car var)
+                    (delq nil (mapcar
+                               (lambda (el)
+                                 (if (eq '$ el)
+                                     (setq quote t)
+                                   (prog1 (if quote
+                                              (format "\"%s\"" el)
+                                            (org-babel-clean-text-properties el))
+                                     (setq quote nil))))
+                               (cdr var)))))
+            variables)))
+      (unless (stringp source-block)
+       (setq source-block (symbol-name source-block)))
+      ((lambda (result)
+        (org-babel-trim (if (stringp result) result (format "%S" result))))
+       (if (and source-block (> (length source-block) 0))
+          (let ((params
+                 (eval `(org-babel-parse-header-arguments
+                         (concat
+                          ":var results="
+                          ,source-block
+                          "[" ,header-args "]"
+                          "("
+                          (mapconcat
+                           (lambda (var-spec)
+                             (if (> (length (cdr var-spec)) 1)
+                                 (format "%S='%S"
+                                         (car var-spec)
+                                         (mapcar #'read (cdr var-spec)))
+                               (format "%S=%s"
+                                       (car var-spec) (cadr var-spec))))
+                           ',variables ", ")
+                          ")")))))
+            (org-babel-execute-src-block
+             nil (list "emacs-lisp" "results" params)
+             '((:results . "silent"))))
+        "")))))
+(def-edebug-spec sbe (form form))
 
 (provide 'ob-table)
 
index 26549126009d91888a4d99b61faf36561dc60671..f5dbb30631ae5a22e1ba3640e9b9a094d395fbd2 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -96,6 +95,14 @@ controlled by the :comments header argument."
   :group 'org-babel
   :type 'string)
 
+(defcustom org-babel-process-comment-text #'org-babel-trim
+  "Function called to process raw Org-mode text collected to be
+inserted as comments in tangled source-code files.  The function
+should take a single string argument and return a string
+result.  The default value is `org-babel-trim'."
+  :group 'org-babel
+  :type 'function)
+
 (defun org-babel-find-file-noselect-refresh (file)
   "Find file ensuring that the latest changes on disk are
 represented in the file."
@@ -119,6 +126,7 @@ evaluating BODY."
         (setf ,temp-result (progn ,@body)))
        (unless ,visited-p (kill-buffer ,temp-file))
        ,temp-result)))
+(def-edebug-spec org-babel-with-temp-filebuffer (form body))
 
 ;;;###autoload
 (defun org-babel-load-file (file)
@@ -345,16 +353,20 @@ code blocks by language."
                    (when (or (string= "both" (cdr (assoc :comments params)))
                              (string= "org" (cdr (assoc :comments params))))
                      ;; from the previous heading or code-block end
-                     (buffer-substring
-                      (max (condition-case nil
-                               (save-excursion
-                                 (org-back-to-heading t) (point))
-                             (error 0))
-                           (save-excursion
-                             (re-search-backward
-                              org-babel-src-block-regexp nil t)
-                             (match-end 0)))
-                      (point))))
+                     (funcall
+                      org-babel-process-comment-text
+                      (buffer-substring
+                       (max (condition-case nil
+                                (save-excursion
+                                  (org-back-to-heading t)  ; sets match data
+                                  (match-end 0))
+                              (error (point-min)))
+                            (save-excursion
+                              (if (re-search-backward
+                                   org-babel-src-block-regexp nil t)
+                                  (match-end 0)
+                                (point-min))))
+                       (point)))))
                   by-lang)
              ;; add the spec for this block to blocks under it's language
              (setq by-lang (cdr (assoc src-lang blocks)))
@@ -396,12 +408,11 @@ form
                                     (eval el))))
                            '(start-line file link source-name))))
     (flet ((insert-comment (text)
-            (let ((text (org-babel-trim text)))
-             (when (and comments (not (string= comments "no"))
-                        (> (length text) 0))
-               (when padline (insert "\n"))
-               (comment-region (point) (progn (insert text) (point)))
-               (end-of-line nil) (insert "\n")))))
+            (when (and comments (not (string= comments "no"))
+                      (> (length text) 0))
+             (when padline (insert "\n"))
+             (comment-region (point) (progn (insert text) (point)))
+             (end-of-line nil) (insert "\n"))))
       (when comment (insert-comment comment))
       (when link-p
        (insert-comment
index 8bba46721692107acffbc863d60cb0471f75d819..3eee92a906e4cc298e3dd5baf2208a5d22bf8e12 100644 (file)
@@ -6,7 +6,6 @@
 ;;     Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -33,6 +32,7 @@
 (defvar org-src-lang-modes)
 (defvar org-babel-library-of-babel)
 (declare-function show-all "outline" ())
+(declare-function org-reduce "org" (CL-FUNC CL-SEQ &rest CL-KEYS))
 (declare-function tramp-compat-make-temp-file "tramp-compat"
                   (filename &optional dir-flag))
 (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault))
@@ -114,7 +114,7 @@ remove code block execution from the C-c C-c keybinding."
   :type 'boolean)
 
 (defvar org-babel-src-name-regexp
-  "^[ \t]*#\\+\\(srcname\\|source\\|function\\):[ \t]*"
+  "^[ \t]*#\\+name:[ \t]*"
   "Regular expression used to match a source name line.")
 
 (defvar org-babel-multi-line-header-regexp
@@ -144,7 +144,7 @@ remove code block execution from the C-c C-c keybinding."
 (defvar org-babel-inline-src-block-regexp
   (concat
    ;; (1) replacement target (2) lang
-   "[^-[:alnum:]]\\(src_\\([^ \f\t\n\r\v]+\\)"
+   "\\(?:^\\|[^-[:alnum:]]\\)\\(src_\\([^ \f\t\n\r\v]+\\)"
    ;; (3,4) (unused, headers)
    "\\(\\|\\[\\(.*?\\)\\]\\)"
    ;; (5) body
@@ -160,6 +160,39 @@ not match KEY should be returned."
         (lambda (p) (when (funcall (if others #'not #'identity) (eq (car p) key)) p))
         params)))
 
+(defun org-babel-get-inline-src-block-matches()
+  "Set match data if within body of an inline source block.
+Returns non-nil if match-data set"
+  (let ((src-at-0-p (save-excursion
+                     (beginning-of-line 1)
+                     (string= "src" (thing-at-point 'word))))
+       (first-line-p (= 1 (line-number-at-pos)))
+       (orig (point)))
+    (let ((search-for (cond ((and src-at-0-p first-line-p  "src_"))
+                           (first-line-p "[ \t]src_")
+                           (t "[ \f\t\n\r\v]src_")))
+         (lower-limit (if first-line-p
+                          nil
+                        (- (point-at-bol) 1))))
+      (save-excursion
+       (when (or (and src-at-0-p (bobp))
+                 (and (re-search-forward "}" (point-at-eol) t)
+                      (re-search-backward search-for lower-limit t)
+                      (> orig (point))))
+         (when (looking-at org-babel-inline-src-block-regexp)
+           t ))))))
+
+(defvar org-babel-inline-lob-one-liner-regexp)
+(defun org-babel-get-lob-one-liner-matches()
+  "Set match data if on line of an lob one liner.
+Returns non-nil if match-data set"
+  (save-excursion
+    (unless (= (point) (point-at-bol)) ;; move before inline block
+      (re-search-backward "[ \f\t\n\r\v]" nil t))
+    (if (looking-at org-babel-inline-lob-one-liner-regexp)
+       t
+      nil)))
+
 (defun org-babel-get-src-block-info (&optional light)
   "Get information on the current source block.
 
@@ -184,22 +217,30 @@ Returns a list
                   (nth 2 info)
                   (org-babel-parse-header-arguments (match-string 1)))))
          (when (looking-at org-babel-src-name-w-name-regexp)
-           (setq name (org-babel-clean-text-properties (match-string 4)))
-           (when (match-string 6)
+           (setq name (org-babel-clean-text-properties (match-string 3)))
+           (when (and (match-string 5) (> (length (match-string 5)) 0))
              (setf (nth 2 info) ;; merge functional-syntax vars and header-args
                    (org-babel-merge-params
-                    (mapcar (lambda (ref) (cons :var ref))
-                            (org-babel-ref-split-args (match-string 6)))
+                    (mapcar
+                     (lambda (ref) (cons :var ref))
+                     (mapcar
+                      (lambda (var) ;; check that each variable is initialized
+                        (if (string-match ".+=.+" var)
+                            var
+                          (error
+                           "variable \"%s\"%s must be assigned a default value"
+                           var (if name (format " in block \"%s\"" name) ""))))
+                      (org-babel-ref-split-args (match-string 5))))
                     (nth 2 info))))))
       ;; inline source block
-      (when (save-excursion (re-search-backward "[ \f\t\n\r\v]" nil t)
-                           (looking-at org-babel-inline-src-block-regexp))
+      (when (org-babel-get-inline-src-block-matches)
        (setq info (org-babel-parse-inline-src-block-match))))
     ;; resolve variable references and add summary parameters
     (when (and info (not light))
       (setf (nth 2 info) (org-babel-process-params (nth 2 info))))
     (when info (append info (list name indent)))))
 
+(defvar org-current-export-file) ; dynamically bound
 (defun org-babel-confirm-evaluate (info)
   "Confirm evaluation of the code block INFO.
 This behavior can be suppressed by setting the value of
@@ -212,11 +253,15 @@ of potentially harmful code."
   (let* ((eval (or (cdr (assoc :eval (nth 2 info)))
                   (when (assoc :noeval (nth 2 info)) "no")))
          (query (cond ((equal eval "query") t)
+                     ((and org-current-export-file
+                           (equal eval "query-export")) t)
                       ((functionp org-confirm-babel-evaluate)
                        (funcall org-confirm-babel-evaluate
                                 (nth 0 info) (nth 1 info)))
                       (t org-confirm-babel-evaluate))))
     (if (or (equal eval "never") (equal eval "no")
+           (and org-current-export-file (or (equal eval "no-export")
+                                            (equal eval "never-export")))
            (and query
                 (not (yes-or-no-p
                       (format "Evaluate this%scode block%son your system? "
@@ -224,7 +269,9 @@ of potentially harmful code."
                               (if (nth 4 info)
                                   (format " (%s) " (nth 4 info)) " "))))))
        (prog1 nil (message "Evaluation %s"
-                           (if (or (equal eval "never") (equal eval "no"))
+                           (if (or (equal eval "never") (equal eval "no")
+                                   (equal eval "no-export")
+                                   (equal eval "never-export"))
                                "Disabled" "Aborted")))
       t)))
 
@@ -314,10 +361,35 @@ then run `org-babel-pop-to-session'."
 
 (add-hook 'org-metadown-hook 'org-babel-pop-to-session-maybe)
 
+(defconst org-babel-common-header-args-w-values
+  '((cache     . ((no yes)))
+    (cmdline   . :any)
+    (colnames  . ((nil no yes)))
+    (comments  . ((no link yes org both noweb)))
+    (dir       . :any)
+    (eval      . ((never query)))
+    (exports   . ((code results both none)))
+    (file      . :any)
+    (hlines    . ((no yes)))
+    (mkdirp    . ((yes no)))
+    (no-expand)
+    (noeval)
+    (noweb     . ((yes no tangle)))
+    (noweb-ref . :any)
+    (padline   . ((yes no)))
+    (results   . ((file list vector table scalar verbatim)
+                   (raw org html latex code pp wrap)
+                   (replace silent append prepend)
+                   (output value)))
+    (rownames  . ((no yes)))
+    (sep       . :any)
+    (session   . :any)
+    (shebang   . :any)
+    (tangle    . ((tangle yes no :any)))
+    (var       . :any)))
+
 (defconst org-babel-header-arg-names
-  '(cache cmdline colnames dir exports file noweb results
-    session tangle var eval noeval comments no-expand shebang
-    padline noweb-ref)
+  (mapcar #'car org-babel-common-header-args-w-values)
   "Common header arguments used by org-babel.
 Note that individual languages may define their own language
 specific header arguments as well.")
@@ -332,7 +404,7 @@ specific header arguments as well.")
   '((:session . "none") (:results . "replace") (:exports . "results"))
   "Default arguments to use when evaluating an inline source block.")
 
-(defvar org-babel-data-names '("TBLNAME" "RESNAME" "RESULTS" "DATA"))
+(defvar org-babel-data-names '("TBLNAME" "RESULTS" "NAME"))
 
 (defvar org-babel-result-regexp
   (concat "^[ \t]*#\\+"
@@ -365,11 +437,17 @@ can not be resolved.")
 
 (defvar org-babel-after-execute-hook nil
   "Hook for functions to be called after `org-babel-execute-src-block'")
+
 (defun org-babel-named-src-block-regexp-for-name (name)
   "This generates a regexp used to match a src block named NAME."
-  (concat org-babel-src-name-regexp (regexp-quote name) "[ \t\n]*"
+  (concat org-babel-src-name-regexp (regexp-quote name)
+         "\\([ \t]\\|$\\|(\\)" ".*[\r\n]"
          (substring org-babel-src-block-regexp 1)))
 
+(defun org-babel-named-data-regexp-for-name (name)
+  "This generates a regexp used to match data named NAME."
+  (concat org-babel-result-regexp (regexp-quote name) "\\([ \t]\\|$\\)"))
+
 ;;; functions
 (defvar call-process-region)
 ;;;###autoload
@@ -380,9 +458,8 @@ Insert the results of execution into the buffer.  Source code
 execution and the collection and formatting of results can be
 controlled through a variety of header arguments.
 
-With prefix argument ARG, force re-execution even if an
-existing result cached in the buffer would otherwise have been
-returned.
+With prefix argument ARG, force re-execution even if an existing
+result cached in the buffer would otherwise have been returned.
 
 Optionally supply a value for INFO in the form returned by
 `org-babel-get-src-block-info'.
@@ -519,6 +596,7 @@ arguments and pop open the results in a preview buffer."
   (interactive)
   ;; TODO: report malformed code block
   ;; TODO: report incompatible combinations of header arguments
+  ;; TODO: report uninitialized variables
   (let ((too-close 2)) ;; <- control closeness to report potential match
     (dolist (header (mapcar (lambda (arg) (substring (symbol-name (car arg)) 1))
                            (and (org-babel-where-is-src-block-head)
@@ -532,6 +610,41 @@ arguments and pop open the results in a preview buffer."
                 header name))))
     (message "No suspicious header arguments found.")))
 
+;;;###autoload
+(defun org-babel-insert-header-arg ()
+  "Insert a header argument selecting from lists of common args and values."
+  (interactive)
+  (let* ((lang (car (org-babel-get-src-block-info 'light)))
+        (lang-headers (intern (concat "org-babel-header-arg-names:" lang)))
+        (headers (append (if (boundp lang-headers)
+                             (mapcar (lambda (h) (cons h :any))
+                                     (eval lang-headers))
+                           nil)
+                         org-babel-common-header-args-w-values))
+        (arg (org-icompleting-read
+             "Header Arg: "
+             (mapcar
+              (lambda (header-spec) (symbol-name (car header-spec)))
+              headers))))
+    (insert ":" arg)
+    (let ((vals (cdr (assoc (intern arg) headers))))
+      (when vals
+       (insert
+        " "
+        (cond
+         ((eq vals :any)
+          (read-from-minibuffer "value: "))
+         ((listp vals)
+          (mapconcat
+           (lambda (group)
+             (let ((arg (org-icompleting-read
+                         "value: "
+                         (cons "default" (mapcar #'symbol-name group)))))
+               (if (and arg (not (string= "default" arg)))
+                   (concat arg " ")
+                 "")))
+           vals ""))))))))
+
 ;;;###autoload
 (defun org-babel-load-in-session (&optional arg info)
   "Load the body of the current source-code block.
@@ -625,6 +738,7 @@ Return t if a code block was found at point, nil otherwise."
         (if (org-bound-and-true-p org-edit-src-from-org-mode)
             (org-edit-src-exit)))
        t)))
+(def-edebug-spec org-babel-do-in-edit-buffer (body))
 
 (defun org-babel-do-key-sequence-in-edit-buffer (key)
   "Read key sequence and execute the command in edit buffer.
@@ -721,6 +835,7 @@ end-body --------- point at the end of the body"
             (goto-char end-block))))
        (unless visited-p (kill-buffer to-be-removed))
        (goto-char point))))
+(def-edebug-spec org-babel-map-src-blocks (form body))
 
 ;;;###autoload
 (defmacro org-babel-map-inline-src-blocks (file &rest body)
@@ -743,6 +858,31 @@ buffer."
           (goto-char (match-end 0))))
        (unless visited-p (kill-buffer to-be-removed))
        (goto-char point))))
+(def-edebug-spec org-babel-map-inline-src-blocks (form body))
+
+(defvar org-babel-lob-one-liner-regexp)
+;;;###autoload
+(defmacro org-babel-map-call-lines (file &rest body)
+  "Evaluate BODY forms on each call line in FILE.
+If FILE is nil evaluate BODY forms on source blocks in current
+buffer."
+  (declare (indent 1))
+  (let ((tempvar (make-symbol "file")))
+    `(let* ((,tempvar ,file)
+           (visited-p (or (null ,tempvar)
+                          (get-file-buffer (expand-file-name ,tempvar))))
+           (point (point)) to-be-removed)
+       (save-window-excursion
+        (when ,tempvar (find-file ,tempvar))
+        (setq to-be-removed (current-buffer))
+        (goto-char (point-min))
+        (while (re-search-forward org-babel-lob-one-liner-regexp nil t)
+          (goto-char (match-beginning 1))
+          (save-match-data ,@body)
+          (goto-char (match-end 0))))
+       (unless visited-p (kill-buffer to-be-removed))
+       (goto-char point))))
+(def-edebug-spec org-babel-map-call-lines (form body))
 
 ;;;###autoload
 (defun org-babel-execute-buffer (&optional arg)
@@ -755,7 +895,9 @@ the current buffer."
     (org-babel-map-src-blocks nil
       (org-babel-execute-src-block arg))
     (org-babel-map-inline-src-blocks nil
-      (org-babel-execute-src-block arg))))
+      (org-babel-execute-src-block arg))
+    (org-babel-map-call-lines nil
+      (org-babel-lob-execute-maybe))))
 
 ;;;###autoload
 (defun org-babel-execute-subtree (&optional arg)
@@ -784,7 +926,7 @@ the current subtree."
                 lst)
             (norm (arg)
                   (let ((v (if (and (listp (cdr arg)) (null (cddr arg)))
-                               (copy-seq (cdr arg))
+                               (copy-sequence (cdr arg))
                              (cdr arg))))
                     (when (and v (not (and (sequencep v)
                                            (not (consp v))
@@ -857,86 +999,6 @@ This can be called with C-c C-c."
     (when hash (kill-new hash) (message hash))))
 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-hash-at-point)
 
-(defun org-babel-result-hide-spec ()
-  "Hide portions of results lines.
-Add `org-babel-hide-result' as an invisibility spec for hiding
-portions of results lines."
-  (add-to-invisibility-spec '(org-babel-hide-result . t)))
-(add-hook 'org-mode-hook 'org-babel-result-hide-spec)
-
-(defvar org-babel-hide-result-overlays nil
-  "Overlays hiding results.")
-
-(defun org-babel-result-hide-all ()
-  "Fold all results in the current buffer."
-  (interactive)
-  (org-babel-show-result-all)
-  (save-excursion
-    (while (re-search-forward org-babel-result-regexp nil t)
-      (save-excursion (goto-char (match-beginning 0))
-                      (org-babel-hide-result-toggle-maybe)))))
-
-(defun org-babel-show-result-all ()
-  "Unfold all results in the current buffer."
-  (mapc 'delete-overlay org-babel-hide-result-overlays)
-  (setq org-babel-hide-result-overlays nil))
-
-;;;###autoload
-(defun org-babel-hide-result-toggle-maybe ()
-  "Toggle visibility of result at point."
-  (interactive)
-  (let ((case-fold-search t))
-    (if (save-excursion
-          (beginning-of-line 1)
-          (looking-at org-babel-result-regexp))
-        (progn (org-babel-hide-result-toggle)
-               t) ;; to signal that we took action
-      nil))) ;; to signal that we did not
-
-(defun org-babel-hide-result-toggle (&optional force)
-  "Toggle the visibility of the current result."
-  (interactive)
-  (save-excursion
-    (beginning-of-line)
-    (if (re-search-forward org-babel-result-regexp nil t)
-        (let ((start (progn (beginning-of-line 2) (- (point) 1)))
-              (end (progn (goto-char (- (org-babel-result-end) 1)) (point)))
-              ov)
-          (if (memq t (mapcar (lambda (overlay)
-                                (eq (overlay-get overlay 'invisible)
-                                   'org-babel-hide-result))
-                              (overlays-at start)))
-              (if (or (not force) (eq force 'off))
-                  (mapc (lambda (ov)
-                          (when (member ov org-babel-hide-result-overlays)
-                            (setq org-babel-hide-result-overlays
-                                  (delq ov org-babel-hide-result-overlays)))
-                          (when (eq (overlay-get ov 'invisible)
-                                    'org-babel-hide-result)
-                            (delete-overlay ov)))
-                        (overlays-at start)))
-            (setq ov (make-overlay start end))
-            (overlay-put ov 'invisible 'org-babel-hide-result)
-            ;; make the block accessible to isearch
-            (overlay-put
-             ov 'isearch-open-invisible
-             (lambda (ov)
-               (when (member ov org-babel-hide-result-overlays)
-                 (setq org-babel-hide-result-overlays
-                       (delq ov org-babel-hide-result-overlays)))
-               (when (eq (overlay-get ov 'invisible)
-                         'org-babel-hide-result)
-                 (delete-overlay ov))))
-            (push ov org-babel-hide-result-overlays)))
-      (error "Not looking at a result line"))))
-
-;; org-tab-after-check-for-cycling-hook
-(add-hook 'org-tab-first-hook 'org-babel-hide-result-toggle-maybe)
-;; Remove overlays when changing major mode
-(add-hook 'org-mode-hook
-         (lambda () (org-add-hook 'change-major-mode-hook
-                                  'org-babel-show-result-all 'append 'local)))
-
 (defvar org-file-properties)
 (defun org-babel-params-from-properties (&optional lang)
   "Retrieve parameters specified as properties.
@@ -944,40 +1006,21 @@ Return an association list of any source block params which
 may be specified in the properties of the current outline entry."
   (save-match-data
     (let (val sym)
-      (delq nil
-           (mapcar
-            (lambda (header-arg)
-              (and (setq val
-                         (or (org-entry-get (point) header-arg t)
-                             (org-entry-get (point) (concat ":" header-arg) t)))
-                   (cons (intern (concat ":" header-arg))
-                         (org-babel-read val))))
+      (org-babel-parse-multiple-vars
+       (delq nil
             (mapcar
-             'symbol-name
-             (append
-              org-babel-header-arg-names
-              (progn
-                (setq sym (intern (concat "org-babel-header-arg-names:" lang)))
-                (and (boundp sym) (eval sym))))))))))
-
-(defun org-babel-params-from-buffer ()
-  "Retrieve per-buffer parameters.
- Return an association list of any source block params which
-may be specified in the current buffer."
-  (let (local-properties)
-    (save-match-data
-      (save-excursion
-       (save-restriction
-         (widen)
-         (goto-char (point-min))
-         (while (re-search-forward
-                 (org-make-options-regexp (list "BABEL" "PROPERTIES")) nil t)
-           (setq local-properties
-                 (org-babel-merge-params
-                  local-properties
-                  (org-babel-parse-header-arguments
-                   (org-match-string-no-properties 2)))))
-         local-properties)))))
+             (lambda (header-arg)
+               (and (setq val (org-entry-get (point) header-arg t))
+                    (cons (intern (concat ":" header-arg))
+                          (org-babel-read val))))
+             (mapcar
+              'symbol-name
+              (append
+               org-babel-header-arg-names
+               (progn
+                 (setq sym (intern (concat "org-babel-header-arg-names:"
+                                           lang)))
+                 (and (boundp sym) (eval sym)))))))))))
 
 (defvar org-src-preserve-indentation)
 (defun org-babel-parse-src-block-match ()
@@ -989,9 +1032,10 @@ may be specified in the current buffer."
          (body (org-babel-clean-text-properties
                (let* ((body (match-string 5))
                       (sub-length (- (length body) 1)))
-                 (if (string= "\n" (substring body sub-length))
+                 (if (and (> sub-length 0)
+                          (string= "\n" (substring body sub-length)))
                      (substring body 0 sub-length)
-                   body))))
+                   (or body "")))))
         (preserve-indentation (or org-src-preserve-indentation
                                   (string-match "-i\\>" switches))))
     (list lang
@@ -1003,7 +1047,6 @@ may be specified in the current buffer."
               (buffer-string)))
          (org-babel-merge-params
           org-babel-default-header-args
-          (org-babel-params-from-buffer)
            (org-babel-params-from-properties lang)
           (if (boundp lang-headers) (eval lang-headers) nil)
           (org-babel-parse-header-arguments
@@ -1020,50 +1063,105 @@ may be specified in the current buffer."
            (org-babel-clean-text-properties (match-string 5)))
           (org-babel-merge-params
            org-babel-default-inline-header-args
-          (org-babel-params-from-buffer)
            (org-babel-params-from-properties lang)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (org-babel-parse-header-arguments
             (org-babel-clean-text-properties (or (match-string 4) "")))))))
 
+(defun org-babel-balanced-split (string alts)
+  "Split STRING on instances of ALTS.
+ALTS is a cons of two character options where each option may be
+either the numeric code of a single character or a list of
+character alternatives.  For example to split on balanced
+instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
+  (flet ((matches (ch spec) (or (and (numberp spec) (= spec ch))
+                               (member ch spec)))
+        (matched (ch last)
+                 (if (consp alts)
+                     (and (matches ch (cdr alts))
+                          (matches last (car alts)))
+                   (matches ch alts))))
+    (let ((balance 0) (quote nil) (partial nil) (lst nil) (last 0))
+      (mapc (lambda (ch)  ; split on [], (), "" balanced instances of [ \t]:
+             (setq balance (+ balance
+                              (cond ((or (equal 91 ch) (equal 40 ch)) 1)
+                                    ((or (equal 93 ch) (equal 41 ch)) -1)
+                                    (t 0))))
+             (when (and (equal 34 ch) (not (equal 92 last)))
+               (setq quote (not quote)))
+             (setq partial (cons ch partial))
+             (when (and (= balance 0) (not quote) (matched ch last))
+               (setq lst (cons (apply #'string (nreverse
+                                                (if (consp alts)
+                                                    (cddr partial)
+                                                  (cdr partial))))
+                               lst))
+               (setq partial nil))
+             (setq last ch))
+           (string-to-list string))
+      (nreverse (cons (apply #'string (nreverse partial)) lst)))))
+
+(defun org-babel-join-splits-near-ch (ch list)
+  "Join splits where \"=\" is on either end of the split."
+  (flet ((last= (str) (= ch (aref str (1- (length str)))))
+         (first= (str) (= ch (aref str 0))))
+    (reverse
+     (org-reduce (lambda (acc el)
+               (let ((head (car acc)))
+                 (if (and head (or (last= head) (first= el)))
+                     (cons (concat head el) (cdr acc))
+                   (cons el acc))))
+             list :initial-value nil))))
+
 (defun org-babel-parse-header-arguments (arg-string)
   "Parse a string of header arguments returning an alist."
   (when (> (length arg-string) 0)
-    (delq nil
-         (mapcar
-          (lambda (arg)
-            (if (string-match
-                 "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)"
-                 arg)
-                (cons (intern (match-string 1 arg))
-                      (org-babel-read (org-babel-chomp (match-string 2 arg))))
-              (cons (intern (org-babel-chomp arg)) nil)))
-          (let ((balance 0) (partial nil) (lst nil) (last 0))
-            (mapc (lambda (ch)  ; split on [] balanced instances of [ \t]:
-                    (setq balance (+ balance
-                                     (cond ((equal 91 ch) 1)
-                                           ((equal 93 ch) -1)
-                                           (t 0))))
-                    (setq partial (cons ch partial))
-                    (when (and (= ch 58) (= balance 0)
-                               (or (= last 32) (= last 9)))
-                      (setq lst (cons (apply #'string (nreverse (cddr partial)))
-                                      lst))
-                      (setq partial (list ch)))
-                    (setq last ch))
-                  (string-to-list arg-string))
-            (nreverse (cons (apply #'string (nreverse partial)) lst)))))))
+    (org-babel-parse-multiple-vars
+     (delq nil
+          (mapcar
+           (lambda (arg)
+             (if (string-match
+                  "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)"
+                  arg)
+                 (cons (intern (match-string 1 arg))
+                       (org-babel-read (org-babel-chomp (match-string 2 arg))))
+               (cons (intern (org-babel-chomp arg)) nil)))
+           ((lambda (raw)
+              (cons (car raw) (mapcar (lambda (r) (concat ":" r)) (cdr raw))))
+            (org-babel-balanced-split arg-string '((32 9) . 58))))))))
+
+(defun org-babel-parse-multiple-vars (header-arguments)
+  "Expand multiple variable assignments behind a single :var keyword.
+
+This allows expression of multiple variables with one :var as
+shown below.
+
+#+PROPERTY: var foo=1, bar=2"
+  (let (results)
+    (mapc (lambda (pair)
+           (if (eq (car pair) :var)
+               (mapcar (lambda (v) (push (cons :var (org-babel-trim v)) results))
+                       (org-babel-join-splits-near-ch
+                        61 (org-babel-balanced-split (cdr pair) 32)))
+             (push pair results)))
+         header-arguments)
+    (nreverse results)))
 
 (defun org-babel-process-params (params)
   "Expand variables in PARAMS and add summary parameters."
-  (let* ((vars-and-names (org-babel-disassemble-tables
-                         (mapcar (lambda (el)
-                                   (if (consp (cdr el))
-                                       (cdr el) (org-babel-ref-parse (cdr el))))
-                                 (org-babel-get-header params :var))
-                         (cdr (assoc :hlines params))
-                         (cdr (assoc :colnames params))
-                         (cdr (assoc :rownames params))))
+  (let* ((processed-vars (mapcar (lambda (el)
+                                  (if (consp (cdr el))
+                                      (cdr el)
+                                    (org-babel-ref-parse (cdr el))))
+                                (org-babel-get-header params :var)))
+        (vars-and-names (if (and (assoc :colname-names params)
+                                 (assoc :rowname-names params))
+                            (list processed-vars)
+                          (org-babel-disassemble-tables
+                           processed-vars
+                           (cdr (assoc :hlines params))
+                           (cdr (assoc :colnames params))
+                           (cdr (assoc :rownames params)))))
         (raw-result (or (cdr (assoc :results params)) ""))
         (result-params (append
                         (split-string (if (stringp raw-result)
@@ -1170,7 +1268,7 @@ of the vars, cnames and rnames."
             (setq var (cons (car var) (org-babel-del-hlines (cdr var))))))
         var)
       vars)
-     cnames rnames)))
+     (reverse cnames) (reverse rnames))))
 
 (defun org-babel-reassemble-table (table colnames rownames)
   "Add column and row names to a table.
@@ -1245,7 +1343,7 @@ org-babel-named-src-block-regexp."
          (regexp (org-babel-named-src-block-regexp-for-name name)) msg)
       (goto-char (point-min))
       (when (or (re-search-forward regexp nil t)
-                (re-search-backward regexp nil t))
+               (re-search-backward regexp nil t))
         (match-beginning 0)))))
 
 (defun org-babel-src-block-names (&optional file)
@@ -1254,7 +1352,7 @@ org-babel-named-src-block-regexp."
     (when file (find-file file)) (goto-char (point-min))
     (let (names)
       (while (re-search-forward org-babel-src-name-w-name-regexp nil t)
-       (setq names (cons (match-string 4) names)))
+       (setq names (cons (match-string 3) names)))
       names)))
 
 ;;;###autoload
@@ -1270,16 +1368,21 @@ org-babel-named-src-block-regexp."
         (progn (goto-char point) (org-show-context))
       (message "result '%s' not found in this buffer" name))))
 
-(defun org-babel-find-named-result (name)
+(defun org-babel-find-named-result (name &optional point)
   "Find a named result.
 Return the location of the result named NAME in the current
 buffer or nil if no such result exists."
   (save-excursion
-    (goto-char (point-min))
-    (when (re-search-forward
-           (concat org-babel-result-regexp
-                   "[ \t]" (regexp-quote name) "[ \t\n\f\v\r]") nil t)
-      (beginning-of-line 0) (point))))
+    (goto-char (or point (point-min)))
+    (catch 'is-a-code-block
+      (when (re-search-forward
+            (concat org-babel-result-regexp
+                    "[ \t]" (regexp-quote name) "[ \t\n\f\v\r]") nil t)
+       (when (and (string= "name" (downcase (match-string 1)))
+                  (or (looking-at org-babel-src-block-regexp)
+                      (looking-at org-babel-multi-line-header-regexp)))
+         (throw 'is-a-code-block (org-babel-find-named-result name (point))))
+       (beginning-of-line 0) (point)))))
 
 (defun org-babel-result-names (&optional file)
   "Returns the names of results in FILE or the current buffer."
@@ -1334,6 +1437,8 @@ is created.  In both cases if the region is demarcated and if the
 region is not active then the point is demarcated."
   (interactive "P")
   (let ((info (org-babel-get-src-block-info 'light))
+       (headers (progn (org-babel-where-is-src-block-head)
+                       (match-string 4)))
        (stars (concat (make-string (or (org-current-level) 1) ?*) " ")))
     (if info
         (mapc
@@ -1346,11 +1451,16 @@ region is not active then the point is demarcated."
                                   (buffer-substring (point-at-bol)
                                                     (point-at-eol)))
                 (delete-region (point-at-bol) (point-at-eol)))
-               (insert (concat (if (looking-at "^") "" "\n")
-                               indent "#+end_src\n"
-                               (if arg stars indent) "\n"
-                               indent "#+begin_src " lang
-                               (if (looking-at "[\n\r]") "" "\n")))))
+               (insert (concat
+                       (if (looking-at "^") "" "\n")
+                       indent "#+end_src\n"
+                       (if arg stars indent) "\n"
+                       indent "#+begin_src " lang
+                       (if (> (length headers) 1)
+                           (concat " " headers) headers)
+                       (if (looking-at "[\n\r]")
+                           ""
+                         (concat "\n" (make-string (current-column) ? )))))))
           (move-end-of-line 2))
          (sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
       (let ((start (point))
@@ -1369,7 +1479,6 @@ region is not active then the point is demarcated."
        (goto-char start) (move-end-of-line 1)))))
 
 (defvar org-babel-lob-one-liner-regexp)
-(defvar org-babel-inline-lob-one-liner-regexp)
 (defun org-babel-where-is-src-block-result (&optional insert info hash indent)
   "Find where the current source block results begin.
 Return the point at the beginning of the result of the current
@@ -1380,13 +1489,11 @@ following the source block."
     (let* ((on-lob-line (save-excursion
                          (beginning-of-line 1)
                          (looking-at org-babel-lob-one-liner-regexp)))
-          (inlinep (save-excursion
-                     (re-search-backward "[ \f\t\n\r\v]" nil t)
-                     (when (looking-at org-babel-inline-src-block-regexp)
-                       (match-end 0))))
+          (inlinep (when (org-babel-get-inline-src-block-matches)
+                       (match-end 0)))
           (name (if on-lob-line
                     (nth 0 (org-babel-lob-get-info))
-                  (nth 4 (or info (org-babel-get-src-block-info)))))
+                  (nth 4 (or info (org-babel-get-src-block-info 'light)))))
           (head (unless on-lob-line (org-babel-where-is-src-block-head)))
           found beg end)
       (when head (goto-char head))
@@ -1538,6 +1645,10 @@ raw ----- results are added directly to the Org-mode file.  This
           is a good option if you code block will output org-mode
           formatted text.
 
+wrap ---- results are added directly to the Org-mode file as with
+          \"raw\", but are wrapped in a RESULTS drawer, allowing
+          them to later be replaced or removed automatically.
+
 org ----- similar in effect to raw, only the results are wrapped
           in an org code block.  Similar to the raw option, on
           export the results will be interpreted as org-formatted
@@ -1571,10 +1682,8 @@ code ---- the results are extracted in the syntax of the source
     (save-excursion
       (let* ((inlinep
              (save-excursion
-               (or (= (point) (point-at-bol))
-                   (re-search-backward "[ \f\t\n\r\v]" nil t))
-               (when (or (looking-at org-babel-inline-src-block-regexp)
-                         (looking-at org-babel-inline-lob-one-liner-regexp))
+               (when (or (org-babel-get-inline-src-block-matches)
+                         (org-babel-get-lob-one-liner-matches))
                  (goto-char (match-end 0))
                  (insert (if (listp result) "\n" " "))
                  (point))))
@@ -1606,41 +1715,45 @@ code ---- the results are extracted in the syntax of the source
           ((member "prepend" result-params)))) ; already there
        (setq results-switches
              (if results-switches (concat " " results-switches) ""))
-       ;; insert results based on type
-       (cond
-        ;; do nothing for an empty result
-        ((= (length result) 0))
-        ;; insert a list if preferred
-        ((member "list" result-params)
-         (insert
-          (org-babel-trim
-           (org-list-to-generic
-            (cons 'unordered
-                  (mapcar
-                   (lambda (el) (list nil (if (stringp el) el (format "%S" el))))
-                   (if (listp result) result (list result))))
-            '(:splicep nil :istart "- " :iend "\n")))
-          "\n"))
-        ;; assume the result is a table if it's not a string
-        ((not (stringp result))
-         (goto-char beg)
-         (insert (concat (orgtbl-to-orgtbl
-                          (if (or (eq 'hline (car result))
-                                  (and (listp (car result))
-                                       (listp (cdr (car result)))))
-                              result (list result))
-                          '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
-         (goto-char beg) (when (org-at-table-p) (org-table-align)))
-        ((member "file" result-params)
-         (insert result))
-        (t (goto-char beg) (insert result)))
-       (when (listp result) (goto-char (org-table-end)))
-       (setq end (point-marker))
-       ;; possibly wrap result
        (flet ((wrap (start finish)
                     (goto-char beg) (insert (concat start "\n"))
                     (goto-char end) (insert (concat finish "\n"))
-                    (setq end (point-marker))))
+                    (setq end (point-marker)))
+              (proper-list-p (it) (and (listp it) (null (cdr (last it))))))
+         ;; insert results based on type
+         (cond
+          ;; do nothing for an empty result
+          ((null result))
+          ;; insert a list if preferred
+          ((member "list" result-params)
+           (insert
+            (org-babel-trim
+             (org-list-to-generic
+              (cons 'unordered
+                    (mapcar
+                     (lambda (el) (list nil (if (stringp el) el (format "%S" el))))
+                     (if (listp result) result (list result))))
+              '(:splicep nil :istart "- " :iend "\n")))
+            "\n"))
+          ;; assume the result is a table if it's not a string
+          ((proper-list-p result)
+           (goto-char beg)
+           (insert (concat (orgtbl-to-orgtbl
+                            (if (or (eq 'hline (car result))
+                                    (and (listp (car result))
+                                         (listp (cdr (car result)))))
+                                result (list result))
+                            '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
+           (goto-char beg) (when (org-at-table-p) (org-table-align)))
+          ((and (listp result) (not (proper-list-p result)))
+           (insert (format "%s\n" result)))
+          ((member "file" result-params)
+           (when inlinep (goto-char inlinep))
+           (insert result))
+          (t (goto-char beg) (insert result)))
+         (when (proper-list-p result) (goto-char (org-table-end)))
+         (setq end (point-marker))
+         ;; possibly wrap result
          (cond
           ((member "html" result-params)
            (wrap "#+BEGIN_HTML" "#+END_HTML"))
@@ -1654,10 +1767,9 @@ code ---- the results are extracted in the syntax of the source
           ((member "raw" result-params)
            (goto-char beg) (if (org-at-table-p) (org-cycle)))
           ((member "wrap" result-params)
-           (when (and (stringp result) (not (member "file" result-params)))
-             (org-babel-examplize-region beg end results-switches))
-           (wrap "#+BEGIN_RESULT" "#+END_RESULT"))
-          ((and (stringp result) (not (member "file" result-params)))
+           (wrap ":RESULTS:" ":END:"))
+          ((and (not (proper-list-p result))
+                (not (member "file" result-params)))
            (org-babel-examplize-region beg end results-switches)
            (setq end (point)))))
        ;; possibly indent the results to match the #+results line
@@ -1666,7 +1778,7 @@ code ---- the results are extracted in the syntax of the source
                   (not (and (listp result)
                             (member "append" result-params))))
          (indent-rigidly beg end indent))))
-    (if (= (length result) 0)
+    (if (null result)
        (if (member "value" result-params)
            (message "Code block returned no value.")
          (message "Code block produced no output."))
@@ -1677,8 +1789,9 @@ code ---- the results are extracted in the syntax of the source
   (interactive)
   (let ((location (org-babel-where-is-src-block-result nil info)) start)
     (when location
+      (setq start (- location 1))
       (save-excursion
-        (goto-char location) (setq start (point)) (forward-line 1)
+        (goto-char location) (forward-line 1)
         (delete-region start (org-babel-result-end))))))
 
 (defun org-babel-result-end ()
@@ -1689,6 +1802,8 @@ code ---- the results are extracted in the syntax of the source
      ((org-at-item-p) (let* ((struct (org-list-struct))
                             (prvs (org-list-prevs-alist struct)))
                        (org-list-get-list-end (point-at-bol) struct prvs)))
+     ((looking-at "^\\([ \t]*\\):RESULTS:")
+      (re-search-forward (concat "^" (match-string 1) ":END:")))
      (t
       (let ((case-fold-search t)
            (blocks-re (regexp-opt
@@ -1757,12 +1872,11 @@ Later elements of PLISTS override the values of previous elements.
 This takes into account some special considerations for certain
 parameters when merging lists."
   (let ((results-exclusive-groups
-        '(("file" "list" "vector" "table" "scalar" "verbatim" "raw" "org"
-            "html" "latex" "code" "pp" "wrap")
-          ("replace" "silent" "append" "prepend")
-          ("output" "value")))
+        (mapcar (lambda (group) (mapcar #'symbol-name group))
+                (cdr (assoc 'results org-babel-common-header-args-w-values))))
        (exports-exclusive-groups
-        '(("code" "results" "both" "none")))
+        (mapcar (lambda (group) (mapcar #'symbol-name group))
+                (cdr (assoc 'exports org-babel-common-header-args-w-values))))
        (variable-index 0)
        params results exports tangle noweb cache vars shebang comments padline)
     (flet ((e-merge (exclusive-groups &rest result-params)
@@ -1806,12 +1920,16 @@ parameters when merging lists."
                                       vars))
                              vars)
                            (list (cons name pair))))
-                  ;; if no name is given, then assign to variables in order
-                  (prog1 (setf (cddr (nth variable-index vars))
-                               (concat (symbol-name
-                                        (car (nth variable-index vars)))
-                                       "=" (cdr pair)))
-                    (incf variable-index)))))
+                  ;; if no name is given and we already have named variables
+                  ;; then assign to named variables in order
+                  (if (and vars (nth variable-index vars))
+                      (prog1 (setf (cddr (nth variable-index vars))
+                                   (concat (symbol-name
+                                            (car (nth variable-index vars)))
+                                           "=" (cdr pair)))
+                        (incf variable-index))
+                    (error "variable \"%s\" must be assigned a default value"
+                           (cdr pair))))))
              (:results
               (setq results (e-merge results-exclusive-groups
                                      results
@@ -1861,6 +1979,12 @@ parameters when merging lists."
      '(results exports tangle noweb padline cache shebang comments))
     params))
 
+(defvar *org-babel-use-quick-and-dirty-noweb-expansion* nil
+  "Set to true to use regular expressions to expand noweb references.
+This results in much faster noweb reference expansion but does
+not properly allow code blocks to inherit the \":noweb-ref\"
+header argument from buffer or subtree wide properties.")
+
 (defun org-babel-expand-noweb-references (&optional info parent-buffer)
   "Expand Noweb references in the body of the current source code block.
 
@@ -1896,21 +2020,15 @@ block but are passed literally to the \"example-block\"."
          (lang (nth 0 info))
          (body (nth 1 info))
         (comment (string= "noweb" (cdr (assoc :comments (nth 2 info)))))
+        (rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|"
+                           ":noweb-ref[ \t]+" "\\)"))
          (new-body "") index source-name evaluate prefix blocks-in-buffer)
     (flet ((nb-add (text) (setq new-body (concat new-body text)))
           (c-wrap (text)
                   (with-temp-buffer
                     (funcall (intern (concat lang "-mode")))
                     (comment-region (point) (progn (insert text) (point)))
-                    (org-babel-trim (buffer-string))))
-          (blocks () ;; return the info lists of all blocks in this buffer
-                  (let (infos)
-                    (save-restriction
-                      (widen)
-                      (org-babel-map-src-blocks nil
-                        (setq infos (cons (org-babel-get-src-block-info 'light)
-                                          infos))))
-                    (reverse infos))))
+                    (org-babel-trim (buffer-string)))))
       (with-temp-buffer
         (insert body) (goto-char (point-min))
         (setq index (point))
@@ -1944,21 +2062,33 @@ block but are passed literally to the \"example-block\"."
                    (when (org-babel-ref-goto-headline-id source-name)
                      (org-babel-ref-headline-body)))
                  ;; find the expansion of reference in this buffer
-                 (mapconcat
-                  (lambda (i)
-                    (when (string= source-name
-                                   (or (cdr (assoc :noweb-ref (nth 2 i)))
-                                       (nth 4 i)))
-                      (let ((body (org-babel-expand-noweb-references i)))
-                        (if comment
-                            ((lambda (cs)
-                               (concat (c-wrap (car cs)) "\n"
-                                       body "\n" (c-wrap (cadr cs))))
-                             (org-babel-tangle-comment-links i))
-                          body))))
-                  (or blocks-in-buffer
-                      (setq blocks-in-buffer (blocks)))
-                  "")
+                 (let ((rx (concat rx-prefix source-name))
+                       expansion)
+                   (save-excursion
+                     (goto-char (point-min))
+                     (if *org-babel-use-quick-and-dirty-noweb-expansion*
+                         (while (re-search-forward rx nil t)
+                           (let* ((i (org-babel-get-src-block-info 'light))
+                                  (body (org-babel-expand-noweb-references i)))
+                             (if comment
+                                 ((lambda (cs)
+                                    (concat (c-wrap (car cs)) "\n"
+                                            body "\n" (c-wrap (cadr cs))))
+                                  (org-babel-tangle-comment-links i))
+                               (setq expansion (concat expansion body)))))
+                       (org-babel-map-src-blocks nil
+                         (let ((i (org-babel-get-src-block-info 'light)))
+                           (when (equal (or (cdr (assoc :noweb-ref (nth 2 i)))
+                                            (nth 4 i))
+                                        source-name)
+                             (let ((body (org-babel-expand-noweb-references i)))
+                               (if comment
+                                   ((lambda (cs)
+                                      (concat (c-wrap (car cs)) "\n"
+                                              body "\n" (c-wrap (cadr cs))))
+                                    (org-babel-tangle-comment-links i))
+                                 (setq expansion (concat expansion body)))))))))
+                   expansion)
                  ;; possibly raise an error if named block doesn't exist
                  (if (member lang org-babel-noweb-error-langs)
                      (error "%s" (concat
index a54f3c4c3d32a7986f162f57905dab136a820f39..f3024b171a63d2fd71e1a77ca8fd6bb557bd325e 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-agenda.el --- Dynamic task and appointment lists for Org
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 ;;; Commentary:
 
 ;; This file contains the code for creating and using the Agenda for Org-mode.
+;;
+;; The functions `org-batch-agenda', `org-batch-agenda-csv', and
+;; `org-batch-store-agenda-views' are implemented as macros to provide
+;; a conveniant way for extracting agenda information from the command
+;; line. The Lisp does not evaluate parameters of a macro call; thus
+;; it is not necessary to quote the parameters passed to one of those
+;; functions. E.g. you can write:
+;;
+;;   emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a" org-agenda-span 7)'
+;;
+;; To export an agenda spanning 7 days. If `org-batch-agenda' would
+;; have been implemented as a regular function you'd have to quote the
+;; symbol org-agenda-span. Moreover: To use a symbol as parameter
+;; value you would have to double quote the symbol.
+;;
+;; This is a hack, but it works even when running Org byte-compiled.
+;;
 
 ;;; Code:
 
@@ -50,6 +66,8 @@
 (declare-function calendar-julian-date-string   "cal-julian" (&optional date))
 (declare-function calendar-mayan-date-string    "cal-mayan"  (&optional date))
 (declare-function calendar-persian-date-string  "cal-persia" (&optional date))
+(declare-function calendar-check-holidays       "holidays" (date))
+
 (declare-function org-datetree-find-date-create "org-datetree"
                  (date &optional keep-restriction))
 (declare-function org-columns-quit              "org-colview" ())
@@ -60,6 +78,8 @@
 (declare-function org-is-habit-p "org-habit" (&optional pom))
 (declare-function org-habit-parse-todo "org-habit" (&optional pom))
 (declare-function org-habit-get-priority "org-habit" (habit &optional moment))
+(declare-function org-pop-to-buffer-same-window "org-compat"
+                 (&optional buffer-or-name norecord label))
 
 (defvar calendar-mode-map)
 (defvar org-clock-current-task) ; defined in org-clock.el
@@ -156,7 +176,7 @@ and `org-agenda-entry-text-maxlines'."
   "Non-nil means export org-links as descriptive links in agenda added text.
 This variable applies to the text added to the agenda when
 `org-agenda-add-entry-text-maxlines' is larger than 0.
-When this variable is nil, the URL will (also) be shown."
+When this variable nil, the URL will (also) be shown."
   :group 'org-agenda
   :type 'boolean)
 
@@ -225,6 +245,10 @@ you can \"misuse\" it to also add other text to the header.  However,
     (const user-defined-up) (const user-defined-down))
   "Sorting choices.")
 
+;; Keep custom values for `org-agenda-filter-preset' compatible with
+;; the new variable `org-agenda-tag-filter-preset'.
+(defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
+
 (defconst org-agenda-custom-commands-local-options
   `(repeat :tag "Local settings for this command. Remember to quote values"
           (choice :tag "Setting"
@@ -266,8 +290,14 @@ you can \"misuse\" it to also add other text to the header.  However,
            (list :tag "Deadline Warning days"
                  (const org-deadline-warning-days)
                  (integer :value 1))
+           (list :tag "Category filter preset"
+                 (const org-agenda-category-filter-preset)
+                 (list
+                  (const :format "" quote)
+                  (repeat
+                   (string :tag "+category or -category"))))
            (list :tag "Tags filter preset"
-                 (const org-agenda-filter-preset)
+                 (const org-agenda-tag-filter-preset)
                  (list
                   (const :format "" quote)
                   (repeat
@@ -330,7 +360,8 @@ This will be spliced into the custom type of
 `org-agenda-custom-commands'.")
 
 
-(defcustom org-agenda-custom-commands nil
+(defcustom org-agenda-custom-commands '(("n" "Agenda and all TODO's"
+                                        ((agenda "") (alltodo))))
   "Custom commands for the agenda.
 These commands will be offered on the splash screen displayed by the
 agenda dispatcher \\[org-agenda].  Each entry is a list like this:
@@ -339,7 +370,7 @@ agenda dispatcher \\[org-agenda].  Each entry is a list like this:
 
 key      The key (one or more characters as a string) to be associated
          with the command.
-desc     A description of the command; when omitted or nil, a default
+desc     A description of the command, when omitted or nil, a default
          description is built using MATCH.
 type     The command type, any of the following symbols:
           agenda      The daily/weekly agenda.
@@ -354,7 +385,7 @@ type     The command type, any of the following symbols:
 match    What to search for:
           - a single keyword for TODO keyword searches
           - a tags match expression for tags searches
-          - a word search expression for text searches
+          - a word search expression for text searches.
           - a regular expression for occur searches
           For all other commands, this should be the empty string.
 settings  A list of option settings, similar to that in a let form, so like
@@ -363,7 +394,7 @@ settings  A list of option settings, similar to that in a let form, so like
 files     A list of files file to write the produced agenda buffer to
           with the command `org-store-agenda-views'.
           If a file name ends in \".html\", an HTML version of the buffer
-          is written out.  If it ends in \".ps\", a PostScript version is
+          is written out.  If it ends in \".ps\", a postscript version is
           produced.  Otherwise, only the plain text is written to the file.
 
 You can also define a set of commands, to create a composite agenda buffer.
@@ -764,11 +795,11 @@ because you will take care of it on the day when scheduled."
   :group 'org-agenda-skip
   :group 'org-agenda-daily/weekly
   :type '(choice
-         (const :tag "Always show prewarning" nil)
+         (const :tag "Alwas show prewarning" nil)
          (const :tag "Remove prewarning if entry is scheduled" t)
          (integer :tag "Restart prewarning N days before deadline")))
 
-(defcustom org-agenda-skip-additional-timestamps-same-entry t
+(defcustom org-agenda-skip-additional-timestamps-same-entry nil
   "When nil, multiple same-day timestamps in entry make multiple agenda lines.
 When non-nil, after the search for timestamps has matched once in an
 entry, the rest of the entry will not be searched."
@@ -853,6 +884,12 @@ Needs to be set before org.el is loaded."
   :group 'org-agenda-startup
   :type 'boolean)
 
+(defcustom org-agenda-follow-indirect nil
+  "Non-nil means `org-agenda-follow-mode' displays only the
+current item's tree, in an indirect buffer."
+  :group 'org-agenda
+  :type 'boolean)
+
 (defcustom org-agenda-show-outline-path t
   "Non-nil means show outline path in echo area after line motion."
   :group 'org-agenda-startup
@@ -1048,6 +1085,15 @@ and timeline buffers."
              (const :tag "Saturday" 6)
              (const :tag "Sunday" 0)))
 
+(defcustom org-agenda-move-date-from-past-immediately-to-today t
+  "Non-nil means jumpt to today when moving a past date forward in time.
+When using S-right in the agenda to move a a date forward, and the date
+stamp currently points to the past, the first key press will move it
+to today.  WHen nil, just move one day forward even if the date stays
+in the past."
+  :group 'org-agenda-daily/weekly
+  :type 'boolean)
+
 (defcustom org-agenda-include-diary nil
   "If non-nil, include in the agenda entries from the Emacs Calendar's diary.
 Custom commands can set this variable in the options section."
@@ -1060,14 +1106,6 @@ Custom commands can set this variable in the options section."
   :group 'org-agenda-daily/weekly
   :type 'boolean)
 
-(defcustom org-agenda-include-all-todo nil
-  "Set  means weekly/daily agenda will always contain all TODO entries.
-The TODO entries will be listed at the top of the agenda, before
-the entries for specific days.
-This option is deprecated, it is better to define a block agenda instead."
-  :group 'org-agenda-daily/weekly
-  :type 'boolean)
-
 (defcustom org-agenda-repeating-timestamp-show-all t
   "Non-nil means show all occurrences of a repeating stamp in the agenda.
 When set to a list of strings, only show occurrences of repeating
@@ -1396,6 +1434,7 @@ This format works similar to a printf format, with the following meaning:
 
   %c   the category of the item, \"Diary\" for entries from the diary,
        or as given by the CATEGORY keyword or derived from the file name
+  %e   the effort required by the item
   %i   the icon category of the item, see `org-agenda-category-icon-alist'
   %T   the last tag of the item (ignore inherited tags, which come first)
   %t   the HH:MM time-of-day specification if one applies to the entry
@@ -1619,7 +1658,7 @@ Where CATEGORY-REGEXP is a regexp matching the categories where
 the icon should be displayed.
 FILE-OR-DATA either a file path or a string containing image data.
 
-The other fields can be omitted safely if not needed:
+The other fields can be omited safely if not needed:
 TYPE indicates the image type.
 DATA-P is a boolean indicating whether the FILE-OR-DATA string is
 image data.
@@ -1711,12 +1750,14 @@ Note that functions in this alist don't need to be quoted."
 If STRING is non-nil, the text property will be fetched from position 0
 in that string.  If STRING is nil, it will be fetched from the beginning
 of the current line."
-  `(let ((marker (get-text-property (if string 0 (point-at-bol))
-                                   'org-hd-marker string)))
-     (with-current-buffer (marker-buffer marker)
-       (save-excursion
-        (goto-char marker)
-        ,@body))))
+  (org-with-gensyms (marker)
+    `(let ((,marker (get-text-property (if string 0 (point-at-bol))
+                                      'org-hd-marker ,string)))
+       (with-current-buffer (marker-buffer ,marker)
+        (save-excursion
+          (goto-char ,marker)
+          ,@body)))))
+(def-edebug-spec org-agenda-with-point-at-orig-entry (form body))
 
 (defun org-add-agenda-custom-command (entry)
   "Replace or add a command in `org-agenda-custom-commands'.
@@ -1870,7 +1911,7 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
-(org-defkey org-agenda-mode-map "\C-x\C-w" 'org-write-agenda)
+(org-defkey org-agenda-mode-map "\C-x\C-w" 'org-agenda-write)
 (org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
 (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
 (org-defkey org-agenda-mode-map "P" 'org-agenda-show-priority)
@@ -1918,6 +1959,7 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
 (org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
 (org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
+(org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
 (org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
 (define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg"    'org-mobile-pull)
@@ -1984,7 +2026,7 @@ The following commands are available:
       :keys "v A"]
      "--"
      ["Remove Restriction" org-agenda-remove-restriction-lock org-agenda-restrict])
-    ["Write view to file" org-write-agenda t]
+    ["Write view to file" org-agenda-write t]
     ["Rebuild buffer" org-agenda-redo t]
     ["Save all Org-mode Buffers" org-save-all-org-buffers t]
     "--"
@@ -2295,7 +2337,7 @@ Pressing `<' twice means to restrict to the current subtree or region
                               nil 'face 'org-warning)))))))
         t t))
        ((equal keys "L")
-       (unless (org-mode-p)
+       (unless (eq major-mode 'org-mode)
          (error "This is not an Org-mode file"))
        (unless restriction
          (put 'org-agenda-files 'org-restrict (list bfn))
@@ -2330,7 +2372,7 @@ Agenda views are separated by `org-agenda-block-separator'."
   "The user interface for selecting an agenda command."
   (catch 'exit
     (let* ((bfn (buffer-file-name (buffer-base-buffer)))
-          (restrict-ok (and bfn (org-mode-p)))
+          (restrict-ok (and bfn (eq major-mode 'org-mode)))
           (region-p (org-region-active-p))
           (custom org-agenda-custom-commands)
           (selstring "")
@@ -2572,23 +2614,13 @@ If CMD-KEY is a string of length 1, it is used as a key in
 longer string it is used as a tags/todo match string.
 Parameters are alternating variable names and values that will be bound
 before running the agenda command."
-  (let (pars)
-    (while parameters
-      (push (list (pop parameters) (if parameters (pop parameters))) pars))
+  (org-eval-in-environment (org-make-parameter-alist parameters)
     (if (> (length cmd-key) 2)
-       (eval (list 'let (nreverse pars)
-                   (list 'org-tags-view nil cmd-key)))
-      (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key))))
-    (set-buffer org-agenda-buffer-name)
-    (princ (org-encode-for-stdout (buffer-string)))))
-
-;(defun org-encode-for-stdout (string)
-;  (if (fboundp 'encode-coding-string)
-;      (encode-coding-string string buffer-file-coding-system)
-;    string))
-
-(defun org-encode-for-stdout (string)
-  string)
+       (org-tags-view nil cmd-key)
+      (org-agenda nil cmd-key)))
+  (set-buffer org-agenda-buffer-name)
+  (princ (buffer-string)))
+(def-edebug-spec org-batch-agenda (form &rest sexp))
 
 (defvar org-agenda-info nil)
 
@@ -2627,30 +2659,26 @@ extra        Sting with extra planning info
 priority-l   The priority letter if any was given
 priority-n   The computed numerical priority
 agenda-day   The day in the agenda where this is listed"
-
-  (let (pars)
-    (while parameters
-      (push (list (pop parameters) (if parameters (pop parameters))) pars))
-    (push (list 'org-agenda-remove-tags t) pars)
+  (org-eval-in-environment (append '((org-agenda-remove-tags t))
+                                  (org-make-parameter-alist parameters))
     (if (> (length cmd-key) 2)
-       (eval (list 'let (nreverse pars)
-                   (list 'org-tags-view nil cmd-key)))
-      (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key))))
-    (set-buffer org-agenda-buffer-name)
-    (let* ((lines (org-split-string (buffer-string) "\n"))
-          line)
-      (while (setq line (pop lines))
-       (catch 'next
-         (if (not (get-text-property 0 'org-category line)) (throw 'next nil))
-         (setq org-agenda-info
-               (org-fix-agenda-info (text-properties-at 0 line)))
-         (princ
-          (org-encode-for-stdout
-           (mapconcat 'org-agenda-export-csv-mapper
-                      '(org-category txt type todo tags date time extra
-                                     priority-letter priority agenda-day)
-                     ",")))
-         (princ "\n"))))))
+       (org-tags-view nil cmd-key)
+      (org-agenda nil cmd-key)))
+  (set-buffer org-agenda-buffer-name)
+  (let* ((lines (org-split-string (buffer-string) "\n"))
+        line)
+    (while (setq line (pop lines))
+      (catch 'next
+       (if (not (get-text-property 0 'org-category line)) (throw 'next nil))
+       (setq org-agenda-info
+             (org-fix-agenda-info (text-properties-at 0 line)))
+       (princ
+        (mapconcat 'org-agenda-export-csv-mapper
+                   '(org-category txt type todo tags date time extra
+                                  priority-letter priority agenda-day)
+                   ","))
+       (princ "\n")))))
+(def-edebug-spec org-batch-agenda-csv (form &rest sexp))
 
 (defun org-fix-agenda-info (props)
   "Make sure all properties on an agenda item have a canonical form.
@@ -2700,17 +2728,14 @@ This ensures the export commands can easily use it."
   (interactive)
   (eval (list 'org-batch-store-agenda-views)))
 
-;; FIXME, why is this a macro?????
 ;;;###autoload
 (defmacro org-batch-store-agenda-views (&rest parameters)
   "Run all custom agenda commands that have a file argument."
   (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
        (pop-up-frames nil)
        (dir default-directory)
-       pars cmd thiscmdkey files opts cmd-or-set)
-    (while parameters
-      (push (list (pop parameters) (if parameters (pop parameters))) pars))
-    (setq pars (reverse pars))
+       (pars (org-make-parameter-alist parameters))
+       cmd thiscmdkey files opts cmd-or-set)
     (save-window-excursion
       (while cmds
        (setq cmd (pop cmds)
@@ -2720,15 +2745,17 @@ This ensures the export commands can easily use it."
              files (nth (if (listp cmd-or-set) 4 5) cmd))
        (if (stringp files) (setq files (list files)))
        (when files
-         (eval (list 'let (append org-agenda-exporter-settings opts pars)
-                     (list 'org-agenda nil thiscmdkey)))
+         (org-eval-in-environment (append org-agenda-exporter-settings
+                                          opts pars)
+           (org-agenda nil thiscmdkey))
          (set-buffer org-agenda-buffer-name)
          (while files
-           (eval (list 'let (append org-agenda-exporter-settings opts pars)
-                       (list 'org-write-agenda
-                             (expand-file-name (pop files) dir) nil t))))
+           (org-eval-in-environment (append org-agenda-exporter-settings
+                                            opts pars)
+             (org-agenda-write (expand-file-name (pop files) dir) nil t)))
          (and (get-buffer org-agenda-buffer-name)
               (kill-buffer org-agenda-buffer-name)))))))
+(def-edebug-spec org-batch-store-agenda-views (&rest sexp))
 
 (defun org-agenda-mark-header-line (pos)
   "Mark the line at POS as an agenda structure header."
@@ -2741,11 +2768,12 @@ This ensures the export commands can easily use it."
                         'org-agenda-title-append org-agenda-title-append))))
 
 (defvar org-mobile-creating-agendas)
-(defun org-write-agenda (file &optional open nosettings)
+(defvar org-agenda-write-buffer-name "Agenda View")
+(defun org-agenda-write (file &optional open nosettings)
   "Write the current buffer (an agenda view) as a file.
 Depending on the extension of the file name, plain text (.txt),
-HTML (.html or .htm) or PostScript (.ps) is produced.
-If the extension is .ics, run iCalendar export over all files used
+HTML (.html or .htm) or Postscript (.ps) is produced.
+If the extension is .ics, run icalendar export over all files used
 to construct the agenda and limit the export to entries listed in the
 agenda now.
 With prefix argument OPEN, open the new file immediately.
@@ -2763,7 +2791,7 @@ higher priority settings."
         (let ((bs (copy-sequence (buffer-string))) beg)
           (org-agenda-unmark-filtered-text)
           (with-temp-buffer
-            (rename-buffer "Agenda View" t)
+            (rename-buffer org-agenda-write-buffer-name t)
             (set-buffer-modified-p nil)
             (insert bs)
             (org-agenda-remove-marked-text 'org-filtered)
@@ -2793,7 +2821,7 @@ higher priority settings."
              ((string-match "\\.ps\\'" file)
               (require 'ps-print)
               (ps-print-buffer-with-faces file)
-              (message "PostScript written to %s" file))
+              (message "Postscript written to %s" file))
              ((string-match "\\.pdf\\'" file)
               (require 'ps-print)
               (ps-print-buffer-with-faces
@@ -2824,7 +2852,8 @@ higher priority settings."
     (set-buffer org-agenda-buffer-name))
   (when open (org-open-file file)))
 
-(defvar org-agenda-filter-overlays nil)
+(defvar org-agenda-tag-filter-overlays nil)
+(defvar org-agenda-cat-filter-overlays nil)
 
 (defun org-agenda-mark-filtered-text ()
   "Mark all text hidden by filtering with a text property."
@@ -2835,7 +2864,8 @@ higher priority settings."
         (put-text-property
          (overlay-start o) (overlay-end o)
          'org-filtered t)))
-     org-agenda-filter-overlays)))
+     (append org-agenda-tag-filter-overlays
+            org-agenda-cat-filter-overlays))))
 
 (defun org-agenda-unmark-filtered-text ()
   "Remove the filtering text property."
@@ -2882,7 +2912,7 @@ removed from the entry content.  Currently only `planning' is allowed here."
   (let (txt drawer-re kwd-time-re ind)
     (save-excursion
       (with-current-buffer (marker-buffer marker)
-       (if (not (org-mode-p))
+       (if (not (eq major-mode 'org-mode))
            (setq txt "")
          (save-excursion
            (save-restriction
@@ -2972,7 +3002,7 @@ removed from the entry content.  Currently only `planning' is allowed here."
     (nreverse markers)))
 
 (defun org-create-marker-find-array (marker-list)
-  "Create an alist of files names with all marker positions in that file."
+  "Create a alist of files names with all marker positions in that file."
   (let (f tbl m a p)
     (while (setq m (pop marker-list))
       (setq p (marker-position m)
@@ -2997,8 +3027,8 @@ removed from the entry content.  Currently only `planning' is allowed here."
             (member (point) (cdr a)))))))
 
 (defun org-check-for-org-mode ()
-  "Make sure current buffer is in Org-mode.  Error if not."
-  (or (org-mode-p)
+  "Make sure current buffer is in org-mode.  Error if not."
+  (or (eq major-mode 'org-mode)
       (error "Cannot execute org-mode agenda command on buffer in %s"
             major-mode)))
 
@@ -3018,9 +3048,10 @@ removed from the entry content.  Currently only `planning' is allowed here."
 (defvar org-pre-agenda-window-conf nil)
 (defvar org-agenda-columns-active nil)
 (defvar org-agenda-name nil)
-(defvar org-agenda-filter nil)
-(defvar org-agenda-filter-while-redo nil)
-(defvar org-agenda-filter-preset nil
+(defvar org-agenda-tag-filter nil)
+(defvar org-agenda-category-filter nil)
+(defvar org-agenda-tag-filter-while-redo nil)
+(defvar org-agenda-tag-filter-preset nil
   "A preset of the tags filter used for secondary agenda filtering.
 This must be a list of strings, each string must be a single tag preceded
 by \"+\" or \"-\".
@@ -3030,13 +3061,25 @@ the entire agenda view.  In a block agenda, it will not work reliably to
 define a filter for one of the individual blocks.  You need to set it in
 the global options and expect it to be applied to the entire view.")
 
+(defvar org-agenda-category-filter-preset nil
+  "A preset of the categeory filter used for secondary agenda filtering.
+This must be a list of strings, each string must be a single category
+preceded by \"+\" or \"-\".
+This variable should not be set directly, but agenda custom commands can
+bind it in the options section.  The preset filter is a global property of
+the entire agenda view.  In a block agenda, it will not work reliably to
+define a filter for one of the individual blocks.  You need to set it in
+the global options and expect it to be applied to the entire view.")
+
 (defun org-prepare-agenda (&optional name)
   (setq org-todo-keywords-for-agenda nil)
   (setq org-done-keywords-for-agenda nil)
   (setq org-drawers-for-agenda nil)
   (unless org-agenda-persistent-filter
-    (setq org-agenda-filter nil))
-  (put 'org-agenda-filter :preset-filter org-agenda-filter-preset)
+    (setq org-agenda-tag-filter nil
+          org-agenda-category-filter nil))
+  (put 'org-agenda-tag-filter :preset-filter org-agenda-tag-filter-preset)
+  (put 'org-agenda-category-filter :preset-filter org-agenda-category-filter-preset)
   (if org-agenda-multi
       (progn
        (setq buffer-read-only nil)
@@ -3065,7 +3108,7 @@ the global options and expect it to be applied to the entire view.")
        (awin (select-window awin))
        ((not (setq org-pre-agenda-window-conf (current-window-configuration))))
        ((equal org-agenda-window-setup 'current-window)
-       (switch-to-buffer abuf))
+       (org-pop-to-buffer-same-window abuf))
        ((equal org-agenda-window-setup 'other-window)
        (org-switch-to-buffer-other-window abuf))
        ((equal org-agenda-window-setup 'other-frame)
@@ -3076,7 +3119,7 @@ the global options and expect it to be applied to the entire view.")
       ;; additional test in case agenda is invoked from within agenda
       ;; buffer via elisp link
       (unless (equal (current-buffer) abuf)
-       (switch-to-buffer abuf)))
+       (org-pop-to-buffer-same-window abuf)))
     (setq buffer-read-only nil)
     (let ((inhibit-read-only t)) (erase-buffer))
     (org-agenda-mode)
@@ -3115,8 +3158,10 @@ the global options and expect it to be applied to the entire view.")
          (org-habit-insert-consistency-graphs))
       (run-hooks 'org-finalize-agenda-hook)
       (setq org-agenda-type (org-get-at-bol 'org-agenda-type))
-      (when (or org-agenda-filter (get 'org-agenda-filter :preset-filter))
-       (org-agenda-filter-apply org-agenda-filter))
+      (when (or org-agenda-tag-filter (get 'org-agenda-tag-filter :preset-filter))
+       (org-agenda-filter-apply org-agenda-tag-filter 'tag))
+      (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
+       (org-agenda-filter-apply org-agenda-category-filter 'category))
       )))
 
 (defun org-agenda-mark-clocking-task ()
@@ -3190,17 +3235,9 @@ the global options and expect it to be applied to the entire view.")
        (setq org-blocked-by-checkboxes nil invis1 invis)
        (let ((marker (org-get-at-bol 'org-hd-marker)))
          (when (and marker
-                    (not (with-current-buffer (marker-buffer marker)
-                           (save-excursion
-                             (goto-char marker)
-                             (if (org-entry-get nil "NOBLOCKING")
-                                 t ;; Never block this entry
-                               (run-hook-with-args-until-failure
-                                'org-blocker-hook
-                                (list :type 'todo-state-change
-                                      :position marker
-                                      :from 'todo
-                                      :to 'done)))))))
+                    (with-current-buffer (marker-buffer marker)
+                      (save-excursion (goto-char marker)
+                                      (org-entry-blocked-p))))
            (if org-blocked-by-checkboxes (setq invis1 nil))
            (setq b (if invis1
                        (max (point-min) (1- (point-at-bol)))
@@ -3334,7 +3371,7 @@ no longer in use."
 
 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
 
-(defun org-timeline (&optional include-all)
+(defun org-timeline (&optional dotodo)
   "Show a time-sorted view of the entries in the current org file.
 Only entries with a time stamp of today or later will be listed.  With
 \\[universal-argument] prefix, all unfinished TODO items will also be shown,
@@ -3345,7 +3382,6 @@ dates."
   (org-compile-prefix-format 'timeline)
   (org-set-sorting-strategy 'timeline)
   (let* ((dopast t)
-        (dotodo include-all)
         (doclosed org-agenda-show-log)
         (entry (buffer-file-name (or (buffer-base-buffer (current-buffer))
                                      (current-buffer))))
@@ -3364,7 +3400,7 @@ dates."
     (setq org-agenda-redo-command
          (list 'progn
                (list 'org-switch-to-buffer-other-window (current-buffer))
-               (list 'org-timeline (list 'quote include-all))))
+               (list 'org-timeline (list 'quote dotodo))))
     (if (not dopast)
        ;; Remove past dates from the list of dates.
        (setq day-numbers (delq nil (mapcar (lambda(x)
@@ -3432,22 +3468,26 @@ When EMPTY is non-nil, also include days without any entries."
   (let ((re (concat
             (if pre-re pre-re "")
             (if inactive org-ts-regexp-both org-ts-regexp)))
-        dates dates1 date day day1 day2 ts1 ts2)
+        dates dates1 date day day1 day2 ts1 ts2 pos)
     (if force-today
        (setq dates (list (org-today))))
     (save-excursion
       (goto-char beg)
       (while (re-search-forward re end t)
        (setq day (time-to-days (org-time-string-to-time
-                                (substring (match-string 1) 0 10))))
+                                (substring (match-string 1) 0 10)
+                                (current-buffer) (match-beginning 0))))
        (or (memq day dates) (push day dates)))
       (unless no-ranges
        (goto-char beg)
        (while (re-search-forward org-tr-regexp end t)
+         (setq pos (match-beginning 0))
          (setq ts1 (substring (match-string 1) 0 10)
                ts2 (substring (match-string 2) 0 10)
-               day1 (time-to-days (org-time-string-to-time ts1))
-               day2 (time-to-days (org-time-string-to-time ts2)))
+               day1 (time-to-days (org-time-string-to-time
+                                   ts1 (current-buffer) pos))
+               day2 (time-to-days (org-time-string-to-time
+                                   ts2  (current-buffer) pos)))
          (while (< (setq day1 (1+ day1)) day2)
            (or (memq day1 dates) (push day1 dates)))))
       (setq dates (sort dates '<))
@@ -3472,7 +3512,7 @@ Custom commands can set this variable in the options section.")
 (defvar org-starting-day nil) ; local variable in the agenda buffer
 (defvar org-agenda-current-span nil
   "The current span used in the agenda view.") ; local variable in the agenda buffer
-(defvar org-include-all-loc nil) ; local variable
+(defvar org-arg-loc nil) ; local variable
 
 (defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
   "List of types searched for when creating the daily/weekly agenda.
@@ -3508,29 +3548,29 @@ somewhat less efficient) way of determining what is included in
 the daily/weekly agenda, see `org-agenda-skip-function'.")
 
 ;;;###autoload
-(defun org-agenda-list (&optional include-all start-day span)
+(defun org-agenda-list (&optional arg start-day span)
   "Produce a daily/weekly view from all files in variable `org-agenda-files'.
 The view will be for the current day or week, but from the overview buffer
 you will be able to go to other days/weeks.
 
 With a numeric prefix argument in an interactive call, the agenda will
-span INCLUDE-ALL days.  Lisp programs should instead specify SPAN to change
+span ARG days.  Lisp programs should instead specify SPAN to change
 the number of days.  SPAN defaults to `org-agenda-span'.
 
 START-DAY defaults to TODAY, or to the most recent match for the weekday
 given in `org-agenda-start-on-weekday'."
   (interactive "P")
-  (if (and (integerp include-all) (> include-all 0))
-      (setq span include-all include-all nil))
+  (if (and (integerp arg) (> arg 0))
+      (setq span arg arg nil))
   (setq start-day (or start-day org-agenda-start-day))
   (if org-agenda-overriding-arguments
-      (setq include-all (car org-agenda-overriding-arguments)
+      (setq arg (car org-agenda-overriding-arguments)
            start-day (nth 1 org-agenda-overriding-arguments)
            span (nth 2 org-agenda-overriding-arguments)))
   (if (stringp start-day)
       ;; Convert to an absolute day number
       (setq start-day (time-to-days (org-read-date nil t start-day))))
-  (setq org-agenda-last-arguments (list include-all start-day span))
+  (setq org-agenda-last-arguments (list arg start-day span))
   (org-compile-prefix-format 'agenda)
   (org-set-sorting-strategy 'agenda)
   (let* ((span (org-agenda-ndays-to-span
@@ -3557,7 +3597,7 @@ given in `org-agenda-start-on-weekday'."
         s e rtn rtnall file date d start-pos end-pos todayp
         clocktable-start clocktable-end filter)
     (setq org-agenda-redo-command
-         (list 'org-agenda-list (list 'quote include-all) start-day (list 'quote span)))
+         (list 'org-agenda-list (list 'quote arg) start-day (list 'quote span)))
     (dotimes (n (1- ndays))
       (push (1+ (car day-numbers)) day-numbers))
     (setq day-numbers (nreverse day-numbers))
@@ -3565,7 +3605,7 @@ given in `org-agenda-start-on-weekday'."
          clocktable-end (1+ (or (org-last day-numbers) 0)))
     (org-prepare-agenda "Day/Week")
     (org-set-local 'org-starting-day (car day-numbers))
-    (org-set-local 'org-include-all-loc include-all)
+    (org-set-local 'org-arg-loc arg)
     (org-set-local 'org-agenda-current-span (org-agenda-ndays-to-span span))
     (unless org-agenda-compact-blocks
       (let* ((d1 (car day-numbers))
@@ -3616,7 +3656,7 @@ given in `org-agenda-start-on-weekday'."
              (setq rtn (apply 'org-agenda-get-day-entries
                               file date
                               org-agenda-entry-types)))))
-         (setq rtnall (append rtnall rtn))))
+         (setq rtnall (append rtnall rtn)))) ;; all entries
       (if org-agenda-include-diary
          (let ((org-agenda-search-headline-for-time t))
            (require 'diary-lib)
@@ -3638,7 +3678,7 @@ given in `org-agenda-start-on-weekday'."
            (put-text-property s (1- (point)) 'org-day-cnt day-cnt)
            (when todayp
              (put-text-property s (1- (point)) 'org-today t))
-           (if rtnall (insert
+           (if rtnall (insert ;; all entries
                        (org-finalize-agenda-entries
                         (org-agenda-add-time-grid-maybe
                          rtnall ndays todayp))
@@ -3655,8 +3695,8 @@ given in `org-agenda-start-on-weekday'."
        (setq p (plist-put p :tend clocktable-end))
        (setq p (plist-put p :scope 'agenda))
        (when (and (eq org-agenda-clockreport-mode 'with-filter)
-                  (setq filter (or org-agenda-filter-while-redo
-                                   (get 'org-agenda-filter :preset-filter))))
+                  (setq filter (or org-agenda-tag-filter-while-redo
+                                   (get 'org-agenda-tag-filter :preset-filter))))
          (setq p (plist-put p :tags (mapconcat (lambda (x)
                                                  (if (string-match "[<>=]" x)
                                                      ""
@@ -3715,9 +3755,9 @@ given in `org-agenda-start-on-weekday'."
 (defvar org-todo-only nil)
 
 (defvar org-search-syntax-table nil
-  "Special syntax table for Org-mode search.
-In this table, we have single quotes not as word constituents, so
-that when \"+Ameli\" is searched as a word, it will also match \"Ameli's\"")
+  "Special syntax table for org-mode search.
+In this table, we have single quotes not as word constituents, to
+that when \"+Ameli\" is searched as a work, it will also match \"Ameli's\"")
 
 (defun org-search-syntax-table ()
   (unless org-search-syntax-table
@@ -3786,7 +3826,7 @@ in `org-agenda-text-search-extra-files'."
         (full-words org-agenda-search-view-force-full-words)
         (org-agenda-text-search-extra-files org-agenda-text-search-extra-files)
         regexp rtn rtnall files file pos
-        marker category tags c neg re boolean
+        marker category org-category-pos tags c neg re boolean
         ee txt beg end words regexps+ regexps- hdl-only buffer beg1 str)
     (unless (and (not edit-at)
                 (stringp string)
@@ -3869,7 +3909,7 @@ in `org-agenda-text-search-extra-files'."
     (if (not regexps+)
        (setq regexp org-outline-regexp-bol)
       (setq regexp (pop regexps+))
-      (if hdl-only (setq regexp (concat "^" org-outline-regexp ".*?"
+      (if hdl-only (setq regexp (concat org-outline-regexp-bol ".*?"
                                        regexp))))
     (setq files (org-agenda-files nil 'ifmode))
     (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives)
@@ -3890,7 +3930,7 @@ in `org-agenda-text-search-extra-files'."
                                    file))))
        (with-current-buffer buffer
          (with-syntax-table (org-search-syntax-table)
-           (unless (org-mode-p)
+           (unless (eq major-mode 'org-mode)
              (error "Agenda file %s is not in `org-mode'" file))
            (let ((case-fold-search t))
              (save-excursion
@@ -3900,7 +3940,7 @@ in `org-agenda-text-search-extra-files'."
                                        org-agenda-restrict-end)
                    (widen))
                  (goto-char (point-min))
-                 (unless (or (org-on-heading-p)
+                 (unless (or (org-at-heading-p)
                              (outline-next-heading))
                    (throw 'nextfile t))
                  (goto-char (max (point-min) (1- (point))))
@@ -3930,8 +3970,9 @@ in `org-agenda-text-search-extra-files'."
                      (goto-char beg)
                      (setq marker (org-agenda-new-marker (point))
                            category (org-get-category)
+                           org-category-pos (get-text-property (point) 'org-category-position)
                            tags (org-get-tags-at (point))
-                           txt (org-format-agenda-item
+                           txt (org-agenda-format-item
                                 ""
                                 (buffer-substring-no-properties
                                  beg1 (point-at-eol))
@@ -3941,6 +3982,7 @@ in `org-agenda-text-search-extra-files'."
                        'org-todo-regexp org-todo-regexp
                        'org-complex-heading-regexp org-complex-heading-regexp
                        'priority 1000 'org-category category
+                       'org-category-position org-category-pos
                        'type "search")
                      (push txt ee)
                      (goto-char (1- end))))))))))
@@ -4081,7 +4123,7 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
                       (format "ORG-AGENDA-ERROR: No such org-file %s" file))
                  rtnall (append rtnall rtn))
          (with-current-buffer buffer
-           (unless (org-mode-p)
+           (unless (eq major-mode 'org-mode)
              (error "Agenda file %s is not in `org-mode'" file))
            (save-excursion
              (save-restriction
@@ -4305,8 +4347,8 @@ of what a project is and how to check if it stuck, customize the variable
                          "\\)\\>"))
         (tags (nth 2 org-stuck-projects))
         (tags-re (if (member "*" tags)
-                     (org-re (concat org-outline-regexp-bol
-                                     ".*:[[:alnum:]_@#%]+:[ \t]*$"))
+                     (concat org-outline-regexp-bol
+                             (org-re ".*:[[:alnum:]_@#%]+:[ \t]*$"))
                    (if tags
                        (concat org-outline-regexp-bol
                                ".*:\\("
@@ -4380,7 +4422,7 @@ of what a project is and how to check if it stuck, customize the variable
       (setq entries
            (mapcar
             (lambda (x)
-              (setq x (org-format-agenda-item "" x "Diary" nil 'time))
+              (setq x (org-agenda-format-item "" x "Diary" nil 'time))
               ;; Extend the text properties to the beginning of the line
               (org-add-props x (text-properties-at (1- (length x)) x)
                 'type "diary" 'date date 'face 'org-agenda-diary))
@@ -4425,7 +4467,7 @@ date.  It also removes lines that contain only whitespace."
           (setq string (org-modify-diary-entry-string string))))))
 
 (defun org-modify-diary-entry-string (string)
-  "Add text properties to string, allowing Org-mode to act on it."
+  "Add text properties to string, allowing org-mode to act on it."
   (org-add-props string nil
     'mouse-face 'highlight
     'help-echo (if buffer-file-name
@@ -4525,7 +4567,7 @@ the documentation of `org-diary'."
        ;; If file does not exist, make sure an error message ends up in diary
        (list (format "ORG-AGENDA-ERROR: No such org-file %s" file))
       (with-current-buffer buffer
-       (unless (org-mode-p)
+       (unless (eq major-mode 'org-mode)
          (error "Agenda file %s is not in `org-mode'" file))
        (let ((case-fold-search nil))
          (save-excursion
@@ -4562,6 +4604,7 @@ the documentation of `org-diary'."
                  (setq results (append results rtn))))))))
        results))))
 
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
 (defun org-agenda-get-todos ()
   "Return the TODO information for agenda display."
   (let* ((props (list 'face nil
@@ -4573,16 +4616,20 @@ the documentation of `org-diary'."
                      'help-echo
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
-        (regexp (concat "^\\*+[ \t]+\\("
-                        (if org-select-this-todo-keyword
-                            (if (equal org-select-this-todo-keyword "*")
-                                org-todo-regexp
-                              (concat "\\<\\("
-                                      (mapconcat 'identity (org-split-string org-select-this-todo-keyword "|") "\\|")
-                                    "\\)\\>"))
-                          org-not-done-regexp)
-                        "[^\n\r]*\\)"))
-        marker priority category tags todo-state
+        (regexp (format org-heading-keyword-regexp-format
+                        (cond
+                         ((and org-select-this-todo-keyword
+                               (equal org-select-this-todo-keyword "*"))
+                          org-todo-regexp)
+                         (org-select-this-todo-keyword
+                          (concat "\\("
+                                  (mapconcat 'identity
+                                             (org-split-string
+                                              org-select-this-todo-keyword
+                                              "|")
+                                             "\\|") "\\)"))
+                         (t org-not-done-regexp))))
+        marker priority category org-category-pos tags todo-state
         ee txt beg end)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
@@ -4595,21 +4642,24 @@ the documentation of `org-diary'."
            (goto-char (1+ beg))
            (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
            (throw :skip nil)))
-       (goto-char (match-beginning 1))
+       (goto-char (match-beginning 2))
        (setq marker (org-agenda-new-marker (match-beginning 0))
              category (org-get-category)
-             txt (match-string 1)
+             org-category-pos (get-text-property (point) 'org-category-position)
+             txt (org-trim
+                  (buffer-substring (match-beginning 2) (match-end 0)))
              tags (org-get-tags-at (point))
-             txt (org-format-agenda-item "" txt category tags)
+             txt (org-agenda-format-item "" txt category tags)
              priority (1+ (org-get-priority txt))
              todo-state (org-get-todo-state))
        (org-add-props txt props
          'org-marker marker 'org-hd-marker marker
          'priority priority 'org-category category
+         'org-category-position org-category-pos
          'type "todo" 'todo-state todo-state)
        (push txt ee)
        (if org-agenda-todo-list-sublevels
-           (goto-char (match-end 1))
+           (goto-char (match-end 2))
          (org-end-of-subtree 'invisible))))
     (nreverse ee)))
 
@@ -4691,7 +4741,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 
 (defun org-agenda-get-timestamps ()
   "Return the date stamp information for agenda display."
-  (let* ((props (list 'face nil
+  (let* ((props (list 'face 'org-agenda-calendar-event
                      'org-not-done-regexp org-not-done-regexp
                      'org-todo-regexp org-todo-regexp
                      'org-complex-heading-regexp org-complex-heading-regexp
@@ -4720,8 +4770,8 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
           "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
           "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
         marker hdmarker deadlinep scheduledp clockp closedp inactivep
-        donep tmp priority category ee txt timestr tags b0 b3 e3 head
-        todo-state end-of-match show-all)
+        donep tmp priority category org-category-pos ee txt timestr tags
+        b0 b3 e3 head todo-state end-of-match show-all)
     (goto-char (point-min))
     (while (setq end-of-match (re-search-forward regexp nil t))
       (setq b0 (match-beginning 0)
@@ -4735,7 +4785,8 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
        (org-agenda-skip)
        (if (and (match-end 1)
                 (not (= d1 (org-time-string-to-absolute
-                            (match-string 1) d1 nil show-all))))
+                            (match-string 1) d1 nil show-all
+                            (current-buffer) b0))))
            (throw :skip nil))
        (if (and e3
                 (not (org-diary-sexp-entry (buffer-substring b3 e3) "" date)))
@@ -4760,7 +4811,8 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
            ;; substring should only run to end of time stamp
            (setq timestr (substring timestr 0 (match-end 0))))
        (setq marker (org-agenda-new-marker b0)
-             category (org-get-category b0))
+             category (org-get-category b0)
+             org-category-pos (get-text-property b0 'org-category-position))
        (save-excursion
          (if (not (re-search-backward org-outline-regexp-bol nil t))
              (setq txt org-agenda-no-heading-message)
@@ -4769,7 +4821,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
                  tags (org-get-tags-at))
            (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
            (setq head (or (match-string 1) ""))
-           (setq txt (org-format-agenda-item
+           (setq txt (org-agenda-format-item
                       (if inactivep org-agenda-inactive-leader nil)
                       head category tags timestr
                       remove-re)))
@@ -4778,6 +4830,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
            'org-marker marker 'org-hd-marker hdmarker)
          (org-add-props txt nil 'priority priority
                         'org-category category 'date date
+                        'org-category-position org-category-pos
                         'todo-state todo-state
                         'type "timestamp")
          (push txt ee))
@@ -4789,13 +4842,14 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 (defun org-agenda-get-sexps ()
   "Return the sexp information for agenda display."
   (require 'diary-lib)
-  (let* ((props (list 'mouse-face 'highlight
+  (let* ((props (list 'face 'org-agenda-calendar-sexp
+                     'mouse-face 'highlight
                      'help-echo
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
         (regexp "^&?%%(")
-        marker category ee txt tags entry result beg b sexp sexp-entry
-        todo-state)
+        marker category org-category-pos ee txt tags entry
+        result beg b sexp sexp-entry todo-state)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -4812,6 +4866,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
        (when result
          (setq marker (org-agenda-new-marker beg)
                category (org-get-category beg)
+               org-category-pos (get-text-property beg 'org-category-position)
                todo-state (org-get-todo-state))
 
          (dolist (r (if (stringp result)
@@ -4821,11 +4876,12 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
                (setq txt r)
              (setq txt "SEXP entry returned empty string"))
 
-           (setq txt (org-format-agenda-item
+           (setq txt (org-agenda-format-item
                       "" txt category tags 'time))
            (org-add-props txt props 'org-marker marker)
            (org-add-props txt nil
              'org-category category 'date date 'todo-state todo-state
+             'org-category-position org-category-pos
              'type "sexp")
            (push txt ee)))))
     (nreverse ee)))
@@ -4860,9 +4916,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 ;; Define the` org-class' function
 (defun org-class (y1 m1 d1 y2 m2 d2 dayname &rest skip-weeks)
   "Entry applies if date is between dates on DAYNAME, but skips SKIP-WEEKS.
-DAYNAME is a number between 0 (Sunday) and 6 (Saturday).  SKIP-WEEKS
-is any number of ISO weeks in the block period for which the item should
-be skipped."
+DAYNAME is a number between 0 (Sunday) and 6 (Saturday).
+SKIP-WEEKS is any number of ISO weeks in the block period for which the
+item should be skipped.  If any of the SKIP-WEEKS arguments is the symbol
+`holidays', then any date that is known by the Emacs calendar to be a
+holidy will also be skipped."
   (let* ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1)))
         (date2 (calendar-absolute-from-gregorian (list m2 d2 y2)))
         (d (calendar-absolute-from-gregorian date)))
@@ -4874,6 +4932,8 @@ be skipped."
         (progn
           (require 'cal-iso)
           (not (member (car (calendar-iso-from-absolute d)) skip-weeks))))
+     (not (and (memq 'holidays skip-weeks)
+              (calendar-check-holidays date)))
      entry)))
 
 (defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks)
@@ -4894,6 +4954,7 @@ please use `org-class' instead."
      (nth 2 date1) (car date1) (nth 1 date1)
      (nth 2 date2) (car date2) (nth 1 date2)
      dayname skip-weeks)))
+(make-obsolete 'org-diary-class 'org-class "")
 
 (defalias 'org-get-closed 'org-agenda-get-progress)
 (defun org-agenda-get-progress ()
@@ -4929,8 +4990,8 @@ please use `org-class' instead."
                            (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
                    1 11))))
         (org-agenda-search-headline-for-time nil)
-        marker hdmarker priority category tags closedp statep clockp state
-        ee txt extra timestr rest clocked)
+        marker hdmarker priority category org-category-pos tags closedp
+        statep clockp state ee txt extra timestr rest clocked)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -4941,14 +5002,15 @@ please use `org-class' instead."
              clockp (not (or closedp statep))
              state (and statep (match-string 2))
              category (org-get-category (match-beginning 0))
-             timestr (buffer-substring (match-beginning 0) (point-at-eol))
-             )
+             org-category-pos (get-text-property (match-beginning 0) 'org-category-position)
+             timestr (buffer-substring (match-beginning 0) (point-at-eol)))
        (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) (not statep)
-                  (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*?\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)" rest))
+                  (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*?\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)"
+                                rest))
              (progn (setq timestr (concat (substring timestr 0 -1)
                                           "-" (match-string 1 rest) "]"))
                     (setq clocked (match-string 2 rest)))
@@ -4975,7 +5037,7 @@ please use `org-class' instead."
                  (setq txt (concat (substring txt 0 (match-beginning 1))
                                    " - " extra " " (match-string 2 txt)))
                (setq txt (concat txt " - " extra))))
-           (setq txt (org-format-agenda-item
+           (setq txt (org-agenda-format-item
                       (cond
                        (closedp "Closed:    ")
                            (statep (concat "State:     (" state ")"))
@@ -4985,6 +5047,7 @@ please use `org-class' instead."
          (org-add-props txt props
            'org-marker marker 'org-hd-marker hdmarker 'face 'org-agenda-done
            'priority priority 'org-category category
+           'org-category-position org-category-pos
            'type "closed" 'date date
            'undone-face 'org-warning 'done-face 'org-agenda-done)
          (push txt ee))
@@ -5059,7 +5122,7 @@ See also the user option `org-agenda-clock-consistency-checks'."
                              (/ (- tlend ts) 60))
                face (or (plist-get pl :overlap-face) face)))
         ((and (> tlend 0) (> ts (+ tlend (* 60 maxgap))))
-         ;; There is a gap, let's see if we need to report it
+         ;; There is a gap, lets see if we need to report it
          (unless (org-agenda-check-clock-gap tlend ts gapok)
            (setq issue (format "Clocking gap: %d minutes"
                                  (/ (- ts tlend) 60))
@@ -5122,9 +5185,9 @@ See also the user option `org-agenda-clock-consistency-checks'."
         (regexp org-deadline-time-regexp)
         (todayp (org-agenda-todayp date)) ; DATE bound by calendar
         (d1 (calendar-absolute-from-gregorian date))  ; DATE bound by calendar
-        d2 diff dfrac wdays pos pos1 category tags
-        suppress-prewarning
-        ee txt head face s todo-state show-all upcomingp donep timestr)
+        d2 diff dfrac wdays pos pos1 category org-category-pos
+        tags suppress-prewarning ee txt head face s todo-state
+        show-all upcomingp donep timestr)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (setq suppress-prewarning nil)
@@ -5147,13 +5210,14 @@ See also the user option `org-agenda-clock-consistency-checks'."
                           (member todo-state
                                    org-agenda-repeating-timestamp-show-all))
              d2 (org-time-string-to-absolute
-                 (match-string 1) d1 'past show-all)
+                 (match-string 1) d1 'past show-all
+                 (current-buffer) pos)
              diff (- d2 d1)
              wdays (if suppress-prewarning
                        (let ((org-deadline-warning-days suppress-prewarning))
                          (org-get-wdays s))
                      (org-get-wdays s))
-             dfrac (/ (* 1.0 (- wdays diff)) (max wdays 1))
+             dfrac (- 1 (/ (* 1.0 diff) (max wdays 1)))
              upcomingp (and todayp (> diff 0)))
        ;; When to show a deadline in the calendar:
        ;; If the expiration is within wdays warning time.
@@ -5168,7 +5232,8 @@ See also the user option `org-agenda-clock-consistency-checks'."
                       (or org-agenda-skip-deadline-if-done
                           (not (= diff 0))))
                  (setq txt nil)
-               (setq category (org-get-category))
+               (setq category (org-get-category)
+                     org-category-pos (get-text-property (point) 'org-category-position))
                (if (not (re-search-backward "^\\*+[ \t]+" nil t))
                    (setq txt org-agenda-no-heading-message)
                  (goto-char (match-end 0))
@@ -5182,7 +5247,7 @@ See also the user option `org-agenda-clock-consistency-checks'."
                      (setq timestr
                            (concat (substring s (match-beginning 1)) " "))
                    (setq timestr 'time))
-                 (setq txt (org-format-agenda-item
+                 (setq txt (org-agenda-format-item
                             (if (= diff 0)
                                 (car org-agenda-deadline-leaders)
                               (if (functionp
@@ -5195,13 +5260,14 @@ See also the user option `org-agenda-clock-consistency-checks'."
                             head category tags
                             (if (not (= diff 0)) nil timestr)))))
              (when txt
-               (setq face (org-agenda-deadline-face dfrac wdays))
+               (setq face (org-agenda-deadline-face dfrac))
                (org-add-props txt props
                  'org-marker (org-agenda-new-marker pos)
                  'org-hd-marker (org-agenda-new-marker pos1)
                  'priority (+ (- diff)
                               (org-get-priority txt))
                  'org-category category
+                 'org-category-position org-category-pos
                  'todo-state todo-state
                  'type (if upcomingp "upcoming-deadline" "deadline")
                  'date (if upcomingp date d2)
@@ -5210,10 +5276,9 @@ See also the user option `org-agenda-clock-consistency-checks'."
                (push txt ee))))))
     (nreverse ee)))
 
-(defun org-agenda-deadline-face (fraction &optional wdays)
+(defun org-agenda-deadline-face (fraction)
   "Return the face to displaying a deadline item.
 FRACTION is what fraction of the head-warning time has passed."
-  (if (equal wdays 0) (setq fraction 1.))
   (let ((faces org-agenda-deadline-faces) f)
     (catch 'exit
       (while (setq f (pop faces))
@@ -5238,7 +5303,7 @@ FRACTION is what fraction of the head-warning time has passed."
                                        0 'org-hd-marker a))
                              (cons (marker-position mm) a)))
                  deadline-results))
-        d2 diff pos pos1 category tags donep
+        d2 diff pos pos1 category org-category-pos tags donep
         ee txt head pastschedp todo-state face timestr s habitp show-all)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
@@ -5252,7 +5317,8 @@ FRACTION is what fraction of the head-warning time has passed."
                           (member todo-state
                                   org-agenda-repeating-timestamp-show-all))
              d2 (org-time-string-to-absolute
-                 (match-string 1) d1 'past show-all)
+                 (match-string 1) d1 'past show-all
+                 (current-buffer) pos)
              diff (- d2 d1))
        (setq pastschedp (and todayp (< diff 0)))
        ;; When to show a scheduled item in the calendar:
@@ -5271,7 +5337,8 @@ FRACTION is what fraction of the head-warning time has passed."
                (setq txt nil)
              (setq habitp (and (functionp 'org-is-habit-p)
                                (org-is-habit-p)))
-             (setq category (org-get-category))
+             (setq category (org-get-category)
+                   org-category-pos (get-text-property (point) 'org-category-position))
              (if (not (re-search-backward "^\\*+[ \t]+" nil t))
                  (setq txt org-agenda-no-heading-message)
                (goto-char (match-end 0))
@@ -5295,7 +5362,7 @@ FRACTION is what fraction of the head-warning time has passed."
                    (setq timestr
                          (concat (substring s (match-beginning 1)) " "))
                  (setq timestr 'time))
-               (setq txt (org-format-agenda-item
+               (setq txt (org-agenda-format-item
                           (if (= diff 0)
                               (car org-agenda-scheduled-leaders)
                             (format (nth 1 org-agenda-scheduled-leaders)
@@ -5322,6 +5389,7 @@ FRACTION is what fraction of the head-warning time has passed."
                              (org-habit-get-priority habitp)
                            (+ 94 (- 5 diff) (org-get-priority txt)))
                'org-category category
+               'org-category-position org-category-pos
                'org-habit-p habitp
                'todo-state todo-state)
              (push txt ee))))))
@@ -5339,8 +5407,8 @@ FRACTION is what fraction of the head-warning time has passed."
                              (abbreviate-file-name buffer-file-name))))
         (regexp org-tr-regexp)
         (d0 (calendar-absolute-from-gregorian date))
-        marker hdmarker ee txt d1 d2 s1 s2 category todo-state tags pos
-        head donep)
+        marker hdmarker ee txt d1 d2 s1 s2 category org-category-pos
+        todo-state tags pos head donep)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -5350,8 +5418,8 @@ FRACTION is what fraction of the head-warning time has passed."
              (end-time (match-string 2)))
          (setq s1 (match-string 1)
                s2 (match-string 2)
-               d1 (time-to-days (org-time-string-to-time s1))
-               d2 (time-to-days (org-time-string-to-time s2)))
+               d1 (time-to-days (org-time-string-to-time s1 (current-buffer) pos))
+               d2 (time-to-days (org-time-string-to-time s2 (current-buffer) pos)))
          (if (and (> (- d0 d1) -1) (> (- d2 d0) -1))
              ;; Only allow days between the limits, because the normal
              ;; date stamps will catch the limits.
@@ -5361,7 +5429,8 @@ FRACTION is what fraction of the head-warning time has passed."
                (if (and donep org-agenda-skip-timestamp-if-done)
                    (throw :skip t))
                (setq marker (org-agenda-new-marker (point)))
-               (setq category (org-get-category))
+               (setq category (org-get-category)
+                     org-category-pos (get-text-property (point) 'org-category-position))
                (if (not (re-search-backward org-outline-regexp-bol nil t))
                    (setq txt org-agenda-no-heading-message)
                  (goto-char (match-beginning 0))
@@ -5376,13 +5445,15 @@ FRACTION is what fraction of the head-warning time has passed."
                              "--"
                              "<" (regexp-quote s2) ".*?>")
                           nil)))
-                   (setq txt (org-format-agenda-item
+                   (setq txt (org-agenda-format-item
                               (format
                                (nth (if (= d1 d2) 0 1)
                                     org-agenda-timerange-leaders)
                                (1+ (- d0 d1)) (1+ (- d2 d1)))
                               head category tags
-                              (cond ((= d1 d0)
+                              (cond ((and (= d1 d0) (= d2 d0))
+                                     (concat "<" start-time ">--<" end-time ">"))
+                                     ((= d1 d0)
                                      (concat "<" start-time ">"))
                                     ((= d2 d0)
                                      (concat "<" end-time ">"))
@@ -5392,7 +5463,8 @@ FRACTION is what fraction of the head-warning time has passed."
                  'org-marker marker 'org-hd-marker hdmarker
                  'type "block" 'date date
                  'todo-state todo-state
-                 'priority (org-get-priority txt) 'org-category category)
+                 'priority (org-get-priority txt) 'org-category category
+                 'org-category-position org-category-pos)
                (push txt ee))))
        (goto-char pos)))
     ;; Sort the entries by expiration date.
@@ -5422,7 +5494,7 @@ The flag is set if the currently compiled format contains a `%e'.")
          (return (cadr entry))
       (return (apply 'create-image (cdr entry)))))))
 
-(defun org-format-agenda-item (extra txt &optional category tags dotime
+(defun org-agenda-format-item (extra txt &optional category tags dotime
                                     remove-re habitp)
   "Format TXT to be inserted into the agenda buffer.
 In particular, it adds the prefix and corresponding text properties.  EXTRA
@@ -5464,7 +5536,7 @@ Any match of REMOVE-RE will be removed from TXT."
           (time-of-day (and dotime (org-get-time-of-day ts)))
           stamp plain s0 s1 s2 rtn srp l
           duration thecategory)
-      (and (org-mode-p) buffer-file-name
+      (and (eq major-mode 'org-mode) buffer-file-name
           (add-to-list 'org-agenda-contributing-files buffer-file-name))
       (when (and dotime time-of-day)
        ;; Extract starting and ending time and move them to prefix
@@ -5512,7 +5584,7 @@ Any match of REMOVE-RE will be removed from TXT."
                     (concat (make-string (max (- 50 (length txt)) 1) ?\ )
                             (match-string 2 txt))
                     t t txt))))
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
        (setq effort
              (condition-case nil
                  (org-get-effort
@@ -5642,14 +5714,14 @@ The modified list may contain inherited tags, and tags matched by
       (while (setq time (pop gridtimes))
        (unless (and remove (member time have))
          (setq time (replace-regexp-in-string " " "0" (format "%04s" time)))
-         (push (org-format-agenda-item
+         (push (org-agenda-format-item
                 nil string "" nil
                 (concat (substring time 0 -2) ":" (substring time -2)))
                new)
          (put-text-property
           2 (length (car new)) 'face 'org-time-grid (car new))))
       (when (and todayp org-agenda-show-current-time-in-grid)
-       (push (org-format-agenda-item
+       (push (org-agenda-format-item
               nil
               org-agenda-current-time-string
               "" nil
@@ -5667,7 +5739,8 @@ The modified list may contain inherited tags, and tags matched by
 The resulting form is returned and stored in the variable
 `org-prefix-format-compiled'."
   (setq org-prefix-has-time nil org-prefix-has-tag nil
-       org-prefix-category-length nil  org-prefix-has-effort nil)
+       org-prefix-category-length nil
+       org-prefix-has-effort nil)
   (let ((s (cond
            ((stringp org-agenda-prefix-format)
             org-agenda-prefix-format)
@@ -5779,7 +5852,7 @@ could bind the variable in the options section of a custom command.")
 (defun org-agenda-highlight-todo (x)
   (let ((org-done-keywords org-done-keywords-for-agenda)
        (case-fold-search nil)
-        re)
+       re)
     (if (eq x 'line)
        (save-excursion
          (beginning-of-line 1)
@@ -5800,13 +5873,13 @@ could bind the variable in the options section of a custom command.")
          (add-text-properties
           (or (match-end 1) (match-end 0)) (match-end 0)
           (list 'face (org-get-todo-face (match-string 2 x)))
-        x)
+          x)
          (when (match-end 1)
            (setq x (concat (substring x 0 (match-end 1))
                            (format org-agenda-todo-keyword-format
                                    (match-string 2 x))
-                         (org-add-props " " (text-properties-at 0 x))
-                         (substring x (match-end 3)))))))
+                           (org-add-props " " (text-properties-at 0 x))
+                           (substring x (match-end 3)))))))
       x)))
 
 (defsubst org-cmp-priority (a b)
@@ -5818,7 +5891,7 @@ could bind the variable in the options section of a custom command.")
          (t nil))))
 
 (defsubst org-cmp-effort (a b)
-  "Compare the priorities of string A and B."
+  "Compare the effort values of string A and B."
   (let* ((def (if org-sort-agenda-noeffort-is-high 32767 -1))
         (ea (or (get-text-property 1 'effort-minutes a) def))
         (eb (or (get-text-property 1 'effort-minutes b) def)))
@@ -6081,29 +6154,45 @@ in the agenda."
 When this is the global TODO list, a prefix argument will be interpreted."
   (interactive)
   (let* ((org-agenda-keep-modes t)
-        (filter org-agenda-filter)
-        (preset (get 'org-agenda-filter :preset-filter))
-        (org-agenda-filter-while-redo (or filter preset))
+        (tag-filter org-agenda-tag-filter)
+        (tag-preset (get 'org-agenda-tag-filter :preset-filter))
+        (cat-filter org-agenda-category-filter)
+        (cat-preset (get 'org-agenda-category-filter :preset-filter))
+        (org-agenda-tag-filter-while-redo (or tag-filter tag-preset))
         (cols org-agenda-columns-active)
         (line (org-current-line))
         (window-line (- line (org-current-line (window-start))))
         (lprops (get 'org-agenda-redo-command 'org-lprops)))
-    (put 'org-agenda-filter :preset-filter nil)
+    (put 'org-agenda-tag-filter :preset-filter nil)
+    (put 'org-agenda-category-filter :preset-filter nil)
     (and cols (org-columns-quit))
     (message "Rebuilding agenda buffer...")
     (org-let lprops '(eval org-agenda-redo-command))
     (setq org-agenda-undo-list nil
          org-agenda-pending-undo-list nil)
     (message "Rebuilding agenda buffer...done")
-    (put 'org-agenda-filter :preset-filter preset)
-    (and (or filter preset) (org-agenda-filter-apply filter))
+    (put 'org-agenda-tag-filter :preset-filter tag-preset)
+    (put 'org-agenda-category-filter :preset-filter cat-preset)
+    (and (or tag-filter tag-preset) (org-agenda-filter-apply tag-filter 'tag))
+    (and (or cat-filter cat-preset) (org-agenda-filter-apply cat-filter 'category))
     (and cols (org-called-interactively-p 'any) (org-agenda-columns))
     (org-goto-line line)
     (recenter window-line)))
 
-
 (defvar org-global-tags-completion-table nil)
 (defvar org-agenda-filter-form nil)
+
+(defun org-agenda-filter-by-category (strip)
+  "Keep only those lines in the agenda buffer that have a specific category.
+The category is that of the current line."
+  (interactive "P")
+  (if org-agenda-filtered-by-category
+      (org-agenda-filter-show-all-cat)
+    (let ((cat (org-no-properties (get-text-property (point) 'org-category))))
+      (if cat (org-agenda-filter-apply
+              (list (concat (if strip "-" "+") cat)) 'category)
+       (error "No category at point")))))
+
 (defun org-agenda-filter-by-tag (strip &optional char narrow)
   "Keep only those lines in the agenda buffer that have a specific tag.
 The tag is selected with its fast selection letter, as configured.
@@ -6127,21 +6216,21 @@ to switch to narrowing."
         (effort-op org-agenda-filter-effort-default-operator)
         (effort-prompt "")
         (inhibit-read-only t)
-        (current org-agenda-filter)
+        (current org-agenda-tag-filter)
         maybe-refresh a n tag)
     (unless char
       (message
        "%s by tag [%s ], [TAB], %s[/]:off, [+-]:narrow, [>=<?]:effort: "
        (if narrow "Narrow" "Filter") tag-chars
        (if org-agenda-auto-exclude-function "[RET], " ""))
-      (setq char (read-char)))
+      (setq char (read-char-exclusive)))
     (when (member char '(?+ ?-))
       ;; Narrowing down
       (cond ((equal char ?-) (setq strip t narrow t))
            ((equal char ?+) (setq strip nil narrow t)))
       (message
        "Narrow by tag [%s ], [TAB], [/]:off, [>=<]:effort: " tag-chars)
-      (setq char (read-char)))
+      (setq char (read-char-exclusive)))
     (when (member char '(?< ?> ?= ??))
       ;; An effort operator
       (setq effort-op (char-to-string char))
@@ -6154,7 +6243,7 @@ to switch to narrowing."
                     (if (= i 9) "0" (int-to-string (1+ i)))
                     "]" (nth i efforts))))
        (message "Effort%s: %s " effort-op effort-prompt)
-       (setq char (read-char))
+       (setq char (read-char-exclusive))
        (when (or (< char ?0) (> char ?9))
          (error "Need 1-9,0 to select effort" ))))
     (when (equal char ?\t)
@@ -6166,20 +6255,26 @@ to switch to narrowing."
                   "Tag: " org-global-tags-completion-table))))
     (cond
      ((equal char ?\r)
-      (org-agenda-filter-by-tag-show-all)
+      (org-agenda-filter-show-all-tag)
       (when org-agenda-auto-exclude-function
-       (setq org-agenda-filter '())
+       (setq org-agenda-tag-filter '())
        (dolist (tag (org-agenda-get-represented-tags))
          (let ((modifier (funcall org-agenda-auto-exclude-function tag)))
            (if modifier
-               (push modifier org-agenda-filter))))
-       (if (not (null org-agenda-filter))
-           (org-agenda-filter-apply org-agenda-filter)))
+               (push modifier org-agenda-tag-filter))))
+       (if (not (null org-agenda-tag-filter))
+           (org-agenda-filter-apply org-agenda-tag-filter 'tag)))
       (setq maybe-refresh t))
      ((equal char ?/)
-      (org-agenda-filter-by-tag-show-all)
-      (when (get 'org-agenda-filter :preset-filter)
-       (org-agenda-filter-apply org-agenda-filter))
+      (org-agenda-filter-show-all-tag)
+      (when (get 'org-agenda-tag-filter :preset-filter)
+       (org-agenda-filter-apply org-agenda-tag-filter 'tag))
+      (setq maybe-refresh t))
+     ((equal char ?. )
+      (setq org-agenda-tag-filter
+           (mapcar (lambda(tag) (concat "+" tag))
+                   (org-get-at-bol 'tags)))
+      (org-agenda-filter-apply org-agenda-tag-filter 'tag)
       (setq maybe-refresh t))
      ((or (equal char ?\ )
          (setq a (rassoc char alist))
@@ -6191,12 +6286,12 @@ to switch to narrowing."
               (setq tag "?eff")
               a (cons tag nil))
          (and tag (setq a (cons tag nil))))
-      (org-agenda-filter-by-tag-show-all)
+      (org-agenda-filter-show-all-tag)
       (setq tag (car a))
-      (setq org-agenda-filter
+      (setq org-agenda-tag-filter
            (cons (concat (if strip "-" "+") tag)
                  (if narrow current nil)))
-      (org-agenda-filter-apply org-agenda-filter)
+      (org-agenda-filter-apply org-agenda-tag-filter 'tag)
       (setq maybe-refresh t))
      (t (error "Invalid tag selection character %c" char)))
     (when (and maybe-refresh
@@ -6215,15 +6310,17 @@ to switch to narrowing."
     tags))
 
 (defun org-agenda-filter-by-tag-refine (strip &optional char)
-  "Refine the current filter.  See `org-agenda-filter-by-tag."
+  "Refine the current filter.  See `org-agenda-filter-by-tag'."
   (interactive "P")
   (org-agenda-filter-by-tag strip char 'refine))
 
 (defun org-agenda-filter-make-matcher ()
-  "Create the form that tests a line for the agenda filter."
+  "Create the form that tests a line for agenda filter."
   (let (f f1)
-    (dolist (x (append (get 'org-agenda-filter :preset-filter)
-                      org-agenda-filter))
+    ;; first compute the tag-filter matcher
+    (dolist (x (delete-dups
+               (append (get 'org-agenda-tag-filter
+                            :preset-filter) org-agenda-tag-filter)))
       (if (member x '("-" "+"))
          (setq f1 (if (equal x "-") 'tags '(not tags)))
        (if (string-match "[<=>?]" x)
@@ -6232,6 +6329,12 @@ to switch to narrowing."
        (if (equal (string-to-char x) ?-)
            (setq f1 (list 'not f1))))
       (push f1 f))
+    ;; then compute the category-filter matcher
+    (dolist (x (delete-dups
+               (append (get 'org-agenda-category-filter
+                            :preset-filter) org-agenda-category-filter)))
+      (setq f1 (list 'equal (substring x 1) 'cat))
+      (push f1 f))
     (cons 'and (nreverse f))))
 
 (defun org-agenda-filter-effort-form (e)
@@ -6256,49 +6359,64 @@ If the line does not have an effort defined, return nil."
       (funcall op (or eff (if org-sort-agenda-noeffort-is-high 32767 0))
               value))))
 
-(defun org-agenda-filter-apply (filter)
+(defvar org-agenda-filtered-by-category nil)
+(defun org-agenda-filter-apply (filter type)
   "Set FILTER as the new agenda filter and apply it."
   (let (tags)
-    (setq org-agenda-filter filter
-         org-agenda-filter-form (org-agenda-filter-make-matcher))
+    (if (eq type 'tag)
+       (setq org-agenda-tag-filter filter)
+      (setq org-agenda-category-filter filter
+           org-agenda-filtered-by-category t))
+    (setq org-agenda-filter-form (org-agenda-filter-make-matcher))
     (org-agenda-set-mode-name)
     (save-excursion
       (goto-char (point-min))
       (while (not (eobp))
        (if (org-get-at-bol 'org-marker)
            (progn
-             (setq tags (org-get-at-bol 'tags)) ; used in eval
+             (setq tags (org-get-at-bol 'tags) ; used in eval
+                   cat (get-text-property (point) 'org-category))
              (if (not (eval org-agenda-filter-form))
-                 (org-agenda-filter-by-tag-hide-line))
+                 (org-agenda-filter-hide-line type))
              (beginning-of-line 2))
          (beginning-of-line 2))))
     (if (get-char-property (point) 'invisible)
        (org-agenda-previous-line))))
 
-(defun org-agenda-filter-by-tag-hide-line ()
+(defun org-agenda-filter-hide-line (type)
   (let (ov)
     (setq ov (make-overlay (max (point-min) (1- (point-at-bol)))
                               (point-at-eol)))
     (overlay-put ov 'invisible t)
-    (overlay-put ov 'type 'tags-filter)
-    (push ov org-agenda-filter-overlays)))
+    (overlay-put ov 'type type)
+    (if (eq type 'tag)
+       (push ov org-agenda-tag-filter-overlays)
+      (push ov org-agenda-cat-filter-overlays))))
 
 (defun org-agenda-fix-tags-filter-overlays-at (&optional pos)
   (setq pos (or pos (point)))
   (save-excursion
     (dolist (ov (overlays-at pos))
       (when (and (overlay-get ov 'invisible)
-                (eq (overlay-get ov 'type) 'tags-filter))
+                (eq (overlay-get ov 'type) 'tag))
        (goto-char pos)
        (if (< (overlay-start ov) (point-at-eol))
            (move-overlay ov (point-at-eol)
                              (overlay-end ov)))))))
 
-(defun org-agenda-filter-by-tag-show-all ()
-  (mapc 'delete-overlay org-agenda-filter-overlays)
-  (setq org-agenda-filter-overlays nil)
-  (setq org-agenda-filter nil)
-  (setq org-agenda-filter-form nil)
+(defun org-agenda-filter-show-all-tag nil
+  (mapc 'delete-overlay org-agenda-tag-filter-overlays)
+  (setq org-agenda-tag-filter-overlays nil
+       org-agenda-tag-filter nil
+       org-agenda-filter-form nil)
+  (org-agenda-set-mode-name))
+
+(defun org-agenda-filter-show-all-cat nil
+  (mapc 'delete-overlay org-agenda-cat-filter-overlays)
+  (setq org-agenda-cat-filter-overlays nil
+       org-agenda-filtered-by-category nil
+       org-agenda-category-filter nil
+       org-agenda-filter-form nil)
   (org-agenda-set-mode-name))
 
 (defun org-agenda-manipulate-query-add ()
@@ -6592,8 +6710,7 @@ so that the date SD will be in that range."
   (interactive)
   (setq org-agenda-follow-mode (not org-agenda-follow-mode))
   (org-agenda-set-mode-name)
-  (if (and org-agenda-follow-mode (org-get-at-bol 'org-marker))
-      (org-agenda-show))
+  (org-agenda-do-context-action)
   (message "Follow mode is %s"
           (if org-agenda-follow-mode "on" "off")))
 
@@ -6714,13 +6831,33 @@ When called with a prefix argument, include all archive files as well."
               ((eq org-agenda-show-log 'clockcheck) " ClkCk")
               (org-agenda-show-log " Log")
               (t ""))
-             (if (or org-agenda-filter (get 'org-agenda-filter
+             (if (or org-agenda-category-filter (get 'org-agenda-category-filter
+                                                     :preset-filter))
+                 '(:eval (org-propertize
+                          (concat " <"
+                                  (mapconcat
+                                   'identity
+                                   (append
+                                    (get 'org-agenda-category-filter :preset-filter)
+                                    org-agenda-category-filter)
+                                   "")
+                                  ">")
+                          'face 'org-agenda-filter-category
+                          'help-echo "Category used in filtering"))
+               "")
+             (if (or org-agenda-tag-filter (get 'org-agenda-tag-filter
                                             :preset-filter))
-                 (concat " {" (mapconcat
-                               'identity
-                               (append (get 'org-agenda-filter
-                                            :preset-filter)
-                                       org-agenda-filter) "") "}")
+                 '(:eval (org-propertize
+                          (concat " {"
+                                  (mapconcat
+                                   'identity
+                                   (append
+                                    (get 'org-agenda-tag-filter :preset-filter)
+                                    org-agenda-tag-filter)
+                                   "")
+                                  "}")
+                          'face 'org-agenda-filter-tags
+                          'help-echo "Tags used in filtering"))
                "")
              (if org-agenda-archives-mode
                  (if (eq org-agenda-archives-mode t)
@@ -6754,11 +6891,13 @@ When called with a prefix argument, include all archive files as well."
 (defun org-agenda-do-context-action ()
   "Show outline path and, maybe, follow mode window."
   (let ((m (org-get-at-bol 'org-marker)))
-    (if (and org-agenda-follow-mode m)
-       (org-agenda-show))
-    (if (and m org-agenda-show-outline-path)
-       (org-with-point-at m
-         (org-display-outline-path t)))))
+    (when (and (markerp m) (marker-buffer m))
+      (and org-agenda-follow-mode
+          (if org-agenda-follow-indirect
+              (org-agenda-tree-to-indirect-buffer)
+            (org-agenda-show)))
+      (and org-agenda-show-outline-path
+          (org-with-point-at m (org-display-outline-path t))))))
 
 (defun org-agenda-show-priority ()
   "Show the priority of the current item.
@@ -6788,7 +6927,7 @@ and by additional input from the age of a schedules or deadline entry."
     (widen)
     (push-mark)
     (goto-char pos)
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (org-show-context 'agenda)
       (save-excursion
        (and (outline-next-heading)
@@ -6817,7 +6956,7 @@ Point is in the buffer where the item originated.")
      (with-current-buffer buffer
        (save-excursion
         (goto-char pos)
-        (if (and (org-mode-p) (not (member type '("sexp"))))
+        (if (and (eq major-mode 'org-mode) (not (member type '("sexp"))))
             (setq dbeg (progn (org-back-to-heading t) (point))
                   dend (org-end-of-subtree t t))
           (setq dbeg (point-at-bol)
@@ -6869,7 +7008,7 @@ Point is in the buffer where the item originated.")
         (pos (marker-position marker)))
     (org-with-remote-undo buffer
       (with-current-buffer buffer
-       (if (org-mode-p)
+       (if (eq major-mode 'org-mode)
            (if (and confirm
                     (not (y-or-n-p "Archive this subtree or entry? ")))
                (error "Abort")
@@ -6970,11 +7109,11 @@ at the text of the entry itself."
                       (org-agenda-error)))
           (buffer (marker-buffer marker))
           (pos (marker-position marker)))
-      (switch-to-buffer buffer)
+      (org-pop-to-buffer-same-window buffer)
       (and delete-other-windows (delete-other-windows))
       (widen)
       (goto-char pos)
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
        (org-show-context 'agenda)
        (save-excursion
          (and (outline-next-heading)
@@ -7138,6 +7277,22 @@ With numerical prefix arg ARG, go up to this level and then take that tree.
 With a \\[universal-argument] prefix, make a separate frame for this tree (i.e. don't
 use the dedicated frame)."
   (interactive)
+  (if (and current-prefix-arg (listp current-prefix-arg))
+      (org-agenda-do-tree-to-indirect-buffer)
+    (let ((agenda-window (selected-window))
+          (indirect-window (get-buffer-window org-last-indirect-buffer)))
+      (save-window-excursion (org-agenda-do-tree-to-indirect-buffer))
+      (unwind-protect
+          (progn
+            (unless indirect-window
+              (setq indirect-window (split-window agenda-window)))
+            (select-window indirect-window)
+            (switch-to-buffer org-last-indirect-buffer :norecord)
+            (fit-window-to-buffer indirect-window))
+        (select-window agenda-window)))))
+
+(defun org-agenda-do-tree-to-indirect-buffer ()
+  "Same as `org-agenda-tree-to-indirect-buffer' without saving window."
   (org-agenda-check-no-diary)
   (let* ((marker (or (org-get-at-bol 'org-marker)
                     (org-agenda-error)))
@@ -7227,7 +7382,7 @@ the same tree node, and the headline of the tree node in the Org-mode file."
                                            &optional fixface just-this)
   "Change all lines in the agenda buffer which match HDMARKER.
 The new content of the line will be NEWHEAD (as modified by
-`org-format-agenda-item').  HDMARKER is checked with
+`org-agenda-format-item').  HDMARKER is checked with
 `equal' against all `org-hd-marker' text properties in the file.
 If FIXFACE is non-nil, the face of each item is modified according to
 the new TODO state.
@@ -7260,7 +7415,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
                    (save-excursion
                      (save-restriction
                        (widen)
-                       (org-format-agenda-item (org-get-at-bol 'extra)
+                       (org-agenda-format-item (org-get-at-bol 'extra)
                                                newhead cat tags dotime)))))
                pl (text-property-any (point-at-bol) (point-at-eol) 'org-heading t)
                undone-face (org-get-at-bol 'undone-face)
@@ -7494,15 +7649,33 @@ the same tree node, and the headline of the tree node in the Org-mode file."
   (let* ((marker (or (org-get-at-bol 'org-marker)
                     (org-agenda-error)))
         (buffer (marker-buffer marker))
-        (pos (marker-position marker)))
+        (pos (marker-position marker))
+        cdate today)
     (org-with-remote-undo buffer
-     (with-current-buffer buffer
-       (widen)
-       (goto-char pos)
-       (if (not (org-at-timestamp-p))
-          (error "Cannot find time stamp"))
-       (org-timestamp-change arg (or what 'day)))
-     (org-agenda-show-new-time marker org-last-changed-timestamp))
+      (with-current-buffer buffer
+       (widen)
+       (goto-char pos)
+       (if (not (org-at-timestamp-p))
+           (error "Cannot find time stamp"))
+       (when (and org-agenda-move-date-from-past-immediately-to-today
+                  (equal arg 1)
+                  (or (not what) (eq what 'day))
+                  (not (save-match-data (org-at-date-range-p))))
+         (setq cdate (org-parse-time-string (match-string 0) 'nodefault)
+               cdate (calendar-absolute-from-gregorian
+                      (list (nth 4 cdate) (nth 3 cdate) (nth 5 cdate)))
+               today (org-today))
+         (if (> today cdate)
+             ;; immediately shift to today
+             (setq arg (- today cdate))))
+       (org-timestamp-change arg (or what 'day))
+       (when (and (org-at-date-range-p)
+                  (re-search-backward org-tr-regexp-both (point-at-bol)))
+         (let ((end org-last-changed-timestamp))
+           (org-timestamp-change arg (or what 'day))
+           (setq org-last-changed-timestamp
+                 (concat org-last-changed-timestamp "--" end)))))
+      (org-agenda-show-new-time marker org-last-changed-timestamp))
     (message "Time stamp changed to %s" org-last-changed-timestamp)))
 
 (defun org-agenda-date-earlier (arg &optional what)
@@ -7827,7 +8000,7 @@ the resulting entry will not be shown.  When TEXT is empty, switch to
      ((eq type 'anniversary)
       (or (re-search-forward "^*[ \t]+Anniversaries" nil t)
        (progn
-         (or (org-on-heading-p t)
+         (or (org-at-heading-p t)
              (progn
                (outline-next-heading)
                (insert "* Anniversaries\n\n")
@@ -7843,10 +8016,10 @@ the resulting entry will not be shown.  When TEXT is empty, switch to
            (org-agenda-time-leading-zero t)
            fmt time time2)
        (if org-agenda-insert-diary-extract-time
-           ;; Use org-format-agenda-item to parse text for a time-range and
+           ;; Use org-agenda-format-item to parse text for a time-range and
            ;; remove it.  FIXME: This is a hack, we should refactor
            ;; that function to make time extraction available separately
-           (setq fmt (org-format-agenda-item nil text nil nil t)
+           (setq fmt (org-agenda-format-item nil text nil nil t)
                  time (get-text-property 0 'time fmt)
                  time2 (if (> (length time) 0)
                            ;; split-string removes trailing ...... if
@@ -8299,7 +8472,8 @@ The prefix arg is passed through to the command if possible."
          (progn (message "Skipping removed entry at %s" e)
                 (setq cntskip (1+ cntskip)))
        (goto-char pos)
-       (eval cmd)
+       (let (org-loop-over-headlines-in-active-region)
+         (eval cmd))
        (setq org-agenda-bulk-marked-entries
              (delete e org-agenda-bulk-marked-entries))
        (setq cnt (1+ cnt))))
@@ -8331,7 +8505,7 @@ tag and (if present) the flagging note."
          (org-agenda-remove-flag hdmarker)
          (let ((win (get-buffer-window "*Flagging Note*")))
            (and win (delete-window win)))
-         (message "Entry unflagged"))
+         (message "Entry unflaged"))
       (setq note (org-entry-get hdmarker "THEFLAGGINGNOTE"))
       (unless note
        (error "No flagging note"))
@@ -8354,7 +8528,7 @@ tag and (if present) the flagging note."
       (org-entry-delete nil "THEFLAGGINGNOTE")
       (setq newhead (org-get-heading)))
     (org-agenda-change-all-lines newhead marker)
-    (message "Entry unflagged")))
+    (message "Entry unflaged")))
 
 (defun org-agenda-get-any-marker (&optional pos)
   (or (get-text-property (or pos (point-at-bol)) 'org-hd-marker)
@@ -8365,7 +8539,7 @@ tag and (if present) the flagging note."
 (defvar appt-time-msg-list)
 
 ;;;###autoload
-(defun org-agenda-to-appt (&optional refresh filter)
+(defun org-agenda-to-appt (&optional refresh filter &rest args)
   "Activate appointments found in `org-agenda-files'.
 With a \\[universal-argument] prefix, refresh the list of
 appointments.
@@ -8376,6 +8550,10 @@ expression, and filter out entries that don't match it.
 If FILTER is a string, use this string as a regular expression
 for filtering entries out.
 
+If FILTER is a function, filter out entries against which
+calling the function returns nil.  This function takes one
+argument: an entry from `org-agenda-get-day-entries'.
+
 FILTER can also be an alist with the car of each cell being
 either 'headline or 'category.  For example:
 
@@ -8383,12 +8561,18 @@ either 'headline or 'category.  For example:
     (category \"Work\"))
 
 will only add headlines containing IMPORTANT or headlines
-belonging to the \"Work\" category."
+belonging to the \"Work\" category.
+
+ARGS are symbols indicating what kind of entries to consider.
+By default `org-agenda-to-appt' will use :deadline, :scheduled
+and :timestamp entries.  See the docstring of `org-diary' for
+details and examples."
   (interactive "P")
   (if refresh (setq appt-time-msg-list nil))
   (if (eq filter t)
       (setq filter (read-from-minibuffer "Regexp filter: ")))
   (let* ((cnt 0) ; count added events
+        (scope (or args '(:deadline :scheduled :timestamp)))
         (org-agenda-new-buffers nil)
         (org-deadline-warning-days 0)
         ;; Do not use `org-today' here because appt only takes
@@ -8402,10 +8586,10 @@ belonging to the \"Work\" category."
     (org-prepare-agenda-buffers files)
     (while (setq file (pop files))
       (setq entries
-           (append entries
-                   (org-agenda-get-day-entries
-                    file today :timestamp :scheduled :deadline))))
-    (setq entries (delq nil entries))
+           (delq nil
+                 (append entries
+                         (apply 'org-agenda-get-day-entries
+                                file today scope)))))
     ;; Map thru entries and find if we should filter them out
     (mapc
      (lambda(x)
@@ -8414,11 +8598,14 @@ belonging to the \"Work\" category."
              (tod (get-text-property 1 'time-of-day x))
              (ok (or (null filter)
                      (and (stringp filter) (string-match filter evt))
+                     (and (functionp filter) (funcall filter x))
                      (and (listp filter)
-                          (or (string-match
-                               (cadr (assoc 'category filter)) cat)
-                              (string-match
-                               (cadr (assoc 'headline filter)) evt))))))
+                          (let ((cat-filter (cadr (assoc 'category filter)))
+                                (evt-filter (cadr (assoc 'headline filter))))
+                            (or (and (stringp cat-filter)
+                                     (string-match cat-filter cat))
+                                (and (stringp evt-filter)
+                                     (string-match evt-filter evt))))))))
         ;; FIXME: Shall we remove text-properties for the appt text?
         ;; (setq evt (set-text-properties 0 (length evt) nil evt))
         (when (and ok tod)
@@ -8441,8 +8628,14 @@ belonging to the \"Work\" category."
                date)))
     (eq date today)))
 
-(provide 'org-agenda)
-
+(defun org-agenda-todo-yesterday (&optional arg)
+  "Like `org-agenda-todo' but the time of change will be 23:59 of yesterday"
+  (interactive "P")
+  (let* ((hour (third (decode-time
+                       (org-current-time))))
+         (org-extend-today-until (1+ hour)))
+    (org-agenda-todo arg)))
 
+(provide 'org-agenda)
 
 ;;; org-agenda.el ends here
index 7436696433c2fcfd5b2b926488e648f1593a5a0a..ffa7f1cabee8e13847185be65ea67bea8727a459 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-archive.el --- Archiving for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -191,158 +190,166 @@ If the cursor is not at a headline when this command is called, try all level
 1 trees.  If the cursor is on a headline, only try the direct children of
 this heading."
   (interactive "P")
-  (if find-done
-      (org-archive-all-done)
-    ;; Save all relevant TODO keyword-relatex variables
-
-    (let ((tr-org-todo-line-regexp org-todo-line-regexp) ; keep despite compiler
-         (tr-org-todo-keywords-1 org-todo-keywords-1)
-         (tr-org-todo-kwd-alist org-todo-kwd-alist)
-         (tr-org-done-keywords org-done-keywords)
-         (tr-org-todo-regexp org-todo-regexp)
-         (tr-org-todo-line-regexp org-todo-line-regexp)
-         (tr-org-odd-levels-only org-odd-levels-only)
-         (this-buffer (current-buffer))
-         ;; start of variables that will be used for saving context
-         ;; The compiler complains about them - keep them anyway!
-         (file (abbreviate-file-name
-                (or (buffer-file-name (buffer-base-buffer))
-                    (error "No file associated to buffer"))))
-         (olpath (mapconcat 'identity (org-get-outline-path) "/"))
-         (time (format-time-string
-                (substring (cdr org-time-stamp-formats) 1 -1)
-                (current-time)))
-         category todo priority ltags itags atags
-         ;; end of variables that will be used for saving context
-         location afile heading buffer level newfile-p infile-p visiting)
-
-      ;; Find the local archive location
-      (setq location (org-get-local-archive-location)
-           afile (org-extract-archive-file location)
-           heading (org-extract-archive-heading location)
-           infile-p (equal file (abbreviate-file-name afile)))
-      (unless afile
-       (error "Invalid `org-archive-location'"))
-
-      (if (> (length afile) 0)
-         (setq newfile-p (not (file-exists-p 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))
-      (if (and (> (length heading) 0)
-              (string-match "^\\*+" heading))
-         (setq level (match-end 0))
-       (setq heading nil level 0))
-      (save-excursion
-       (org-back-to-heading t)
-       ;; Get context information that will be lost by moving the tree
-       (setq category (org-get-category nil 'force-refresh)
-             todo (and (looking-at org-todo-line-regexp)
-                       (match-string 2))
-             priority (org-get-priority
-                       (if (match-end 3) (match-string 3) ""))
-             ltags (org-get-tags)
-             itags (org-delete-all ltags (org-get-tags-at))
-             atags (org-get-tags-at))
-       (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,
-       ;; which would lead to duplication of subtrees
-       (let (this-command) (org-copy-subtree 1 nil t))
-       (set-buffer buffer)
-       ;; Enforce org-mode for the archive buffer
-       (if (not (org-mode-p))
-           ;; Force the mode for future visits.
-           (let ((org-insert-mode-line-in-empty-file t)
-                 (org-inhibit-startup t))
-             (call-interactively 'org-mode)))
-       (when newfile-p
-         (goto-char (point-max))
-         (insert (format "\nArchived entries from file %s\n\n"
-                         (buffer-file-name this-buffer))))
-       ;; Force the TODO keywords of the original buffer
-       (let ((org-todo-line-regexp tr-org-todo-line-regexp)
-             (org-todo-keywords-1 tr-org-todo-keywords-1)
-             (org-todo-kwd-alist tr-org-todo-kwd-alist)
-             (org-done-keywords tr-org-done-keywords)
-             (org-todo-regexp tr-org-todo-regexp)
-             (org-todo-line-regexp tr-org-todo-line-regexp)
-             (org-odd-levels-only
-              (if (local-variable-p 'org-odd-levels-only (current-buffer))
-                  org-odd-levels-only
-                tr-org-odd-levels-only)))
-         (goto-char (point-min))
-         (show-all)
-         (if heading
-             (progn
-               (if (re-search-forward
-                    (concat "^" (regexp-quote heading)
-                            (org-re "[ \t]*\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\($\\|\r\\)"))
-                    nil t)
-                   (goto-char (match-end 0))
-                 ;; Heading not found, just insert it at the end
-                 (goto-char (point-max))
-                 (or (bolp) (insert "\n"))
-                 (insert "\n" heading "\n")
-                 (end-of-line 0))
-               ;; Make the subtree visible
-               (show-subtree)
-               (if org-archive-reversed-order
-                   (progn
-                     (org-back-to-heading t)
-                     (outline-next-heading))
-                 (org-end-of-subtree t))
-               (skip-chars-backward " \t\r\n")
-               (and (looking-at "[ \t\r\n]*")
-                    (replace-match "\n\n")))
-           ;; No specific heading, just go to end of file.
-           (goto-char (point-max)) (insert "\n"))
-         ;; Paste
-         (org-paste-subtree (org-get-valid-level level (and heading 1)))
-         ;; Shall we append inherited tags?
-         (and itags
-              (or (and (eq org-archive-subtree-add-inherited-tags 'infile)
-                       infile-p)
-                  (eq org-archive-subtree-add-inherited-tags t))
-              (org-set-tags-to atags))
-         ;; Mark the entry as done
-         (when (and org-archive-mark-done
-                    (looking-at org-todo-line-regexp)
-                    (or (not (match-end 2))
-                        (not (member (match-string 2) org-done-keywords))))
-           (let (org-log-done org-todo-log-states)
-             (org-todo
-              (car (or (member org-archive-mark-done org-done-keywords)
-                       org-done-keywords)))))
-
-         ;; Add the context info
-         (when org-archive-save-context-info
-           (let ((l org-archive-save-context-info) e n v)
-             (while (setq e (pop l))
-               (when (and (setq v (symbol-value e))
-                          (stringp v) (string-match "\\S-" v))
-                 (setq n (concat "ARCHIVE_" (upcase (symbol-name e))))
-                 (org-entry-put (point) n v)))))
-
-         ;; Save and kill the buffer, if it is not the same buffer.
-         (when (not (eq this-buffer buffer))
-           (save-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))
-      (when (featurep 'org-inlinetask)
-       (org-inlinetask-remove-END-maybe))
-      (setq org-markers-to-move nil)
-      (message "Subtree archived %s"
-              (if (eq this-buffer buffer)
-                  (concat "under heading: " heading)
-                (concat "in file: " (abbreviate-file-name afile))))))
-  (org-reveal)
-  (if (looking-at "^[ \t]*$")
-      (outline-next-visible-heading 1)))
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
+                   'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        `(progn (setq org-map-continue-from (progn (org-back-to-heading) (point)))
+                (org-archive-subtree ,find-done))
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (if find-done
+       (org-archive-all-done)
+      ;; Save all relevant TODO keyword-relatex variables
+      (let ((tr-org-todo-line-regexp org-todo-line-regexp) ; keep despite compiler
+           (tr-org-todo-keywords-1 org-todo-keywords-1)
+           (tr-org-todo-kwd-alist org-todo-kwd-alist)
+           (tr-org-done-keywords org-done-keywords)
+           (tr-org-todo-regexp org-todo-regexp)
+           (tr-org-todo-line-regexp org-todo-line-regexp)
+           (tr-org-odd-levels-only org-odd-levels-only)
+           (this-buffer (current-buffer))
+           ;; start of variables that will be used for saving context
+           ;; The compiler complains about them - keep them anyway!
+           (file (abbreviate-file-name
+                  (or (buffer-file-name (buffer-base-buffer))
+                      (error "No file associated to buffer"))))
+           (olpath (mapconcat 'identity (org-get-outline-path) "/"))
+           (time (format-time-string
+                  (substring (cdr org-time-stamp-formats) 1 -1)
+                  (current-time)))
+           category todo priority ltags itags atags
+           ;; end of variables that will be used for saving context
+           location afile heading buffer level newfile-p infile-p visiting)
+
+       ;; Find the local archive location
+       (setq location (org-get-local-archive-location)
+             afile (org-extract-archive-file location)
+             heading (org-extract-archive-heading location)
+             infile-p (equal file (abbreviate-file-name afile)))
+       (unless afile
+         (error "Invalid `org-archive-location'"))
+
+       (if (> (length afile) 0)
+           (setq newfile-p (not (file-exists-p 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))
+       (if (and (> (length heading) 0)
+                (string-match "^\\*+" heading))
+           (setq level (match-end 0))
+         (setq heading nil level 0))
+       (save-excursion
+         (org-back-to-heading t)
+         ;; Get context information that will be lost by moving the tree
+         (setq category (org-get-category nil 'force-refresh)
+               todo (and (looking-at org-todo-line-regexp)
+                         (match-string 2))
+               priority (org-get-priority
+                         (if (match-end 3) (match-string 3) ""))
+               ltags (org-get-tags)
+               itags (org-delete-all ltags (org-get-tags-at))
+               atags (org-get-tags-at))
+         (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,
+         ;; which would lead to duplication of subtrees
+         (let (this-command) (org-copy-subtree 1 nil t))
+         (set-buffer buffer)
+         ;; Enforce org-mode for the archive buffer
+         (if (not (eq major-mode 'org-mode))
+             ;; Force the mode for future visits.
+             (let ((org-insert-mode-line-in-empty-file t)
+                   (org-inhibit-startup t))
+               (call-interactively 'org-mode)))
+         (when newfile-p
+           (goto-char (point-max))
+           (insert (format "\nArchived entries from file %s\n\n"
+                           (buffer-file-name this-buffer))))
+         ;; Force the TODO keywords of the original buffer
+         (let ((org-todo-line-regexp tr-org-todo-line-regexp)
+               (org-todo-keywords-1 tr-org-todo-keywords-1)
+               (org-todo-kwd-alist tr-org-todo-kwd-alist)
+               (org-done-keywords tr-org-done-keywords)
+               (org-todo-regexp tr-org-todo-regexp)
+               (org-todo-line-regexp tr-org-todo-line-regexp)
+               (org-odd-levels-only
+                (if (local-variable-p 'org-odd-levels-only (current-buffer))
+                    org-odd-levels-only
+                  tr-org-odd-levels-only)))
+           (goto-char (point-min))
+           (show-all)
+           (if heading
+               (progn
+                 (if (re-search-forward
+                      (concat "^" (regexp-quote heading)
+                              (org-re "[ \t]*\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\($\\|\r\\)"))
+                      nil t)
+                     (goto-char (match-end 0))
+                   ;; Heading not found, just insert it at the end
+                   (goto-char (point-max))
+                   (or (bolp) (insert "\n"))
+                   (insert "\n" heading "\n")
+                   (end-of-line 0))
+                 ;; Make the subtree visible
+                 (show-subtree)
+                 (if org-archive-reversed-order
+                     (progn
+                       (org-back-to-heading t)
+                       (outline-next-heading))
+                   (org-end-of-subtree t))
+                 (skip-chars-backward " \t\r\n")
+                 (and (looking-at "[ \t\r\n]*")
+                      (replace-match "\n\n")))
+             ;; No specific heading, just go to end of file.
+             (goto-char (point-max)) (insert "\n"))
+           ;; Paste
+           (org-paste-subtree (org-get-valid-level level (and heading 1)))
+           ;; Shall we append inherited tags?
+           (and itags
+                (or (and (eq org-archive-subtree-add-inherited-tags 'infile)
+                         infile-p)
+                    (eq org-archive-subtree-add-inherited-tags t))
+                (org-set-tags-to atags))
+           ;; Mark the entry as done
+           (when (and org-archive-mark-done
+                      (looking-at org-todo-line-regexp)
+                      (or (not (match-end 2))
+                          (not (member (match-string 2) org-done-keywords))))
+             (let (org-log-done org-todo-log-states)
+               (org-todo
+                (car (or (member org-archive-mark-done org-done-keywords)
+                         org-done-keywords)))))
+
+           ;; Add the context info
+           (when org-archive-save-context-info
+             (let ((l org-archive-save-context-info) e n v)
+               (while (setq e (pop l))
+                 (when (and (setq v (symbol-value e))
+                            (stringp v) (string-match "\\S-" v))
+                   (setq n (concat "ARCHIVE_" (upcase (symbol-name e))))
+                   (org-entry-put (point) n v)))))
+
+           ;; Save and kill the buffer, if it is not the same buffer.
+           (when (not (eq this-buffer buffer))
+             (save-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))
+       (when (featurep 'org-inlinetask)
+         (org-inlinetask-remove-END-maybe))
+       (setq org-markers-to-move nil)
+       (message "Subtree archived %s"
+                (if (eq this-buffer buffer)
+                    (concat "under heading: " heading)
+                  (concat "in file: " (abbreviate-file-name afile))))))
+    (org-reveal)
+    (if (looking-at "^[ \t]*$")
+       (outline-next-visible-heading 1))))
 
 (defun org-archive-to-archive-sibling ()
   "Archive the current heading by moving it under the archive sibling.
@@ -350,69 +357,83 @@ The archive sibling is a sibling of the heading with the heading name
 `org-archive-sibling-heading' and an `org-archive-tag' tag.  If this
 sibling does not exist, it will be created at the end of the subtree."
   (interactive)
-  (save-restriction
-    (widen)
-    (let (b e pos leader level)
-      (org-back-to-heading t)
-      (looking-at outline-regexp)
-      (setq leader (match-string 0)
-           level (funcall outline-level))
-      (setq pos (point))
-      (condition-case nil
-         (outline-up-heading 1 t)
-       (error (setq e (point-max)) (goto-char (point-min))))
-      (setq b (point))
-      (unless e
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (when (eq org-loop-over-headlines-in-active-region 'start-level)
+                 'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        '(progn (setq org-map-continue-from
+                      (progn (org-back-to-heading)
+                             (if (looking-at (concat "^.*:" org-archive-tag ":.*$"))
+                                 (org-end-of-subtree t)
+                               (point))))
+                (when (org-at-heading-p)
+                  (org-archive-to-archive-sibling)))
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (save-restriction
+      (widen)
+      (let (b e pos leader level)
+       (org-back-to-heading t)
+       (looking-at org-outline-regexp)
+       (setq leader (match-string 0)
+             level (funcall outline-level))
+       (setq pos (point))
        (condition-case nil
-           (org-end-of-subtree t t)
-         (error (goto-char (point-max))))
-       (setq e (point)))
-      (goto-char b)
-      (unless (re-search-forward
-              (concat "^" (regexp-quote leader)
-                      "[ \t]*"
-                      org-archive-sibling-heading
-                      "[ \t]*:"
-                      org-archive-tag ":") e t)
-       (goto-char e)
-       (or (bolp) (newline))
-       (insert leader org-archive-sibling-heading "\n")
-       (beginning-of-line 0)
-       (org-toggle-tag org-archive-tag 'on))
-      (beginning-of-line 1)
-      (if org-archive-reversed-order
-         (outline-next-heading)
-       (org-end-of-subtree t t))
-      (save-excursion
-       (goto-char pos)
-       (let ((this-command this-command)) (org-cut-subtree)))
-      (org-paste-subtree (org-get-valid-level level 1))
-      (org-set-property
-       "ARCHIVE_TIME"
-       (format-time-string
-       (substring (cdr org-time-stamp-formats) 1 -1)
-       (current-time)))
-      (outline-up-heading 1 t)
-      (hide-subtree)
-      (org-cycle-show-empty-lines 'folded)
-      (goto-char pos)))
-  (org-reveal)
-  (if (looking-at "^[ \t]*$")
-      (outline-next-visible-heading 1)))
+           (outline-up-heading 1 t)
+         (error (setq e (point-max)) (goto-char (point-min))))
+       (setq b (point))
+       (unless e
+         (condition-case nil
+             (org-end-of-subtree t t)
+           (error (goto-char (point-max))))
+         (setq e (point)))
+       (goto-char b)
+       (unless (re-search-forward
+                (concat "^" (regexp-quote leader)
+                        "[ \t]*"
+                        org-archive-sibling-heading
+                        "[ \t]*:"
+                        org-archive-tag ":") e t)
+         (goto-char e)
+         (or (bolp) (newline))
+         (insert leader org-archive-sibling-heading "\n")
+         (beginning-of-line 0)
+         (org-toggle-tag org-archive-tag 'on))
+       (beginning-of-line 1)
+       (if org-archive-reversed-order
+           (outline-next-heading)
+         (org-end-of-subtree t t))
+       (save-excursion
+         (goto-char pos)
+         (let ((this-command this-command)) (org-cut-subtree)))
+       (org-paste-subtree (org-get-valid-level level 1))
+       (org-set-property
+        "ARCHIVE_TIME"
+        (format-time-string
+         (substring (cdr org-time-stamp-formats) 1 -1)
+         (current-time)))
+       (outline-up-heading 1 t)
+       (hide-subtree)
+       (org-cycle-show-empty-lines 'folded)
+       (goto-char pos)))
+    (org-reveal)
+    (if (looking-at "^[ \t]*$")
+       (outline-next-visible-heading 1))))
 
 (defun org-archive-all-done (&optional tag)
   "Archive sublevels of the current tree without open TODO items.
 If the cursor is not on a headline, try all level 1 trees.  If
 it is on a headline, try all direct children.
 When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
-  (let ((re (concat org-outline-regexp-bol "+" org-not-done-regexp)) re1
+  (let ((re org-not-done-heading-regexp) re1
        (rea (concat ".*:" org-archive-tag ":"))
        (begm (make-marker))
        (endm (make-marker))
        (question (if tag "Set ARCHIVE tag (no open TODO items)? "
                    "Move subtree to archive (no open TODO items)? "))
        beg end (cntarch 0))
-    (if (org-on-heading-p)
+    (if (org-at-heading-p)
        (progn
          (setq re1 (concat "^" (regexp-quote
                                 (make-string
@@ -449,20 +470,36 @@ When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
 With prefix ARG, check all children of current headline and offer tagging
 the children that do not contain any open TODO items."
   (interactive "P")
-  (if find-done
-      (org-archive-all-done 'tag)
-    (let (set)
-      (save-excursion
-       (org-back-to-heading t)
-       (setq set (org-toggle-tag org-archive-tag))
-       (when set (hide-subtree)))
-      (and set (beginning-of-line 1))
-      (message "Subtree %s" (if set "archived" "unarchived")))))
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
+                   'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        `(org-toggle-archive-tag ,find-done)
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (if find-done
+       (org-archive-all-done 'tag)
+      (let (set)
+       (save-excursion
+         (org-back-to-heading t)
+         (setq set (org-toggle-tag org-archive-tag))
+         (when set (hide-subtree)))
+       (and set (beginning-of-line 1))
+       (message "Subtree %s" (if set "archived" "unarchived"))))))
 
 (defun org-archive-set-tag ()
   "Set the ARCHIVE tag."
   (interactive)
-  (org-toggle-tag org-archive-tag 'on))
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
+                   'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        'org-archive-set-tag
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (org-toggle-tag org-archive-tag 'on)))
 
 ;;;###autoload
 (defun org-archive-subtree-default ()
@@ -482,6 +519,4 @@ This command is set with the variable `org-archive-default-command'."
 
 (provide 'org-archive)
 
-
-
 ;;; org-archive.el ends here
index d6a4e30714be6072b3853ba32a6bcdef501367bd..154133244806e241a9de5c16fc8fa5a63987e54e 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-ascii.el --- ASCII export for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -145,7 +144,7 @@ command to convert it."
   (interactive "r")
   (let (reg ascii buf pop-up-frames)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
          (setq ascii (org-export-region-as-ascii
                      beg end t 'string))
        (setq reg (buffer-substring beg end)
@@ -284,7 +283,7 @@ publishing directory."
                    "UNTITLED"))
         (email (plist-get opt-plist :email))
         (language (plist-get opt-plist :language))
-        (quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
+        (quote-re0 (concat "^\\(" org-quote-string "\\)\\( +\\|[ \t]*$\\)"))
         (todo nil)
         (lang-words nil)
         (region
@@ -407,7 +406,7 @@ publishing directory."
                                   txt))
                             (setq txt (replace-match "" t t txt)))
                         (if (string-match quote-re0 txt)
-                            (setq txt (replace-match "" t t txt)))
+                            (setq txt (replace-match "" t t txt 1)))
 
                         (if org-export-with-section-numbers
                             (setq txt (concat (org-section-number level)
@@ -725,5 +724,4 @@ publishing directory."
 
 (provide 'org-ascii)
 
-
 ;;; org-ascii.el ends here
index aa8c476e89b0d487d672081a4cca08f66cafd938..0525bee6198412bef5f98c56503903fc6a69d48e 100644 (file)
@@ -4,7 +4,6 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -437,5 +436,4 @@ prefix."
 
 (provide 'org-attach)
 
-
 ;;; org-attach.el ends here
index 8401196c81aad72989c7fd330ecbf9cf4ace0af7..ddb7e4ab8c54cb0f8d9d3ff3231787a678644ea6 100644 (file)
@@ -1,12 +1,11 @@
 ;;; org-bbdb.el --- Support for links to BBDB entries from within Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>,
 ;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 
 (defvar date)   ;; dynamically scoped from Org
 
+;; Support for version 2.35
+(defvar org-bbdb-old (fboundp 'bbdb-record-get-field-internal))
+
 ;; Customization
 
 (defgroup org-bbdb-anniversaries nil
@@ -196,8 +198,11 @@ date year)."
   "Store a link to a BBDB database entry."
   (when (eq major-mode 'bbdb-mode)
     ;; This is BBDB, we make this link!
-    (let* ((name (bbdb-record-name (bbdb-current-record)))
-          (company (bbdb-record-getprop (bbdb-current-record) 'company))
+    (let* ((rec (bbdb-current-record))
+           (name (bbdb-record-name rec))
+          (company (if org-bbdb-old
+                        (bbdb-record-getprop rec 'company)
+                      (car (bbdb-record-get-field rec 'organization))))
           (link (org-make-link "bbdb:" name)))
       (org-store-link-props :type "bbdb" :name name :company company
                            :link link :description name)
@@ -219,24 +224,49 @@ italicized, in all other cases it is left unchanged."
   (require 'bbdb)
   (let ((inhibit-redisplay (not debug-on-error))
        (bbdb-electric-p nil))
-    (catch 'exit
-      ;; Exact match on name
-      (bbdb-name (concat "\\`" name "\\'") nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-      ;; Exact match on name
-      (bbdb-company (concat "\\`" name "\\'") nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-      ;; Partial match on name
-      (bbdb-name name nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-      ;; Partial match on company
-      (bbdb-company name nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-      ;; General match including network address and notes
-      (bbdb name nil)
-      (when (= 0 (buffer-size (get-buffer "*BBDB*")))
-       (delete-window (get-buffer-window "*BBDB*"))
-       (error "No matching BBDB record")))))
+    (if org-bbdb-old
+        (org-bbdb-open-old)
+      (org-bbdb-open-new))))
+
+(defun org-bbdb-open-old ()
+  (catch 'exit
+    ;; Exact match on name
+    (bbdb-name (concat "\\`" name "\\'") nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; Exact match on name
+    (bbdb-company (concat "\\`" name "\\'") nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; Partial match on name
+    (bbdb-name name nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; Partial match on company
+    (bbdb-company name nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; General match including network address and notes
+    (bbdb name nil)
+    (when (= 0 (buffer-size (get-buffer "*BBDB*")))
+      (delete-window (get-buffer-window "*BBDB*"))
+      (error "No matching BBDB record"))))
+
+(defun org-bbdb-open-new ()
+  (catch 'exit
+    ;; Exact match on name
+    (bbdb-search-name (concat "\\`" name "\\'") nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; Exact match on name
+    (bbdb-search-organization (concat "\\`" name "\\'") nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; Partial match on name
+    (bbdb-search-name name nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; Partial match on company
+    (bbdb-search-organization name nil)
+    (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+    ;; General match including network address and notes
+    (bbdb name nil)
+    (when (= 0 (buffer-size (get-buffer "*BBDB*")))
+      (delete-window (get-buffer-window "*BBDB*"))
+      (error "No matching BBDB record"))))
 
 (defun org-bbdb-anniv-extract-date (time-str)
   "Convert YYYY-MM-DD to (month date year).
@@ -357,7 +387,7 @@ This is used by Org to re-create the anniversary hash table."
          (bbdb-record-name (car (bbdb-completing-read-record "Name: ")))))
 
 (defun org-bbdb-anniv-export-ical ()
-  "Extract anniversaries from BBDB and convert them to iCalendar format."
+  "Extract anniversaries from BBDB and convert them to icalendar format."
   (require 'bbdb)
   (require 'diary-lib)
   (unless (hash-table-p org-bbdb-anniv-hash)
@@ -391,6 +421,4 @@ END:VEVENT\n"
 
 (provide 'org-bbdb)
 
-
-
 ;;; org-bbdb.el ends here
index d5f9beea337df2fa1330be6979e1baedce903bdc..d64ce2ddc5a1ec654dc583418cedbb1dd9156a32 100644 (file)
@@ -2,7 +2,6 @@
 ;;
 ;; Copyright (C) 2007-2011 Free Software Foundation, Inc.
 ;;
-;; Version: 7.7
 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex
@@ -400,7 +399,7 @@ the value will be inserted right after the documentclass statement."
       (insert org-beamer-header-extra)
       (or (bolp) (insert "\n"))))))
 
-(defcustom org-beamer-fragile-re "^[ \t]*\\\\begin{\\(verbatim\\|lstlisting\\|minted\\)}"
+(defcustom org-beamer-fragile-re "\\\\\\(verb\\|lstinline\\)\\|^[ \t]*\\\\begin{\\(verbatim\\|lstlisting\\|minted\\)}"
   "If this regexp matches in a frame, the frame is marked as fragile."
   :group 'org-beamer
   :type 'regexp)
@@ -411,7 +410,7 @@ the value will be inserted right after the documentclass statement."
 
 
 ;; Functions to initialize and post-process
-;; These functions will be hooked into various places in the export process
+;; These fuctions will be hooked into various places in the export process
 
 (defun org-beamer-initialize-open-trackers ()
   "Reset variables that track if certain environments are open during export."
@@ -451,7 +450,7 @@ The effect is that these values will be accessible during export."
      ((stringp org-beamer-frame-level-now)
       (setq org-beamer-frame-level-now
            (string-to-number org-beamer-frame-level-now))))
-    ;; Find the header additions, most likely theme commands
+    ;; Find the header additons, most likely theme commands
     (setq org-beamer-header-extra
          (or (and (org-region-active-p)
                   (save-excursion
@@ -632,6 +631,4 @@ include square brackets."
 
 (provide 'org-beamer)
 
-
-
 ;;; org-beamer.el ends here
index 3607458a410bce8a33ba12ca0b3d098f493bde3d..71a3bd07d801bf2dcea981f6e08b77c2a58e860b 100644 (file)
@@ -6,7 +6,6 @@
 ;;         Carsten Dominik <carsten dot dominik at gmail dot com>
 ;;         Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: org, wp, remember
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
     (:pages        . "One or more page numbers or range of numbers, such as 42-111 or 7,41,73-97 or 43+ (the â€˜+’ in this last example indicates pages following that don’t form simple range). BibTEX requires double dashes for page ranges (--).")
     (:publisher    . "The publisher’s name.")
     (:school       . "The name of the school where a thesis was written.")
-    (:series       . "The name of a series or set of books. When citing an entire book, the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
+    (:series       . "The name of a series or set of books. When citing an entire book, the the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
     (:title        . "The work’s title, typed as explained in the LaTeX book.")
     (:type         . "The type of a technical report for example, 'Research Note'.")
     (:volume       . "The volume of a journal or multi-volume book.")
 
 (defcustom org-bibtex-prefix nil
   "Optional prefix for all bibtex property names.
-For example setting to 'BIB_' would allow interoperability with Fireforg."
+For example setting to 'BIB_' would allow interoperability with fireforg."
   :group 'org-bibtex
   :type  'string)
 
@@ -275,12 +274,20 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
   :group 'org-bibtex
   :type '(repeat :tag "Tag" (string)))
 
+(defcustom org-bibtex-type-property-name "btype"
+  "Property in which to store bibtex entry type (e.g., article)."
+  :group 'org-bibtex
+  :type 'string)
+
 \f
 ;;; Utility functions
 (defun org-bibtex-get (property)
   ((lambda (it) (when it (org-babel-trim it)))
-   (or (org-entry-get (point) (upcase property))
-       (org-entry-get (point) (concat org-bibtex-prefix (upcase property))))))
+   (let ((org-special-properties
+         (delete "FILE" (copy-sequence org-special-properties))))
+     (or
+      (org-entry-get (point) (upcase property))
+      (org-entry-get (point) (concat org-bibtex-prefix (upcase property)))))))
 
 (defun org-bibtex-put (property value)
   (let ((prop (upcase (if (keywordp property)
@@ -303,7 +310,7 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
                                    lsts))))
     (let ((notes (buffer-string))
           (id (org-bibtex-get org-bibtex-key-property))
-          (type (org-bibtex-get "type"))
+          (type (org-bibtex-get org-bibtex-type-property-name))
          (tags (when org-bibtex-tags-are-keywords
                  (delq nil
                        (mapcar
@@ -317,16 +324,20 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
         (let ((entry (format
                       "@%s{%s,\n%s\n}\n" type id
                       (mapconcat
-                       (lambda (pair) (format "  %s={%s}" (car pair) (cdr pair)))
+                       (lambda (pair)
+                        (format "  %s={%s}" (car pair) (cdr pair)))
                        (remove nil
                         (if (and org-bibtex-export-arbitrary-fields
                                  org-bibtex-prefix)
                             (mapcar
                              (lambda (kv)
                                (let ((key (car kv)) (val (cdr kv)))
-                                 (when (and (string-match org-bibtex-prefix key)
-                                            (not (string=
-                                                  (downcase (concat org-bibtex-prefix "TYPE")) (downcase key))))
+                                 (when (and
+                                        (string-match org-bibtex-prefix key)
+                                        (not (string=
+                                              (downcase (concat org-bibtex-prefix
+                                                                org-bibtex-type-property-name))
+                                              (downcase key))))
                                    (cons (downcase (replace-regexp-in-string
                                                     org-bibtex-prefix "" key))
                                          val))))
@@ -514,9 +525,20 @@ Headlines are exported using `org-bibtex-export-headline'."
          "Bibtex file: " nil nil nil
          (file-name-nondirectory
           (concat (file-name-sans-extension (buffer-file-name)) ".bib")))))
-  (let ((bibtex-entries (remove nil (org-map-entries #'org-bibtex-headline))))
-    (with-temp-file filename
-      (insert (mapconcat #'identity bibtex-entries "\n")))))
+  ((lambda (error-point)
+     (when error-point
+       (goto-char error-point)
+       (message "Bibtex error at %S" (nth 4 (org-heading-components)))))
+   (catch 'bib
+     (let ((bibtex-entries (remove nil (org-map-entries
+                                       (lambda ()
+                                         (condition-case foo
+                                             (org-bibtex-headline)
+                                           (error (throw 'bib (point)))))))))
+       (with-temp-file filename
+        (insert (mapconcat #'identity bibtex-entries "\n")))
+       (message "Successfully exported %d bibtex entries to %s"
+               (length bibtex-entries) filename) nil))))
 
 (defun org-bibtex-check (&optional optional)
   "Check the current headline for required fields.
@@ -525,7 +547,7 @@ With prefix argument OPTIONAL also prompt for optional fields."
   (save-restriction
     (org-narrow-to-subtree)
     (let ((type ((lambda (name) (when name (intern (concat ":" name))))
-                 (org-bibtex-get "TYPE"))))
+                 (org-bibtex-get org-bibtex-type-property-name))))
       (when type (org-bibtex-fleshout type optional)))))
 
 (defun org-bibtex-check-all (&optional optional)
@@ -542,7 +564,8 @@ If nonew is t, add data to the headline of the entry at point."
                "Type: " (mapcar (lambda (type)
                                   (substring (symbol-name (car type)) 1))
                                 org-bibtex-types)
-               nil nil (when nonew (org-bibtex-get "TYPE"))))
+               nil nil (when nonew
+                         (org-bibtex-get org-bibtex-type-property-name))))
         (type (if (keywordp type) type (intern (concat ":" type))))
         (org-bibtex-treat-headline-as-title (if nonew nil t)))
     (unless (assoc type org-bibtex-types)
@@ -553,7 +576,8 @@ If nonew is t, add data to the headline of the entry at point."
       (let ((title (org-bibtex-ask :title)))
        (insert title)
        (org-bibtex-put "TITLE" title)))
-    (org-bibtex-put "TYPE" (substring (symbol-name type) 1))
+    (org-bibtex-put org-bibtex-type-property-name
+                   (substring (symbol-name type) 1))
     (org-bibtex-fleshout type arg)
     (mapc (lambda (tag) (org-toggle-tag tag 'on)) org-bibtex-tags)))
 
@@ -598,7 +622,7 @@ This uses `bibtex-parse-entry'."
       (org-insert-heading)
       (insert (val :title))
       (org-bibtex-put "TITLE" (val :title))
-      (org-bibtex-put "TYPE"  (downcase (val :type)))
+      (org-bibtex-put org-bibtex-type-property-name (downcase (val :type)))
       (dolist (pair entry)
         (case (car pair)
           (:title    nil)
@@ -637,11 +661,10 @@ This function relies `org-search-view' to locate results."
   (let ((org-agenda-overriding-header "Bib search results:")
         (org-agenda-search-view-always-boolean t))
     (org-search-view nil
-                    (format "%s +{:%sTYPE:}"
-                            string org-bibtex-prefix))))
+                    (format "%s +{:%s%s:}"
+                            string org-bibtex-prefix
+                            org-bibtex-type-property-name))))
 
 (provide 'org-bibtex)
 
-
-
 ;;; org-bibtex.el ends here
index e3a87b77b5cb5bc638bbc1272d11ac7287108772..e0c75b59e9265493a3f4f281f023e95b2d6db8f3 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-capture.el --- Fast note taking in Org-mode
 
-;; Copyright (C) 2010-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -57,6 +56,8 @@
                  (date &optional keep-restriction))
 (declare-function org-table-get-specials "org-table" ())
 (declare-function org-table-goto-line "org-table" (N))
+(declare-function org-pop-to-buffer-same-window "org-compat" 
+                 (&optional buffer-or-name norecord label))
 
 (defvar org-remember-default-headline)
 (defvar org-remember-templates)
@@ -332,7 +333,8 @@ calendar                |  %:type %:date"
 
 (defcustom org-capture-before-finalize-hook nil
   "Hook that is run right before a capture process is finalized.
-The capture buffer is still current when this hook runs."
+The capture buffer is still current when this hook runs and it is
+widened to the entire buffer."
   :group 'org-capture
   :type 'hook)
 
@@ -372,7 +374,7 @@ to avoid conflicts with other active capture processes."
   (plist-get (if local org-capture-current-plist org-capture-plist) prop))
 
 (defun org-capture-member (prop &optional local)
-  "Is PROP a property in `org-capture-plist'.
+  "Is PROP a preperty in `org-capture-plist'.
 When LOCAL is set, use the local variable `org-capture-current-plist',
 this is necessary after initialization of the capture process,
 to avoid conflicts with other active capture processes."
@@ -484,7 +486,7 @@ bypassed."
             (error "Capture template `%s': %s"
                    (org-capture-get :key)
                    (nth 1 error))))
-         (if (and (org-mode-p)
+         (if (and (eq major-mode 'org-mode)
                   (org-capture-get :clock-in))
              (condition-case nil
                  (progn
@@ -574,7 +576,7 @@ captured item after finalizing."
          (org-capture-empty-lines-after
           (or (org-capture-get :empty-lines 'local) 0))))
       ;; Postprocessing:  Update Statistics cookies, do the sorting
-      (when (org-mode-p)
+      (when (eq major-mode 'org-mode)
        (save-excursion
          (when (ignore-errors (org-back-to-heading))
            (org-update-parent-todo-statistics)
@@ -722,7 +724,7 @@ already gone.  Any prefix argument will be passed to the refile command."
        (widen)
        (let ((hd (nth 2 target)))
          (goto-char (point-min))
-         (unless (org-mode-p)
+         (unless (eq major-mode 'org-mode)
            (error
             "Target buffer \"%s\" for file+headline should be in Org mode"
             (current-buffer)))
@@ -754,7 +756,7 @@ already gone.  Any prefix argument will be passed to the refile command."
              (goto-char (if (org-capture-get :prepend)
                             (match-beginning 0) (match-end 0)))
              (org-capture-put :exact-position (point))
-             (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
+             (setq target-entry-p (and (eq major-mode 'org-mode) (org-at-heading-p))))
          (error "No match for target regexp in file %s" (nth 1 target))))
 
        ((memq (car target) '(file+datetree file+datetree+prompt))
@@ -776,7 +778,8 @@ already gone.  Any prefix argument will be passed to the refile command."
            (let ((prompt-time (org-read-date
                                nil t nil "Date for tree entry:"
                                (current-time))))
-             (org-capture-put :prompt-time prompt-time)
+             (org-capture-put :prompt-time prompt-time
+                              :default-time prompt-time)
              (time-to-days prompt-time)))
           (t
            ;; current date, possible corrected for late night workers
@@ -788,12 +791,12 @@ already gone.  Any prefix argument will be passed to the refile command."
        (widen)
        (funcall (nth 2 target))
        (org-capture-put :exact-position (point))
-       (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
+       (setq target-entry-p (and (eq major-mode 'org-mode) (org-at-heading-p))))
 
        ((eq (car target) 'function)
        (funcall (nth 1 target))
        (org-capture-put :exact-position (point))
-       (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
+       (setq target-entry-p (and (eq major-mode 'org-mode) (org-at-heading-p))))
 
        ((eq (car target) 'clock)
        (if (and (markerp org-clock-hd-marker)
@@ -847,6 +850,7 @@ it.  When it is a variable, retrieve the value.  Return whatever we get."
   (goto-char (org-capture-get :pos))
   (org-set-local 'org-capture-target-marker
                 (move-marker (make-marker) (point)))
+  (org-set-local 'outline-level 'org-outline-level)
   (let* ((template (org-capture-get :template))
         (type (org-capture-get :type)))
     (case type
@@ -1146,11 +1150,11 @@ Point will remain at the first line after the inserted text."
     (or (bolp) (newline))
     (setq beg (point))
     (cond
-     ((and (eq type 'entry) (org-mode-p))
+     ((and (eq type 'entry) (eq major-mode 'org-mode))
       (org-capture-verify-tree (org-capture-get :template))
       (org-paste-subtree nil template t))
      ((and (memq type '(item checkitem))
-          (org-mode-p)
+          (eq major-mode 'org-mode)
           (save-excursion (skip-chars-backward " \t\n")
                           (setq pp (point))
                           (org-in-item-p)))
@@ -1199,7 +1203,7 @@ The user is queried for the template."
       (error "No capture template selected"))
     (org-capture-set-plist entry)
     (org-capture-set-target-location)
-    (switch-to-buffer (org-capture-get :buffer))
+    (org-pop-to-buffer-same-window (org-capture-get :buffer))
     (goto-char (org-capture-get :pos))))
 
 (defun org-capture-get-indirect-buffer (&optional buffer prefix)
@@ -1212,8 +1216,10 @@ Use PREFIX as a prefix for the name of the indirect buffer."
       (setq bname (concat prefix "-" (number-to-string (incf n)) "-" base)))
     (condition-case nil
         (make-indirect-buffer buffer bname 'clone)
-      (error (make-indirect-buffer buffer bname)))))
-
+      (error
+       (let ((buf (make-indirect-buffer buffer bname)))
+        (with-current-buffer buf (org-mode))
+        buf)))))
 
 (defun org-capture-verify-tree (tree)
   "Throw error if TREE is not a valid tree"
@@ -1309,7 +1315,7 @@ The template may still contain \"%?\" for cursor positioning."
            (sit-for 1))
     (save-window-excursion
       (delete-other-windows)
-      (switch-to-buffer (get-buffer-create "*Capture*"))
+      (org-pop-to-buffer-same-window (get-buffer-create "*Capture*"))
       (erase-buffer)
       (insert template)
       (goto-char (point-min))
@@ -1411,7 +1417,7 @@ The template may still contain \"%?\" for cursor positioning."
                (or (equal (char-before) ?:) (insert ":"))
                (insert ins)
                (or (equal (char-after) ?:) (insert ":"))
-               (and (org-on-heading-p) (org-set-tags nil 'align)))))
+               (and (org-at-heading-p) (org-set-tags nil 'align)))))
           ((equal char "C")
            (cond ((= (length clipboards) 1) (insert (car clipboards)))
                  ((> (length clipboards) 1)
@@ -1449,7 +1455,7 @@ The template may still contain \"%?\" for cursor positioning."
       (goto-char (point-min))
       (while (looking-at "[ \t]*\n") (replace-match ""))
       (if (re-search-forward "[ \t\n]*\\'" nil t) (replace-match "\n"))
-      ;; Return the expanded template and kill the temporary buffer
+      ;; Return the expanded tempate and kill the temporary buffer
       (untabify (point-min) (point-max))
       (set-buffer-modified-p nil)
       (prog1 (buffer-string) (kill-buffer (current-buffer))))))
@@ -1503,6 +1509,4 @@ The template may still contain \"%?\" for cursor positioning."
 
 (provide 'org-capture)
 
-
-
 ;;; org-capture.el ends here
index 09b646d40ba84e44c0fd47959bb56d996d4c49e8..411e3a4bc35741f4af603f67440b1a56fbde41e5 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-clock.el --- The time clocking code for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -36,6 +35,7 @@
 
 (declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
 (declare-function notifications-notify "notifications" (&rest params))
+(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
 (defvar org-time-stamp-formats)
 (defvar org-ts-what)
 
@@ -328,7 +328,7 @@ to add an effort property.")
   "Hook run when stopping the current clock.")
 
 (defvar org-clock-cancel-hook nil
-  "Hook run when canceling the current clock.")
+  "Hook run when cancelling the current clock.")
 (defvar org-clock-goto-hook nil
   "Hook run when selecting the currently clocked-in entry.")
 (defvar org-clock-has-been-used nil
@@ -346,7 +346,7 @@ to add an effort property.")
 (defvar org-clock-start-time "")
 
 (defvar org-clock-leftover-time nil
-  "If non-nil, user canceled a clock; this is when leftover time started.")
+  "If non-nil, user cancelled a clock; this is when leftover time started.")
 
 (defvar org-clock-effort ""
   "Effort estimate of the currently clocking task.")
@@ -658,7 +658,7 @@ Use alsa's aplay tool if available."
 
 (defun org-program-exists (program-name)
   "Checks whenever we can locate program and launch it."
-  (if (eq system-type 'gnu/linux)
+  (if (member system-type '(gnu/linux darwin))
       (= 0 (call-process "which" nil nil nil program-name))))
 
 (defvar org-clock-mode-line-entry nil
@@ -691,7 +691,7 @@ Use alsa's aplay tool if available."
         (goto-char (car ,clock))
         (beginning-of-line)
         ,@forms))))
-
+(def-edebug-spec org-with-clock-position (form body))
 (put 'org-with-clock-position 'lisp-indent-function 1)
 
 (defmacro org-with-clock (clock &rest forms)
@@ -707,7 +707,7 @@ This macro also protects the current active clock from being altered."
                                  (outline-back-to-heading t)
                                  (point-marker))))
        ,@forms)))
-
+(def-edebug-spec org-with-clock (form body))
 (put 'org-with-clock 'lisp-indent-function 1)
 
 (defsubst org-clock-clock-in (clock &optional resume start-time)
@@ -1066,7 +1066,7 @@ the clocking selection, associated with the letter `d'."
 
       ;; Clock in at which position?
       (setq target-pos
-           (if (and (eobp) (not (org-on-heading-p)))
+           (if (and (eobp) (not (org-at-heading-p)))
                (point-at-bol 0)
              (point)))
       (run-hooks 'org-clock-in-prepare-hook)
@@ -1115,9 +1115,9 @@ the clocking selection, associated with the letter `d'."
            (cond
             ((and org-clock-in-resume
                   (looking-at
-                   (concat "^[ \t]* " org-clock-string
+                   (concat "^[ \t]*" org-clock-string
                            " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-                           " +\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
+                           " *\\sw+\.? +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
              (message "Matched %s" (match-string 1))
              (setq ts (concat "[" (match-string 1) "]"))
              (goto-char (match-end 1))
@@ -1247,9 +1247,9 @@ line and position cursor in that line."
       (goto-char beg)
       (when (and find-unclosed
                 (re-search-forward
-                 (concat "^[ \t]* " org-clock-string
+                 (concat "^[ \t]*" org-clock-string
                          " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-                         " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
+                         " *\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")
                  end t))
        (beginning-of-line 1)
        (throw 'exit t))
@@ -1261,7 +1261,7 @@ line and position cursor in that line."
            (and (re-search-forward org-property-end-re nil t)
                 (goto-char (match-beginning 0))))
        (throw 'exit t))
-      ;; Let's count the CLOCK lines
+      ;; Lets count the CLOCK lines
       (goto-char beg)
       (while (re-search-forward re end t)
        (setq first (or first (match-beginning 0))
@@ -1497,7 +1497,7 @@ With prefix arg SELECT, offer recently clocked tasks for selection."
              (setq recent t)
              (car org-clock-history))
             (t (error "No active or recent clock task")))))
-    (switch-to-buffer (marker-buffer m))
+    (org-pop-to-buffer-same-window (marker-buffer m))
     (if (or (< m (point-min)) (> m (point-max))) (widen))
     (goto-char m)
     (org-show-entry)
@@ -1696,7 +1696,9 @@ from the `before-change-functions' in the current buffer."
   "Clock out if the current entry contains the running clock.
 This is used to stop the clock after a TODO entry is marked DONE,
 and is only done if the variable `org-clock-out-when-done' is not nil."
-  (when (and org-clock-out-when-done
+  (when (and (org-clocking-p)
+            org-clock-out-when-done
+            (marker-buffer org-clock-marker)
             (or (and (eq t org-clock-out-when-done)
                      (member state org-done-keywords))
                 (and (listp org-clock-out-when-done)
@@ -1998,7 +2000,8 @@ the currently selected interval size."
                         (encode-time 0 0 0 (+ d n) m y))))
           ((and wp (string-match "w\\|W" wp) mw (> (length wp) 0))
            (require 'cal-iso)
-           (setq date (calendar-gregorian-from-absolute (calendar-absolute-from-iso (list (+ mw n) 1 y))))
+           (setq date (calendar-gregorian-from-absolute 
+                      (calendar-absolute-from-iso (list (+ mw n) 1 y))))
            (setq ins (format-time-string
                       "%G-W%V"
                       (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date)))))
@@ -2014,7 +2017,8 @@ the currently selected interval size."
                (setq mw 5
                      y (- y 1))
              ())
-           (setq date (calendar-gregorian-from-absolute (calendar-absolute-from-iso (org-quarter-to-date (+ mw n) y))))
+           (setq date (calendar-gregorian-from-absolute 
+                      (calendar-absolute-from-iso (org-quarter-to-date (+ mw n) y))))
            (setq ins (format-time-string
                       (concatenate 'string (number-to-string y) "-Q" (number-to-string (+ mw n)))
                       (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date)))))
@@ -2050,7 +2054,6 @@ the currently selected interval size."
                          'org-clocktable-write-default))
           cc range-text ipos pos one-file-with-archives
           scope-is-list tbls level)
-
       ;; Check if we need to do steps
       (when block
        ;; Get the range text for the header
@@ -2125,7 +2128,7 @@ the currently selected interval size."
   "Write out a clock table at position IPOS in the current buffer.
 TABLES is a list of tables with clocking data as produced by
 `org-clock-get-table-data'.  PARAMS is the parameter property list obtained
-from the dynamic block definition."
+from the dynamic block defintion."
   ;; This function looks quite complicated, mainly because there are a
   ;; lot of options which can add or remove columns.  I have massively
   ;; commented this function, the I hope it is understandable.  If
@@ -2638,6 +2641,5 @@ The details of what will be saved are regulated by the variable
 
 (provide 'org-clock)
 
-
-
 ;;; org-clock.el ends here
+
index 0f6fc0bed6a3ba66cf0b0b95158335d1f94e6df8..c62c6835d3f5959f6b3ee403f26ab64c62aaf9ef 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-colview.el --- Column View in Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -187,7 +186,7 @@ This is the compiled version of the format.")
                    (cons "ITEM"
                          ;; When in a buffer, get the whole line,
                          ;; we'll clean it later…
-                         (if (org-mode-p)
+                         (if (eq major-mode 'org-mode)
                              (save-match-data
                                (org-no-properties
                                 (org-remove-tabs
@@ -209,9 +208,9 @@ This is the compiled version of the format.")
                          (funcall org-columns-modify-value-for-display-function
                                   title val))
                         ((equal property "ITEM")
-                         (if (org-mode-p)
-                             (org-columns-cleanup-item
-                              val org-columns-current-fmt-compiled)))
+                         (org-columns-cleanup-item
+                          val org-columns-current-fmt-compiled
+                          (or org-complex-heading-regexp cphr)))
                         ((and calc (functionp calc)
                               (not (string= val ""))
                               (not (get-text-property 0 'org-computed val)))
@@ -341,24 +340,28 @@ for the duration of the command.")
       (when (local-variable-p 'org-colview-initial-truncate-line-value)
        (setq truncate-lines org-colview-initial-truncate-line-value)))))
 
-(defun org-columns-cleanup-item (item fmt)
-  "Remove from ITEM what is a column in the format FMT."
-  (if (not org-complex-heading-regexp)
-      item
-    (when (string-match org-complex-heading-regexp 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-cleanup-item (item fmt cphr)
+  "Remove from ITEM what is a column in the format FMT.
+CPHR is the complex heading regexp to use for parsing ITEM."
+  (let (fixitem)
+    (if (not cphr)
+       item
+      (unless (string-match "^\*+ " item)
+       (setq item (concat "* " item) fixitem t))
+      (if (string-match cphr 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))
+      (if fixitem (replace-regexp-in-string "^\*+ " "" item) item))))
 
 (defun org-columns-compact-links (s)
   "Replace [[link][desc]] with [desc] or [link]."
@@ -494,7 +497,7 @@ Where possible, use the standard interface for changing this line."
                (org-columns-eval eval))
            (org-columns-display-here)))
        (org-move-to-column col)
-       (if (and (org-mode-p)
+       (if (and (eq major-mode 'org-mode)
                 (nth 3 (assoc key org-columns-current-fmt-compiled)))
            (org-columns-update key)))))))
 
@@ -544,7 +547,7 @@ Where possible, use the standard interface for changing this line."
       (beginning-of-line 1)
       ;; `next-line' is needed here, because it skips invisible line.
       (condition-case nil (org-no-warnings (next-line 1)) (error nil))
-      (setq hidep (org-on-heading-p 1)))
+      (setq hidep (org-at-heading-p 1)))
     (eval form)
     (and hidep (hide-entry))))
 
@@ -872,7 +875,7 @@ display, or in the #+COLUMNS line of the current buffer."
              (replace-match (concat "#+COLUMNS: " fmt) t t))
            (unless (> cnt 0)
              (goto-char (point-min))
-             (or (org-on-heading-p t) (outline-next-heading))
+             (or (org-at-heading-p t) (outline-next-heading))
              (let ((inhibit-read-only t))
                (insert-before-markers "#+COLUMNS: " fmt "\n")))
            (org-set-local 'org-columns-default-format fmt))))))
@@ -1000,7 +1003,7 @@ Don't set this, this is meant for dynamic scoping.")
       (if (marker-position org-columns-begin-marker)
          (goto-char org-columns-begin-marker))
       (org-columns-remove-overlays)
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
          (call-interactively 'org-columns)
        (org-agenda-redo)
        (call-interactively 'org-agenda-columns)))
@@ -1139,6 +1142,8 @@ calc         function to get values from base elements"
 
 ;;; Dynamic block for Column view
 
+(defvar org-heading-regexp) ; defined in org.el
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
 (defun org-columns-capture-view (&optional maxlevel skip-empty-rows)
   "Get the column view of the current buffer or subtree.
 The first optional argument MAXLEVEL sets the level limit.  A
@@ -1149,11 +1154,12 @@ containing the title row and all other rows.  Each row is a list
 of fields."
   (save-excursion
     (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled))
-          (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>"))
+          (re-comment (format org-heading-keyword-regexp-format
+                              org-comment-string))
           (re-archive (concat ".*:" org-archive-tag ":"))
           (n (length title)) row tbl)
       (goto-char (point-min))
-      (while (re-search-forward "^\\(\\*+\\) " nil t)
+      (while (re-search-forward org-heading-regexp nil t)
        (catch 'next
          (when (and (or (null maxlevel)
                         (>= maxlevel
@@ -1525,6 +1531,4 @@ The string should be two numbers joined with a \"-\"."
 
 (provide 'org-colview)
 
-
-
 ;;; org-colview.el ends here
index 5e4935caa7e1e36d153ada1bd1553f602bdfbf70..c053758bdd9ebb840660253ef7ee5e9128034d57 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-compat.el --- Compatibility code for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -252,8 +251,12 @@ Works on both Emacs and XEmacs."
   (defun org-activate-mark ()
     (when (mark t)
       (setq mark-active t)
-      (unless transient-mark-mode
-       (setq transient-mark-mode 'lambda)))))
+      (when (and (boundp 'transient-mark-mode)
+                (not transient-mark-mode))
+       (setq transient-mark-mode 'lambda))
+      (when (boundp 'zmacs-regions)
+       (setq zmacs-regions t)))))
+
 
 ;; Invisibility compatibility
 
@@ -272,7 +275,7 @@ Works on both Emacs and XEmacs."
     nil))
 
 (defmacro org-xemacs-without-invisibility (&rest body)
-  "Turn off extents with invisibility while executing BODY."
+  "Turn off exents with invisibility while executing BODY."
   `(let ((ext-inv (extent-list nil (point-at-bol) (point-at-eol)
                               'all-extents-closed-open 'invisible))
         ext-inv-specs)
@@ -285,6 +288,7 @@ Works on both Emacs and XEmacs."
      (dolist (ext-inv-spec ext-inv-specs)
        (set-extent-property (car ext-inv-spec) 'invisible
                            (cadr ext-inv-spec)))))
+(def-edebug-spec org-xemacs-without-invisibility (body))
 
 (defun org-indent-to-column (column &optional minimum buffer)
   "Work around a bug with extents with invisibility in XEmacs."
@@ -432,8 +436,15 @@ With two arguments, return floor and remainder of their quotient."
   (let ((q (floor x y)))
     (list q (- x (if y (* y q) q)))))
 
-(provide 'org-compat)
-
+;; `pop-to-buffer-same-window' has been introduced with Emacs 24.1.
+(defun org-pop-to-buffer-same-window
+  (&optional buffer-or-name norecord label)
+  "Pop to buffer specified by BUFFER-OR-NAME in the selected window."
+  (if (fboundp 'pop-to-buffer-same-window)
+      (funcall
+       'pop-to-buffer-same-window buffer-or-name norecord)
+    (funcall 'switch-to-buffer buffer-or-name norecord)))
 
+(provide 'org-compat)
 
 ;;; org-compat.el ends here
index b260391a0dab3c66d4857b45a4e31263f3a8ddfe..f7644048f486d641e8b68ca517259ba7addea671 100644 (file)
@@ -4,7 +4,6 @@
 
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-crypt.el
-;; Version: 7.7
 ;; Keywords: org-mode
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: Peter Jones <pjones@pmade.com>
@@ -117,6 +116,35 @@ nil      : Leave auto-save-mode enabled.
                  (const :tag "Ask"     ask)
                  (const :tag "Encrypt" encrypt)))
 
+(defun org-crypt-check-auto-save ()
+  "Check whether auto-save-mode is enabled for the current buffer.
+
+`auto-save-mode' may cause leakage when decrypting entries, so
+check whether it's enabled, and decide what to do about it.
+
+See `org-crypt-disable-auto-save'."
+  (when buffer-auto-save-file-name
+    (cond
+     ((or
+       (eq org-crypt-disable-auto-save t)
+       (and
+       (eq org-crypt-disable-auto-save 'ask)
+       (y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? ")))
+      (message (concat "org-decrypt: Disabling auto-save-mode for " (or (buffer-file-name) (current-buffer))))
+      ; The argument to auto-save-mode has to be "-1", since
+      ; giving a "nil" argument toggles instead of disabling.
+      (auto-save-mode -1))
+     ((eq org-crypt-disable-auto-save nil)
+      (message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))
+     ((eq org-crypt-disable-auto-save 'encrypt)
+      (message "org-decrypt: Enabling re-encryption on auto-save.")
+      (add-hook 'auto-save-hook
+               (lambda ()
+                 (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
+                 (org-encrypt-entries))
+               nil t))
+     (t nil))))
+
 (defun org-crypt-key-for-heading ()
   "Return the encryption key for the current heading."
   (save-excursion
@@ -165,30 +193,6 @@ nil      : Leave auto-save-mode enabled.
 (defun org-decrypt-entry ()
   "Decrypt the content of the current headline."
   (interactive)
-
-  ; auto-save-mode may cause leakage, so check whether it's enabled.
-  (when buffer-auto-save-file-name
-    (cond
-     ((or
-       (eq org-crypt-disable-auto-save t)
-       (and
-        (eq org-crypt-disable-auto-save 'ask)
-        (y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? ")))
-      (message (concat "org-decrypt: Disabling auto-save-mode for " (or (buffer-file-name) (current-buffer))))
-      ; The argument to auto-save-mode has to be "-1", since
-      ; giving a "nil" argument toggles instead of disabling.
-      (auto-save-mode -1))
-     ((eq org-crypt-disable-auto-save nil)
-      (message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))
-     ((eq org-crypt-disable-auto-save 'encrypt)
-      (message "org-decrypt: Enabling re-encryption on auto-save.")
-      (add-hook 'auto-save-hook
-                (lambda ()
-                  (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
-                  (org-encrypt-entries))
-                nil t))
-     (t nil)))
-
   (require 'epg)
   (unless (org-before-first-heading-p)
     (save-excursion
@@ -200,6 +204,7 @@ nil      : Leave auto-save-mode enabled.
               (outline-invisible-p))))
        (forward-line)
        (when (looking-at "-----BEGIN PGP MESSAGE-----")
+         (org-crypt-check-auto-save)
          (let* ((end (save-excursion
                        (search-forward "-----END PGP MESSAGE-----")
                        (forward-line)
@@ -252,6 +257,4 @@ nil      : Leave auto-save-mode enabled.
 
 (provide 'org-crypt)
 
-
-
 ;;; org-crypt.el ends here
index d567b9290561624cd38abcdef54b72890f92376b..609c09414232c51d95c30badbf6fcbd2b3c583a1 100644 (file)
@@ -3,10 +3,9 @@
 ;; Copyright (C) 2007-2011 Free Software Foundation, Inc.
 
 ;; Author: Paul Sexton <eeeickythump@gmail.com>
-;; Version: 7.7
+
 
 ;; Keywords: org, wp
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -36,7 +35,7 @@
 ;; links to these 'tagged' destinations, allowing seamless navigation between
 ;; multiple org-mode files. Topics can be created in any org mode file and
 ;; will always be found by plain links from other files. Other file types
-;; recognized by ctags (source code files, latex files, etc) will also be
+;; recognised by ctags (source code files, latex files, etc) will also be
 ;; available as destinations for plain links, and similarly, org-mode links
 ;; will be available as tags from source files. Finally, the function
 ;; `org-ctags-find-tag-interactive' lets you choose any known tag, using
 ;; with the same name as the link; then, if unsuccessful, ask the user if
 ;; he/she wants to rebuild the 'TAGS' database and try again; then ask if
 ;; the user wishes to append 'tag' as a new toplevel heading at the end of
-;; the buffer; and finally, defer to org's default behavior which is to
+;; the buffer; and finally, defer to org's default behaviour which is to
 ;; search the entire text of the current buffer for 'tag'.
 ;;
-;; This behavior can be modified by changing the value of
+;; This behaviour can be modified by changing the value of
 ;; ORG-CTAGS-OPEN-LINK-FUNCTIONS. For example I have the following in my
-;; .emacs, which describes the same behavior as the above paragraph with
+;; .emacs, which describes the same behaviour as the above paragraph with
 ;; one difference:
 ;;
 ;; (setq org-ctags-open-link-functions
 ;;       '(org-ctags-find-tag
 ;;         org-ctags-ask-rebuild-tags-file-then-find-tag
 ;;         org-ctags-ask-append-topic
-;;         org-ctags-fail-silently))  ; <-- prevents org default behavior
+;;         org-ctags-fail-silently))  ; <-- prevents org default behaviour
 ;;
 ;;
 ;; Usage
 
 (require 'org)
 
+(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
+
 (defgroup org-ctags nil
   "Options concerning use of ctags within org mode."
   :tag "Org-Ctags"
@@ -305,7 +306,7 @@ The new topic will be titled NAME (or TITLE if supplied)."
                            activate compile)
   "Before trying to find a tag, save our current position on org mark ring."
   (save-excursion
-    (if (and (org-mode-p) org-ctags-enabled-p)
+    (if (and (eq major-mode 'org-mode) org-ctags-enabled-p)
         (org-mark-ring-push))))
 
 
@@ -385,7 +386,7 @@ the new file."
     (cond
      ((get-buffer (concat name ".org"))
       ;; Buffer is already open
-      (switch-to-buffer (get-buffer (concat name ".org"))))
+      (org-pop-to-buffer-same-window (get-buffer (concat name ".org"))))
      ((file-exists-p filename)
       ;; File exists but is not open --> open it
       (message "Opening existing org file `%S'..."
@@ -537,5 +538,4 @@ a new topic."
 
 (provide 'org-ctags)
 
-
 ;;; org-ctags.el ends here
index f02f37898236e35e3644b50a72aa28b774ca8b4b..ae3d04a24fa031114e214783a251cd0e87f6bd63 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -195,6 +194,4 @@ before running this command, even though the command tries to be smart."
 
 (provide 'org-datetree)
 
-
-
 ;;; org-datetree.el ends here
index f964a93fa1ca6e187fa507a2b2f50388f4dac61b..6b103543a31729fa5294a12461ae0750d4792cb7 100644 (file)
@@ -4,7 +4,6 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-docbook.el
-;; Version: 7.7
 ;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
 ;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
 ;; Keywords: org, wp, docbook
@@ -294,7 +293,7 @@ then use this command to convert it."
   (interactive "r")
   (let (reg docbook buf)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
          (setq docbook (org-export-region-as-docbook
                         beg end t 'string))
        (setq reg (buffer-substring beg end)
@@ -394,6 +393,8 @@ in a window.  A non-interactive call will only return the buffer."
        (org-open-file pdffile)
       (error "PDF file was not produced"))))
 
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
+
 ;;;###autoload
 (defun org-export-as-docbook (&optional hidden ext-plist
                                        to-buffer body-only pub-dir)
@@ -475,9 +476,11 @@ publishing directory."
         (current-dir (if buffer-file-name
                          (file-name-directory buffer-file-name)
                        default-directory))
+        (auto-insert nil); Avoid any auto-insert stuff for the new file
         (buffer (if to-buffer
                     (cond
-                     ((eq to-buffer 'string) (get-buffer-create "*Org DocBook Export*"))
+                     ((eq to-buffer 'string)
+                      (get-buffer-create "*Org DocBook Export*"))
                      (t (get-buffer-create to-buffer)))
                   (find-file-noselect filename)))
         ;; org-levels-open is a global variable
@@ -499,8 +502,9 @@ publishing directory."
         ;; We will use HTML table formatter to export tables to DocBook
         ;; format, so need to set html-table-tag here.
         (html-table-tag (plist-get opt-plist :html-table-tag))
-        (quote-re0   (concat "^[ \t]*" org-quote-string "\\>"))
-        (quote-re    (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
+        (quote-re0   (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
+        (quote-re    (format org-heading-keyword-regexp-format
+                             org-quote-string))
         (inquote     nil)
         (infixed     nil)
         (inverse     nil)
@@ -970,7 +974,7 @@ publishing directory."
                    (push (cons num 1) footref-seen))))))
 
          (cond
-          ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
+          ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
            ;; This is a headline
            (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
                                         level-offset))
@@ -1445,5 +1449,4 @@ the alist of previous items."
 
 (provide 'org-docbook)
 
-
 ;;; org-docbook.el ends here
index 201567251d7c7c36fde5715656c72eee442b453b..cf1801f2b53718e612cd3798c5ed2c3515ff72f1 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Jan Böcker <jan.boecker at jboecker dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -88,6 +87,4 @@ and append it."
 
 (provide 'org-docview)
 
-
-
 ;;; org-docview.el ends here
index 1e7fd627a17fd9e18155470d453ab3bca081b5c3..eb6994e712f7c41159465bebfa64af217d56a089 100644 (file)
@@ -6,7 +6,6 @@
 ;;         Ulf Stegemann <ulf at zeitform dot de>
 ;; Keywords: outlines, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -568,6 +567,4 @@ Kind can be any of `latex', `html', `ascii', `latin1', or `utf8'."
 ;; coding: utf-8
 ;; End:
 
-
-
 ;;; org-entities.el ends here
diff --git a/lisp/org/org-eshell.el b/lisp/org/org-eshell.el
new file mode 100644 (file)
index 0000000..5486b1e
--- /dev/null
@@ -0,0 +1,64 @@
+;;; org-eshell.el - Support for links to working directories in eshell
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+;;
+;; Author: Konrad Hinsen <konrad.hinsen AT fastmail.net>
+;; Version: 0.1
+;;
+;; This file is part of GNU Emacs.
+;;
+;; Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'org)
+(require 'eshell)
+(require 'esh-mode)
+
+(org-add-link-type "eshell" 'org-eshell-open)
+(add-hook 'org-store-link-functions 'org-eshell-store-link)
+
+(defun org-eshell-open (link)
+  "Switch to am eshell buffer and execute a command line.
+   The link can be just a command line (executed in the default
+   eshell buffer) or a command line prefixed by a buffer name
+   followed by a colon."
+  (let* ((buffer-and-command
+          (if (string-match "\\([A-Za-z0-9-+*]+\\):\\(.*\\)" link)
+            (list (match-string 1 link)
+                  (match-string 2 link))
+            (list eshell-buffer-name link)))
+         (eshell-buffer-name (car buffer-and-command))
+         (command (cadr buffer-and-command)))
+     (if (get-buffer eshell-buffer-name)
+       (org-pop-to-buffer-same-window eshell-buffer-name)
+       (eshell))
+     (end-of-buffer)
+     (eshell-kill-input)
+     (insert command)
+     (eshell-send-input)))
+
+(defun org-eshell-store-link ()
+  "Store a link that, when opened, switches back to the current eshell buffer
+   and the current working directory."
+  (when (eq major-mode 'eshell-mode)
+    (let* ((command (concat "cd " dired-directory))
+           (link  (concat (buffer-name) ":" command)))
+      (org-store-link-props
+       :link (org-make-link "eshell:" link)
+       :description command))))
+
+(provide 'org-eshell)
+
+;;; org-eshell.el ends here
index 398da3859d054e65a9b809b9a51e0f258852e435..3396d5812a7c65aba8d50f7418686cb8f8a05c09 100644 (file)
@@ -1,9 +1,8 @@
 ;;; org-exp-blocks.el --- pre-process blocks when exporting org files
 
-;; Copyright (C) 2009-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -176,10 +175,10 @@ which defaults to the value of `org-export-blocks-witheld'."
        (setq start (point))
        (let ((beg-re "^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]"))
          (while (re-search-forward beg-re nil t)
-           (let* ((match-start (match-beginning 0))
-                  (body-start (match-end 0))
+           (let* ((match-start (copy-marker (match-beginning 0)))
+                  (body-start (copy-marker (match-end 0)))
                   (indentation (length (match-string 1)))
-                  (inner-re (format "[\r\n]*[ \t]*#\\+\\(begin\\|end\\)_%s"
+                  (inner-re (format "^[ \t]*#\\+\\(begin\\|end\\)_%s"
                                     (regexp-quote (downcase (match-string 2)))))
                   (type (intern (downcase (match-string 2))))
                   (headers (save-match-data
@@ -196,7 +195,7 @@ which defaults to the value of `org-export-blocks-witheld'."
              (when (not (zerop balanced))
                (error "unbalanced begin/end_%s blocks with %S"
                       type (buffer-substring match-start (point))))
-             (setq match-end (match-end 0))
+             (setq match-end (copy-marker (match-end 0)))
              (unless preserve-indent
                (setq body (save-match-data (org-remove-indentation
                                             (buffer-substring
@@ -211,7 +210,11 @@ which defaults to the value of `org-export-blocks-witheld'."
                    (delete-region match-start match-end)
                    (goto-char match-start) (insert replacement)
                    (unless preserve-indent
-                     (indent-code-rigidly match-start (point) indentation))))))
+                     (indent-code-rigidly match-start (point) indentation)))))
+             ;; cleanup markers
+             (set-marker match-start nil)
+             (set-marker body-start nil)
+             (set-marker match-end nil))
            (setq start (point))))
        (interblock start (point-max))
        (run-hooks 'org-export-blocks-postblock-hook)))))
@@ -376,5 +379,4 @@ other backends, it converts the comment into an EXAMPLE segment."
 
 (provide 'org-exp-blocks)
 
-
 ;;; org-exp-blocks.el ends here
index 20275714a0e7d7b3c015007cf218f7188d0c30ee..8a7ca622759e758194cc607588a617e8f4073998 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
 (declare-function org-table-cookie-line-p "org-table" (line))
 (declare-function org-table-colgroup-line-p "org-table" (line))
+(declare-function org-pop-to-buffer-same-window "org-compat"
+                 (&optional buffer-or-name norecord label))
 
 (autoload 'org-export-generic "org-export-generic" "Export using the generic exporter" t)
 
 (autoload 'org-export-as-odt "org-odt"
-  "Export the outline to a OpenDocumentText file." t)
+  "Export the outline to a OpenDocument Text file." t)
 (autoload 'org-export-as-odt-and-open "org-odt"
-  "Export the outline to a OpenDocumentText file and open it." t)
+  "Export the outline to a OpenDocument Text file and open it." t)
 
 (defgroup org-export nil
   "Options for exporting org-listings."
@@ -216,6 +217,11 @@ and in `org-clock-clocktable-language-setup'."
   :group 'org-export-general
   :type 'string)
 
+(defcustom org-export-date-timestamp-format "%Y-%m-%d"
+  "Time string format for Org timestamps in the #+DATE option."
+  :group 'org-export-general
+  :type 'string)
+
 (defvar org-export-page-description ""
   "The page description, for the XHTML meta tag.
 This is best set with the #+DESCRIPTION line in a file, it does not make
@@ -725,6 +731,7 @@ must accept the property list as an argument, and must return the (possibly
 modified) list.")
 
 ;; FIXME: should we fold case here?
+
 (defun org-infile-export-plist ()
   "Return the property list with file-local settings for export."
   (save-excursion
@@ -736,13 +743,13 @@ modified) list.")
                  '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
                    "MATHJAX"
                    "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE"
-                   "LATEX_HEADER" "LATEX_CLASS"
+                   "LATEX_HEADER" "LATEX_CLASS" "LATEX_CLASS_OPTIONS"
                    "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
                    "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT")
                  (mapcar 'car org-export-inbuffer-options-extra))))
            (case-fold-search t)
            p key val text options mathjax a pr style
-           latex-header latex-class macros letbind
+           latex-header latex-class latex-class-options macros letbind
            ext-setup-or-nil setup-file setup-dir setup-contents (start 0))
        (while (or (and ext-setup-or-nil
                        (string-match re ext-setup-or-nil start)
@@ -758,7 +765,15 @@ modified) list.")
           ((string-equal key "TITLE") (setq p (plist-put p :title val)))
           ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
           ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
-          ((string-equal key "DATE") (setq p (plist-put p :date val)))
+          ((string-equal key "DATE")
+           ;; If date is an Org timestamp, convert it to a time
+           ;; string using `org-export-date-timestamp-format'
+           (when (string-match org-ts-regexp3 val)
+             (setq val (format-time-string
+                        org-export-date-timestamp-format
+                        (apply 'encode-time (org-parse-time-string
+                                             (match-string 0 val))))))
+           (setq p (plist-put p :date val)))
           ((string-equal key "KEYWORDS") (setq p (plist-put p :keywords val)))
           ((string-equal key "DESCRIPTION")
            (setq p (plist-put p :description val)))
@@ -769,6 +784,8 @@ modified) list.")
            (setq latex-header (concat latex-header "\n" val)))
           ((string-equal key "LATEX_CLASS")
            (setq latex-class val))
+           ((string-equal key "LATEX_CLASS_OPTIONS")
+            (setq latex-class-options val))
           ((string-equal key "TEXT")
            (setq text (if text (concat text "\n" val) val)))
           ((string-equal key "OPTIONS")
@@ -812,6 +829,8 @@ modified) list.")
          (setq p (plist-put p :latex-header-extra (substring latex-header 1))))
        (when latex-class
          (setq p (plist-put p :latex-class latex-class)))
+        (when latex-class-options
+          (setq p (plist-put p :latex-class-options latex-class-options)))
        (when options
          (setq p (org-export-add-options-to-plist p options)))
        (when mathjax
@@ -947,7 +966,7 @@ Pressing `1' will switch between these two options."
 
 \[D] export as DocBook   [V] export as DocBook, process to PDF, and open
 
-\[o] export as OpenDocumentText                    [O] ... and open
+\[o] export as OpenDocument Text                   [O] ... and open
 
 \[j] export as TaskJuggler                         [J] ... and open
 
@@ -1011,6 +1030,7 @@ Pressing `1' will switch between these two options."
                 (message "Export buffer: "))
                ((not subtree-p)
                 (setq subtree-p t)
+                (setq bpos (point))
                 (message "Export subtree: "))))
        (when (eq r1 ?\ )
          (let ((case-fold-search t)
@@ -1027,7 +1047,7 @@ Pressing `1' will switch between these two options."
                  (setq r1 (read-char-exclusive)))
              (error "No enclosing node with LaTeX_CLASS or EXPORT_TITLE or EXPORT_FILE_NAME")
              )))))
-    (redisplay)
+    (if (fboundp 'redisplay) (redisplay)) ;; XEmacs does not have/need (redisplay)
     (and bpos (goto-char bpos))
     (setq r2 (if (< r1 27) (+ r1 96) r1))
     (unless (setq ass (assq r2 cmds))
@@ -1277,6 +1297,9 @@ on this string to produce the exported version."
       ;; Remove #+TBLFM and #+TBLNAME lines
       (org-export-handle-table-metalines)
 
+      ;; Remove #+results and #+name lines
+      (org-export-res/src-name-cleanup)
+
       ;; Run the final hook
       (run-hooks 'org-export-preprocess-final-hook)
 
@@ -1407,7 +1430,7 @@ the current file."
                   (setq found (condition-case nil (org-link-search link)
                                 (error nil)))
                   (when (and found
-                             (or (org-on-heading-p)
+                             (or (org-at-heading-p)
                                  (not (eq found 'dedicated))))
                     (or (get-text-property (point) 'target)
                         (get-text-property
@@ -1438,7 +1461,7 @@ the current file."
 
 (defvar org-export-format-drawer-function nil
   "Function to be called to format the contents of a drawer.
-The function must accept three parameters:
+The function must accept two parameters:
   NAME     the drawer name, like \"PROPERTIES\"
   CONTENT  the content of the drawer.
 You can check the export backend through `org-export-current-backend'.
@@ -1518,7 +1541,7 @@ removed as well."
       (setq beg (point))
       (put-text-property beg (point-max) :org-delete t)
       (while (re-search-forward re-sel nil t)
-       (when (org-on-heading-p)
+       (when (org-at-heading-p)
          (org-back-to-heading)
          (remove-text-properties
           (max (1- (point)) (point-min))
@@ -1588,7 +1611,7 @@ from the buffer."
     (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))
+       (if (not (org-at-heading-p t))
            (goto-char (point-at-eol))
          (beginning-of-line 1)
          (setq a (if export-archived-trees
@@ -1634,9 +1657,11 @@ from the buffer."
       (org-if-unprotected
        (replace-match "")))))
 
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
 (defun org-export-protect-quoted-subtrees ()
   "Mark quoted subtrees with the protection property."
-  (let ((org-re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
+  (let ((org-re-quote (format org-heading-keyword-regexp-format
+                             org-quote-string)))
     (goto-char (point-min))
     (while (re-search-forward org-re-quote nil t)
       (goto-char (match-beginning 0))
@@ -1737,8 +1762,14 @@ from the buffer."
                (save-excursion
                  (save-match-data
                    (goto-char beg-content)
-                   (while (re-search-forward "^[ \t]*\\(,\\)" end-content t)
-                     (replace-match "" nil nil nil 1))))
+                   (let ((front-line (save-excursion
+                                       (re-search-forward
+                                        "[^[:space:]]" end-content t)
+                                       (goto-char (match-beginning 0))
+                                       (current-column))))
+                     (while (re-search-forward "^[ \t]*\\(,\\)" end-content t)
+                       (when (= (current-column) front-line)
+                         (replace-match "" nil nil nil 1))))))
                (delete-region (match-beginning 0) (match-end 0))
                (save-excursion
                  (goto-char beg)
@@ -1924,7 +1955,8 @@ table line.  If it is a link, add it to the line containing the link."
 
 (defun org-export-remove-comment-blocks-and-subtrees ()
   "Remove the comment environment, and also commented subtrees."
-  (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
+  (let ((re-commented (format org-heading-keyword-regexp-format
+                             org-comment-string))
        case-fold-search)
     ;; Remove comment environment
     (goto-char (point-min))
@@ -1977,6 +2009,18 @@ When it is nil, all comments will be removed."
        (replace-match "")
        (goto-char (max (point-min) (1- pos)))))))
 
+(defun org-export-res/src-name-cleanup ()
+  "Clean up #+results and #+name lines for export.
+This function should only be called after all block processing
+has taken place."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (let ((case-fold-search t))
+      (while (org-re-search-forward-unprotected
+             "#\\+\\(name\\|results\\(\\[[a-z0-9]+\\]\\)?\\):" nil t)
+       (delete-region (match-beginning 0) (progn (forward-line) (point)))))))
+
 (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
@@ -1994,23 +2038,28 @@ When it is nil, all comments will be removed."
 
 (defun org-store-forced-table-alignment ()
   "Find table lines which force alignment, store the results in properties."
-  (let (line cnt aligns)
+  (let (line cnt cookies)
     (goto-char (point-min))
-    (while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t)
+    (while (re-search-forward "|[ \t]*<\\([lrc]?[0-9]+\\|[lrc]\\)>[ \t]*|"
+                             nil t)
       ;; OK, this looks like a table line with an alignment cookie
       (org-if-unprotected
        (setq line (buffer-substring (point-at-bol) (point-at-eol)))
        (when (and (org-at-table-p)
                  (org-table-cookie-line-p line))
-        (setq cnt 0 aligns nil)
+        (setq cnt 0 cookies nil)
         (mapc
          (lambda (x)
            (setq cnt (1+ cnt))
-           (if (string-match "\\`<\\([lrc]\\)" x)
-               (push (cons cnt (downcase (match-string 1 x))) aligns)))
+           (when (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'" x)
+             (let ((align (and (match-end 1)
+                               (downcase (match-string 1 x))))
+                   (width (and (match-end 2)
+                               (string-to-number (match-string 2 x)))))
+               (push (cons cnt (list align width)) cookies))))
          (org-split-string line "[ \t]*|[ \t]*"))
         (add-text-properties (org-table-begin) (org-table-end)
-                             (list 'org-forced-aligns aligns))))
+                             (list 'org-col-cookies cookies))))
       (goto-char (point-at-eol)))))
 
 (defun org-export-remove-special-table-lines ()
@@ -2048,10 +2097,11 @@ Also, store forced alignment information found in such lines."
        (re-angle-link (concat "\\([^[]\\)" org-angle-link-re))
        nodesc)
     (goto-char (point-min))
+    (while (re-search-forward org-bracket-link-regexp nil t)
+      (put-text-property (match-beginning 0) (match-end 0) 'org-normalized-link t))
+    (goto-char (point-min))
     (while (re-search-forward re-plain-link nil t)
-      (unless (org-string-match-p
-              "\\[\\[\\S-+:\\S-*?\\<"
-              (buffer-substring (point-at-bol) (match-beginning 0)))
+      (unless (get-text-property (match-beginning 0) 'org-normalized-link)
        (goto-char (1- (match-end 0)))
        (org-if-unprotected-at (1+ (match-beginning 0))
          (let* ((s (concat (match-string 1)
@@ -2131,24 +2181,31 @@ can work correctly."
                   (save-excursion (outline-next-heading) (point)))))
        (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t)
          ;; Mark the line so that it will not be exported as normal text.
-         (org-unmodified
-          (add-text-properties (match-beginning 0) (match-end 0)
-                               (list :org-license-to-kill t)))
+         (unless (org-in-block-p org-list-forbidden-blocks)
+           (org-unmodified
+            (add-text-properties (match-beginning 0) (match-end 0)
+                                 (list :org-license-to-kill t))))
          ;; Return the title string
          (org-trim (match-string 0)))))))
 
 (defun org-export-get-title-from-subtree ()
   "Return subtree title and exclude it from export."
   (let ((rbeg (region-beginning)) (rend (region-end))
-       (inhibit-read-only t) title)
+       (inhibit-read-only t)
+       (tags (plist-get (org-infile-export-plist) :tags))
+       title)
     (save-excursion
       (goto-char rbeg)
       (when (and (org-at-heading-p)
                 (>= (org-end-of-subtree t t) rend))
+       (when (plist-member org-export-opt-plist :tags)
+         (setq tags (or (plist-get org-export-opt-plist :tags) tags)))
        ;; This is a subtree, we take the title from the first heading
        (goto-char rbeg)
-       (looking-at org-todo-line-regexp)
-       (setq title (match-string 3))
+       (looking-at org-todo-line-tags-regexp)
+       (setq title (if (eq tags t)
+                       (format "%s\t%s" (match-string 3) (match-string 4))
+                     (match-string 3)))
        (org-unmodified
         (add-text-properties (point) (1+ (point-at-eol))
                              (list :org-license-to-kill t)))
@@ -2688,11 +2745,11 @@ INDENT was the original indentation of the block."
                       (format "\\begin{%s}\n%s\\end{%s}\n"
                               custom-environment rtn custom-environment))
                      (listings-p
-                      (format "\\begin{%s}\n%s\\end{%s}\n"
+                      (format "\\begin{%s}\n%s\\end{%s}"
                               "lstlisting" rtn "lstlisting"))
                      (minted-p
                       (format
-                       "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
+                       "\\begin{minted}[%s]{%s}\n%s\\end{minted}"
                        (mapconcat #'make-option-string
                                   org-export-latex-minted-options ",")
                        backend-lang rtn)))))))
@@ -2717,13 +2774,60 @@ INDENT was the original indentation of the block."
             "\n#+BEGIN_" backend-name "\n"
             (org-add-props rtn
                 '(org-protected t org-example t org-native-text t))
-            "\n#+END_" backend-name "\n\n"))
+            "\n#+END_" backend-name "\n"))
       (org-add-props rtn nil 'original-indentation indent))))
 
 (defun org-export-number-lines (text &optional skip1 skip2 number cont
-                                    replace-labels label-format)
+                                    replace-labels label-format preprocess)
+  "Apply line numbers to literal examples and handle code references.
+Handle user-specified options under info node `(org)Literal
+examples' and return the modified source block.
+
+TEXT contains the source or example block.
+
+SKIP1 and SKIP2 are the number of lines that are to be skipped at
+the beginning and end of TEXT.  Use these to skip over
+backend-specific lines pre-pended or appended to the original
+source block.
+
+NUMBER is non-nil if the literal example specifies \"+n\" or
+\"-n\" switch. If NUMBER is non-nil add line numbers.
+
+CONT is non-nil if the literal example specifies \"+n\" switch.
+If CONT is nil, start numbering this block from 1.  Otherwise
+continue numbering from the last numbered block.
+
+REPLACE-LABELS is dual-purpose.
+1. It controls the retention of labels in the exported block.
+2. It specifies in what manner the links (or references) to a
+   labelled line be formatted.
+
+REPLACE-LABELS is the symbol `keep' if the literal example
+specifies \"-k\" option, is numeric if the literal example
+specifies \"-r\" option and is nil otherwise.
+
+Handle REPLACE-LABELS as below:
+- If nil, retain labels in the exported block and use
+  user-provided labels for referencing the labelled lines.
+- If it is a number, remove labels in the exported block and use
+  one of line numbers or labels for referencing labelled lines based
+  on NUMBER option.
+- If it is a keep, retain labels in the exported block and use
+  one of line numbers or labels for referencing labelled lines
+  based on NUMBER option.
+
+LABEL-FORMAT is the value of \"-l\" switch associated with
+literal example.  See `org-coderef-label-format'.
+
+PREPROCESS is intended for backend-agnostic handling of source
+block numbering.  When non-nil do the following:
+- do not number the lines
+- always strip the labels from exported block
+- do not make the labelled line a target of an incoming link.
+  Instead mark the labelled line with `org-coderef' property and
+  store the label in it."
   (setq skip1 (or skip1 0) skip2 (or skip2 0))
-  (if (not cont) (setq org-export-last-code-line-counter-value 0))
+  (if (and number (not cont)) (setq org-export-last-code-line-counter-value 0))
   (with-temp-buffer
     (insert text)
     (goto-char (point-max))
@@ -2760,9 +2864,10 @@ INDENT was the original indentation of the block."
 
       (org-goto-line (1+ skip1))
       (while (and (re-search-forward "^" nil t) (not (eobp)) (< n nmax))
-       (if number
-           (insert (format fm (incf n)))
-         (forward-char 1))
+       (when number (incf n))
+       (if (or preprocess (not number))
+           (forward-char 1)
+         (insert (format fm n)))
        (when (looking-at lbl-re)
          (setq ref (match-string 3))
          (cond ((numberp replace-labels)
@@ -2775,7 +2880,8 @@ INDENT was the original indentation of the block."
                 ;; lines are numbered, use labels otherwise
                 (goto-char (match-beginning 2))
                 (delete-region (match-beginning 2) (match-end 2))
-                (insert "(" ref ")")
+                (unless preprocess
+                  (insert "(" ref ")"))
                 (push (cons ref (if (> n 0) n (concat "(" ref ")")))
                       org-export-code-refs))
                (t
@@ -2783,15 +2889,19 @@ INDENT was the original indentation of the block."
                 ;; references
                 (goto-char (match-beginning 2))
                 (delete-region (match-beginning 2) (match-end 2))
-                (insert "(" ref ")")
+                (unless preprocess
+                  (insert "(" ref ")"))
                 (push (cons ref (concat "(" ref ")")) org-export-code-refs)))
-         (when (eq org-export-current-backend 'html)
+         (when (and (eq org-export-current-backend 'html) (not preprocess))
            (save-excursion
              (beginning-of-line 1)
              (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
                              ref))
              (end-of-line 1)
-             (insert "</span>")))))
+             (insert "</span>")))
+         (when preprocess
+           (add-text-properties
+            (point-at-bol) (point-at-eol) (list 'org-coderef ref)))))
       (setq org-export-last-code-line-counter-value n)
       (goto-char (point-max))
       (newline)
@@ -2893,17 +3003,6 @@ command."
       (switch-to-buffer-other-window buffer)
       (goto-char (point-min)))))
 
-(defun org-find-visible ()
-  (let ((s (point)))
-    (while (and (not (= (point-max) (setq s (next-overlay-change s))))
-               (get-char-property s 'invisible)))
-    s))
-(defun org-find-invisible ()
-  (let ((s (point)))
-    (while (and (not (= (point-max) (setq s (next-overlay-change s))))
-               (not (get-char-property s 'invisible))))
-    s))
-
 (defvar org-export-htmlized-org-css-url) ;; defined in org-html.el
 
 (defun org-export-string (string fmt &optional dir)
@@ -2922,7 +3021,7 @@ to the value of `temporary-file-directory'."
          (org-load-modules-maybe)
          (unless org-local-vars
            (setq org-local-vars (org-get-local-variables)))
-         (eval ;; convert to fmt -- mimicking `org-run-like-in-org-mode'
+         (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode'
           (list 'let org-local-vars
                 (list (intern (format "org-export-as-%s" fmt))
                       nil nil nil ''string t))))
@@ -2972,7 +3071,7 @@ directory."
         (region (buffer-string))
          str-ret)
     (save-excursion
-      (switch-to-buffer buffer)
+      (org-pop-to-buffer-same-window buffer)
       (erase-buffer)
       (insert region)
       (let ((org-inhibit-startup t)) (org-mode))
@@ -3218,7 +3317,7 @@ If yes remove the column and the special lines."
 
 (defun org-export-push-to-kill-ring (format)
   "Push buffer content to kill ring.
-The depends on the variable `org-export-copy-to-kill'."
+The depends on the variable `org-export-copy-to-kill-ring'."
   (when org-export-copy-to-kill-ring
     (org-kill-new (buffer-string))
     (when (fboundp 'x-set-selection)
@@ -3228,6 +3327,4 @@ The depends on the variable `org-export-copy-to-kill'."
 
 (provide 'org-exp)
 
-
-
 ;;; org-exp.el ends here
index af9632eec44f2d74b8cc3f487b2b0b4b3026a9cd..3bf64df2d3964fe4c2a6b114bf11cc10c2151a9e 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-faces.el --- Face definitions for Org-mode.
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -673,6 +672,18 @@ month and 365.24 days for a year)."
   "Face for showing the agenda restriction lock."
   :group 'org-faces)
 
+(defface org-agenda-filter-tags
+  (org-compatible-face 'modeline
+    nil)
+  "Face for tag(s) in the mode-line when filtering the agenda."
+  :group 'org-faces)
+
+(defface org-agenda-filter-category
+  (org-compatible-face 'modeline
+    nil)
+  "Face for tag(s) in the mode-line when filtering the agenda."
+  :group 'org-faces)
+
 (defface org-time-grid ;; originally copied from font-lock-variable-name-face
   (org-compatible-face nil
     '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
@@ -690,6 +701,18 @@ month and 365.24 days for a year)."
   "Face used for agenda entries that come from the Emacs diary."
   :group 'org-faces)
 
+(defface org-agenda-calendar-event
+  (org-compatible-face 'default
+    nil)
+  "Face used to show events and appointments in the agenda."
+  :group 'org-faces)
+
+(defface org-agenda-calendar-sexp
+  (org-compatible-face 'default
+    nil)
+  "Face used to show events computed from a S-expression."
+  :group 'org-faces)
+
 (defconst org-level-faces
   '(org-level-1 org-level-2 org-level-3 org-level-4
     org-level-5 org-level-6 org-level-7 org-level-8
@@ -735,6 +758,4 @@ level org-n-level-faces"
 
 (provide 'org-faces)
 
-
-
 ;;; org-faces.el ends here
index d1b31f11b4adb4cf7463c249d02067d68303e234..4e300de7b06006e06b179bddcecf1ab60f773ef7 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -436,7 +435,7 @@ it can be a list structured like an entry in `org-feed-alist'."
   (if (stringp feed) (setq feed (assoc feed org-feed-alist)))
   (unless feed
     (error "No such feed in `org-feed-alist"))
-  (switch-to-buffer
+  (org-pop-to-buffer-same-window
    (org-feed-update feed 'retrieve-only))
   (goto-char (point-min)))
 
@@ -674,5 +673,4 @@ formatted as a string, not the original XML data."
 
 (provide 'org-feed)
 
-
 ;;; org-feed.el ends here
index 0d47132d2f8707b887f0ec77c1f84c08cd58508c..a8125513db6ecfbbae080b852af7ea4d56a85b52 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 (require 'org-macs)
 (require 'org-compat)
 
+(declare-function message-point-in-header-p "message" ())
+(declare-function org-back-over-empty-lines "org" ())
+(declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-combine-plists "org" (&rest plists))
+(declare-function org-end-of-subtree "org"  (&optional invisible-ok to-heading))
+(declare-function org-export-preprocess-string "org-exp"
+                 (string &rest parameters))
+(declare-function org-fill-paragraph "org" (&optional justify))
+(declare-function org-icompleting-read "org" (&rest args))
+(declare-function org-id-uuid "org-id" ())
+(declare-function org-in-block-p "org" (names))
 (declare-function org-in-commented-line "org" ())
 (declare-function org-in-indented-comment-line "org" ())
 (declare-function org-in-regexp "org" (re &optional nlines visually))
-(declare-function org-in-block-p "org" (names))
-(declare-function org-mark-ring-push "org" (&optional pos buffer))
-(declare-function outline-next-heading "outline")
-(declare-function org-trim "org" (s))
-(declare-function org-show-context "org" (&optional key))
-(declare-function org-back-to-heading "org" (&optional invisible-ok))
-(declare-function org-end-of-subtree "org"  (&optional invisible-ok to-heading))
 (declare-function org-in-verbatim-emphasis "org" ())
+(declare-function org-inside-LaTeX-fragment-p "org" ())
 (declare-function org-inside-latex-macro-p "org" ())
-(declare-function org-id-uuid "org" ())
-(declare-function org-fill-paragraph "org" (&optional justify))
-(declare-function org-export-preprocess-string "org-exp"
-                 (string &rest parameters))
+(declare-function org-mark-ring-push "org" (&optional pos buffer))
+(declare-function org-show-context "org" (&optional key))
+(declare-function org-trim "org" (s))
+(declare-function outline-next-heading "outline")
 
-(defvar org-outline-regexp-bol) ; defined in org.el
-(defvar org-odd-levels-only) ;; defined in org.el
-(defvar org-bracket-link-regexp) ; defined in org.el
-(defvar message-signature-separator) ;; defined in message.el
+(defvar org-outline-regexp-bol)                ; defined in org.el
+(defvar org-odd-levels-only)           ; defined in org.el
+(defvar org-bracket-link-regexp)       ; defined in org.el
+(defvar message-cite-prefix-regexp)    ; defined in message.el
+(defvar message-signature-separator)   ; defined in message.el
 
 (defconst org-footnote-re
   ;; Only [1]-like footnotes are closed in this regexp, as footnotes
   ;; their definition.
   ;;
   ;; `org-re' is used for regexp compatibility with XEmacs.
-  (org-re (concat "\\[\\(?:"
-                 ;; Match inline footnotes.
-                 "fn:\\([-_[:word:]]+\\)?:\\|"
-                 ;; Match other footnotes.
-                 "\\(?:\\([0-9]+\\)\\]\\)\\|"
-                 "\\(fn:[-_[:word:]]+\\)"
-                 "\\)"))
+  (concat "\\[\\(?:"
+         ;; Match inline footnotes.
+         (org-re "fn:\\([-_[:word:]]+\\)?:\\|")
+         ;; Match other footnotes.
+         "\\(?:\\([0-9]+\\)\\]\\)\\|"
+         (org-re "\\(fn:[-_[:word:]]+\\)")
+         "\\)")
   "Regular expression for matching footnotes.")
 
 (defconst org-footnote-definition-re
-  (org-re "^\\(\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]\\)")
+  (org-re "^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]")
   "Regular expression matching the definition of a footnote.")
 
 (defvar org-footnote-forbidden-blocks '("example" "verse" "src" "ascii" "beamer"
@@ -106,13 +110,17 @@ heading will be removed after extracting footnote definitions."
 
 (defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:"
   "Tag marking the beginning of footnote section.
-The Org-mode footnote engine can be used in arbitrary text files as well
-as in Org-mode.  Outside Org-mode, new footnotes are always placed at
+The Org footnote engine can be used in arbitrary text files as well
+as in Org-mode.  Outside Org mode, new footnotes are always placed at
 the end of the file.  When you normalize the notes, any line containing
 only this tag will be removed, a new one will be inserted at the end
-of the file, followed by the collected and normalized footnotes."
+of the file, followed by the collected and normalized footnotes.
+
+If you don't want any tag in such buffers, set this variable to nil."
   :group 'org-footnote
-  :type 'string)
+  :type '(choice
+         (string :tag "Collect footnotes under tag")
+         (const :tag "Don't use a tag" nil)))
 
 (defcustom org-footnote-define-inline nil
   "Non-nil means define footnotes inline, at reference location.
@@ -171,8 +179,11 @@ extracted will be filled again."
   (save-match-data
     (not (or (org-in-commented-line)
             (org-in-indented-comment-line)
-            (org-in-verbatim-emphasis)
+            (org-inside-LaTeX-fragment-p)
+            ;; Avoid protected environments (LaTeX export)
+            (get-text-property (point) 'org-protected)
             ;; Avoid literal example.
+            (org-in-verbatim-emphasis)
             (save-excursion
               (beginning-of-line)
               (looking-at "[ \t]*:[ \t]+"))
@@ -194,13 +205,13 @@ positions, and the definition, when inlined."
             (or (looking-at org-footnote-re)
                 (org-in-regexp org-footnote-re)
                 (save-excursion (re-search-backward org-footnote-re nil t)))
-            ;; Only inline footnotes can start at bol.
-            (or (eq (char-before (match-end 0)) 58)
-                (/= (match-beginning 0) (point-at-bol))))
+            (/= (match-beginning 0) (point-at-bol)))
     (let* ((beg (match-beginning 0))
-          (label (or (match-string 2) (match-string 3)
+          (label (or (org-match-string-no-properties 2)
+                     (org-match-string-no-properties 3)
                      ;; Anonymous footnotes don't have labels
-                     (and (match-string 1) (concat "fn:" (match-string 1)))))
+                     (and (match-string 1)
+                          (concat "fn:" (org-match-string-no-properties 1)))))
           ;; Inline footnotes don't end at (match-end 0) as
           ;; `org-footnote-re' stops just after the second colon.
           ;; Find the real ending with `scan-sexps', so Org doesn't
@@ -223,12 +234,12 @@ positions, and the definition, when inlined."
                 ;; optional argument of the command.  Thus, check
                 ;; the `org-protected' property of that command.
                 (or (not (org-inside-latex-macro-p))
-                    (and (get-text-property (1- beg) 'org-protected)
-                         (not (get-text-property beg 'org-protected)))))
+                    (get-text-property (1- beg) 'org-protected)))
        (list label beg end
              ;; Definition: ensure this is an inline footnote first.
              (and (or (not label) (match-string 1))
-                  (org-trim (buffer-substring (match-end 0) (1- end)))))))))
+                  (org-trim (buffer-substring-no-properties
+                             (match-end 0) (1- end)))))))))
 
 (defun org-footnote-at-definition-p ()
   "Is the cursor at a footnote definition?
@@ -239,7 +250,7 @@ footnote text is included and defined locally.
 
 The return value will be nil if not at a footnote definition, and a list with
 label, start, end and definition of the footnote otherwise."
-  (when (org-footnote-in-valid-context-p)
+  (when (save-excursion (beginning-of-line) (org-footnote-in-valid-context-p))
     (save-excursion
       (end-of-line)
       (let ((lim (save-excursion (re-search-backward
@@ -247,7 +258,7 @@ label, start, end and definition of the footnote otherwise."
                                          "\\|^[ \t]*$") nil t))))
        (when (re-search-backward org-footnote-definition-re lim t)
          (end-of-line)
-         (list (match-string 2)
+         (list (org-match-string-no-properties 1)
                (match-beginning 0)
                (save-match-data
                  ;; In a message, limit search to signature.
@@ -257,15 +268,14 @@ label, start, end and definition of the footnote otherwise."
                                      (re-search-backward
                                       message-signature-separator nil t)))))
                    (or (and (re-search-forward
-                             (org-re
-                              (concat "^[ \t]*$" "\\|"
-                                      org-outline-regexp-bol
-                                      "\\|"
-                                      "^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]"))
+                             (concat org-outline-regexp-bol "\\|"
+                                     org-footnote-definition-re "\\|"
+                                     "^[ \t]*$")
                              bound 'move)
                             (progn (skip-chars-forward " \t\n") (point-at-bol)))
                        (point))))
-               (org-trim (buffer-substring (match-end 0) (point)))))))))
+               (org-trim (buffer-substring-no-properties
+                          (match-end 0) (point)))))))))
 
 (defun org-footnote-get-next-reference (&optional label backward limit)
   "Return complete reference of the next footnote.
@@ -295,10 +305,11 @@ LIMIT is the buffer position bounding the search.
 Return value is a list like those provided by
 `org-footnote-at-reference-p' or `org-footnote-at-definition-p'.
 If no footnote is found, return nil."
-  (let* (ref)
+  (let* (ref (origin (point)))
     (catch 'exit
       (while t
        (unless (re-search-forward org-footnote-re limit t)
+         (goto-char origin)
          (throw 'exit nil))
        ;; Beware: with [1]-like footnotes point will be just after
        ;; the closing square bracket.
@@ -320,19 +331,21 @@ If no footnote is found, return nil."
         (re (format "^\\[%s\\]\\|.\\[%s:" label label))
         pos)
     (save-excursion
-      (when (or (re-search-forward re nil t)
-               (and (goto-char (point-min))
-                    (re-search-forward re nil t))
-               (and (progn (widen) t)
-                    (goto-char (point-min))
-                    (re-search-forward re nil t)))
-       (let ((refp (org-footnote-at-reference-p)))
-         (cond
-          ((and (nth 3 refp) refp))
-          ((org-footnote-at-definition-p))))))))
+      (save-restriction
+       (when (or (re-search-forward re nil t)
+                 (and (goto-char (point-min))
+                      (re-search-forward re nil t))
+                 (and (progn (widen) t)
+                      (goto-char (point-min))
+                      (re-search-forward re nil t)))
+         (let ((refp (org-footnote-at-reference-p)))
+           (cond
+            ((and (nth 3 refp) refp))
+            ((org-footnote-at-definition-p)))))))))
 
 (defun org-footnote-goto-definition (label)
-  "Move point to the definition of the footnote LABEL."
+  "Move point to the definition of the footnote LABEL.
+Return a non-nil value when a definition has been found."
   (interactive "sLabel: ")
   (org-mark-ring-push)
   (let ((def (org-footnote-get-definition label)))
@@ -342,7 +355,9 @@ If no footnote is found, return nil."
       (looking-at (format "\\[%s\\]\\|\\[%s:" label label))
       (goto-char (match-end 0))
       (org-show-context 'link-search)
-      (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))))
+      (when (eq major-mode 'org-mode)
+       (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))
+      t)))
 
 (defun org-footnote-goto-previous-reference (label)
   "Find the first closest (to point) reference of footnote with label LABEL."
@@ -406,7 +421,12 @@ and value definition."
 
 (defun org-footnote-unique-label (&optional current)
   "Return a new unique footnote label.
-The returns the firsts fn:N labels that is currently not used."
+
+The function returns the first \"fn:N\" or \"N\" label that is
+currently not used.
+
+Optional argument CURRENT is the list of labels active in the
+buffer."
   (unless current (setq current (org-footnote-all-labels)))
   (let ((fmt (if (eq org-footnote-auto-label 'plain) "%d" "fn:%d"))
        (cnt 1))
@@ -414,21 +434,17 @@ The returns the firsts fn:N labels that is currently not used."
       (incf cnt))
     (format fmt cnt)))
 
-(defvar org-footnote-label-history nil
-  "History of footnote labels entered in current buffer.")
-(make-variable-buffer-local 'org-footnote-label-history)
-
 (defun org-footnote-new ()
   "Insert a new footnote.
 This command prompts for a label.  If this is a label referencing an
 existing label, only insert the label.  If the footnote label is empty
 or new, let the user edit the definition of the footnote."
   (interactive)
-  (unless (and (not (bolp)) (org-footnote-in-valid-context-p))
+  (unless (org-footnote-in-valid-context-p)
     (error "Cannot insert a footnote here"))
-  (let* ((labels (and (not (equal org-footnote-auto-label 'random))
-                     (org-footnote-all-labels)))
-        (propose (org-footnote-unique-label labels))
+  (let* ((lbls (and (not (equal org-footnote-auto-label 'random))
+                   (org-footnote-all-labels)))
+        (propose (org-footnote-unique-label lbls))
         (label
          (org-footnote-normalize-label
           (cond
@@ -438,16 +454,16 @@ or new, let the user edit the definition of the footnote."
             (require 'org-id)
             (substring (org-id-uuid) 0 8))
            (t
-            (completing-read
+            (org-icompleting-read
              "Label (leave empty for anonymous): "
-             (mapcar 'list labels) nil nil
-             (if (eq org-footnote-auto-label 'confirm) propose nil)
-             'org-footnote-label-history))))))
+             (mapcar 'list lbls) nil nil
+             (if (eq org-footnote-auto-label 'confirm) propose nil)))))))
     (cond
+     ((bolp) (error "Cannot create a footnote reference at left margin"))
      ((not label)
       (insert "[fn:: ]")
       (backward-char 1))
-     ((member label labels)
+     ((member label lbls)
       (insert "[" label "]")
       (message "New reference to existing note"))
      (org-footnote-define-inline
@@ -459,51 +475,78 @@ or new, let the user edit the definition of the footnote."
       (org-footnote-create-definition label)
       (org-footnote-auto-adjust-maybe)))))
 
+(defvar org-blank-before-new-entry nil) ; silence byte-compiler
 (defun org-footnote-create-definition (label)
   "Start the definition of a footnote with label LABEL."
   (interactive "sLabel: ")
   (let ((label (org-footnote-normalize-label label)))
     (cond
-     ((org-mode-p)
-      ;; No section, put footnote into the current outline node Try to
-      ;; find or make the special node
+     ;; In an Org file.
+     ((eq major-mode 'org-mode)
+      ;; If `org-footnote-section' is defined, find it, or create it
+      ;; at the end of the buffer.
       (when org-footnote-section
        (goto-char (point-min))
        (let ((re (concat "^\\*+[ \t]+" org-footnote-section "[ \t]*$")))
          (unless (or (re-search-forward re nil t)
                      (and (progn (widen) t)
                           (re-search-forward re nil t)))
-         (goto-char (point-max))
-         (insert "\n\n* " org-footnote-section "\n"))))
-      ;; Now go to the end of this entry and insert there.
+           (goto-char (point-max))
+           (skip-chars-backward " \t\r\n")
+           (unless (bolp) (newline))
+           ;; Insert new section.  Separate it from the previous one
+           ;; with a blank line, unless `org-blank-before-new-entry'
+           ;; explicitly says no.
+           (when (and (cdr (assq 'heading org-blank-before-new-entry))
+                      (zerop (save-excursion (org-back-over-empty-lines))))
+             (insert "\n"))
+           (insert "* " org-footnote-section "\n"))))
+      ;; Move to the end of this entry (which may be
+      ;; `org-footnote-section' or the current one).
       (org-footnote-goto-local-insertion-point)
       (org-show-context 'link-search))
      (t
       ;; In a non-Org file.  Search for footnote tag, or create it if
-      ;; necessary (at the end of buffer, or before a signature if in
+      ;; specified (at the end of buffer, or before signature if in
       ;; Message mode).  Set point after any definition already there.
-      (let ((tag (concat "^" org-footnote-tag-for-non-org-mode-files "[ \t]*$"))
-           (max (save-excursion
-                  (if (and (derived-mode-p 'message-mode)
-                           (re-search-forward
-                            message-signature-separator nil t))
-                      (copy-marker (point-at-bol) t)
-                    (copy-marker (point-max) t)))))
+      (let ((tag (and org-footnote-tag-for-non-org-mode-files
+                     (concat "^" (regexp-quote
+                                  org-footnote-tag-for-non-org-mode-files)
+                             "[ \t]*$")))
+           (max (if (and (derived-mode-p 'message-mode)
+                         (goto-char (point-max))
+                         (re-search-backward
+                          message-signature-separator nil t))
+                    (progn
+                      ;; Ensure one blank line separates last
+                      ;; footnote from signature.
+                      (beginning-of-line)
+                      (open-line 2)
+                      (point-marker))
+                  (point-max-marker))))
+       (set-marker-insertion-type max t)
        (goto-char max)
-       (unless (re-search-backward tag nil t)
+       ;; Check if the footnote tag is defined but missing.  In this
+       ;; case, insert it, before any footnote or one blank line
+       ;; after any previous text.
+       (when (and tag (not (re-search-backward tag nil t)))
          (skip-chars-backward " \t\r\n")
-         (delete-region (point) max)
-         (insert "\n\n" org-footnote-tag-for-non-org-mode-files "\n"))
-       ;; Skip existing footnotes.
-       (while (re-search-forward org-footnote-definition-re max t))
-       (let ((def (org-footnote-at-definition-p)))
-         (when def (goto-char (nth 2 def))))
+         (while (re-search-backward org-footnote-definition-re nil t))
+         (unless (bolp) (newline 2))
+         (insert org-footnote-tag-for-non-org-mode-files "\n\n"))
+       ;; Remove superfluous white space and clear marker.
+       (goto-char max)
+       (skip-chars-backward " \t\r\n")
+       (delete-region (point) max)
+       (unless (bolp) (newline))
        (set-marker max nil))))
-    ;; Insert footnote label, position point and notify user.
-    (unless (bolp) (insert "\n"))
-    (insert "\n[" label "] \n")
-    (backward-char)
-    (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
+    ;; Insert footnote label.
+    (insert "\n[" label "] ")
+    ;; Only notify user about next possible action when in an Org
+    ;; buffer, as the bindings may have different meanings otherwise.
+    (when (eq major-mode 'org-mode)
+      (message
+       "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))))
 
 ;;;###autoload
 (defun org-footnote-action (&optional special)
@@ -570,11 +613,11 @@ If Org is amidst an export process, EXPORT-PROPS will hold the
 export properties of the buffer.
 
 When EXPORT-PROPS is non-nil, the default action is to insert
-normalized footnotes towards the end of the pre-processing buffer.
-Some exporters like docbook, odt, etc. expect that footnote
-definitions be available before any references to them.  Such
-exporters can let bind `org-footnote-insert-pos-for-preprocessor' to
-symbol 'point-min to achieve the desired behavior.
+normalized footnotes towards the end of the pre-processing
+buffer.  Some exporters (docbook, odt...) expect footnote
+definitions to be available before any references to them.  Such
+exporters can let bind `org-footnote-insert-pos-for-preprocessor'
+to symbol `point-min' to achieve the desired behaviour.
 
 Additional note on `org-footnote-insert-pos-for-preprocessor':
 1. This variable has not effect when FOR-PREPROCESSOR is nil.
@@ -634,8 +677,8 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
            (and inlinep
                 org-footnote-fill-after-inline-note-extraction
                 (org-fill-paragraph)))
-         ;; Add label (REF), identifier (MARKER) and definition (DEF)
-         ;; to REF-TABLE if data was unknown.
+         ;; Add label (REF), identifier (MARKER), definition (DEF)
+         ;; and type (INLINEP) to REF-TABLE if data was unknown.
          (unless a
            (let ((def (or (nth 3 ref)  ; inline
                           (and export-props
@@ -646,52 +689,52 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
                          ;; through `org-export-preprocess-string' so
                          ;; it is ready to insert in the
                          ;; backend-specific buffer.
-                         (if export-props
+                         (if (and export-props def)
                              (let ((parameters
                                     (org-combine-plists
                                      export-props
                                      '(:todo-keywords t :tags t :priority t))))
                                (org-export-preprocess-string def parameters))
                            def)
-                         inlinep) ref-table)))
-         ;; Remove definition of non-inlined footnotes.
-         (unless inlinep (org-footnote-delete-definitions lbl))))
+                         inlinep) ref-table)))))
       ;; 2. Find and remove the footnote section, if any.  Also
       ;;    determine where footnotes shall be inserted (INS-POINT).
       (goto-char (point-min))
       (cond
-       ((org-mode-p)
-       (if (and org-footnote-section
-                (re-search-forward
-                 (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
-                         "[ \t]*$")
-                 nil t))
-           (progn
-             (setq ins-point (match-beginning 0))
-             (delete-region (match-beginning 0) (org-end-of-subtree t)))
-         (setq ins-point (point-max))))
+       ((and org-footnote-section
+            (eq major-mode 'org-mode)
+            (re-search-forward
+             (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
+                     "[ \t]*$")
+             nil t))
+       (delete-region (match-beginning 0) (org-end-of-subtree t)))
+       ((eq major-mode 'org-mode)
+       (goto-char (point-max))
+       (unless (bolp) (newline)))
        (t
-       (when (re-search-forward
-              (concat "^"
-                      (regexp-quote org-footnote-tag-for-non-org-mode-files)
-                      "[ \t]*$")
-              nil t)
-         (replace-match ""))
-       ;; In message-mode, ensure footnotes are inserted before the
+       ;; Remove any left-over tag in the buffer, if one is set up.
+       (when org-footnote-tag-for-non-org-mode-files
+         (let ((tag (concat "^" (regexp-quote
+                                 org-footnote-tag-for-non-org-mode-files)
+                            "[ \t]*$")))
+           (while (re-search-forward tag nil t)
+             (replace-match "")
+             (delete-region (point) (progn (forward-line) (point))))))
+       ;; In Message mode, ensure footnotes are inserted before the
        ;; signature.
-       (let ((pt-max
-              (or (and (derived-mode-p 'message-mode)
-                       (save-excursion
-                         (goto-char (point-max))
-                         (re-search-backward
-                          message-signature-separator nil t)
-                         (1- (point))))
-                  (point-max))))
-         (goto-char pt-max)
-         (skip-chars-backward " \t\n\r")
-         (forward-line)
-         (delete-region (point) pt-max))
-       (setq ins-point (point))))
+       (if (and (derived-mode-p 'message-mode)
+                (goto-char (point-max))
+                (re-search-backward message-signature-separator nil t))
+           (beginning-of-line)
+         (goto-char (point-max)))))
+      ;; During export, `org-footnote-insert-pos-for-preprocessor' has
+      ;; precedence over previously found position.
+      (setq ins-point
+           (copy-marker
+            (if (and export-props
+                     (eq org-footnote-insert-pos-for-preprocessor 'point-min))
+                (point-min)
+              (point))))
       ;; 3. Clean-up REF-TABLE.
       (setq ref-table
            (delq nil
@@ -708,34 +751,48 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
                      (t x)))
                   ref-table)))
       (setq ref-table (nreverse ref-table))
-      ;; 4. Insert the footnotes again in the buffer, at the
+      ;; 4. Remove left-over definitions in the buffer.
+      (mapc (lambda (x) (unless (nth 3 x)
+                    (org-footnote-delete-definitions (car x))))
+           ref-table)
+      ;; 5. Insert the footnotes again in the buffer, at the
       ;;    appropriate spot.
-      (goto-char (or
-                 (and export-props
-                      (eq org-footnote-insert-pos-for-preprocessor 'point-min)
-                      (point-min))
-                 ins-point
-                 (point-max)))
+      (goto-char ins-point)
       (cond
        ;; No footnote: exit.
        ((not ref-table))
        ;; Cases when footnotes should be inserted in one place.
-       ((or (not (org-mode-p))
+       ((or (not (eq major-mode 'org-mode))
            org-footnote-section
            (not sort-only))
-       ;; Insert again the section title.
+       ;; Insert again the section title, if any.  Ensure that title,
+       ;; or the subsequent footnotes, will be separated by a blank
+       ;; lines from the rest of the document.  In an Org buffer,
+       ;; separate section with a blank line, unless explicitly
+       ;; stated in `org-blank-before-new-entry'.
        (cond
-        ((not (org-mode-p))
-         (insert "\n\n" org-footnote-tag-for-non-org-mode-files "\n"))
+        ((not (eq major-mode 'org-mode))
+         (skip-chars-backward " \t\n\r")
+         (delete-region (point) ins-point)
+         (unless (bolp) (newline))
+         ;; Keep one blank line between footnotes and signature.
+         (when (and (derived-mode-p 'message-mode)
+                    (save-excursion
+                      (re-search-forward message-signature-separator nil t)))
+           (open-line 1))
+         (when org-footnote-tag-for-non-org-mode-files
+           (insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
         ((and org-footnote-section (not export-props))
-         (or (bolp) (insert "\n"))
+         (when (and (cdr (assq 'heading org-blank-before-new-entry))
+                    (zerop (save-excursion (org-back-over-empty-lines))))
+           (insert "\n"))
          (insert "* " org-footnote-section "\n")))
-       ;; Insert the footnotes.
-       (insert "\n"
-               (mapconcat (lambda (x) (format "[%s] %s"
+       (set-marker ins-point nil)
+       ;; Insert the footnotes, separated by a blank line.
+       (insert (mapconcat (lambda (x) (format "\n[%s] %s"
                                          (nth (if sort-only 0 1) x) (nth 2 x)))
-                          ref-table "\n\n")
-               "\n\n")
+                          ref-table "\n"))
+       (unless (eobp) (insert "\n"))
        ;; When exporting, add newly inserted markers along with their
        ;; associated definition to `org-export-footnotes-seen'.
        (when export-props
@@ -831,20 +888,21 @@ If LABEL is non-nil, delete that footnote instead."
 (defun org-footnote-renumber-fn:N ()
   "Renumber the simple footnotes like fn:17 into a sequence in the document."
   (interactive)
-  (let (map i (n 0))
-    (save-excursion
-      (save-restriction
-       (widen)
-       (goto-char (point-min))
-       (while (re-search-forward "\\[fn:\\([0-9]+\\)[]:]" nil t)
-         (setq i (string-to-number (match-string 1)))
-         (when (and (string-match "\\S-" (buffer-substring
-                                          (point-at-bol) (match-beginning 0)))
-                    (not (assq i map)))
-           (push (cons i (number-to-string (incf n))) map)))
-       (goto-char (point-min))
-       (while (re-search-forward "\\(\\[fn:\\)\\([0-9]+\\)\\([]:]\\)" nil t)
-         (replace-match (concat "\\1" (cdr (assq (string-to-number (match-string 2)) map)) "\\3")))))))
+  (let (map (n 0))
+    (org-with-wide-buffer
+     (goto-char (point-min))
+     (while (re-search-forward "\\[fn:\\([0-9]+\\)[]:]" nil t)
+       (save-excursion
+        (goto-char (match-beginning 0))
+        ;; Ensure match is a footnote reference or definition.
+        (when (save-match-data (if (bolp)
+                                   (org-footnote-at-definition-p)
+                                 (org-footnote-at-reference-p)))
+          (let ((new-val (or (cdr (assoc (match-string 1) map))
+                             (number-to-string (incf n)))))
+            (unless (assoc (match-string 1) map)
+              (push (cons (match-string 1) new-val) map))
+            (replace-match new-val nil nil nil 1))))))))
 
 (defun org-footnote-auto-adjust-maybe ()
   "Renumber and/or sort footnotes according to user settings."
@@ -862,6 +920,4 @@ If LABEL is non-nil, delete that footnote instead."
 
 (provide 'org-footnote)
 
-
-
 ;;; org-footnote.el ends here
index b01f6d9fa6eccfcf5c271bd5c79f64a7f5d7ba05..7055bfade4e647d68403438f1b5cadd0dc6f2038 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -1220,4 +1219,5 @@ PATH should be a list of steps, where each step has the form
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
 ;;; org-freemind.el ends here
index 0ccb66ca4975f5fa9ae3daa72ed6e41a3a005b45..c7bccc0d8a201da526ca9a21ad5269cb28ab9033 100644 (file)
@@ -1,12 +1,11 @@
 ;;; org-gnus.el --- Support for links to Gnus groups and messages from within Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;         Tassilo Horn <tassilo at member dot fsf dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -291,5 +290,4 @@ If `org-store-link' was called with a prefix arg the meaning of
 (provide 'org-gnus)
 
 
-
 ;;; org-gnus.el ends here
index c146a5bebbd43aba6e17f525cfe5141b20bf4b55..f8bd12ae42928670d400706c1e920c5ff4bedc9d 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: John Wiegley <johnw at gnu dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -68,6 +67,16 @@ relative to the current effective date."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-today-glyph ?!
+  "Glyph character used to identify today."
+  :group 'org-habit
+  :type 'character)
+
+(defcustom org-habit-completed-glyph ?*
+  "Glyph character used to show completed days on which a task was done."
+  :group 'org-habit
+  :type 'character)
+
 (defface org-habit-clear-face
   '((((background light)) (:background "#8270f9"))
     (((background dark)) (:background "blue")))
@@ -297,7 +306,7 @@ current time."
                              (days-to-time
                               (- start (time-to-days starting))))))
 
-             (aset graph index ?*)
+             (aset graph index org-habit-completed-glyph)
              (setq markedp t)
              (put-text-property
               index (1+ index) 'help-echo
@@ -307,7 +316,7 @@ current time."
                (setq last-done-date (car done-dates)
                      done-dates (cdr done-dates))))
          (if todayp
-             (aset graph index ?!)))
+             (aset graph index org-habit-today-glyph)))
        (setq face (if (or in-the-past-p todayp)
                       (car faces)
                     (cdr faces)))
@@ -358,6 +367,4 @@ current time."
 
 (provide 'org-habit)
 
-
-
 ;;; org-habit.el ends here
index 46126ce25736bc6837c9a60423a0a8a2a0c195b1..c6a19c8d8ba9a713b895638835bbce49e39eae0e 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-html.el --- HTML export for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -34,6 +33,8 @@
 
 (declare-function org-id-find-id-file "org-id" (id))
 (declare-function htmlize-region "ext:htmlize" (beg end))
+(declare-function org-pop-to-buffer-same-window
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 (defgroup org-export-html nil
   "Options specific for HTML export of Org-mode files."
@@ -155,6 +156,12 @@ not be modified."
   dt { font-weight: bold; }
   div.figure { padding: 0.5em; }
   div.figure p { text-align: center; }
+  div.inlinetask {
+    padding:10px;
+    border:2px solid gray;
+    margin:10px;
+    background: #ffffcc;
+  }
   textarea { overflow-x: auto; }
   .linenr { font-size:smaller }
   .code-highlighted {background-color:#ffff00;}
@@ -348,6 +355,14 @@ CSS classes, then this prefix can be very useful."
   :group 'org-export-html
   :type 'string)
 
+(defcustom org-export-html-headline-anchor-format "<a name=\"%s\" id=\"%s\"></a>"
+  "Format for anchors in HTML headlines.
+It requires to %s: both will be replaced by the anchor referring
+to the headline (e.g. \"sec-2\").  When set to `nil', don't insert
+HTML anchors in headlines."
+  :group 'org-export-html
+  :type 'string)
+
 (defcustom org-export-html-preamble t
   "Non-nil means insert a preamble in HTML export.
 
@@ -355,8 +370,8 @@ When `t', insert a string as defined by one of the formatting
 strings in `org-export-html-preamble-format'.  When set to a
 string, this string overrides `org-export-html-preamble-format'.
 When set to a function, apply this function and insert the
-returned string.  The function takes the property list of export
-options as its only argument.
+returned string.  The function takes no argument, but you can
+use `opt-plist' to access the current export options.
 
 Setting :html-preamble in publishing projects will take
 precedence over this variable."
@@ -388,8 +403,8 @@ string overrides `org-export-html-postamble-format'.  When set to
 'auto, discard `org-export-html-postamble-format' and honor
 `org-export-author/email/creator-info' variables.  When set to a
 function, apply this function and insert the returned string.
-The function takes the property list of export options as its
-only argument.
+The function takes no argument, but you can use `opt-plist' to
+access the current export options.
 
 Setting :html-postamble in publishing projects will take
 precedence over this variable."
@@ -619,7 +634,10 @@ This variable is obsolete since Org version 7.7.
 Please set `org-export-html-divs' instead.")
 
 (defcustom org-export-html-divs '("preamble" "content" "postamble")
-  "The name of the main divs for HTML export."
+  "The name of the main divs for HTML export.
+This is a list of three strings, the first one for the preamble
+DIV, the second one for the content DIV and the third one for the
+postamble DIV."
   :group 'org-export-html
   :type '(list
          (string :tag " Div for the preamble:")
@@ -703,7 +721,7 @@ command to convert it."
   (interactive "r")
   (let (reg html buf pop-up-frames)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
          (setq html (org-export-region-as-html
                      beg end t 'string))
        (setq reg (buffer-substring beg end)
@@ -801,11 +819,11 @@ description.  See variables `org-export-html-inline-images' and
                             may-inline-p)
    "Make an HTML link.
 OPT-PLIST is an options list.
-TYPE is the device-type of the link (THIS://foo.html)
-PATH is the path of the link (http://THIS#locationx)
-FRAGMENT is the fragment part of the link, if any (foo.html#THIS)
+TYPE is the device-type of the link (THIS://foo.html).
+PATH is the path of the link (http://THIS#location).
+FRAGMENT is the fragment part of the link, if any (foo.html#THIS).
 DESC is the link description, if any.
-ATTR is a string of other attributes of the a element.
+ATTR is a string of other attributes of the \"a\" element.
 MAY-INLINE-P allows inlining it as an image."
 
    (declare (special org-par-open))
@@ -896,7 +914,7 @@ OPT-PLIST is the export options list."
                         (string-match "^\\.\\.?/" path)))
                   "file")
                  (t "internal")))
-      (setq path (org-extract-attributes (org-link-unescape path)))
+      (setq path (org-extract-attributes path))
       (setq attr (get-text-property 0 'org-attributes path))
       (setq desc1 (if (match-end 5) (match-string 5 line))
            desc2 (if (match-end 2) (concat type ":" path) path)
@@ -909,7 +927,7 @@ OPT-PLIST is the export options list."
          (if (string-match "^file:" desc)
              (setq desc (substring desc (match-end 0)))))
        (setq desc (org-add-props
-                      (concat "<img src=\"" desc "\" alt=\"" 
+                      (concat "<img src=\"" desc "\" alt=\""
                               (file-name-nondirectory desc) "\"/>")
                       '(org-protected t))))
       (cond
@@ -1036,14 +1054,17 @@ OPT-PLIST is the export options list."
 
        (t
        ;; just publish the path, as default
-       (setq rpl (concat "@<i>&lt;" type ":"
+       (setq rpl (concat "<i>&lt;" type ":"
                          (save-match-data (org-link-unescape path))
-                         "&gt;@</i>"))))
+                         "&gt;</i>"))))
       (setq line (replace-match rpl t t line)
            start (+ start (length rpl))))
     line))
 
 ;;; org-export-as-html
+
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
+
 ;;;###autoload
 (defun org-export-as-html (arg &optional hidden ext-plist
                               to-buffer body-only pub-dir)
@@ -1137,14 +1158,15 @@ PUB-DIR is set, use this as the publishing directory."
         (current-dir (if buffer-file-name
                          (file-name-directory buffer-file-name)
                        default-directory))
+        (auto-insert nil); Avoid any auto-insert stuff for the new file
         (buffer (if to-buffer
                     (cond
                      ((eq to-buffer 'string) (get-buffer-create "*Org HTML Export*"))
                      (t (get-buffer-create to-buffer)))
                   (find-file-noselect filename)))
         (org-levels-open (make-vector org-level-max nil))
-        (date (plist-get opt-plist :date))
-        (author      (plist-get opt-plist :author))
+        (date        (org-html-expand (plist-get opt-plist :date)))
+        (author      (org-html-expand (plist-get opt-plist :author)))
         (html-validation-link (or org-export-html-validation-link ""))
         (title       (org-html-expand
                       (or (and subtree-p (org-export-get-title-from-subtree))
@@ -1165,15 +1187,16 @@ PUB-DIR is set, use this as the publishing directory."
                         (plist-get opt-plist :link-home)))
         (dummy (setq opt-plist (plist-put opt-plist :title title)))
         (html-table-tag (plist-get opt-plist :html-table-tag))
-        (quote-re0   (concat "^[ \t]*" org-quote-string "\\>"))
-        (quote-re    (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
+        (quote-re0   (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
+        (quote-re    (format org-heading-keyword-regexp-format
+                             org-quote-string))
         (inquote     nil)
         (infixed     nil)
         (inverse     nil)
         (email       (plist-get opt-plist :email))
         (language    (plist-get opt-plist :language))
-        (keywords    (plist-get opt-plist :keywords))
-        (description (plist-get opt-plist :description))
+        (keywords    (org-html-expand (plist-get opt-plist :keywords)))
+        (description (org-html-expand (plist-get opt-plist :description)))
         (num         (plist-get opt-plist :section-numbers))
         (lang-words  nil)
         (head-count  0) cnt
@@ -1287,11 +1310,11 @@ PUB-DIR is set, use this as the publishing directory."
                 "%s
 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
                \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
-<html xmlns=\"http://www.w3.org/1999/xhtml\"
-lang=\"%s\" xml:lang=\"%s\">
+<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">
 <head>
 <title>%s</title>
 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
+<meta name=\"title\" content=\"%s\"/>
 <meta name=\"generator\" content=\"Org-mode\"/>
 <meta name=\"generated\" content=\"%s\"/>
 <meta name=\"author\" content=\"%s\"/>
@@ -1314,7 +1337,7 @@ lang=\"%s\" xml:lang=\"%s\">
                 language language
                 title
                 (or charset "iso-8859-1")
-                date author description keywords
+                title date author description keywords
                 style
                 mathjax
                 (if (or link-up link-home)
@@ -1327,28 +1350,35 @@ lang=\"%s\" xml:lang=\"%s\">
 
        ;; insert html preamble
        (when (plist-get opt-plist :html-preamble)
-         (let ((html-pre (plist-get opt-plist :html-preamble)))
-           (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+         (let ((html-pre (plist-get opt-plist :html-preamble))
+               html-pre-real-contents)
            (cond ((stringp html-pre)
-                  (insert
-                   (format-spec html-pre `((?t . ,title) (?a . ,author)
-                                           (?d . ,date) (?e . ,email)))))
+                  (setq html-pre-real-contents
+                        (format-spec html-pre `((?t . ,title) (?a . ,author)
+                                                (?d . ,date) (?e . ,email)))))
                  ((functionp html-pre)
-                  (funcall html-pre))
+                  (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+                  (if (stringp (funcall html-pre)) (insert (funcall html-pre)))
+                  (insert "\n</div>\n"))
                  (t
-                  (insert
+                  (setq html-pre-real-contents
                    (format-spec
                     (or (cadr (assoc (nth 0 lang-words)
                                      org-export-html-preamble-format))
                         (cadr (assoc "en" org-export-html-preamble-format)))
                     `((?t . ,title) (?a . ,author)
                       (?d . ,date) (?e . ,email))))))
-           (insert "\n</div>\n")))
+           ;; don't output an empty preamble DIV
+           (unless (and (functionp html-pre)
+                        (equal html-pre-real-contents ""))
+             (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+             (insert html-pre-real-contents)
+             (insert "\n</div>\n"))))
 
        ;; begin wrap around body
-       (insert (format "\n<div id=\"%s\">" 
+       (insert (format "\n<div id=\"%s\">"
                        ;; FIXME org-export-html-content-div is obsolete since 7.7
-                       (or org-export-html-content-div 
+                       (or org-export-html-content-div
                            (nth 1 org-export-html-divs)))
                ;; FIXME this should go in the preamble but is here so
                ;; that org-infojs can still find it
@@ -1365,7 +1395,7 @@ lang=\"%s\" xml:lang=\"%s\">
            (push "<div id=\"text-table-of-contents\">\n" thetoc)
            (push "<ul>\n<li>" thetoc)
            (setq lines
-                 (mapcar 
+                 (mapcar
                   #'(lambda (line)
                       (if (and (string-match org-todo-line-regexp line)
                                (not (get-text-property 0 'org-protected line)))
@@ -1391,7 +1421,7 @@ lang=\"%s\" xml:lang=\"%s\">
                                             line lines level))))
                             (if (string-match
                                  (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
-                                (setq txt (replace-match  
+                                (setq txt (replace-match
                                            "&nbsp;&nbsp;&nbsp;<span class=\"tag\"> \\1</span>" t nil txt)))
                             (if (string-match quote-re0 txt)
                                 (setq txt (replace-match "" t t txt)))
@@ -1419,7 +1449,7 @@ lang=\"%s\" xml:lang=\"%s\">
                                   ;; Check for targets
                                   (while (string-match org-any-target-regexp line)
                                     (setq line (replace-match
-                                                (concat "@<span class=\"target\">" 
+                                                (concat "@<span class=\"target\">"
                                                         (match-string 1 line) "@</span> ")
                                                 t t line)))
                                   (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
@@ -1427,8 +1457,8 @@ lang=\"%s\" xml:lang=\"%s\">
                                   (setq href
                                         (replace-regexp-in-string
                                          "\\." "-" (format "sec-%s" snumber)))
-                                  (setq href (org-solidify-link-text 
-                                              (or (cdr (assoc href 
+                                  (setq href (org-solidify-link-text
+                                              (or (cdr (assoc href
                                                               org-export-preferred-target-alist)) href)))
                                   (push
                                    (format
@@ -1436,7 +1466,7 @@ lang=\"%s\" xml:lang=\"%s\">
                                         "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>"
                                       "</li>\n<li><a href=\"#%s\">%s</a>")
                                     href txt) thetoc)
-                                  
+
                                   (setq org-last-level level)))))
                       line)
                   lines))
@@ -1445,15 +1475,15 @@ lang=\"%s\" xml:lang=\"%s\">
              (push "</li>\n</ul>\n" thetoc))
            (push "</div>\n" thetoc)
            (setq thetoc (if have-headings (nreverse thetoc) nil))))
-      
+
       (setq head-count 0)
       (org-init-section-numbers)
-      
+
       (org-open-par)
-      
+
       (while (setq line (pop lines) origline line)
        (catch 'nextline
-         
+
          ;; end of quote section?
          (when (and inquote (string-match org-outline-regexp-bol line))
            (insert "</pre>\n")
@@ -1588,7 +1618,8 @@ lang=\"%s\" xml:lang=\"%s\">
          (setq line (org-html-handle-links line opt-plist))
 
          ;; TODO items
-         (if (and (string-match org-todo-line-regexp line)
+         (if (and org-todo-line-regexp
+                  (string-match org-todo-line-regexp line)
                   (match-beginning 2))
 
              (setq line
@@ -1597,9 +1628,9 @@ lang=\"%s\" xml:lang=\"%s\">
                            (if (member (match-string 2 line)
                                        org-done-keywords)
                                "done" "todo")
-                           " " (match-string 2 line)
-                           "\"> " (org-export-html-get-todo-kwd-class-name
-                                   (match-string 2 line))
+                           " " (org-export-html-get-todo-kwd-class-name
+                                (match-string 2 line))
+                           "\"> " (match-string 2 line)
                            "</span>" (substring line (match-end 2)))))
 
          ;; Does this contain a reference to a footnote?
@@ -1636,7 +1667,7 @@ lang=\"%s\" xml:lang=\"%s\">
                         t t line))))))
 
          (cond
-          ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
+          ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
            ;; This is a headline
            (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
                                         level-offset))
@@ -1785,7 +1816,7 @@ lang=\"%s\" xml:lang=\"%s\">
                                          (?d . ,date)   (?c . ,creator-info)
                                          (?v . ,html-validation-link)))))
                  ((functionp html-post)
-                  (funcall html-post))
+                  (if (stringp (funcall html-post)) (insert (funcall html-post))))
                  ((eq html-post 'auto)
                   ;; fall back on default postamble
                   (when (plist-get opt-plist :time-stamp-file)
@@ -1808,7 +1839,7 @@ lang=\"%s\" xml:lang=\"%s\">
                              (?d . ,date)   (?c . ,creator-info)
                              (?v . ,html-validation-link))))))
            (insert "\n</div>"))))
-      
+
       ;; FIXME `org-export-html-with-timestamp' has been declared
       ;; obsolete since Org 7.7 -- don't forget to remove this.
       (if org-export-html-with-timestamp
@@ -1941,7 +1972,7 @@ NO-CSS is passed to the exporter."
   (if (string-match "^[ \t]*|" (car lines))
       ;; A normal org table
       (org-format-org-table-html lines nil no-css)
-    ;; Table made by table.el 
+    ;; Table made by table.el
     (or (org-format-table-table-html-using-table-generate-source
         olines (not org-export-prefer-native-exporter-for-tables))
        ;; We are here only when table.el table has NO col or row
@@ -1969,8 +2000,8 @@ for formatting.  This is required for the DocBook exporter."
 
   (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
         (label (org-find-text-property-in-string 'org-label (car lines)))
-        (forced-aligns (org-find-text-property-in-string 'org-forced-aligns
-                                                         (car lines)))
+        (col-cookies (org-find-text-property-in-string 'org-col-cookies
+                                                       (car lines)))
         (attributes (org-find-text-property-in-string 'org-attributes
                                                       (car lines)))
         (html-table-tag (org-export-splice-attributes
@@ -1983,9 +2014,9 @@ for formatting.  This is required for the DocBook exporter."
         tbopen line fields html gr colgropen rowstart rowend
         ali align aligns n)
     (setq caption (and caption (org-html-do-expand caption)))
-    (when (and forced-aligns org-table-clean-did-remove-column)
-    (setq forced-aligns
-         (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns)))
+    (when (and col-cookies org-table-clean-did-remove-column)
+      (setq col-cookies
+           (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
     (if splice (setq head nil))
     (unless splice (push (if head "<thead>" "<tbody>") html))
     (setq tbopen t)
@@ -2046,8 +2077,8 @@ for formatting.  This is required for the DocBook exporter."
             (lambda (x)
               (setq gr (pop org-table-colgroup-info)
                     i (1+ i)
-                    align (if (assoc i forced-aligns)
-                              (cdr (assoc (cdr (assoc i forced-aligns))
+                    align (if (nth 1 (assoc i col-cookies))
+                              (cdr (assoc (nth 1 (assoc i col-cookies))
                                           '(("l" . "left") ("r" . "right")
                                             ("c" . "center"))))
                             (if (> (/ (float x) nline)
@@ -2203,19 +2234,20 @@ for further information."
   "Format time stamps in string S, or remove them."
   (catch 'exit
     (let (r b)
-      (while (string-match org-maybe-keyword-time-regexp s)
-       (or b (setq b (substring s 0 (match-beginning 0))))
-       (setq r (concat
-                r (substring s 0 (match-beginning 0))
-                " @<span class=\"timestamp-wrapper\">"
-                (if (match-end 1)
-                    (format "@<span class=\"timestamp-kwd\">%s @</span>"
-                            (match-string 1 s)))
-                (format " @<span class=\"timestamp\">%s@</span>"
-                        (substring
-                         (org-translate-time (match-string 3 s)) 1 -1))
-                "@</span>")
-             s (substring s (match-end 0))))
+      (when org-maybe-keyword-time-regexp
+       (while (string-match org-maybe-keyword-time-regexp s)
+         (or b (setq b (substring s 0 (match-beginning 0))))
+         (setq r (concat
+                  r (substring s 0 (match-beginning 0))
+                  " @<span class=\"timestamp-wrapper\">"
+                  (if (match-end 1)
+                      (format "@<span class=\"timestamp-kwd\">%s @</span>"
+                              (match-string 1 s)))
+                  (format " @<span class=\"timestamp\">%s@</span>"
+                          (substring
+                           (org-translate-time (match-string 3 s)) 1 -1))
+                  "@</span>")
+               s (substring s (match-end 0)))))
       ;; Line break if line started and ended with time stamp stuff
       (if (not r)
          s
@@ -2263,7 +2295,7 @@ that uses these same face definitions."
        (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*")
+  (org-pop-to-buffer-same-window "*html*")
   (goto-char (point-min))
   (if (re-search-forward "<style" nil t)
       (delete-region (point-min) (match-beginning 0)))
@@ -2286,18 +2318,20 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
 
 (defun org-html-expand (string)
   "Prepare STRING for HTML export.  Apply all active conversions.
-If there are links in the string, don't modify these."
-  (let* ((re (concat org-bracket-link-regexp "\\|"
-                    (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
-        m s l res)
-    (while (setq m (string-match re string))
-      (setq s (substring string 0 m)
-           l (match-string 0 string)
-           string (substring string (match-end 0)))
-      (push (org-html-do-expand s) res)
+If there are links in the string, don't modify these.  If STRING
+is nil, return nil."
+  (when string
+    (let* ((re (concat org-bracket-link-regexp "\\|"
+                      (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
+          m s l res)
+      (while (setq m (string-match re string))
+       (setq s (substring string 0 m)
+             l (match-string 0 string)
+             string (substring string (match-end 0)))
+       (push (org-html-do-expand s) res)
       (push l res))
-    (push (org-html-do-expand string) res)
-    (apply 'concat (nreverse res))))
+      (push (org-html-do-expand string) res)
+      (apply 'concat (nreverse res)))))
 
 (defun org-html-do-expand (s)
   "Apply all active conversions to translate special ASCII to HTML."
@@ -2412,8 +2446,9 @@ When TITLE is nil, just close all open levels."
          (mapconcat (lambda (x)
                       (setq x (org-solidify-link-text
                                (if (org-uuidgen-p x) (concat "ID-" x) x)))
-                      (format "<a name=\"%s\" id=\"%s\"></a>"
-                              x x))
+                      (if (stringp org-export-html-headline-anchor-format)
+                          (format org-export-html-headline-anchor-format x x)
+                        ""))
                     extra-targets
                     ""))
     (while (>= l level)
@@ -2604,5 +2639,4 @@ the alist of previous items."
 
 (provide 'org-html)
 
-
 ;;; org-html.el ends here
index 8a2d66306f37835831d24dc697b631128ced68e6..969d895634a6b0aa823d720685bd901eb098520a 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-icalendar.el --- iCalendar export for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -204,7 +203,7 @@ When nil of the empty string, use the abbreviation retrieved from Emacs."
   (if org-icalendar-use-UTC-date-time
       ":%Y%m%dT%H%M%SZ"
     ":%Y%m%dT%H%M%S")
-  "Format-string for exporting iCalendar DATE-TIME.
+  "Format-string for exporting icalendar DATE-TIME.
 See `format-time-string' for a full documentation.  The only
 difference is that `org-icalendar-timezone' is used for %Z.
 
@@ -418,7 +417,7 @@ When COMBINE is non nil, add the category to each line."
          (let ((t1 (ignore-errors (org-parse-time-string ts 'nodefault))))
            (if (and (> org-icalendar-alarm-time 0)
                     (car t1) (nth 1 t1) (nth 2 t1))
-               (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0D0H%dM0S\nEND:VALARM" summary org-icalendar-alarm-time))
+               (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0DT0H%dM0S\nEND:VALARM" summary org-icalendar-alarm-time))
              (setq alarm ""))
            )
          (if (string-match org-bracket-link-regexp summary)
@@ -684,5 +683,4 @@ a time), or the day by one (if it does not contain a time)."
 
 (provide 'org-icalendar)
 
-
 ;;; org-icalendar.el ends here
index c2d5cf0f25badbdc9b3bd05357f80a14d0eaa9f1..a00297d6a60fc25be20f1bc49a219b20b5a9f487 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -74,6 +73,8 @@
 (require 'org)
 
 (declare-function message-make-fqdn "message" ())
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 ;;; Customization
 
@@ -253,7 +254,7 @@ Move the cursor to that entry in that buffer."
   (let ((m (org-id-find id 'marker)))
     (unless m
       (error "Cannot find entry with ID \"%s\"" id))
-    (switch-to-buffer (marker-buffer m))
+    (org-pop-to-buffer-same-window (marker-buffer m))
     (goto-char m)
     (move-marker m nil)
     (org-show-context)))
@@ -430,7 +431,7 @@ When CHECK is given, prepare detailed information about duplicate IDs."
                 (delq nil
                       (mapcar (lambda (b)
                                 (with-current-buffer b
-                                  (and (org-mode-p) (buffer-file-name))))
+                                  (and (eq major-mode 'org-mode) (buffer-file-name))))
                               (buffer-list)))
                 ;; All files known to have IDs
                 org-id-files)))
@@ -599,7 +600,7 @@ optional argument MARKERP, return the position as a new marker."
 (defun org-id-store-link ()
   "Store a link to the current entry, using its ID."
   (interactive)
-  (when (and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+  (when (and (buffer-file-name (buffer-base-buffer)) (eq major-mode 'org-mode))
     (let* ((link (org-make-link "id:" (org-id-get-create)))
           (case-fold-search nil)
           (desc (save-excursion
index a2099a4bde3d52800397732be94f7d600b5d66fe..034b1630b0cb6151ec600f720fc4b5b20cd0eb9c 100644 (file)
@@ -4,7 +4,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 ;; This is an implementation of dynamic virtual indentation.  It works
 ;; by adding text properties to a buffer to make sure lines are
 ;; indented according to outline structure.
-
+;;
+;; The process is synchronous, toggled at every buffer modification.
+;; Though, the initialization (indentation of text already in the
+;; buffer), which can take a few seconds in large buffers, happens on
+;; idle time.
+;;
 ;;; Code:
 
 (require 'org-macs)
@@ -38,9 +42,9 @@
 (eval-when-compile
   (require 'cl))
 
-(defvar org-inlinetask-min-level)
 (declare-function org-inlinetask-get-task-level "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
+(declare-function org-list-item-body-column "org-list" (item))
 
 (defgroup org-indent nil
   "Options concerning dynamic virtual outline indentation."
 
 (defconst org-indent-max 40
   "Maximum indentation in characters.")
-(defconst org-indent-max-levels 40
-  "Maximum indentation in characters.")
+(defconst org-indent-max-levels 20
+  "Maximum added level through virtual indentation, in characters.
+
+It is computed by multiplying `org-indent-indentation-per-level'
+minus one by actual level of the headline minus one.")
 
 (defvar org-indent-strings nil
   "Vector with all indentation strings.
@@ -58,8 +65,31 @@ It will be set in `org-indent-initialize'.")
 (defvar org-indent-stars nil
   "Vector with all indentation star strings.
 It will be set in `org-indent-initialize'.")
+(defvar org-indent-inlinetask-first-star (org-add-props "*" '(face org-warning))
+  "First star of inline tasks, with correct face.")
+(defvar org-indent-agent-timer nil
+  "Timer running the initialize agent.")
+(defvar org-indent-agentized-buffers nil
+  "List of buffers watched by the initialize agent.")
+(defvar org-indent-agent-resume-timer nil
+  "Timer to reschedule agent after switching to other idle processes.")
+(defvar org-indent-agent-active-delay '(0 2 0)
+  "Time to run agent before switching to other idle processes.
+Delay used when the buffer to initialize is current.")
+(defvar org-indent-agent-passive-delay '(0 0 400000)
+  "Time to run agent before switching to other idle processes.
+Delay used when the buffer to initialize isn't current.")
+(defvar org-indent-agent-resume-delay '(0 0 100000)
+  "Minimal time for other idle processes before switching back to agent.")
+(defvar org-indent-initial-marker nil
+  "Position of initialization before interrupt.
+This is used locally in each buffer being initialized.")
 (defvar org-hide-leading-stars-before-indent-mode nil
   "Used locally.")
+(defvar org-indent-modified-headline-flag nil
+  "Non-nil means the last deletion operated on an headline.
+It is modified by `org-indent-notify-modified-headline'.")
+
 
 (defcustom org-indent-boundary-char ?\   ; comment to protect space char
   "The end of the virtual indentation strings, a single-character string.
@@ -90,28 +120,15 @@ turn on `org-hide-leading-stars'."
   :group 'org-indent
   :type 'integer)
 
-(defcustom org-indent-fix-section-after-idle-time 0.2
-  "Seconds of idle time before fixing virtual indentation of section.
-The hooking-in of virtual indentation is not yet perfect.  Occasionally,
-a change does not trigger to proper change of indentation.  For this we
-have a timer action that fixes indentation in the current section after
-a short amount idle time.  If we ever get the integration to work perfectly,
-this variable can be set to nil to get rid of the timer."
-  :group 'org-indent
-  :type '(choice
-         (const "Do not install idle timer" nil)
-         (number :tag "Idle time")))
+(defface org-indent
+  (org-compatible-face nil nil)
+  "Face for outline indentation.
+The default is to make it look like whitespace.  But you may find it
+useful to make it ever so slightly different."
+  :group 'org-faces)
 
 (defun org-indent-initialize ()
-  "Initialize the indentation strings and set the idle timer."
-  ;; We use an idle timer to "repair" the current section, because the
-  ;; redisplay seems to have some problems.
-  (unless org-indent-strings
-    (when org-indent-fix-section-after-idle-time
-      (run-with-idle-timer
-       org-indent-fix-section-after-idle-time
-       t 'org-indent-refresh-section)))
-  ;; Initialize the indentation and star vectors
+  "Initialize the indentation strings."
   (setq org-indent-strings (make-vector (1+ org-indent-max) nil))
   (setq org-indent-stars (make-vector (1+ org-indent-max) nil))
   (aset org-indent-strings 0 nil)
@@ -127,14 +144,21 @@ this variable can be set to nil to get rid of the timer."
              (org-add-props (make-string i ?*)
                  nil 'face 'org-hide))))
 
+(defsubst org-indent-remove-properties (beg end)
+  "Remove indentations between BEG and END."
+  (with-silent-modifications
+    (remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
+
 ;;;###autoload
 (define-minor-mode org-indent-mode
   "When active, indent text according to outline structure.
 
-Internally this works by adding `line-prefix' properties to all non-headlines.
-These properties are updated locally in idle time.
-FIXME:  How to update when broken?"
-  nil " Ind" nil
+Internally this works by adding `line-prefix' and `wrap-prefix'
+properties, after each buffer modification, on the modified zone.
+
+The process is synchronous.  Though, initial indentation of
+buffer, which can take a few seconds on large buffers, is done
+during idle time." nil " Ind" nil
   (cond
    ((org-bound-and-true-p org-inhibit-startup)
     (setq org-indent-mode nil))
@@ -151,6 +175,7 @@ FIXME:  How to update when broken?"
     ;; mode was turned on.
     (org-set-local 'indent-tabs-mode nil)
     (or org-indent-strings (org-indent-initialize))
+    (org-set-local 'org-indent-initial-marker (copy-marker 1))
     (when org-indent-mode-turns-off-org-adapt-indentation
       (org-set-local 'org-adapt-indentation nil))
     (when org-indent-mode-turns-on-hiding-stars
@@ -160,56 +185,49 @@ FIXME:  How to update when broken?"
     (make-local-variable 'buffer-substring-filters)
     (add-to-list 'buffer-substring-filters
                 'org-indent-remove-properties-from-string)
-    (org-add-hook 'org-after-demote-entry-hook
-                 'org-indent-refresh-section nil 'local)
-    (org-add-hook 'org-after-promote-entry-hook
-                 'org-indent-refresh-section nil 'local)
-    (org-add-hook 'org-font-lock-hook
-                 'org-indent-refresh-to nil 'local)
+    (org-add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local)
+    (org-add-hook 'before-change-functions
+                 'org-indent-notify-modified-headline nil 'local)
     (and font-lock-mode (org-restart-font-lock))
-    )
+    (org-indent-remove-properties (point-min) (point-max))
+    ;; Submit current buffer to initialize agent.  If it's the first
+    ;; buffer submitted, also start the agent.  Current buffer is
+    ;; pushed in both cases to avoid a race condition.
+    (if org-indent-agentized-buffers
+       (push (current-buffer) org-indent-agentized-buffers)
+      (push (current-buffer) org-indent-agentized-buffers)
+      (setq org-indent-agent-timer
+           (run-with-idle-timer 0.2 t #'org-indent-initialize-agent))))
    (t
     ;; mode was turned off (or we refused to turn it on)
-    (save-excursion
-      (save-restriction
-       (org-indent-remove-properties (point-min) (point-max))
-       (kill-local-variable 'org-adapt-indentation)
-       (when (boundp 'org-hide-leading-stars-before-indent-mode)
-         (org-set-local 'org-hide-leading-stars
-                        org-hide-leading-stars-before-indent-mode))
-       (setq buffer-substring-filters
-             (delq 'org-indent-remove-properties-from-string
-                   buffer-substring-filters))
-       (remove-hook 'org-after-promote-entry-hook
-                    'org-indent-refresh-section 'local)
-       (remove-hook 'org-after-demote-entry-hook
-                    'org-indent-refresh-section 'local)
-       (and font-lock-mode (org-restart-font-lock))
-       (redraw-display))))))
-
-
-(defface org-indent
-  (org-compatible-face nil nil)
-  "Face for outline indentation.
-The default is to make it look like whitespace.  But you may find it
-useful to make it ever so slightly different."
-  :group 'org-faces)
+    (kill-local-variable 'org-adapt-indentation)
+    (setq org-indent-agentized-buffers
+         (delq (current-buffer) org-indent-agentized-buffers))
+    (when (markerp org-indent-initial-marker)
+      (set-marker org-indent-initial-marker nil))
+    (when (boundp 'org-hide-leading-stars-before-indent-mode)
+      (org-set-local 'org-hide-leading-stars
+                    org-hide-leading-stars-before-indent-mode))
+    (setq buffer-substring-filters
+         (delq 'org-indent-remove-properties-from-string
+               buffer-substring-filters))
+    (remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local)
+    (remove-hook 'before-change-functions
+                'org-indent-notify-modified-headline 'local)
+    (org-with-wide-buffer
+     (org-indent-remove-properties (point-min) (point-max)))
+    (and font-lock-mode (org-restart-font-lock))
+    (redraw-display))))
 
 (defun org-indent-indent-buffer ()
-  "Add indentation properties for the whole buffer."
+  "Add indentation properties to the accessible part of the buffer."
   (interactive)
-  (when org-indent-mode
-    (save-excursion
-      (save-restriction
-       (widen)
-       (org-indent-remove-properties (point-min) (point-max))
-       (org-indent-add-properties (point-min) (point-max))))))
-
-(defun org-indent-remove-properties (beg end)
-  "Remove indentations between BEG and END."
-  (let ((inhibit-modification-hooks t))
-    (with-silent-modifications
-      (remove-text-properties beg end '(line-prefix nil wrap-prefix nil)))))
+  (if (not (eq major-mode 'org-mode))
+      (error "Not in Org mode")
+    (message "Setting buffer indentation. It may take a few seconds...")
+    (org-indent-remove-properties (point-min) (point-max))
+    (org-indent-add-properties (point-min) (point-max))
+    (message "Indentation of buffer set.")))
 
 (defun org-indent-remove-properties-from-string (string)
   "Remove indentation properties from STRING."
@@ -217,110 +235,193 @@ useful to make it ever so slightly different."
                          '(line-prefix nil wrap-prefix nil) string)
   string)
 
-(defvar org-indent-outline-re org-outline-regexp-bol
-  "Outline heading regexp.")
+(defun org-indent-initialize-agent ()
+  "Start or resume current buffer initialization.
+Only buffers in `org-indent-agentized-buffers' trigger an action.
+When no more buffer is being watched, the agent suppress itself."
+  (when org-indent-agent-resume-timer
+    (cancel-timer org-indent-agent-resume-timer))
+  (setq org-indent-agentized-buffers
+       (org-remove-if-not #'buffer-live-p org-indent-agentized-buffers))
+  (cond
+   ;; Job done:  kill agent.
+   ((not org-indent-agentized-buffers) (cancel-timer org-indent-agent-timer))
+   ;; Current buffer is agentized: start/resume initialization
+   ;; somewhat aggressively.
+   ((memq (current-buffer) org-indent-agentized-buffers)
+    (org-indent-initialize-buffer (current-buffer)
+                                 org-indent-agent-active-delay))
+   ;; Else, start/resume initialization of the last agentized buffer,
+   ;; softly.
+   (t (org-indent-initialize-buffer (car org-indent-agentized-buffers)
+                                   org-indent-agent-passive-delay))))
+
+(defun org-indent-initialize-buffer (buffer delay)
+  "Set virtual indentation for the buffer BUFFER, asynchronously.
+Give hand to other idle processes if it takes longer than DELAY,
+a time value."
+  (with-current-buffer buffer
+    (when org-indent-mode
+      (org-with-wide-buffer
+       (let ((interruptp
+             ;; Always nil unless interrupted.
+             (catch 'interrupt
+               (and org-indent-initial-marker
+                    (marker-position org-indent-initial-marker)
+                    (org-indent-add-properties org-indent-initial-marker
+                                               (point-max)
+                                               delay)
+                    nil))))
+        (move-marker org-indent-initial-marker interruptp)
+        ;; Job is complete: un-agentize buffer.
+        (unless interruptp
+          (setq org-indent-agentized-buffers
+                (delq buffer org-indent-agentized-buffers))))))))
 
-(defun org-indent-add-properties (beg end)
+(defsubst org-indent-set-line-properties (l w h)
+  "Set prefix properties on current line an move to next one.
+
+Prefix properties `line-prefix' and `wrap-prefix' in current line
+are set to, respectively, length L and W.
+
+If H is non-nil, `line-prefix' will be starred.  If H is
+`inline', the first star will have `org-warning' face.
+
+Assume point is at beginning of line."
+  (let ((line (cond
+              ((eq 'inline h)
+               (let ((stars (aref org-indent-stars
+                                  (min l org-indent-max-levels))))
+                 (and stars
+                      (concat org-indent-inlinetask-first-star
+                              (substring stars 1)))))
+              (h (aref org-indent-stars
+                       (min l org-indent-max-levels)))
+              (t (aref org-indent-strings
+                       (min l org-indent-max)))))
+       (wrap (aref org-indent-strings (min w org-indent-max))))
+    ;; Add properties down to the next line to indent empty lines.
+    (add-text-properties (point) (min (1+ (point-at-eol)) (point-max))
+                        `(line-prefix ,line wrap-prefix ,wrap)))
+  (forward-line 1))
+
+(defun org-indent-add-properties (beg end &optional delay)
   "Add indentation properties between BEG and END.
-Assumes that BEG is at the beginning of a line."
-  (let* ((inhibit-modification-hooks t)
-        (inlinetaskp (featurep 'org-inlinetask))
-        (get-real-level (lambda (pos lvl)
-                          (save-excursion
-                            (goto-char pos)
-                            (if (and inlinetaskp (org-inlinetask-in-task-p))
-                                (org-inlinetask-get-task-level)
-                              lvl))))
-        (b beg)
-        (e end)
-        (level 0)
-        (n 0)
-        exit nstars)
-    (with-silent-modifications
-      (save-excursion
-       (goto-char beg)
-       (while (not exit)
-         (setq e end)
-         (if (not (re-search-forward org-indent-outline-re nil t))
-             (setq e (point-max) exit t)
-           (setq e (match-beginning 0))
-           (if (>= e end) (setq exit t))
-           (unless (and inlinetaskp (org-inlinetask-in-task-p))
-             (setq level (- (match-end 0) (match-beginning 0) 1)))
-           (setq nstars (* (1- (funcall get-real-level e level))
-                           (1- org-indent-indentation-per-level)))
-           (add-text-properties
-            (point-at-bol) (point-at-eol)
-            (list 'line-prefix
-                  (aref org-indent-stars nstars)
-                  'wrap-prefix
-                  (aref org-indent-strings
-                        (* (funcall get-real-level e level)
-                           org-indent-indentation-per-level)))))
-         (when (> e b)
-           (add-text-properties
-            b  e (list 'line-prefix (aref org-indent-strings n)
-                       'wrap-prefix (aref org-indent-strings n))))
-         (setq b (1+ (point-at-eol))
-               n (* (funcall get-real-level b level)
-                    org-indent-indentation-per-level)))))))
-
-(defvar org-inlinetask-min-level)
-(defun org-indent-refresh-section ()
-  "Refresh indentation properties in the current outline section.
-Point is assumed to be at the beginning of a headline."
-  (interactive)
-  (when org-indent-mode
-    (let (beg end)
-      (save-excursion
-       (when (ignore-errors (let ((org-outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
-                               (if (featurep 'org-inlinetask)
-                                   (1- org-inlinetask-min-level)
-                                 ""))))
-                              (org-back-to-heading)))
-         (setq beg (point))
-         (setq end (or (save-excursion (or (outline-next-heading) (point)))))
-         (org-indent-remove-properties beg end)
-         (org-indent-add-properties beg end))))))
-
-(defun org-indent-refresh-to (limit)
-  "Refresh indentation properties in the current outline section.
-Point is assumed to be at the beginning of a headline."
-  (interactive)
-  (when org-indent-mode
-    (let ((beg (point)) (end limit))
-      (save-excursion
-       (and (ignore-errors (let ((org-outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
-                               (if (featurep 'org-inlinetask)
-                                   (1- org-inlinetask-min-level)
-                                 ""))))
-                             (org-back-to-heading)))
-            (setq beg (point))))
-      (org-indent-remove-properties beg end)
-      (org-indent-add-properties beg end)))
-  (goto-char limit))
-
-(defun org-indent-refresh-subtree ()
-  "Refresh indentation properties in the current outline subtree.
-Point is assumed to be at the beginning of a headline."
-  (interactive)
+
+When DELAY is non-nil, it must be a time value.  In that case,
+the process is asynchronous and can be interrupted, either by
+user request, or after DELAY.  This is done by throwing the
+`interrupt' tag along with the buffer position where the process
+stopped."
+  (save-match-data
+    (org-with-wide-buffer
+     (goto-char beg)
+     (beginning-of-line)
+     ;; 1. Initialize prefix at BEG.  This is done by storing two
+     ;;    variables: INLINE-PF and PF, representing respectively
+     ;;    length of current `line-prefix' when line is inside an
+     ;;    inline task or not.
+     (let* ((case-fold-search t)
+           (limited-re (org-get-limited-outline-regexp))
+           (added-ind-per-lvl (1- org-indent-indentation-per-level))
+           (pf (save-excursion
+                 (and (ignore-errors (let ((outline-regexp limited-re))
+                                       (org-back-to-heading t)))
+                      (+ (* org-indent-indentation-per-level
+                            (- (match-end 0) (match-beginning 0) 2)) 2))))
+           (pf-inline (and (featurep 'org-inlinetask)
+                           (org-inlinetask-in-task-p)
+                           (+ (* org-indent-indentation-per-level
+                                 (1- (org-inlinetask-get-task-level))) 2)))
+           (time-limit (and delay (time-add (current-time) delay))))
+       ;; 2. For each line, set `line-prefix' and `wrap-prefix'
+       ;;    properties depending on the type of line (headline,
+       ;;    inline task, item or other).
+       (with-silent-modifications
+        (while (and (<= (point) end) (not (eobp)))
+          (cond
+           ;; When in asynchronous mode, check if interrupt is
+           ;; required.
+           ((and delay (input-pending-p)) (throw 'interrupt (point)))
+           ;; In asynchronous mode, take a break of
+           ;; `org-indent-agent-resume-delay' every DELAY to avoid
+           ;; blocking any other idle timer or process output.
+           ((and delay (time-less-p time-limit (current-time)))
+            (setq org-indent-agent-resume-timer
+                  (run-with-idle-timer
+                   (time-add (current-idle-time)
+                             org-indent-agent-resume-delay)
+                   nil #'org-indent-initialize-agent))
+            (throw 'interrupt (point)))
+           ;; Headline or inline task.
+           ((looking-at org-outline-regexp)
+            (let* ((nstars (- (match-end 0) (match-beginning 0) 1))
+                   (line (* added-ind-per-lvl (1- nstars)))
+                   (wrap (+ line (1+ nstars))))
+              (cond
+               ;; Headline: new value for PF.
+               ((looking-at limited-re)
+                (org-indent-set-line-properties line wrap t)
+                (setq pf wrap))
+               ;; End of inline task: PF-INLINE is now nil.
+               ((looking-at "\\*+ end[ \t]*$")
+                (org-indent-set-line-properties line wrap 'inline)
+                (setq pf-inline nil))
+               ;; Start of inline task.  Determine if it contains
+               ;; text, or if it is only one line long.  Set
+               ;; PF-INLINE accordingly.
+               (t (org-indent-set-line-properties line wrap 'inline)
+                  (setq pf-inline (and (org-inlinetask-in-task-p) wrap))))))
+           ;; List item: `wrap-prefix' is set where body starts.
+           ((org-at-item-p)
+            (let* ((line (or pf-inline pf 0))
+                   (wrap (+ (org-list-item-body-column (point)) line)))
+              (org-indent-set-line-properties line wrap nil)))
+           ;; Normal line: use PF-INLINE, PF or nil as prefixes.
+           (t (let* ((line (or pf-inline pf 0))
+                     (wrap (+ line (org-get-indentation))))
+                (org-indent-set-line-properties line wrap nil))))))))))
+
+(defun org-indent-notify-modified-headline (beg end)
+  "Set `org-indent-modified-headline-flag' depending on context.
+
+BEG and END are the positions of the beginning and end of the
+range of deleted text.
+
+This function is meant to be called by `before-change-functions'.
+Flag will be non-nil if command is going to modify or delete an
+headline."
   (when org-indent-mode
-    (save-excursion
-      (let (beg end)
-       (setq beg (point))
-       (setq end (save-excursion (org-end-of-subtree t t)))
-       (org-indent-remove-properties beg end)
-       (org-indent-add-properties beg end)))))
+    (setq org-indent-modified-headline-flag
+         (save-excursion
+           (goto-char beg)
+           (save-match-data
+             (or (and (org-at-heading-p) (< beg (match-end 0)))
+                 (re-search-forward org-outline-regexp-bol end t)))))))
 
-(defun org-indent-refresh-buffer ()
-  "Refresh indentation properties in the current outline subtree.
-Point is assumed to be at the beginning of a headline."
-  (interactive)
+(defun org-indent-refresh-maybe (beg end dummy)
+  "Refresh indentation properties in an adequate portion of buffer.
+BEG and END are the positions of the beginning and end of the
+range of inserted text.  DUMMY is an unused argument.
+
+This function is meant to be called by `after-change-functions'."
   (when org-indent-mode
-    (org-indent-mode -1)
-    (org-indent-mode 1)))
+    (save-match-data
+      ;; If an headline was modified or inserted, set properties until
+      ;; next headline.
+      (if (or org-indent-modified-headline-flag
+             (save-excursion
+               (goto-char beg)
+               (re-search-forward org-outline-regexp-bol end t)))
+       (let ((end (save-excursion
+                    (goto-char end)
+                    (org-with-limited-levels (outline-next-heading))
+                    (point))))
+         (setq org-indent-modified-headline-flag nil)
+         (org-indent-add-properties beg end))
+       ;; Otherwise, only set properties on modified area.
+       (org-indent-add-properties beg end)))))
 
 (provide 'org-indent)
 
-
 ;;; org-indent.el ends here
index 4f44045f9bfff20ad90e27a1124c333e2805dcef..a3e9cd1f9e76c326cac05cdd278e0c4add5fa468 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-info.el --- Support for links to Info nodes from within Org-Mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -77,6 +76,4 @@
 
 (provide 'org-info)
 
-
-
 ;;; org-info.el ends here
index 72c19062983e273fadd6eddf31bf23d6ee080e48..a6331975f559d982618777b6339519621dd08fc2 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
@@ -107,11 +106,14 @@ When nil, they will not be exported."
   :type 'boolean)
 
 (defvar org-inlinetask-export-templates
-  '((html "<pre class=\"inlinetask\"><b>%s%s</b><br />%s</pre>"
+  '((html "<div class=\"inlinetask\"><b>%s%s</b><br />%s</div>"
          '((unless (eq todo "")
              (format "<span class=\"%s %s\">%s%s</span> "
                      class todo todo priority))
            heading content))
+    (odt "%s" '((org-odt-format-inlinetask heading content
+                                          todo priority tags)))
+
     (latex "\\begin\{description\}\n\\item[%s%s]~%s\\end\{description\}"
           '((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
             heading content))
@@ -132,9 +134,9 @@ When nil, they will not be exported."
               heading content)))
   "Templates for inline tasks in various exporters.
 
-This variable is an alist in the shape of (BACKEND STRING OBJECTS).
+This variable is an alist in the shape of \(BACKEND STRING OBJECTS\).
 
-BACKEND is the name of the backend for the template (ascii, html...).
+BACKEND is the name of the backend for the template \(ascii, html...\).
 
 STRING is a format control string.
 
@@ -151,14 +153,14 @@ defined in an inline task, their value is the empty string.
 
 As an example, valid associations are:
 
-(html \"<ul><li>%s <p>%s</p></li></ul>\" (heading content))
+\(html \"<ul><li>%s <p>%s</p></li></ul>\" \(heading content\)\)
 
 or, with the additional package \"todonotes\" for LaTeX,
 
-(latex \"\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}\"
-       '((unless (eq todo \"\")
-          (format \"\\textsc{%s%s}\" todo priority))
-        heading content)))")
+\(latex \"\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}\"
+       '\(\(unless \(eq todo \"\"\)
+          \(format \"\\textsc{%s%s}\" todo priority\)\)
+        heading content\)\)\)")
 
 (defvar org-odd-levels-only)
 (defvar org-keyword-time-regexp)
@@ -179,15 +181,22 @@ default, or nil of no state should be assigned."
   "Insert an inline task.
 If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'."
   (interactive "P")
+  ;; Error when inside an inline task, except if point was at its very
+  ;; beginning, in which case the new inline task will be inserted
+  ;; before this one.
+  (when (and (org-inlinetask-in-task-p)
+            (not (and (org-inlinetask-at-task-p) (bolp))))
+    (error "Cannot nest inline tasks"))
   (or (bolp) (newline))
-  (let ((indent org-inlinetask-min-level))
-    (if org-odd-levels-only
-        (setq indent (- (* 2 indent) 1)))
-    (insert (make-string indent ?*)
-            (if (or no-state (not org-inlinetask-default-state))
-               " \n"
-             (concat " " org-inlinetask-default-state " \n"))
-            (make-string indent ?*) " END\n"))
+  (let* ((indent (if org-odd-levels-only
+                    (1- (* 2 org-inlinetask-min-level))
+                  org-inlinetask-min-level))
+        (indent-string (concat (make-string indent ?*) " ")))
+    (insert indent-string
+           (if (or no-state (not org-inlinetask-default-state))
+               "\n"
+             (concat org-inlinetask-default-state " \n"))
+           indent-string "END\n"))
   (end-of-line -1))
 (define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)
 
@@ -228,21 +237,26 @@ The number of levels is controlled by `org-inlinetask-min-level'."
       (re-search-backward inlinetask-re nil t))))
 
 (defun org-inlinetask-goto-end ()
-  "Go to the end of the inline task at point."
-  (beginning-of-line)
-  (let ((case-fold-search t)
-       (inlinetask-re (org-inlinetask-outline-regexp)))
-    (cond
-     ((org-looking-at-p (concat inlinetask-re "END[ \t]*$"))
-      (forward-line 1))
-     ((org-looking-at-p inlinetask-re)
-      (forward-line 1)
-      (when (org-inlinetask-in-task-p)
-       (re-search-forward inlinetask-re nil t)
-       (forward-line 1)))
-     (t
-      (re-search-forward inlinetask-re nil t)
-      (forward-line 1)))))
+  "Go to the end of the inline task at point.
+Return point."
+  (save-match-data
+    (beginning-of-line)
+    (let* ((case-fold-search t)
+          (inlinetask-re (org-inlinetask-outline-regexp))
+          (task-end-re (concat inlinetask-re "END[ \t]*$")))
+      (cond
+       ((looking-at task-end-re) (forward-line))
+       ((looking-at inlinetask-re)
+       (forward-line)
+       (cond
+        ((looking-at task-end-re) (forward-line))
+        ((looking-at inlinetask-re))
+        ((org-inlinetask-in-task-p)
+         (re-search-forward inlinetask-re nil t)
+         (forward-line))))
+       (t (re-search-forward inlinetask-re nil t)
+         (forward-line)))
+      (point))))
 
 (defun org-inlinetask-get-task-level ()
   "Get the level of the inline task around.
@@ -333,7 +347,9 @@ Either remove headline and meta data, or do special formatting."
       ;; Remove the task.
       (goto-char beg)
       (delete-region beg end)
-      (when org-inlinetask-export
+      (when (and org-inlinetask-export
+                (assq org-export-current-backend
+                      org-inlinetask-export-templates))
        ;; Format CONTENT, if appropriate.
        (setq content
              (if (not (and content (string-match "\\S-" content)))
@@ -341,12 +357,14 @@ Either remove headline and meta data, or do special formatting."
                ;; Ensure CONTENT has minimal indentation, a single
                ;; newline character at its boundaries, and isn't
                ;; protected.
-               (when (string-match "`\\([ \t]*\n\\)+" content)
+               (when (string-match "\\`\\([ \t]*\n\\)+" content)
                  (setq content (substring content (match-end 0))))
                (when (string-match "[ \t\n]+\\'" content)
                  (setq content (substring content 0 (match-beginning 0))))
-               (org-add-props (concat "\n" (org-remove-indentation content) "\n")
-                   '(org-protected nil))))
+               (org-add-props
+                   (concat "\n\n" (org-remove-indentation content) "\n\n")
+                   '(org-protected nil org-native-text nil))))
+
        (when (string-match org-complex-heading-regexp headline)
          (let* ((nil-to-str
                  (function
@@ -363,7 +381,7 @@ Either remove headline and meta data, or do special formatting."
                 (backend-spec (assq org-export-current-backend
                                     org-inlinetask-export-templates))
                 (format-str (org-add-props (nth 1 backend-spec)
-                                '(org-protected t)))
+                                '(org-protected t org-native-text t)))
                 (tokens (cadr (nth 2 backend-spec)))
                 ;; Build export string. Ensure it won't break
                 ;; surrounding lists by giving it arbitrary high
@@ -372,6 +390,11 @@ Either remove headline and meta data, or do special formatting."
                                 (eval (append '(format format-str)
                                               (mapcar nil-to-str tokens)))
                                 '(original-indentation 1000))))
+           ;; Ensure task starts a new paragraph.
+           (unless (or (bobp)
+                       (save-excursion (forward-line -1)
+                                       (looking-at "[ \t]*$")))
+             (insert "\n"))
            (insert export-str)
            (unless (bolp) (insert "\n")))))))))
 
@@ -386,21 +409,34 @@ Either remove headline and meta data, or do special formatting."
     (goto-char (match-end 0))
     (current-column)))
 
+(defvar org-indent-indentation-per-level) ; defined in org-indent.el
+
+(defface org-inlinetask
+  (org-compatible-face 'shadow '((t (:bold t))))
+  "Face for inlinetask headlines."
+  :group 'org-faces)
+
 (defun org-inlinetask-fontify (limit)
-  "Fontify the inline tasks."
+  "Fontify the inline tasks down to LIMIT."
   (let* ((nstars (if org-odd-levels-only
                     (1- (* 2 (or org-inlinetask-min-level 200)))
                   (or org-inlinetask-min-level 200)))
         (re (concat "^\\(\\*\\)\\(\\*\\{"
                    (format "%d" (- nstars 3))
-                   ",\\}\\)\\(\\*\\* .*\\)")))
+                   ",\\}\\)\\(\\*\\* .*\\)"))
+        ;; Virtual indentation will add the warning face on the first
+        ;; star. Thus, in that case, only hide it.
+        (start-face (if (and (org-bound-and-true-p org-indent-mode)
+                             (> org-indent-indentation-per-level 1))
+                        'org-hide
+                      'org-warning)))
     (while (re-search-forward re limit t)
       (add-text-properties (match-beginning 1) (match-end 1)
-                          '(face org-warning font-lock-fontified t))
+                          `(face ,start-face font-lock-fontified t))
       (add-text-properties (match-beginning 2) (match-end 2)
                           '(face org-hide font-lock-fontified t))
       (add-text-properties (match-beginning 3) (match-end 3)
-                          '(face shadow font-lock-fontified t)))))
+                          '(face org-inlinetask font-lock-fontified t)))))
 
 (defun org-inlinetask-toggle-visibility ()
   "Toggle visibility of inline task at point."
index 7a84d2053ade6414de72af97a2a74b42dc2f5aa6..c4ad32146d7c9bf7f787d2a52551c8b91bbc508c 100644 (file)
@@ -4,7 +4,6 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -60,6 +59,8 @@
 (declare-function erc-server-buffer "erc" ())
 (declare-function erc-get-server-nickname-list "erc" ())
 (declare-function erc-cmd-JOIN "erc" (channel &optional key))
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 (defvar org-irc-client 'erc
   "The IRC client to act on.")
@@ -232,7 +233,7 @@ default."
                                      (throw 'found x))))))
                (if chan-buf
                    (progn
-                     (switch-to-buffer chan-buf)
+                     (org-pop-to-buffer-same-window chan-buf)
                      ;; if we got a nick, and they're in the chan,
                      ;; then start a chat with them
                      (let ((nick (pop link)))
@@ -243,14 +244,12 @@ default."
                                (insert (concat nick ": ")))
                              (error "%s not found in %s" nick chan-name)))))
                    (progn
-                     (switch-to-buffer server-buffer)
+                     (org-pop-to-buffer-same-window server-buffer)
                      (erc-cmd-JOIN chan-name))))
-             (switch-to-buffer server-buffer)))
+             (org-pop-to-buffer-same-window server-buffer)))
        ;; no server match, make new connection
        (erc-select :server server :port port))))
 
 (provide 'org-irc)
 
-
-
 ;;; org-irc.el ends here
index 3ef8c4c809c090ba569fad4440514f9b5ce9b578..22f5d4ecd6b20e2912512353dc0026d4eee3b120 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-jsinfo.el --- Support for org-info.js Javascript in Org HTML export
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -204,6 +203,4 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
 (provide 'org-infojs)
 (provide 'org-jsinfo)
 
-
-
 ;;; org-jsinfo.el ends here
index 7abf85a7092c8940849b3ee4effc6e2068ecf900..57cb5bac7026d7f1e6bda0706a7ce94468ede871 100644 (file)
@@ -4,8 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-latex.el
-;; Version: 7.7
-;; Author: Bastien Guerry <bzg AT altern DOT org>
+;; Author: Bastien Guerry <bzg AT gnu DOT org>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex
 ;; Description: Converts an org-mode buffer into LaTeX
@@ -74,7 +73,6 @@
          org-deadline-string "\\|"
          org-closed-string"\\)")
   "Regexp matching special time planning keywords plus the time after it.")
-
 (defvar org-re-quote)  ; dynamically scoped from org.el
 (defvar org-commentsp) ; dynamically scoped from org.el
 
@@ -304,8 +302,8 @@ markup defined, the first one in the association list will be used."
 
 (defcustom org-export-latex-href-format "\\href{%s}{%s}"
   "A printf format string to be applied to href links.
-The format must contain either two %s instances or just one.
-If it contains two %s instances, the first will be filled with
+The format must contain either two %s instances or just one.  
+If it contains two %s instances, the first will be filled with 
 the link, the second with the link description.  If it contains
 only one, the %s will be filled with the link."
   :group 'org-export-latex
@@ -359,6 +357,12 @@ string defines the replacement string for this quote."
   :group 'org-export-latex
   :type 'boolean)
 
+(defcustom org-export-latex-table-caption-above t
+  "When non-nil, the caption is set above the table.  When nil,
+the caption is set below the table."
+  :group 'org-export-latex
+  :type 'boolean)
+
 (defcustom org-export-latex-tables-column-borders nil
   "When non-nil, grouping columns can cause outer vertical lines in tables.
 When nil, grouping causes only separation lines between groups."
@@ -402,7 +406,7 @@ will pass them (combined with the LaTeX default list parameters) to
   :type 'plist)
 
 (defcustom org-export-latex-verbatim-wrap
-  '("\\begin{verbatim}\n" . "\\end{verbatim}\n")
+  '("\\begin{verbatim}\n" . "\\end{verbatim}")
   "Environment to be wrapped around a fixed-width section in LaTeX export.
 This is a cons with two strings, to be added before and after the
 fixed-with text.
@@ -594,7 +598,7 @@ and `org-export-with-tags' instead."
   "Extensions of image files that can be inlined into LaTeX.
 Note that the image extension *actually* allowed depend on the way the
 LaTeX file is processed.  When used with pdflatex, pdf, jpg and png images
-are OK.  When processing through dvi to PostScript, only ps and eps are
+are OK.  When processing through dvi to Postscript, only ps and eps are
 allowed.  The default we use here encompasses both."
   :group 'org-export-latex
   :type '(repeat (string :tag "Extension")))
@@ -719,7 +723,7 @@ then use this command to convert it."
   (interactive "r")
   (let (reg latex buf)
     (save-window-excursion
-      (if (org-mode-p)
+      (if (eq major-mode 'org-mode)
          (setq latex (org-export-region-as-latex
                       beg end t 'string))
        (setq reg (buffer-substring beg end)
@@ -865,6 +869,8 @@ when PUB-DIR is set, use this as the publishing directory."
                          (file-truename (or buffer-file-name "dummy.org")))
                   (concat filename ".tex")
                 filename)))
+        (auto-insert nil); Avoid any auto-insert stuff for the new file
+        (TeX-master t) ; Avoid the Query for TeX master from AUCTeX
         (buffer (if to-buffer
                     (cond
                      ((eq to-buffer 'string) (get-buffer-create
@@ -1340,7 +1346,7 @@ LEVEL indicates the default depth for export."
              (save-restriction
                (widen)
                (goto-char (point-min))
-               (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\(-[a-zA-Z]+\\)" nil t)
+               (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([-/a-zA-Z]+\\)" nil t)
                     (match-string 1))))
            (plist-get org-export-latex-options-plist :latex-class)
            org-export-latex-default-class)
@@ -1395,7 +1401,11 @@ OPT-PLIST is the options plist for current buffer."
        (email (replace-regexp-in-string
                "_" "\\\\_"
                (org-export-apply-macros-in-string
-                (plist-get opt-plist :email)))))
+                (plist-get opt-plist :email))))
+       (description (org-export-apply-macros-in-string
+                     (plist-get opt-plist :description)))
+       (keywords (org-export-apply-macros-in-string
+                  (plist-get opt-plist :keywords))))
     (concat
      (if (plist-get opt-plist :time-stamp-file)
         (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
@@ -1429,6 +1439,12 @@ OPT-PLIST is the options plist for current buffer."
             (format-time-string
              (or (plist-get opt-plist :date)
                  org-export-latex-date-format)))
+     ;; add some hyperref options
+     ;; FIXME: let's have a defcustom for this?
+     (format "\\hypersetup{\n  pdfkeywords={%s},\n  pdfsubject={%s},\n  pdfcreator={%s}}\n"
+         (org-export-latex-fontify-headline keywords)
+         (org-export-latex-fontify-headline description)
+        (concat "Emacs Org-mode version " org-version))
      ;; beginning of the document
      "\n\\begin{document}\n\n"
      ;; insert the title command
@@ -1837,7 +1853,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                  (replace-match (concat (match-string 1)
                                         (match-string 2)) t t)
                  (forward-line))
-               (insert "\\end{verbatim}\n\n"))
+               (insert "\\end{verbatim}\n"))
        (progn (goto-char (match-beginning 0))
              (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
                (replace-match (concat "%" (match-string 1)
@@ -1966,13 +1982,13 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                             (concat "\\begin{longtable}{" align "}\n")
                           (if floatp
                              (format "\\begin{%s}%s\n" tblenv placement)))
-                        (if floatp
+                        (if (and floatp org-export-latex-table-caption-above)
                             (format
                              "\\caption%s{%s} %s"
                              (if shortn (concat "[" shortn "]") "")
                              (or caption "")
                             (if label (format "\\label{%s}" label) "")))
-                        (if (and longtblp caption) "\\\\\n" "\n")
+                       (if (and longtblp caption) "\\\\\n" "\n")
                         (if (and org-export-latex-tables-centered (not longtblp))
                             "\\begin{center}\n")
                         (if (not longtblp)
@@ -1994,6 +2010,12 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                         (if (not longtblp) (format "\n\\end{%s}" tabular-env))
                         (if longtblp "\n" (if org-export-latex-tables-centered
                                               "\n\\end{center}\n" "\n"))
+                        (if (and floatp (not org-export-latex-table-caption-above))
+                            (format
+                             "\\caption%s{%s} %s"
+                             (if shortn (concat "[" shortn "]") "")
+                             (or caption "")
+                            (if label (format "\\label{%s}" label) "")))
                         (if longtblp
                             "\\end{longtable}"
                           (if floatp (format "\\end{%s}" tblenv)))))
@@ -2043,11 +2065,12 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
       (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
     (when floatp
       (setq tbl (concat "\\begin{table}\n"
+                       (if (not org-export-latex-table-caption-above) tbl)
                        (format "\\caption%s{%s%s}\n"
                                (if shortn (format "[%s]" shortn) "")
                                (if label (format "\\label{%s}" label) "")
                                (or caption ""))
-                       tbl
+                       (if org-export-latex-table-caption-above tbl)
                        "\n\\end{table}\n")))
     (insert (org-export-latex-protect-string tbl))))
 
@@ -2203,7 +2226,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                ;; a LaTeX issue, but we here implement a work-around anyway.
                (setq path (org-export-latex-protect-amp path)
                      desc (org-export-latex-protect-amp desc)))
-             (insert
+             (insert 
               (if (string-match "%s.*%s" org-export-latex-href-format)
                   (format org-export-latex-href-format path desc)
                 (format org-export-latex-href-format path))))
@@ -2338,7 +2361,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                                          (let ((next (org-footnote-get-next-reference)))
                                            (and next (= (nth 1 next) (nth 2 ref)))))
                          org-export-latex-footnote-separator ""))))
-           (when (org-on-heading-p)
+           (when (org-at-heading-p)
              (setq fnote (concat (org-export-latex-protect-string "\\protect")
                                  fnote)))
            ;; Ensure a footnote at column 0 cannot end a list
@@ -2769,6 +2792,4 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 (provide 'org-export-latex)
 (provide 'org-latex)
 
-
-
 ;;; org-latex.el ends here
index 72fc71854e2cc08d4ec00e906582185c651c15a9..df14625bc61290e708f07070f8ba2855b716e2fc 100644 (file)
@@ -1,12 +1,11 @@
 ;;; org-list.el --- Plain lists for Org-mode
 ;;
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
-;;        Bastien Guerry <bzg AT altern DOT org>
+;;        Bastien Guerry <bzg AT gnu DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 
 ;; This file contains the code dealing with plain lists in Org-mode.
 
-;; The fundamental idea behind lists work is to use structures.
-;; A structure is a snapshot of the list, in the shape of data tree
-;; (see `org-list-struct').
+;; The core concept behind lists is their structure.  A structure is
+;; a snapshot of the list, in the shape of a data tree (see
+;; `org-list-struct').
 
 ;; Once the list structure is stored, it is possible to make changes
-;; directly on it or get useful information about the list, with the
-;; two helper functions, namely `org-list-parents-alist' and
-;; `org-list-prevs-alist', and using accessors or methods.
+;; on it that will be mirrored to the real list or to get information
+;; about the list, using accessors and methods provided in the
+;; library.  Most of them require the use of one or two helper
+;; functions, namely `org-list-parents-alist' and
+;; `org-list-prevs-alist'.
 
 ;; Structure is eventually applied to the buffer with
 ;; `org-list-write-struct'.  This function repairs (bullets,
-;; indentation, checkboxes) the structure before applying it.  It
-;; should be called near the end of any function working on
-;; structures.
+;; indentation, checkboxes) the list in the process.  It should be
+;; called near the end of any function working on structures.
 
 ;; Thus, a function applying to lists should usually follow this
 ;; template:
 
 ;; 1. Verify point is in a list and grab item beginning (with the same
 ;;    function `org-in-item-p').  If the function requires the cursor
-;;    to be at item's bullet, `org-at-item-p' is more selective.  If
-;;    the cursor is amidst the buffer, it is possible to find the
-;;    closest item with `org-list-search-backward', or
-;;    `org-list-search-forward', applied to `org-item-beginning-re'.
+;;    to be at item's bullet, `org-at-item-p' is more selective.  It
+;;    is also possible to move point to the closest item with
+;;    `org-list-search-backward', or `org-list-search-forward',
+;;    applied to the function `org-item-beginning-re'.
 
 ;; 2. Get list structure with `org-list-struct'.
 
 ;; 4. Proceed with the modifications, using methods and accessors.
 
 ;; 5. Verify and apply structure to buffer, using
-;;    `org-list-write-struct'.  Possibly use
-;;    `org-update-checkbox-count-maybe' if checkboxes might have been
-;;    modified.
+;;    `org-list-write-struct'.
 
-;; Computing a list structure can be a costly operation on huge lists
-;; (a few thousand lines long).  Thus, code should follow the rule :
+;; 6. If changes made to the list might have modified check-boxes,
+;;    call `org-update-checkbox-count-maybe'.
+
+;; Computing a structure can be a costly operation on huge lists (a
+;; few thousand lines long).  Thus, code should follow the rule:
 ;; "collect once, use many".  As a corollary, it is usually a bad idea
 ;; to use directly an interactive function inside the code, as those,
-;; being independent entities, read the whole list structure another
+;; being independant entities, read the whole list structure another
 ;; time.
 
 ;;; Code:
@@ -95,7 +96,6 @@
 
 (declare-function org-at-heading-p "org" (&optional ignored))
 (declare-function org-before-first-heading-p "org" ())
-(declare-function org-back-over-empty-lines "org" ())
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-combine-plists "org" (&rest plists))
 (declare-function org-count "org" (cl-item cl-seq))
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function org-level-increment "org" ())
 (declare-function org-narrow-to-subtree "org" ())
-(declare-function org-on-heading-p "org" (&optional invisible-ok))
+(declare-function org-at-heading-p "org" (&optional invisible-ok))
 (declare-function org-previous-line-empty-p "org" ())
 (declare-function org-remove-if "org" (predicate seq))
 (declare-function org-reduced-level "org" (L))
 (declare-function outline-next-heading "outline" ())
 (declare-function outline-previous-heading "outline" ())
 
+
+\f
 ;;; Configuration variables
 
 (defgroup org-plain-lists nil
@@ -271,7 +273,7 @@ By default, automatic actions are taken when using
  \\[org-meta-return], \\[org-metaright], \\[org-metaleft],
  \\[org-shiftmetaright], \\[org-shiftmetaleft],
  \\[org-ctrl-c-minus], \\[org-toggle-checkbox] or
- \\[org-insert-todo-heading]. You can disable individually these
+ \\[org-insert-todo-heading].  You can disable individually these
  rules by setting them to nil.  Valid rules are:
 
 bullet    when non-nil, cycling bullet do not allow lists at
@@ -376,6 +378,7 @@ specifically, type `block' is determined by the variable
 `org-list-forbidden-blocks'.")
 
 
+\f
 ;;; Predicates and regexps
 
 (defconst org-list-end-re (if org-empty-line-terminates-plain-lists
@@ -385,9 +388,9 @@ specifically, type `block' is determined by the variable
 It depends on `org-empty-line-terminates-plain-lists'.")
 
 (defconst org-list-full-item-re
-  (concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\\)"
+  (concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)"
          "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
-         "\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
+         "\\(?:\\(\\[[ X-]\\]\\)\\(?:[ \t]+\\|$\\)\\)?"
          "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?")
   "Matches a list item and puts everything into groups:
 group 1: bullet
@@ -535,6 +538,7 @@ This checks `org-list-ending-method'."
        (match-string 2)))
 
 
+\f
 ;;; Structures and helper functions
 
 (defun org-list-context ()
@@ -681,7 +685,7 @@ Assume point is at an item."
              (cond
               ((<= (point) lim-up)
                ;; At upward limit: if we ended at an item, store it,
-               ;; else dismiss useless data recorded above BEG-CELL.
+               ;; else dimiss useless data recorded above BEG-CELL.
                ;; Jump to part 2.
                (throw 'exit
                       (setq itm-lst
@@ -803,21 +807,9 @@ Assume point is at an item."
              (forward-line 1))))))
       (setq struct (append itm-lst (cdr (nreverse itm-lst-2)))
            end-lst (append end-lst (cdr (nreverse end-lst-2))))
-      ;; 3. Correct ill-formed lists by ensuring top item is the least
-      ;;    indented.
-      (let ((min-ind (nth 1 (car struct))))
-       (mapc (lambda (item)
-               (let ((ind (nth 1 item))
-                     (bul (nth 2 item)))
-                 (when (< ind min-ind)
-                   (setcar (cdr item) min-ind)
-                   ;; Trim bullet so item will be seen as different
-                   ;; when compared with repaired version.
-                   (setcar (nthcdr 2 item) (org-trim bul)))))
-             struct))
-      ;; 4. Associate each item to its end pos.
+      ;; 3. Associate each item to its end position.
       (org-list-struct-assoc-end struct end-lst)
-      ;; 5. Return STRUCT
+      ;; 4. Return STRUCT
       struct)))
 
 (defun org-list-struct-assoc-end (struct end-list)
@@ -854,8 +846,9 @@ This function modifies STRUCT."
 
 (defun org-list-parents-alist (struct)
   "Return alist between item and parent in STRUCT."
-  (let ((ind-to-ori (list (list (nth 1 (car struct)))))
-       (prev-pos (list (caar struct))))
+  (let* ((ind-to-ori (list (list (nth 1 (car struct)))))
+        (top-item (org-list-get-top-point struct))
+        (prev-pos (list top-item)))
     (cons prev-pos
          (mapcar (lambda (item)
                    (let ((pos (car item))
@@ -864,17 +857,34 @@ This function modifies STRUCT."
                      (push pos prev-pos)
                      (cond
                       ((> prev-ind ind)
+                       ;; A sub-list is over.  Find the associated
+                       ;; origin in IND-TO-ORI.  If it cannot be
+                       ;; found (ill-formed list), set its parent as
+                       ;; the first item less indented.  If there is
+                       ;; none, make it a top-level item.
                        (setq ind-to-ori
-                             (member (assq ind ind-to-ori) ind-to-ori))
+                             (or (member (assq ind ind-to-ori) ind-to-ori)
+                                  (catch 'exit
+                                    (mapc
+                                     (lambda (e)
+                                       (when (< (car e) ind)
+                                         (throw 'exit (member e ind-to-ori))))
+                                     ind-to-ori)
+                                    (list (list ind)))))
                        (cons pos (cdar ind-to-ori)))
+                       ;; A sub-list starts.  Every item at IND will
+                       ;; have previous item as its parent.
                       ((< prev-ind ind)
                        (let ((origin (nth 1 prev-pos)))
                          (push (cons ind origin) ind-to-ori)
                          (cons pos origin)))
+                       ;; Another item in the same sub-list: it shares
+                       ;; the same parent as the previous item.
                       (t (cons pos (cdar ind-to-ori))))))
                  (cdr struct)))))
 
 
+\f
 ;;; Accessors
 
 (defsubst org-list-get-nth (n key struct)
@@ -992,8 +1002,8 @@ items, as returned by `org-list-prevs-alist'."
 
 (defun org-list-get-children (item struct parents)
   "List all children of ITEM, or nil.
-STRUCT is the list structure. PARENTS is the alist of parents, as
-returned by `org-list-parents-alist'."
+STRUCT is the list structure.  PARENTS is the alist of parents,
+as returned by `org-list-parents-alist'."
   (let (all child)
     (while (setq child (car (rassq item parents)))
       (setq parents (cdr (member (assq child parents) parents)))
@@ -1052,6 +1062,7 @@ type is determined by the first item of the list."
      (t 'unordered))))
 
 
+\f
 ;;; Searching
 
 (defun org-list-search-generic (search re bound noerr)
@@ -1084,6 +1095,7 @@ Arguments REGEXP, BOUND and NOERROR are similar to those used in
                           regexp (or bound (point-max)) noerror))
 
 
+\f
 ;;; Methods on structures
 
 (defsubst org-list-bullet-string (bullet)
@@ -1168,7 +1180,16 @@ some heuristics to guess the result."
     (let ((item (point))
          (insert-blank-p
           (cdr (assq 'plain-list-item org-blank-before-new-entry)))
-         usr-blank)
+         usr-blank
+         (count-blanks
+          (function
+           (lambda ()
+             ;; Count blank lines above beginning of line.
+             (save-excursion
+               (count-lines (goto-char (point-at-bol))
+                            (progn (skip-chars-backward " \r\t\n")
+                                   (forward-line)
+                                   (point))))))))
       (cond
        ;; Trivial cases where there should be none.
        ((or (and (not (eq org-list-ending-method 'indent))
@@ -1177,21 +1198,20 @@ some heuristics to guess the result."
        ;; When `org-blank-before-new-entry' says so, it is 1.
        ((eq insert-blank-p t) 1)
        ;; `plain-list-item' is 'auto.  Count blank lines separating
-       ;; neighboring items in list.
+       ;; neighbours items in list.
        (t (let ((next-p (org-list-get-next-item item struct prevs)))
            (cond
             ;; Is there a next item?
             (next-p (goto-char next-p)
-                    (org-back-over-empty-lines))
+                    (funcall count-blanks))
             ;; Is there a previous item?
             ((org-list-get-prev-item item struct prevs)
-             (org-back-over-empty-lines))
+             (funcall count-blanks))
             ;; User inserted blank lines, trust him.
             ((and (> pos (org-list-get-item-end-before-blank item struct))
-                  (> (save-excursion
-                       (goto-char pos)
-                       (skip-chars-backward " \t")
-                       (setq usr-blank (org-back-over-empty-lines))) 0))
+                  (> (save-excursion (goto-char pos)
+                                     (setq usr-blank (funcall count-blanks)))
+                     0))
              usr-blank)
             ;; Are there blank lines inside the list so far?
             ((save-excursion
@@ -1207,7 +1227,7 @@ some heuristics to guess the result."
 If POS is before first character after bullet of the item, the
 new item will be created before the current one.
 
-STRUCT is the list structure.  PREVS is the alist of previous
+STRUCT is the list structure.  PREVS is the the alist of previous
 items, as returned by `org-list-prevs-alist'.
 
 Insert a checkbox if CHECKBOX is non-nil, and string AFTER-BULLET
@@ -1364,8 +1384,8 @@ If DEST is a buffer position, the function will assume it points
 to another item in the same list as ITEM, and will move the
 latter just before the former.
 
-If DEST is `begin' \(resp. `end'\), ITEM will be moved at the
-beginning \(resp. end\) of the list it belongs to.
+If DEST is `begin' \(respectively `end'\), ITEM will be moved at
+the beginning \(respectively end\) of the list it belongs to.
 
 If DEST is a string like \"N\", where N is an integer, ITEM will
 be moved at the Nth position in the list.
@@ -1543,12 +1563,13 @@ bullets between START and END."
     (mapcar ind parents)))
 
 
+\f
 ;;; Repairing structures
 
 (defun org-list-use-alpha-bul-p (first struct prevs)
   "Non-nil if list starting at FIRST can have alphabetical bullets.
 
-STRUCT is list structure. PREVS is the alist of previous items,
+STRUCT is list structure.  PREVS is the alist of previous items,
 as returned by `org-list-prevs-alist'."
   (and org-alphabetical-lists
        (catch 'exit
@@ -1746,15 +1767,41 @@ This function modifies STRUCT."
            ;; Return blocking item.
            (nth index all-items)))))))
 
+(defun org-list-struct-fix-item-end (struct)
+  "Verify and correct each item end position in STRUCT.
+
+This function modifies STRUCT."
+  (let (end-list acc-end)
+    (mapc (lambda (e)
+           (let* ((pos (car e))
+                  (ind-pos (org-list-get-ind pos struct))
+                  (end-pos (org-list-get-item-end pos struct)))
+             (unless (assq end-pos struct)
+               ;; To determine real ind of an ending position that is
+               ;; not at an item, we have to find the item it belongs
+               ;; to: it is the last item (ITEM-UP), whose ending is
+               ;; further than the position we're interested in.
+               (let ((item-up (assoc-default end-pos acc-end '>)))
+                 (push (cons
+                        ;; Else part is for the bottom point.
+                        (if item-up (+ (org-list-get-ind item-up struct) 2) 0)
+                        end-pos)
+                       end-list)))
+             (push (cons ind-pos pos) end-list)
+             (push (cons end-pos pos) acc-end)))
+         struct)
+    (setq end-list (sort end-list (lambda (e1 e2) (< (cdr e1) (cdr e2)))))
+    (org-list-struct-assoc-end struct end-list)))
+
 (defun org-list-struct-apply-struct (struct old-struct)
-  "Apply set-difference between STRUCT and OLD-STRUCT to the buffer.
+  "Apply set difference between STRUCT and OLD-STRUCT to the buffer.
 
 OLD-STRUCT is the structure before any modifications, and STRUCT
 the structure to be applied.  The function will only modify parts
 of the list which have changed.
 
 Initial position of cursor is restored after the changes."
-  (let* ((origin (copy-marker (point)))
+  (let* ((origin (point-marker))
         (inlinetask-re (and (featurep 'org-inlinetask)
                             (org-inlinetask-outline-regexp)))
         (item-re (org-item-re))
@@ -1804,13 +1851,11 @@ Initial position of cursor is restored after the changes."
                ((and (match-string 3) new-box)
                 (replace-match new-box nil nil nil 3))
                ((match-string 3)
-                ;; (goto-char (or (match-end 2) (match-end 1)))
-                ;; (skip-chars-backward " \t")
                 (looking-at ".*?\\([ \t]*\\[[ X-]\\]\\)")
                 (replace-match "" nil nil nil 1))
                (t (let ((counterp (match-end 2)))
                     (goto-char (if counterp (1+ counterp) (match-end 1)))
-                  (insert (concat new-box (unless counterp " "))))))
+                    (insert (concat new-box (unless counterp " "))))))
               ;; c. Indent item to appropriate column.
               (unless (= new-ind old-ind)
                 (delete-region (goto-char (point-at-bol))
@@ -1869,53 +1914,38 @@ Initial position of cursor is restored after the changes."
     (goto-char origin)
     (move-marker origin nil)))
 
-(defun org-list-write-struct (struct parents)
+(defun org-list-write-struct (struct parents &optional old-struct)
   "Correct bullets, checkboxes and indentation in list at point.
+
 STRUCT is the list structure.  PARENTS is the alist of parents,
-as returned by `org-list-parents-alist'."
+as returned by `org-list-parents-alist'.
+
+When non-nil, optional argument OLD-STRUCT is the reference
+structure of the list.  It should be provided whenever STRUCT
+doesn't correspond anymore to the real list in buffer."
   ;; Order of functions matters here: checkboxes and endings need
   ;; correct indentation to be set, and indentation needs correct
   ;; bullets.
   ;;
   ;; 0. Save a copy of structure before modifications
-  (let ((old-struct (copy-tree struct)))
+  (let ((old-struct (or old-struct (copy-tree struct))))
     ;; 1. Set a temporary, but coherent with PARENTS, indentation in
     ;;    order to get items endings and bullets properly
     (org-list-struct-fix-ind struct parents 2)
-    ;; 2. Get pseudo-alist of ending positions and sort it by position.
-    ;;    Then associate them to the structure.
-    (let (end-list acc-end)
-    (mapc (lambda (e)
-           (let* ((pos (car e))
-                  (ind-pos (org-list-get-ind pos struct))
-                  (end-pos (org-list-get-item-end pos struct)))
-             (unless (assq end-pos struct)
-               ;; To determine real ind of an ending position that is
-               ;; not at an item, we have to find the item it belongs
-               ;; to: it is the last item (ITEM-UP), whose ending is
-               ;; further than the position we're interested in.
-               (let ((item-up (assoc-default end-pos acc-end '>)))
-                 (push (cons
-                        ;; Else part is for the bottom point.
-                        (if item-up (+ (org-list-get-ind item-up struct) 2) 0)
-                        end-pos)
-                       end-list)))
-             (push (cons ind-pos pos) end-list)
-             (push (cons end-pos pos) acc-end)))
-         struct)
-    (setq end-list (sort end-list (lambda (e1 e2) (< (cdr e1) (cdr e2)))))
-    (org-list-struct-assoc-end struct end-list))
-  ;; 3. Get bullets right.
-  (let ((prevs (org-list-prevs-alist struct)))
-    (org-list-struct-fix-bul struct prevs)
-    ;; 4. Now get real indentation.
-    (org-list-struct-fix-ind struct parents)
-    ;; 5. Eventually fix checkboxes.
-    (org-list-struct-fix-box struct parents prevs))
-  ;; 6. Apply structure modifications to buffer.
-  (org-list-struct-apply-struct struct old-struct)))
-
-
+    ;; 2. Fix each item end to get correct prevs alist.
+    (org-list-struct-fix-item-end struct)
+    ;; 3. Get bullets right.
+    (let ((prevs (org-list-prevs-alist struct)))
+      (org-list-struct-fix-bul struct prevs)
+      ;; 4. Now get real indentation.
+      (org-list-struct-fix-ind struct parents)
+      ;; 5. Eventually fix checkboxes.
+      (org-list-struct-fix-box struct parents prevs))
+    ;; 6. Apply structure modifications to buffer.
+    (org-list-struct-apply-struct struct old-struct)))
+
+
+\f
 ;;; Misc Tools
 
 (defun org-apply-on-list (function init-value &rest args)
@@ -1947,7 +1977,7 @@ beginning of the item."
 (defun org-list-set-item-visibility (item struct view)
   "Set visibility of ITEM in STRUCT to VIEW.
 
-Possible values are: `folded', `children' or `subtree'. See
+Possible values are: `folded', `children' or `subtree'.  See
 `org-cycle' for more information."
   (cond
    ((eq view 'folded)
@@ -1983,6 +2013,7 @@ Possible values are: `folded', `children' or `subtree'. See
     tcol))
 
 
+\f
 ;;; Interactive functions
 
 (defalias 'org-list-get-item-begin 'org-in-item-p)
@@ -2257,7 +2288,7 @@ in subtree, ignoring drawers."
                    (setq lim-up (point-at-bol))
                  (error "No item in region"))
                (setq lim-down (copy-marker limit))))
-            ((org-on-heading-p)
+            ((org-at-heading-p)
              ;; On an heading, start at first item after drawers and
              ;; time-stamps (scheduled, etc.).
              (let ((limit (save-excursion (outline-next-heading) (point))))
@@ -2274,7 +2305,7 @@ in subtree, ignoring drawers."
             ((org-at-item-p)
              (setq singlep t)
              (setq lim-up (point-at-bol)
-                   lim-down (point-at-eol)))
+                   lim-down (copy-marker (point-at-eol))))
             (t (error "Not at an item or heading, and no active region"))))
           ;; Determine the checkbox going to be applied to all items
           ;; within bounds.
@@ -2328,9 +2359,9 @@ in subtree, ignoring drawers."
             "Checkboxes were removed due to unchecked box at line %d"
             (org-current-line block-item))))
          (goto-char bottom)
-         (move-marker lim-down nil)
          (move-marker bottom nil)
-         (org-list-struct-apply-struct struct struct-copy)))))
+         (org-list-struct-apply-struct struct struct-copy)))
+      (move-marker lim-down nil)))
   (org-update-checkbox-count-maybe))
 
 (defun org-reset-checkbox-state-subtree ()
@@ -2416,7 +2447,7 @@ With optional prefix argument ALL, do this for the whole buffer."
              (cond                     ; boxes count
               ;; Cookie is at an heading, but specifically for todo,
               ;; not for checkboxes: skip it.
-              ((and (org-on-heading-p)
+              ((and (org-at-heading-p)
                     (string-match "\\<todo\\>"
                                   (downcase
                                    (or (org-entry-get nil "COOKIE_DATA") ""))))
@@ -2425,14 +2456,14 @@ With optional prefix argument ALL, do this for the whole buffer."
               ;; heading already have been read.  Use data collected
               ;; in STRUCTS-BAK.  This should only happen when
               ;; heading has more than one cookie on it.
-              ((and (org-on-heading-p)
+              ((and (org-at-heading-p)
                     (<= (save-excursion (outline-next-heading) (point))
                         backup-end))
                (funcall count-boxes nil structs-bak recursivep))
               ;; Cookie is at a fresh heading.  Grab structure of
               ;; every list containing a checkbox between point and
               ;; next headline, and save them in STRUCTS-BAK.
-              ((org-on-heading-p)
+              ((org-at-heading-p)
                (setq backup-end (save-excursion
                                   (outline-next-heading) (point))
                      structs-bak nil)
@@ -2491,7 +2522,8 @@ Otherwise it will be `org-todo'."
       'org-checkbox-statistics-todo)))
 
 (defun org-update-checkbox-count-maybe (&optional all)
-  "Update checkbox statistics unless turned off by user."
+  "Update checkbox statistics unless turned off by user.
+With an optional argument ALL, update them in the whole buffer."
   (when (cdr (assq 'checkbox org-list-automatic-rules))
     (org-update-checkbox-count all))
   (run-hooks 'org-checkbox-statistics-hook))
@@ -2642,7 +2674,7 @@ If a region is active, all items inside will be moved."
 (defvar org-tab-ind-state)
 (defun org-cycle-item-indentation ()
   "Cycle levels of indentation of an empty item.
-The first run indents the item, if applicable.  Subsequent runs
+The first run indents the item, if applicable.  Subsequents runs
 outdent it at meaningful levels in the list.  When done, item is
 put back at its original position with its original bullet.
 
@@ -2711,7 +2743,7 @@ Capital letters will reverse the sort order.
 If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies
 a function to be called with point at the beginning of the
 record.  It must return either a string or a number that should
-serve as the sorting key for that record. It will then use
+serve as the sorting key for that record.  It will then use
 COMPARE-FUNC to compare entries."
   (interactive "P")
   (let* ((case-func (if with-case 'identity 'downcase))
@@ -2786,6 +2818,7 @@ COMPARE-FUNC to compare entries."
        (message "Sorting items...done")))))
 
 
+\f
 ;;; Send and receive lists
 
 (defun org-list-parse-list (&optional delete)
@@ -2975,6 +3008,10 @@ for this list."
          (insert txt "\n")))
       (message "List converted and installed at receiver location"))))
 
+(defsubst org-list-item-trim-br (item)
+  "Trim line breaks in a list ITEM."
+  (setq item (replace-regexp-in-string "\n +" " " item)))
+
 (defun org-list-to-generic (list params)
   "Convert a LIST parsed through `org-list-parse-list' to other formats.
 Valid parameters PARAMS are:
@@ -3006,9 +3043,11 @@ Valid parameters PARAMS are:
 :cbon       String to insert for a checked check-box
 :cbtrans    String to insert for a check-box in transitional state
 
+:nobr       Non-nil means remove line breaks in lists items.
+
 Alternatively, each parameter can also be a form returning
 a string.  These sexp can use keywords `counter' and `depth',
-representing respectively counter associated to the current
+reprensenting respectively counter associated to the current
 item, and depth of the current sub-list, starting at 0.
 Obviously, `counter' is only available for parameters applying to
 items."
@@ -3034,6 +3073,7 @@ items."
         (cbon (plist-get p :cbon))
         (cboff (plist-get p :cboff))
         (cbtrans (plist-get p :cbtrans))
+        (nobr (plist-get p :nobr))
         export-sublist                 ; for byte-compiler
         (export-item
          (function
@@ -3065,6 +3105,8 @@ items."
                 (setq first (replace-match cboff t t first)))
                ((string-match "\\[CBTRANS\\]" first)
                 (setq first (replace-match cbtrans t t first))))
+              ;; Replace line breaks if required
+              (when nobr (setq first (org-list-item-trim-br first)))
               ;; Insert descriptive term if TYPE is `descriptive'.
               (when (eq type 'descriptive)
                 (let* ((complete (string-match "^\\(.*\\)[ \t]+::" first))
@@ -3200,5 +3242,4 @@ with overruling parameters for `org-list-to-generic'."
 
 (provide 'org-list)
 
-
 ;;; org-list.el ends here
diff --git a/lisp/org/org-lparse.el b/lisp/org/org-lparse.el
new file mode 100644 (file)
index 0000000..8c98ea7
--- /dev/null
@@ -0,0 +1,2339 @@
+;;; org-lparse.el --- Line-oriented parser-exporter for Org-mode
+
+;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
+
+;; Author: Jambunathan K <kjambunathan at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+;; Homepage: http://orgmode.org
+;;
+;; This file is not (yet) part of GNU Emacs.
+;; However, it is distributed under the same license.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+
+;; `org-lparse' is the entry point for the generic line-oriented
+;; exporter.  `org-do-lparse' is the genericized version of the
+;; original `org-export-as-html' routine.
+
+;; `org-lparse-native-backends' is a good starting point for
+;; exploring the generic exporter.
+
+;; Following new interactive commands are provided by this library.
+;; `org-lparse', `org-lparse-and-open', `org-lparse-to-buffer'
+;; `org-replace-region-by', `org-lparse-region'.
+
+;; Note that the above routines correspond to the following routines
+;; in the html exporter `org-export-as-html',
+;; `org-export-as-html-and-open', `org-export-as-html-to-buffer',
+;; `org-replace-region-by-html' and `org-export-region-as-html'.
+
+;; The new interactive command `org-lparse-convert' can be used to
+;; convert documents between various formats.  Use this to command,
+;; for example, to convert odt file to doc or pdf format.
+
+;; See README.org file that comes with this library for answers to
+;; FAQs and more information on using this library.
+
+;;; Code:
+(eval-when-compile
+  (require 'cl))
+(require 'org-exp)
+(require 'org-list)
+(require 'format-spec)
+
+;;;###autoload
+(defun org-lparse-and-open (target-backend native-backend arg
+                                          &optional file-or-buf)
+  "Export outline to TARGET-BACKEND via NATIVE-BACKEND and open exported file.
+If there is an active region, export only the region.  The prefix
+ARG specifies how many levels of the outline should become
+headlines.  The default is 3.  Lower levels will become bulleted
+lists."
+  (let (f (file-or-buf (or file-or-buf
+                          (org-lparse target-backend native-backend
+                                      arg 'hidden))))
+    (when file-or-buf
+      (setq f (cond
+              ((bufferp file-or-buf) buffer-file-name)
+              ((file-exists-p file-or-buf) file-or-buf)
+              (t (error "org-lparse-and-open: This shouldn't happen"))))
+      (message "Opening file %s" f)
+      (org-open-file f)
+      (when org-export-kill-product-buffer-when-displayed
+       (kill-buffer (current-buffer))))))
+
+;;;###autoload
+(defun org-lparse-batch (target-backend &optional native-backend)
+  "Call the function `org-lparse'.
+This function can be used in batch processing as:
+emacs   --batch
+        --load=$HOME/lib/emacs/org.el
+        --eval \"(setq org-export-headline-levels 2)\"
+        --visit=MyFile --funcall org-lparse-batch"
+  (setq native-backend (or native-backend target-backend))
+  (org-lparse target-backend native-backend
+             org-export-headline-levels 'hidden))
+
+;;;###autoload
+(defun org-lparse-to-buffer (backend arg)
+  "Call `org-lparse' with output to a temporary buffer.
+No file is created.  The prefix ARG is passed through to
+`org-lparse'."
+  (let ((tempbuf (format "*Org %s Export*" (upcase backend))))
+      (org-lparse backend backend arg nil nil tempbuf)
+      (when org-export-show-temporary-export-buffer
+       (switch-to-buffer-other-window tempbuf))))
+
+;;;###autoload
+(defun org-replace-region-by (backend beg end)
+  "Assume the current region has org-mode syntax, and convert it to HTML.
+This can be used in any buffer.  For example, you could write an
+itemized list in org-mode syntax in an HTML buffer and then use
+this command to convert it."
+  (let (reg backend-string buf pop-up-frames)
+    (save-window-excursion
+      (if (eq major-mode 'org-mode)
+         (setq backend-string (org-lparse-region backend beg end t 'string))
+       (setq reg (buffer-substring beg end)
+             buf (get-buffer-create "*Org tmp*"))
+       (with-current-buffer buf
+         (erase-buffer)
+         (insert reg)
+         (org-mode)
+         (setq backend-string (org-lparse-region backend (point-min)
+                                                 (point-max) t 'string)))
+       (kill-buffer buf)))
+    (delete-region beg end)
+    (insert backend-string)))
+
+;;;###autoload
+(defun org-lparse-region (backend beg end &optional body-only buffer)
+  "Convert region from BEG to END in org-mode buffer to HTML.
+If prefix arg BODY-ONLY is set, omit file header, footer, and table of
+contents, and only produce the region of converted text, useful for
+cut-and-paste operations.
+If BUFFER is a buffer or a string, use/create that buffer as a target
+of the converted HTML.  If BUFFER is the symbol `string', return the
+produced HTML as a string and leave not buffer behind.  For example,
+a Lisp program could call this function in the following way:
+
+  (setq html (org-lparse-region \"html\" beg end t 'string))
+
+When called interactively, the output buffer is selected, and shown
+in a window.  A non-interactive call will only return the buffer."
+  (let ((transient-mark-mode t) (zmacs-regions t)
+       ext-plist rtn)
+    (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
+    (goto-char end)
+    (set-mark (point)) ;; to activate the region
+    (goto-char beg)
+    (setq rtn (org-lparse backend backend nil nil ext-plist buffer body-only))
+    (if (fboundp 'deactivate-mark) (deactivate-mark))
+    (if (and (org-called-interactively-p 'any) (bufferp rtn))
+       (switch-to-buffer-other-window rtn)
+      rtn)))
+
+(defvar org-lparse-par-open nil)
+
+(defun org-lparse-should-inline-p (filename descp)
+   "Return non-nil if link FILENAME should be inlined.
+The decision to inline the FILENAME link is based on the current
+settings.  DESCP is the boolean of whether there was a link
+description.  See variables `org-export-html-inline-images' and
+`org-export-html-inline-image-extensions'."
+   (let ((inline-images (org-lparse-get 'INLINE-IMAGES))
+        (inline-image-extensions
+         (org-lparse-get 'INLINE-IMAGE-EXTENSIONS)))
+        (and (or (eq t inline-images) (and inline-images (not descp)))
+            (org-file-image-p filename inline-image-extensions))))
+
+(defun org-lparse-format-org-link (line opt-plist)
+  "Return LINE with markup of Org mode links.
+OPT-PLIST is the export options list."
+  (let ((start 0)
+       (current-dir (if buffer-file-name
+                        (file-name-directory buffer-file-name)
+                      default-directory))
+       (link-validate (plist-get opt-plist :link-validation-function))
+       type id-file fnc
+       rpl path attr desc descp desc1 desc2 link
+       org-lparse-link-description-is-image)
+    (while (string-match org-bracket-link-analytic-regexp++ line start)
+      (setq org-lparse-link-description-is-image nil)
+      (setq start (match-beginning 0))
+      (setq path (save-match-data (org-link-unescape
+                                  (match-string 3 line))))
+      (setq type (cond
+                 ((match-end 2) (match-string 2 line))
+                 ((save-match-data
+                    (or (file-name-absolute-p path)
+                        (string-match "^\\.\\.?/" path)))
+                  "file")
+                 (t "internal")))
+      (setq path (org-extract-attributes path))
+      (setq attr (get-text-property 0 'org-attributes path))
+      (setq desc1 (if (match-end 5) (match-string 5 line))
+           desc2 (if (match-end 2) (concat type ":" path) path)
+           descp (and desc1 (not (equal desc1 desc2)))
+           desc (or desc1 desc2))
+      ;; Make an image out of the description if that is so wanted
+      (when (and descp (org-file-image-p
+                       desc (org-lparse-get 'INLINE-IMAGE-EXTENSIONS)))
+       (setq org-lparse-link-description-is-image t)
+       (save-match-data
+         (if (string-match "^file:" desc)
+             (setq desc (substring desc (match-end 0)))))
+       (save-match-data
+         (setq desc (org-add-props
+                        (org-lparse-format 'INLINE-IMAGE desc)
+                        '(org-protected t)))))
+      (cond
+       ((equal type "internal")
+       (let
+           ((frag-0
+             (if (= (string-to-char path) ?#)
+                 (substring path 1)
+               path)))
+         (setq rpl
+               (org-lparse-format
+                'ORG-LINK opt-plist "" "" (org-solidify-link-text
+                                           (save-match-data
+                                             (org-link-unescape frag-0))
+                                           nil) desc attr descp))))
+       ((and (equal type "id")
+            (setq id-file (org-id-find-id-file path)))
+       ;; This is an id: link to another file (if it was the same file,
+       ;; it would have become an internal link...)
+       (save-match-data
+         (setq id-file (file-relative-name
+                        id-file
+                        (file-name-directory org-current-export-file)))
+         (setq rpl
+               (org-lparse-format
+                'ORG-LINK opt-plist type id-file
+                (concat (if (org-uuidgen-p path) "ID-") path)
+                desc attr descp))))
+       ((member type '("http" "https"))
+       ;; standard URL, can inline as image
+       (setq rpl
+             (org-lparse-format
+              'ORG-LINK opt-plist type path nil desc attr descp)))
+       ((member type '("ftp" "mailto" "news"))
+       ;; standard URL, can't inline as image
+       (setq rpl
+             (org-lparse-format
+              'ORG-LINK opt-plist type path nil desc attr descp)))
+
+       ((string= type "coderef")
+       (setq rpl (org-lparse-format
+                  'ORG-LINK opt-plist type "" path desc nil descp)))
+
+       ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
+       ;; The link protocol has a function for format the link
+       (setq rpl (save-match-data
+                   (funcall fnc (org-link-unescape path)
+                            desc1 (and (boundp 'org-lparse-backend)
+                                       (case org-lparse-backend
+                                         (xhtml 'html)
+                                         (t org-lparse-backend)))))))
+       ((string= type "file")
+       ;; FILE link
+       (save-match-data
+         (let*
+             ((components
+               (if
+                   (string-match "::\\(.*\\)" path)
+                   (list
+                    (replace-match "" t nil path)
+                    (match-string 1 path))
+                 (list path nil)))
+
+              ;;The proper path, without a fragment
+              (path-1
+               (first components))
+
+              ;;The raw fragment
+              (fragment-0
+               (second components))
+
+              ;;Check the fragment.  If it can't be used as
+              ;;target fragment we'll pass nil instead.
+              (fragment-1
+               (if
+                   (and fragment-0
+                        (not (string-match "^[0-9]*$" fragment-0))
+                        (not (string-match "^\\*" fragment-0))
+                        (not (string-match "^/.*/$" fragment-0)))
+                   (org-solidify-link-text
+                    (org-link-unescape fragment-0))
+                 nil))
+              (desc-2
+               ;;Description minus "file:" and ".org"
+               (if (string-match "^file:" desc)
+                   (let
+                       ((desc-1 (replace-match "" t t desc)))
+                     (if (string-match "\\.org$" desc-1)
+                         (replace-match "" t t desc-1)
+                       desc-1))
+                 desc)))
+
+           (setq rpl
+                 (if
+                     (and
+                      (functionp link-validate)
+                      (not (funcall link-validate path-1 current-dir)))
+                     desc
+                   (org-lparse-format
+                    'ORG-LINK opt-plist "file" path-1 fragment-1
+                    desc-2 attr descp))))))
+
+       (t
+       ;; just publish the path, as default
+       (setq rpl (concat "<i>&lt;" type ":"
+                         (save-match-data (org-link-unescape path))
+                         "&gt;</i>"))))
+      (setq line (replace-match rpl t t line)
+           start (+ start (length rpl))))
+    line))
+
+(defvar org-lparse-par-open-stashed)   ; bound during `org-do-lparse'
+(defun org-lparse-stash-save-paragraph-state ()
+  (assert (zerop org-lparse-par-open-stashed))
+  (setq org-lparse-par-open-stashed org-lparse-par-open)
+  (setq org-lparse-par-open nil))
+
+(defun org-lparse-stash-pop-paragraph-state ()
+  (setq org-lparse-par-open org-lparse-par-open-stashed)
+  (setq org-lparse-par-open-stashed 0))
+
+(defmacro with-org-lparse-preserve-paragraph-state (&rest body)
+  `(let ((org-lparse-do-open-par org-lparse-par-open))
+     (org-lparse-end-paragraph)
+     ,@body
+     (when org-lparse-do-open-par
+       (org-lparse-begin-paragraph))))
+(def-edebug-spec with-org-lparse-preserve-paragraph-state (body))
+
+(defvar org-lparse-native-backends nil
+  "List of native backends registered with `org-lparse'.
+A backend can use `org-lparse-register-backend' to add itself to
+this list.
+
+All native backends must implement a get routine and a mandatory
+set of callback routines.
+
+The get routine must be named as org-<backend>-get where backend
+is the name of the backend.  The exporter uses `org-lparse-get'
+and retrieves the backend-specific callback by querying for
+ENTITY-CONTROL and ENTITY-FORMAT variables.
+
+For the sake of illustration, the html backend implements
+`org-xhtml-get'.  It returns
+`org-xhtml-entity-control-callbacks-alist' and
+`org-xhtml-entity-format-callbacks-alist' as the values of
+ENTITY-CONTROL and ENTITY-FORMAT settings.")
+
+(defun org-lparse-register-backend (backend)
+  "Make BACKEND known to `org-lparse' library.
+Add BACKEND to `org-lparse-native-backends'."
+  (when backend
+    (setq backend (cond
+                  ((symbolp backend) (symbol-name backend))
+                  ((stringp backend) backend)
+                  (t (error "Error while registering backend: %S" backend))))
+    (add-to-list 'org-lparse-native-backends backend)))
+
+(defun org-lparse-unregister-backend (backend)
+  (setq org-lparse-native-backends
+       (remove (cond
+                ((symbolp backend) (symbol-name backend))
+                ((stringp backend) backend))
+               org-lparse-native-backends))
+  (message "Unregistered backend %S" backend))
+
+(defun org-lparse-do-reachable-formats (in-fmt)
+  "Return verbose info about formats to which IN-FMT can be converted.
+Return a list where each element is of the
+form (CONVERTER-PROCESS . OUTPUT-FMT-ALIST).  See
+`org-export-odt-convert-processes' for CONVERTER-PROCESS and see
+`org-export-odt-convert-capabilities' for OUTPUT-FMT-ALIST."
+  (let (reachable-formats)
+    (dolist (backend org-lparse-native-backends reachable-formats)
+      (let* ((converter (org-lparse-backend-get
+                        backend 'CONVERT-METHOD))
+            (capabilities (org-lparse-backend-get
+                           backend 'CONVERT-CAPABILITIES)))
+       (when converter
+         (dolist (c capabilities)
+           (when (member in-fmt (nth 1 c))
+             (push (cons converter (nth 2 c)) reachable-formats))))))))
+
+(defun org-lparse-reachable-formats (in-fmt)
+  "Return list of formats to which IN-FMT can be converted.
+The list of the form (OUTPUT-FMT-1 OUTPUT-FMT-2 ...)."
+  (let (l)
+    (mapc (lambda (e) (add-to-list 'l e))
+         (apply 'append (mapcar
+                         (lambda (e) (mapcar 'car (cdr e)))
+                         (org-lparse-do-reachable-formats in-fmt))))
+    l))
+
+(defun org-lparse-reachable-p (in-fmt out-fmt)
+  "Return non-nil if IN-FMT can be converted to OUT-FMT."
+  (catch 'done
+    (let ((reachable-formats (org-lparse-do-reachable-formats in-fmt)))
+      (dolist (e reachable-formats)
+       (let ((out-fmt-spec (assoc out-fmt (cdr e))))
+         (when out-fmt-spec
+           (throw 'done (cons (car e) out-fmt-spec))))))))
+
+(defun org-lparse-backend-is-native-p (backend)
+  (member backend org-lparse-native-backends))
+
+(defun org-lparse (target-backend native-backend arg
+                                 &optional hidden ext-plist
+                                 to-buffer body-only pub-dir)
+  "Export the outline to various formats.
+If there is an active region, export only the region.  The
+outline is first exported to NATIVE-BACKEND and optionally
+converted to TARGET-BACKEND.  See `org-lparse-native-backends'
+for list of known native backends.  Each native backend can
+specify a converter and list of target backends it exports to
+using the CONVERT-PROCESS and OTHER-BACKENDS settings of it's get
+method.  See `org-xhtml-get' for an illustrative example.
+
+ARG is a prefix argument that specifies how many levels of
+outline should become headlines.  The default is 3.  Lower levels
+will become bulleted lists.
+
+HIDDEN is obsolete and does nothing.
+
+EXT-PLIST is a property list that controls various aspects of
+export.  The settings here override org-mode's default settings
+and but are inferior to file-local settings.
+
+TO-BUFFER dumps the exported lines to a buffer or a string
+instead of a file.  If TO-BUFFER is the symbol `string' return the
+exported lines as a string.  If TO-BUFFER is non-nil, create a
+buffer with that name and export to that buffer.
+
+BODY-ONLY controls the presence of header and footer lines in
+exported text.  If BODY-ONLY is non-nil, don't produce the file
+header and footer, simply return the content of <body>...</body>,
+without even the body tags themselves.
+
+PUB-DIR specifies the publishing directory."
+  (let* ((org-lparse-backend (intern native-backend))
+        (org-lparse-other-backend (and target-backend
+                                       (intern target-backend))))
+    (unless (org-lparse-backend-is-native-p native-backend)
+      (error "Don't know how to export natively to backend %s" native-backend))
+
+    (unless (or (equal native-backend target-backend)
+               (org-lparse-reachable-p native-backend target-backend))
+      (error "Don't know how to export to backend %s %s" target-backend
+            (format "via %s" native-backend)))
+    (run-hooks 'org-export-first-hook)
+    (org-do-lparse arg hidden ext-plist to-buffer body-only pub-dir)))
+
+(defcustom org-lparse-use-flashy-warning nil
+  "Control flashing of messages logged with `org-lparse-warn'.
+When non-nil, messages are fontified with warning face and the
+exporter lingers for a while to catch user's attention."
+  :type 'boolean
+  :group 'org-lparse)
+
+(defun org-lparse-convert-read-params ()
+  "Return IN-FILE and OUT-FMT params for `org-lparse-do-convert'.
+This is a helper routine for interactive use."
+  (let* ((input (if (featurep 'ido) 'ido-completing-read 'completing-read))
+        (in-file (read-file-name "File to be converted: "
+                                 nil buffer-file-name t))
+        (in-fmt (file-name-extension in-file))
+        (out-fmt-choices (org-lparse-reachable-formats in-fmt))
+        (out-fmt
+         (or (and out-fmt-choices
+                  (funcall input "Output format:  "
+                           out-fmt-choices nil nil nil))
+             (error
+              "No known converter or no known output formats for %s files"
+              in-fmt))))
+    (list in-file out-fmt)))
+
+(eval-when-compile
+  (require 'browse-url))
+
+(defun org-lparse-do-convert (in-file out-fmt &optional prefix-arg)
+  "Workhorse routine for `org-export-odt-convert'."
+  (require 'browse-url)
+  (let* ((in-file (expand-file-name (or in-file buffer-file-name)))
+        (dummy (or (file-readable-p in-file)
+                   (error "Cannot read %s" in-file)))
+        (in-fmt (file-name-extension in-file))
+        (out-fmt (or out-fmt (error "Output format unspecified")))
+        (how (or (org-lparse-reachable-p in-fmt out-fmt)
+                 (error "Cannot convert from %s format to %s format?"
+                        in-fmt out-fmt)))
+        (convert-process (car how))
+        (program (car convert-process))
+        (dummy (and (or program (error "Converter not configured"))
+                    (or (executable-find program)
+                        (error "Cannot find converter %s" program))))
+        (out-file (concat (file-name-sans-extension in-file) "."
+                          (nth 1 (or (cdr how) out-fmt))))
+        (out-dir (file-name-directory in-file))
+        (arglist (mapcar (lambda (arg)
+                           (format-spec
+                            arg `((?i . ,in-file)
+                                  (?I . ,(browse-url-file-url in-file))
+                                  (?f . ,out-fmt)
+                                  (?o . ,out-file)
+                                  (?O . ,(browse-url-file-url out-file))
+                                  (?d . ,out-dir)
+                                  (?D . ,(browse-url-file-url out-dir)))))
+                         (cdr convert-process))))
+    (when (file-exists-p out-file)
+      (delete-file out-file))
+
+    (message "Executing %s %s" program (mapconcat 'identity arglist " "))
+    (apply 'call-process program nil nil nil arglist)
+    (cond
+     ((file-exists-p out-file)
+      (message "Exported to %s using %s" out-file program)
+      (when prefix-arg
+       (message "Opening %s..."  out-file)
+       (org-open-file out-file))
+      out-file
+      ;; (set-buffer (find-file-noselect out-file))
+      )
+     (t
+      (message "Export to %s failed" out-file)
+      nil))))
+
+(defvar org-lparse-insert-tag-with-newlines 'both)
+
+;; Following variables are let-bound during `org-lparse'
+(defvar org-lparse-dyn-first-heading-pos)
+(defvar org-lparse-toc)
+(defvar org-lparse-entity-control-callbacks-alist)
+(defvar org-lparse-entity-format-callbacks-alist)
+(defvar org-lparse-backend nil
+  "The native backend to which the document is currently exported.
+This variable is let bound during `org-lparse'.  Valid values are
+one of the symbols corresponding to `org-lparse-native-backends'.
+
+Compare this variable with `org-export-current-backend' which is
+bound only during `org-export-preprocess-string' stage of the
+export process.
+
+See also `org-lparse-other-backend'.")
+
+(defvar org-lparse-other-backend nil
+  "The target backend to which the document is currently exported.
+This variable is let bound during `org-lparse'.  This variable is
+set to either `org-lparse-backend' or one of the symbols
+corresponding to OTHER-BACKENDS specification of the
+org-lparse-backend.
+
+For example, if a document is exported to \"odt\" then both
+org-lparse-backend and org-lparse-other-backend are bound to
+'odt.  On the other hand, if a document is exported to \"odt\"
+and then converted to \"doc\" then org-lparse-backend is set to
+'odt and org-lparse-other-backend is set to 'doc.")
+
+(defvar org-lparse-body-only nil
+  "Bind this to BODY-ONLY arg of `org-lparse'.")
+
+(defvar org-lparse-to-buffer nil
+  "Bind this to TO-BUFFER arg of `org-lparse'.")
+
+(defun org-lparse-get-block-params (params)
+  (save-match-data
+    (when params
+      (setq params (org-trim params))
+      (unless (string-match "\\`(.*)\\'" params)
+       (setq params (format "(%s)" params)))
+      (ignore-errors (read params)))))
+
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
+(defvar org-lparse-special-blocks '("list-table" "annotation"))
+(defun org-do-lparse (arg &optional hidden ext-plist
+                         to-buffer body-only pub-dir)
+  "Export the outline to various formats.
+See `org-lparse' for more information. This function is a
+html-agnostic version of the `org-export-as-html' function in 7.5
+version."
+  ;; Make sure we have a file name when we need it.
+  (when (and (not (or to-buffer body-only))
+            (not buffer-file-name))
+    (if (buffer-base-buffer)
+       (org-set-local 'buffer-file-name
+                      (with-current-buffer (buffer-base-buffer)
+                        buffer-file-name))
+      (error "Need a file name to be able to export")))
+
+  (org-lparse-warn
+   (format "Exporting to %s using org-lparse..."
+          (upcase (symbol-name
+                   (or org-lparse-backend org-lparse-other-backend)))))
+
+  (setq-default org-todo-line-regexp org-todo-line-regexp)
+  (setq-default org-deadline-line-regexp org-deadline-line-regexp)
+  (setq-default org-done-keywords org-done-keywords)
+  (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
+  (let* (hfy-user-sheet-assoc          ; let `htmlfontify' know that
+                                       ; we are interested in
+                                       ; collecting styles
+        org-lparse-encode-pending
+        org-lparse-par-open
+        (org-lparse-par-open-stashed 0)
+
+        ;; list related vars
+        (org-lparse-list-level 0)      ; list level starts at 1. A
+                                       ; value of 0 implies we are
+                                       ; outside of any list
+        (org-lparse-list-item-count 0)
+        org-lparse-list-stack
+
+        ;; list-table related vars
+        org-lparse-list-table-p
+        org-lparse-list-table:table-cell-open
+        org-lparse-list-table:table-row
+        org-lparse-list-table:lines
+
+        org-lparse-outline-text-open
+        (org-lparse-latex-fragment-fallback ; currently used only by
+                                       ; odt exporter
+         (or (ignore-errors (org-lparse-get 'LATEX-FRAGMENT-FALLBACK))
+             (if (and (org-check-external-command "latex" "" t)
+                      (org-check-external-command "dvipng" "" t))
+                 'dvipng
+               'verbatim)))
+        (org-lparse-insert-tag-with-newlines 'both)
+        (org-lparse-to-buffer to-buffer)
+        (org-lparse-body-only body-only)
+        (org-lparse-entity-control-callbacks-alist
+         (org-lparse-get 'ENTITY-CONTROL))
+        (org-lparse-entity-format-callbacks-alist
+         (org-lparse-get 'ENTITY-FORMAT))
+        (opt-plist
+         (org-export-process-option-filters
+          (org-combine-plists (org-default-export-plist)
+                              ext-plist
+                              (org-infile-export-plist))))
+        (body-only (or body-only (plist-get opt-plist :body-only)))
+        valid org-lparse-dyn-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
+         (if (plist-get opt-plist :ignore-subtree-p)
+             nil
+           (when region-p
+             (save-excursion
+               (goto-char rbeg)
+               (and (org-at-heading-p)
+                    (>= (org-end-of-subtree t t) rend))))))
+        (level-offset (if subtree-p
+                          (save-excursion
+                            (goto-char rbeg)
+                            (+ (funcall outline-level)
+                               (if org-odd-levels-only 1 0)))
+                        0))
+        (opt-plist (setq org-export-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
+         (or pub-dir (org-lparse-get 'EXPORT-DIR opt-plist)))
+        (org-current-export-file buffer-file-name)
+        (level 0) (line "") (origline "") txt todo
+        (umax nil)
+        (umax-toc nil)
+        (filename (if to-buffer nil
+                    (expand-file-name
+                     (concat
+                      (file-name-sans-extension
+                       (or (and subtree-p
+                                (org-entry-get (region-beginning)
+                                               "EXPORT_FILE_NAME" t))
+                           (file-name-nondirectory buffer-file-name)))
+                      "." (org-lparse-get 'FILE-NAME-EXTENSION opt-plist))
+                     (file-name-as-directory
+                      (or pub-dir (org-lparse-get 'EXPORT-DIR opt-plist))))))
+        (current-dir (if buffer-file-name
+                         (file-name-directory buffer-file-name)
+                       default-directory))
+        (auto-insert nil) ; Avoid any auto-insert stuff for the new file
+        (buffer (if to-buffer
+                    (cond
+                     ((eq to-buffer 'string)
+                      (get-buffer-create (org-lparse-get 'EXPORT-BUFFER-NAME)))
+                     (t (get-buffer-create to-buffer)))
+                  (find-file-noselect
+                   (or (let ((f (org-lparse-get 'INIT-METHOD)))
+                         (and f (functionp f) (funcall f filename)))
+                       filename))))
+        (org-levels-open (make-vector org-level-max nil))
+        (dummy (mapc
+                (lambda(p)
+                  (let* ((val (plist-get opt-plist p))
+                         (val (org-xml-encode-org-text-skip-links val)))
+                    (setq opt-plist (plist-put opt-plist p val))))
+                '(:date :author :keywords :description)))
+        (date (plist-get opt-plist :date))
+        (date (cond
+               ((and date (string-match "%" date))
+                (format-time-string date))
+               (date date)
+               (t (format-time-string "%Y-%m-%d %T %Z"))))
+        (dummy (setq opt-plist (plist-put opt-plist :effective-date date)))
+        (title       (org-xml-encode-org-text-skip-links
+                      (or (and subtree-p (org-export-get-title-from-subtree))
+                          (plist-get opt-plist :title)
+                          (and (not body-only)
+                               (not
+                                (plist-get opt-plist :skip-before-1st-heading))
+                               (org-export-grab-title-from-buffer))
+                          (and buffer-file-name
+                               (file-name-sans-extension
+                                (file-name-nondirectory buffer-file-name)))
+                          "UNTITLED")))
+        (dummy (setq opt-plist (plist-put opt-plist :title title)))
+        (html-table-tag (plist-get opt-plist :html-table-tag))
+        (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
+        (quote-re (format org-heading-keyword-regexp-format
+                          org-quote-string))
+        (org-lparse-dyn-current-environment nil)
+        ;; Get the language-dependent settings
+        (lang-words (or (assoc (plist-get opt-plist :language)
+                               org-export-language-setup)
+                        (assoc "en" org-export-language-setup)))
+        (dummy (setq opt-plist (plist-put opt-plist :lang-words lang-words)))
+        (head-count  0) cnt
+        (start       0)
+        (coding-system-for-write
+         (or (ignore-errors (org-lparse-get 'CODING-SYSTEM-FOR-WRITE))
+             (and (boundp 'buffer-file-coding-system)
+                  buffer-file-coding-system)))
+        (save-buffer-coding-system
+         (or (ignore-errors (org-lparse-get 'CODING-SYSTEM-FOR-SAVE))
+             (and (boundp 'buffer-file-coding-system)
+                  buffer-file-coding-system)))
+        (region
+         (buffer-substring
+          (if region-p (region-beginning) (point-min))
+          (if region-p (region-end) (point-max))))
+        (org-export-have-math nil)
+        (org-export-footnotes-seen nil)
+        (org-export-footnotes-data (org-footnote-all-labels 'with-defs))
+        (org-footnote-insert-pos-for-preprocessor 'point-min)
+        (org-lparse-opt-plist opt-plist)
+        (lines
+         (org-split-string
+          (org-export-preprocess-string
+           region
+           :emph-multiline t
+           :for-backend (if (equal org-lparse-backend 'xhtml) ; hack
+                            'html
+                          org-lparse-backend)
+           :skip-before-1st-heading
+           (plist-get opt-plist :skip-before-1st-heading)
+           :drawers (plist-get opt-plist :drawers)
+           :todo-keywords (plist-get opt-plist :todo-keywords)
+           :tasks (plist-get opt-plist :tasks)
+           :tags (plist-get opt-plist :tags)
+           :priority (plist-get opt-plist :priority)
+           :footnotes (plist-get opt-plist :footnotes)
+           :timestamps (plist-get opt-plist :timestamps)
+           :archived-trees
+           (plist-get opt-plist :archived-trees)
+           :select-tags (plist-get opt-plist :select-tags)
+           :exclude-tags (plist-get opt-plist :exclude-tags)
+           :add-text
+           (plist-get opt-plist :text)
+           :LaTeX-fragments
+           (plist-get opt-plist :LaTeX-fragments))
+          "[\r\n]"))
+        table-open
+        table-buffer table-orig-buffer
+        ind
+        rpl path attr desc descp desc1 desc2 link
+        snumber fnc
+        footnotes footref-seen
+        org-lparse-output-buffer
+        org-lparse-footnote-definitions
+        org-lparse-footnote-number
+        ;; collection
+        org-lparse-collect-buffer
+        (org-lparse-collect-count 0)   ; things will get haywire if
+                                       ; collections are chained. Use
+                                       ; this variable to assert this
+                                       ; pre-requisite
+        org-lparse-toc
+        href
+        )
+
+    (let ((inhibit-read-only t))
+      (org-unmodified
+       (remove-text-properties (point-min) (point-max)
+                              '(:org-license-to-kill t))))
+
+    (message "Exporting...")
+    (org-init-section-numbers)
+
+    ;; Switch to the output buffer
+    (setq org-lparse-output-buffer buffer)
+    (set-buffer org-lparse-output-buffer)
+    (let ((inhibit-read-only t)) (erase-buffer))
+    (fundamental-mode)
+    (org-install-letbind)
+
+    (and (fboundp 'set-buffer-file-coding-system)
+        (set-buffer-file-coding-system coding-system-for-write))
+
+    (let ((case-fold-search nil)
+         (org-odd-levels-only odd))
+      ;; create local variables for all options, to make sure all called
+      ;; functions get the correct information
+      (mapc (lambda (x)
+             (set (make-local-variable (nth 2 x))
+                  (plist-get opt-plist (car x))))
+           org-export-plist-vars)
+      (setq umax (if arg (prefix-numeric-value arg)
+                  org-export-headline-levels))
+      (setq umax-toc (if (integerp org-export-with-toc)
+                        (min org-export-with-toc umax)
+                      umax))
+
+      (when (and org-export-with-toc (not body-only))
+       (setq lines (org-lparse-prepare-toc
+                    lines level-offset opt-plist umax-toc)))
+
+      (unless body-only
+       (org-lparse-begin 'DOCUMENT-CONTENT opt-plist)
+       (org-lparse-begin 'DOCUMENT-BODY opt-plist))
+
+      (setq head-count 0)
+      (org-init-section-numbers)
+
+      (org-lparse-begin-paragraph)
+
+      (while (setq line (pop lines) origline line)
+       (catch 'nextline
+         (when (and (org-lparse-current-environment-p 'quote)
+                    (string-match org-outline-regexp-bol line))
+           (org-lparse-end-environment 'quote))
+
+         (when (org-lparse-current-environment-p 'quote)
+           (org-lparse-insert 'LINE line)
+           (throw 'nextline nil))
+
+         ;; Fixed-width, verbatim lines (examples)
+         (when (and org-export-with-fixed-width
+                    (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
+           (when (not (org-lparse-current-environment-p 'fixedwidth))
+             (org-lparse-begin-environment 'fixedwidth))
+           (org-lparse-insert 'LINE (match-string 3 line))
+           (when (or (not lines)
+                     (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
+                                        (car lines))))
+             (org-lparse-end-environment 'fixedwidth))
+           (throw 'nextline nil))
+
+         ;; Notes: The baseline version of org-html.el (git commit
+         ;; 3d802e), while encoutering a *line-long* protected text,
+         ;; does one of the following two things based on the state
+         ;; of the export buffer.
+
+         ;; 1. If a paragraph element has just been opened and
+         ;;    contains only whitespace as content, insert the
+         ;;    protected text as part of the previous paragraph.
+
+         ;; 2. If the paragraph element has already been opened and
+         ;;    contains some valid content insert the protected text
+         ;;    as part of the current paragraph.
+
+         ;; I think --->
+
+         ;; Scenario 1 mentioned above kicks in when a block of
+         ;; protected text has to be inserted enbloc. For example,
+         ;; this happens, when inserting an source or example block
+         ;; or preformatted content enclosed in #+backend,
+         ;; #+begin_bakend ... #+end_backend)
+
+         ;; Scenario 2 mentioned above kicks in when the protected
+         ;; text is part of a running sentence. For example this
+         ;; happens in the case of an *multiline* LaTeX equation that
+         ;; needs to be inserted verbatim.
+
+         ;; org-html.el in the master branch seems to do some
+         ;; jugglery by moving paragraphs around. Inorder to make
+         ;; these changes backend-agnostic introduce a new text
+         ;; property org-native-text and impose the added semantics
+         ;; that these protected blocks appear outside of a
+         ;; conventional paragraph element.
+         ;;
+         ;; Extra Note: Check whether org-example and org-native-text
+         ;; are entirely equivalent.
+
+         ;; Fixes bug reported by Christian Moe concerning verbatim
+         ;; LaTeX fragments.
+         ;; on git commit 533ba3f90250a1f25f494c390d639ea6274f235c
+         ;; http://repo.or.cz/w/org-mode/org-jambu.git/shortlog/refs/heads/staging
+         ;; See http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01379.html
+
+         ;; Native Text
+         (when (and (get-text-property 0 'org-native-text line)
+                    ;; Make sure it is the entire line that is protected
+                    (not (< (or (next-single-property-change
+                                 0 'org-native-text line) 10000)
+                            (length line))))
+           (let ((ind (get-text-property 0 'original-indentation line)))
+             (org-lparse-begin-environment 'native)
+             (org-lparse-insert 'LINE line)
+             (while (and lines
+                         (or (= (length (car lines)) 0)
+                             (not ind)
+                             (equal ind (get-text-property
+                                         0 'original-indentation (car lines))))
+                         (or (= (length (car lines)) 0)
+                             (get-text-property 0 'org-native-text (car lines))))
+               (org-lparse-insert 'LINE (pop lines)))
+             (org-lparse-end-environment 'native))
+           (throw 'nextline nil))
+
+         ;; Protected HTML
+         (when (and (get-text-property 0 'org-protected line)
+                    ;; Make sure it is the entire line that is protected
+                    (not (< (or (next-single-property-change
+                                 0 'org-protected line) 10000)
+                            (length line))))
+           (let ((ind (get-text-property 0 'original-indentation line)))
+             (org-lparse-insert 'LINE line)
+             (while (and lines
+                         (or (= (length (car lines)) 0)
+                             (not ind)
+                             (equal ind (get-text-property
+                                         0 'original-indentation (car lines))))
+                         (or (= (length (car lines)) 0)
+                             (get-text-property 0 'org-protected (car lines))))
+               (org-lparse-insert 'LINE (pop lines))))
+           (throw 'nextline nil))
+
+         ;; Blockquotes, verse, and center
+         (when (string-match
+                "^ORG-\\(.+\\)-\\(START\\|END\\)\\([ \t]+.*\\)?$" line)
+           (let* ((style (intern (downcase (match-string 1 line))))
+                  (env-options-plist (org-lparse-get-block-params
+                                      (match-string 3 line)))
+                  (f (cdr (assoc (match-string 2 line)
+                                 '(("START" . org-lparse-begin-environment)
+                                   ("END" . org-lparse-end-environment))))))
+             (when (memq style
+                         (append
+                          '(blockquote verse center)
+                          (mapcar 'intern org-lparse-special-blocks)))
+               (funcall f style env-options-plist)
+               (throw 'nextline nil))))
+
+         (run-hooks 'org-export-html-after-blockquotes-hook)
+         (when (org-lparse-current-environment-p 'verse)
+           (let ((i (org-get-string-indentation line)))
+             (if (> i 0)
+                 (setq line (concat
+                             (let ((org-lparse-encode-pending t))
+                               (org-lparse-format 'SPACES (* 2 i)))
+                             " " (org-trim line))))
+             (unless (string-match "\\\\\\\\[ \t]*$" line)
+               (setq line (concat line "\\\\")))))
+
+         ;; make targets to anchors
+         (setq start 0)
+         (while (string-match
+                 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
+           (cond
+            ((get-text-property (match-beginning 1) 'org-protected line)
+             (setq start (match-end 1)))
+            ((match-end 2)
+             (setq line (replace-match
+                         (let ((org-lparse-encode-pending t))
+                           (org-lparse-format
+                            'ANCHOR "" (org-solidify-link-text
+                                        (match-string 1 line))))
+                         t t line)))
+            ((and org-export-with-toc (equal (string-to-char line) ?*))
+             ;; FIXME: NOT DEPENDENT on TOC?????????????????????
+             (setq line (replace-match
+                         (let ((org-lparse-encode-pending t))
+                           (org-lparse-format
+                            'FONTIFY (match-string 1 line) "target"))
+                         ;; (concat "@<i>" (match-string 1 line) "@</i> ")
+                         t t line)))
+            (t
+             (setq line (replace-match
+                         (concat
+                          (let ((org-lparse-encode-pending t))
+                            (org-lparse-format
+                             'ANCHOR (match-string 1 line)
+                             (org-solidify-link-text (match-string 1 line))
+                             "target")) " ")
+                         t t line)))))
+
+         (let ((org-lparse-encode-pending t))
+           (setq line (org-lparse-handle-time-stamps line)))
+
+         ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
+         ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
+         ;; Also handle sub_superscripts and checkboxes
+         (or (string-match org-table-hline-regexp line)
+             (string-match "^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$" line)
+             (setq line (org-xml-encode-org-text-skip-links line)))
+
+         (setq line (org-lparse-format-org-link line opt-plist))
+
+         ;; TODO items
+         (if (and org-todo-line-regexp
+                  (string-match org-todo-line-regexp line)
+                  (match-beginning 2))
+             (setq line (concat
+                         (substring line 0 (match-beginning 2))
+                         (org-lparse-format 'TODO (match-string 2 line))
+                         (substring line (match-end 2)))))
+
+         ;; Does this contain a reference to a footnote?
+         (when org-export-with-footnotes
+           (setq start 0)
+           (while (string-match "\\([^* \t].*?\\)[ \t]*\\[\\([0-9]+\\)\\]" line start)
+             ;; Discard protected matches not clearly identified as
+             ;; footnote markers.
+             (if (or (get-text-property (match-beginning 2) 'org-protected line)
+                     (not (get-text-property (match-beginning 2) 'org-footnote line)))
+                 (setq start (match-end 2))
+               (let ((n (match-string 2 line)) refcnt a)
+                 (if (setq a (assoc n footref-seen))
+                     (progn
+                       (setcdr a (1+ (cdr a)))
+                       (setq refcnt (cdr a)))
+                   (setq refcnt 1)
+                   (push (cons n 1) footref-seen))
+                 (setq line
+                       (replace-match
+                        (concat
+                         (or (match-string 1 line) "")
+                         (org-lparse-format
+                          'FOOTNOTE-REFERENCE
+                          n (cdr (assoc n org-lparse-footnote-definitions))
+                          refcnt)
+                         ;; If another footnote is following the
+                         ;; current one, add a separator.
+                         (if (save-match-data
+                               (string-match "\\`\\[[0-9]+\\]"
+                                             (substring line (match-end 0))))
+                             (ignore-errors
+                               (org-lparse-get 'FOOTNOTE-SEPARATOR))
+                           ""))
+                        t t line))))))
+
+         (cond
+          ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
+           ;; This is a headline
+           (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
+                                        level-offset))
+                 txt (match-string 2 line))
+           (if (string-match quote-re0 txt)
+               (setq txt (replace-match "" t t txt)))
+           (if (<= level (max umax umax-toc))
+               (setq head-count (+ head-count 1)))
+           (unless org-lparse-dyn-first-heading-pos
+             (setq org-lparse-dyn-first-heading-pos (point)))
+           (org-lparse-begin-level level txt umax head-count)
+
+           ;; QUOTES
+           (when (string-match quote-re line)
+             (org-lparse-begin-environment 'quote)))
+
+          ((and org-export-with-tables
+                (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
+           (when (not table-open)
+             ;; New table starts
+             (setq table-open t table-buffer nil table-orig-buffer nil))
+
+           ;; Accumulate lines
+           (setq table-buffer (cons line table-buffer)
+                 table-orig-buffer (cons origline table-orig-buffer))
+           (when (or (not lines)
+                     (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
+                                        (car lines))))
+             (setq table-open nil
+                   table-buffer (nreverse table-buffer)
+                   table-orig-buffer (nreverse table-orig-buffer))
+             (org-lparse-end-paragraph)
+             (org-lparse-insert 'TABLE table-buffer table-orig-buffer)))
+
+          ;; Normal lines
+
+          (t
+           ;; This line either is list item or end a list.
+           (when (get-text-property 0 'list-item line)
+             (setq line (org-lparse-export-list-line
+                         line
+                         (get-text-property 0 'list-item line)
+                         (get-text-property 0 'list-struct line)
+                         (get-text-property 0 'list-prevs line))))
+
+           ;; Horizontal line
+           (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
+             (with-org-lparse-preserve-paragraph-state
+              (org-lparse-insert 'HORIZONTAL-LINE))
+             (throw 'nextline nil))
+
+           ;; Empty lines start a new paragraph.  If hand-formatted lists
+           ;; are not fully interpreted, lines starting with "-", "+", "*"
+           ;; also start a new paragraph.
+           (when (string-match "^ [-+*]-\\|^[ \t]*$" line)
+             (when org-lparse-footnote-number
+               (org-lparse-end-footnote-definition org-lparse-footnote-number)
+               (setq org-lparse-footnote-number nil))
+             (org-lparse-begin-paragraph))
+
+           ;; Is this the start of a footnote?
+           (when org-export-with-footnotes
+             (when (and (boundp 'footnote-section-tag-regexp)
+                        (string-match (concat "^" footnote-section-tag-regexp)
+                                      line))
+               ;; ignore this line
+               (throw 'nextline nil))
+             (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
+               (org-lparse-end-paragraph)
+               (setq org-lparse-footnote-number (match-string 1 line))
+               (setq line (replace-match "" t t line))
+               (org-lparse-begin-footnote-definition org-lparse-footnote-number)))
+           ;; Check if the line break needs to be conserved
+           (cond
+            ((string-match "\\\\\\\\[ \t]*$" line)
+             (setq line (replace-match
+                         (org-lparse-format 'LINE-BREAK)
+                         t t line)))
+            (org-export-preserve-breaks
+             (setq line (concat line (org-lparse-format 'LINE-BREAK)))))
+
+           ;; Check if a paragraph should be started
+           (let ((start 0))
+             (while (and org-lparse-par-open
+                         (string-match "\\\\par\\>" line start))
+               (error "FIXME")
+               ;; Leave a space in the </p> so that the footnote matcher
+               ;; does not see this.
+               (if (not (get-text-property (match-beginning 0)
+                                           'org-protected line))
+                   (setq line (replace-match "</p ><p >" t t line)))
+               (setq start (match-end 0))))
+
+           (org-lparse-insert 'LINE line)))))
+
+      ;; Properly close all local lists and other lists
+      (when (org-lparse-current-environment-p 'quote)
+       (org-lparse-end-environment 'quote))
+
+      (org-lparse-end-level 1 umax)
+
+      ;; the </div> to close the last text-... div.
+      (when (and (> umax 0) org-lparse-dyn-first-heading-pos)
+       (org-lparse-end-outline-text-or-outline))
+
+      (org-lparse-end 'DOCUMENT-BODY opt-plist)
+      (unless body-only
+       (org-lparse-end 'DOCUMENT-CONTENT))
+
+      (unless (plist-get opt-plist :buffer-will-be-killed)
+       (set-auto-mode t))
+
+      (org-lparse-end 'EXPORT)
+
+      ;; kill collection buffer
+      (when org-lparse-collect-buffer
+       (kill-buffer org-lparse-collect-buffer))
+
+      (goto-char (point-min))
+      (or (org-export-push-to-kill-ring
+          (upcase (symbol-name org-lparse-backend)))
+         (message "Exporting... done"))
+
+      (cond
+       ((not to-buffer)
+       (let ((f (org-lparse-get 'SAVE-METHOD)))
+         (or (and f (functionp f) (funcall f filename opt-plist))
+             (save-buffer)))
+       (or (and (boundp 'org-lparse-other-backend)
+                org-lparse-other-backend
+                (not (equal org-lparse-backend org-lparse-other-backend))
+                (org-lparse-do-convert
+                 buffer-file-name (symbol-name org-lparse-other-backend)))
+           (current-buffer)))
+       ((eq to-buffer 'string)
+       (prog1 (buffer-substring (point-min) (point-max))
+         (kill-buffer (current-buffer))))
+       (t (current-buffer))))))
+
+(defun org-lparse-format-table (lines olines)
+  "Retuns backend-specific code for org-type and table-type tables."
+  (if (stringp lines)
+      (setq lines (org-split-string lines "\n")))
+  (if (string-match "^[ \t]*|" (car lines))
+      ;; A normal org table
+      (org-lparse-format-org-table lines nil)
+    ;; Table made by table.el
+    (or (org-lparse-format-table-table-using-table-generate-source
+        ;; FIXME: Need to take care of this during merge
+        (if (eq org-lparse-backend 'xhtml) 'html org-lparse-backend)
+        olines
+        (not org-export-prefer-native-exporter-for-tables))
+       ;; We are here only when table.el table has NO col or row
+       ;; spanning and the user prefers using org's own converter for
+       ;; exporting of such simple table.el tables.
+       (org-lparse-format-table-table lines))))
+
+(defun org-lparse-table-get-colalign-info (lines)
+  (let ((col-cookies (org-find-text-property-in-string
+                       'org-col-cookies (car lines))))
+    (when (and col-cookies org-table-clean-did-remove-column)
+      (setq col-cookies
+           (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
+    col-cookies))
+
+(defvar org-lparse-table-style)
+(defvar org-lparse-table-ncols)
+(defvar org-lparse-table-rownum)
+(defvar org-lparse-table-is-styled)
+(defvar org-lparse-table-begin-marker)
+(defvar org-lparse-table-num-numeric-items-per-column)
+(defvar org-lparse-table-colalign-info)
+(defvar org-lparse-table-colalign-vector)
+
+;; Following variables are defined in org-table.el
+(defvar org-table-number-fraction)
+(defvar org-table-number-regexp)
+(defun org-lparse-org-table-to-list-table (lines &optional splice)
+  "Convert org-table to list-table.
+LINES is a list of the form (ROW1 ROW2 ROW3 ...) where each
+element is a `string' representing a single row of org-table.
+Thus each ROW has vertical separators \"|\" separating the table
+fields.  A ROW could also be a row-group separator of the form
+\"|---...|\".  Return a list of the form (ROW1 ROW2 ROW3
+...). ROW could either be symbol `:hrule' or a list of the
+form (FIELD1 FIELD2 FIELD3 ...) as appropriate."
+  (let (line lines-1)
+    (cond
+     (splice
+      (while (setq line (pop lines))
+       (unless (string-match "^[ \t]*|-" line)
+         (push (org-split-string line "[ \t]*|[ \t]*") lines-1))))
+     (t
+      (while (setq line (pop lines))
+       (cond
+        ((string-match "^[ \t]*|-" line)
+         (when lines
+           (push :hrule lines-1)))
+        (t
+         (push (org-split-string line "[ \t]*|[ \t]*") lines-1))))))
+    (nreverse lines-1)))
+
+(defun org-lparse-insert-org-table (lines &optional splice)
+  "Format a org-type table into backend-specific code.
+LINES is a list of lines.  Optional argument SPLICE means, do not
+insert header and surrounding <table> tags, just format the lines.
+Optional argument NO-CSS means use XHTML attributes instead of CSS
+for formatting.  This is required for the DocBook exporter."
+  (require 'org-table)
+  ;; Get rid of hlines at beginning and end
+  (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
+  (setq lines (nreverse lines))
+  (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
+  (setq lines (nreverse lines))
+  (when org-export-table-remove-special-lines
+    ;; Check if the table has a marking column.  If yes remove the
+    ;; column and the special lines
+    (setq lines (org-table-clean-before-export lines)))
+  (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
+        (caption (and caption (org-xml-encode-org-text caption)))
+        (label (org-find-text-property-in-string 'org-label (car lines)))
+        (org-lparse-table-colalign-info (org-lparse-table-get-colalign-info lines))
+        (attributes (org-find-text-property-in-string 'org-attributes
+                                                      (car lines)))
+        (head (and org-export-highlight-first-table-line
+                   (delq nil (mapcar
+                              (lambda (x) (string-match "^[ \t]*|-" x))
+                              (cdr lines))))))
+    (setq lines (org-lparse-org-table-to-list-table lines splice))
+    (org-lparse-insert-list-table
+     lines splice caption label attributes head org-lparse-table-colalign-info)))
+
+(defun org-lparse-insert-list-table (lines &optional splice
+                                             caption label attributes head
+                                             org-lparse-table-colalign-info)
+  (or (featurep 'org-table)            ; required for
+      (require 'org-table))            ; `org-table-number-regexp'
+  (let* ((org-lparse-table-rownum -1) org-lparse-table-ncols i (cnt 0)
+        tbopen fields line
+        org-lparse-table-cur-rowgrp-is-hdr
+        org-lparse-table-rowgrp-open
+        org-lparse-table-num-numeric-items-per-column
+        org-lparse-table-colalign-vector n
+        org-lparse-table-rowgrp-info
+        org-lparse-table-begin-marker
+        (org-lparse-table-style 'org-table)
+        org-lparse-table-is-styled)
+    (cond
+     (splice
+      (setq org-lparse-table-is-styled nil)
+      (while (setq line (pop lines))
+       (insert (org-lparse-format-table-row line) "\n")))
+     (t
+      (setq org-lparse-table-is-styled t)
+      (org-lparse-begin 'TABLE caption label attributes)
+      (setq org-lparse-table-begin-marker (point))
+      (org-lparse-begin-table-rowgroup head)
+      (while (setq line (pop lines))
+       (cond
+        ((equal line :hrule)
+         (org-lparse-begin-table-rowgroup))
+        (t
+         (insert (org-lparse-format-table-row line) "\n"))))
+      (org-lparse-end 'TABLE-ROWGROUP)
+      (org-lparse-end-table)))))
+
+(defun org-lparse-format-org-table (lines &optional splice)
+  (with-temp-buffer
+    (org-lparse-insert-org-table lines splice)
+    (buffer-substring-no-properties (point-min) (point-max))))
+
+(defun org-lparse-format-list-table (lines &optional splice)
+  (with-temp-buffer
+    (org-lparse-insert-list-table lines splice)
+    (buffer-substring-no-properties (point-min) (point-max))))
+
+(defun org-lparse-insert-table-table (lines)
+  "Format a table generated by table.el into backend-specific code.
+This conversion does *not* use `table-generate-source' from table.el.
+This has the advantage that Org-mode's HTML conversions can be used.
+But it has the disadvantage, that no cell- or row-spanning is allowed."
+  (let (line field-buffer
+            (org-lparse-table-cur-rowgrp-is-hdr
+             org-export-highlight-first-table-line)
+            (caption nil)
+            (attributes nil)
+            (label nil)
+            (org-lparse-table-style 'table-table)
+            (org-lparse-table-is-styled nil)
+            fields org-lparse-table-ncols i (org-lparse-table-rownum -1)
+            (empty (org-lparse-format 'SPACES 1)))
+    (org-lparse-begin 'TABLE caption label attributes)
+    (while (setq line (pop lines))
+      (cond
+       ((string-match "^[ \t]*\\+-" line)
+       (when field-buffer
+         (let ((org-export-table-row-tags '("<tr>" . "</tr>"))
+               ;; (org-export-html-table-use-header-tags-for-first-column nil)
+               )
+           (insert (org-lparse-format-table-row field-buffer empty)))
+         (setq org-lparse-table-cur-rowgrp-is-hdr nil)
+         (setq field-buffer nil)))
+       (t
+       ;; Break the line into fields and store the fields
+       (setq fields (org-split-string line "[ \t]*|[ \t]*"))
+       (if field-buffer
+           (setq field-buffer (mapcar
+                               (lambda (x)
+                                 (concat x (org-lparse-format 'LINE-BREAK)
+                                         (pop fields)))
+                               field-buffer))
+         (setq field-buffer fields)))))
+    (org-lparse-end-table)))
+
+(defun org-lparse-format-table-table (lines)
+  (with-temp-buffer
+    (org-lparse-insert-table-table lines)
+    (buffer-substring-no-properties (point-min) (point-max))))
+
+(defvar table-source-languages)                ; defined in table.el
+(defun org-lparse-format-table-table-using-table-generate-source (backend
+                                                                lines
+                                                                &optional
+                                                                spanned-only)
+  "Format a table into BACKEND, using `table-generate-source' from table.el.
+Use SPANNED-ONLY to suppress exporting of simple table.el tables.
+
+When SPANNED-ONLY is nil, all table.el tables are exported.  When
+SPANNED-ONLY is non-nil, only tables with either row or column
+spans are exported.
+
+This routine returns the generated source or nil as appropriate.
+
+Refer docstring of `org-export-prefer-native-exporter-for-tables'
+for further information."
+  (require 'table)
+  (with-current-buffer (get-buffer-create " org-tmp1 ")
+    (erase-buffer)
+    (insert (mapconcat 'identity lines "\n"))
+    (goto-char (point-min))
+    (if (not (re-search-forward "|[^+]" nil t))
+       (error "Error processing table"))
+    (table-recognize-table)
+    (when (or (not spanned-only)
+             (let* ((dim (table-query-dimension))
+                    (c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
+               (not (= (* c r) cells))))
+      (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
+      (cond
+       ((member backend table-source-languages)
+       (table-generate-source backend " org-tmp2 ")
+       (set-buffer " org-tmp2 ")
+       (buffer-substring (point-min) (point-max)))
+       (t
+       ;; table.el doesn't support the given backend. Currently this
+       ;; happens in case of odt export.  Strip the table from the
+       ;; generated document. A better alternative would be to embed
+       ;; the table as ascii text in the output document.
+       (org-lparse-warn
+        (concat
+         "Found table.el-type table in the source org file. "
+         (format "table.el doesn't support %s backend. "
+                 (upcase (symbol-name backend)))
+         "Skipping ahead ..."))
+       "")))))
+
+(defun org-lparse-handle-time-stamps (s)
+  "Format time stamps in string S, or remove them."
+  (catch 'exit
+    (let (r b)
+      (when org-maybe-keyword-time-regexp
+       (while (string-match org-maybe-keyword-time-regexp s)
+         (or b (setq b (substring s 0 (match-beginning 0))))
+         (setq r (concat
+                  r (substring s 0 (match-beginning 0)) " "
+                  (org-lparse-format
+                   'FONTIFY
+                   (concat
+                    (if (match-end 1)
+                        (org-lparse-format
+                         'FONTIFY
+                         (match-string 1 s) "timestamp-kwd"))
+                    " "
+                    (org-lparse-format
+                     'FONTIFY
+                     (substring (org-translate-time (match-string 3 s)) 1 -1)
+                     "timestamp"))
+                   "timestamp-wrapper"))
+               s (substring s (match-end 0)))))
+
+      ;; Line break if line started and ended with time stamp stuff
+      (if (not r)
+         s
+       (setq r (concat r s))
+       (unless (string-match "\\S-" (concat b s))
+         (setq r (concat r (org-lparse-format 'LINE-BREAK))))
+       r))))
+
+(defun org-xml-encode-plain-text (s)
+  "Convert plain text characters to HTML equivalent.
+Possible conversions are set in `org-export-html-protect-char-alist'."
+  (let ((cl (org-lparse-get 'PLAIN-TEXT-MAP)) c)
+    (while (setq c (pop cl))
+      (let ((start 0))
+       (while (string-match (car c) s start)
+         (setq s (replace-match (cdr c) t t s)
+               start (1+ (match-beginning 0))))))
+    s))
+
+(defun org-xml-encode-org-text-skip-links (string)
+  "Prepare STRING for HTML export.  Apply all active conversions.
+If there are links in the string, don't modify these.  If STRING
+is nil, return nil."
+  (when string
+    (let* ((re (concat org-bracket-link-regexp "\\|"
+                      (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
+          m s l res)
+      (while (setq m (string-match re string))
+       (setq s (substring string 0 m)
+             l (match-string 0 string)
+             string (substring string (match-end 0)))
+       (push (org-xml-encode-org-text s) res)
+       (push l res))
+      (push (org-xml-encode-org-text string) res)
+      (apply 'concat (nreverse res)))))
+
+(defun org-xml-encode-org-text (s)
+  "Apply all active conversions to translate special ASCII to HTML."
+  (setq s (org-xml-encode-plain-text s))
+  (if org-export-html-expand
+      (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
+       (setq s (replace-match "<\\1>" t nil s))))
+  (if org-export-with-emphasize
+      (setq s (org-lparse-apply-char-styles s)))
+  (if org-export-with-special-strings
+      (setq s (org-lparse-convert-special-strings s)))
+  (if org-export-with-sub-superscripts
+      (setq s (org-lparse-apply-sub-superscript-styles s)))
+  (if org-export-with-TeX-macros
+      (let ((start 0) wd rep)
+       (while (setq start (string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
+                                        s start))
+         (if (get-text-property (match-beginning 0) 'org-protected s)
+             (setq start (match-end 0))
+           (setq wd (match-string 1 s))
+           (if (setq rep (org-lparse-format 'ORG-ENTITY wd))
+               (setq s (replace-match rep t t s))
+             (setq start (+ start (length wd))))))))
+  s)
+
+(defun org-lparse-convert-special-strings (string)
+  "Convert special characters in STRING to HTML."
+  (let ((all (org-lparse-get 'SPECIAL-STRING-REGEXPS))
+       e a re rpl start)
+    (while (setq a (pop all))
+      (setq re (car a) rpl (cdr a) start 0)
+      (while (string-match re string start)
+       (if (get-text-property (match-beginning 0) 'org-protected string)
+           (setq start (match-end 0))
+         (setq string (replace-match rpl t nil string)))))
+    string))
+
+(defun org-lparse-apply-sub-superscript-styles (string)
+  "Apply subscript and superscript styles to STRING.
+Use `org-export-with-sub-superscripts' to control application of
+sub and superscript styles."
+  (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
+    (while (string-match org-match-substring-regexp string s)
+      (cond
+       ((and requireb (match-end 8)) (setq s (match-end 2)))
+       ((get-text-property  (match-beginning 2) 'org-protected string)
+       (setq s (match-end 2)))
+       (t
+       (setq s (match-end 1)
+             key (if (string= (match-string 2 string) "_")
+                     'subscript 'superscript)
+             c (or (match-string 8 string)
+                   (match-string 6 string)
+                   (match-string 5 string))
+             string (replace-match
+                     (concat (match-string 1 string)
+                             (org-lparse-format 'FONTIFY c key))
+                     t t string)))))
+    (while (string-match "\\\\\\([_^]\\)" string)
+      (setq string (replace-match (match-string 1 string) t t string)))
+    string))
+
+(defvar org-lparse-char-styles
+  `(("*" bold)
+    ("/" emphasis)
+    ("_" underline)
+    ("=" code)
+    ("~" verbatim)
+    ("+" strike))
+  "Map Org emphasis markers to char styles.
+This is an alist where each element is of the
+form (ORG-EMPHASIS-CHAR . CHAR-STYLE).")
+
+(defun org-lparse-apply-char-styles (string)
+  "Apply char styles to STRING.
+The variable `org-lparse-char-styles' controls how the Org
+emphasis markers are interpreted."
+  (let ((s 0) rpl)
+    (while (string-match org-emph-re string s)
+      (if (not (equal
+               (substring string (match-beginning 3) (1+ (match-beginning 3)))
+               (substring string (match-beginning 4) (1+ (match-beginning 4)))))
+         (setq s (match-beginning 0)
+               rpl
+               (concat
+                (match-string 1 string)
+                (org-lparse-format
+                 'FONTIFY (match-string 4 string)
+                 (nth 1 (assoc (match-string 3 string)
+                               org-lparse-char-styles)))
+                (match-string 5 string))
+               string (replace-match rpl t t string)
+               s (+ s (- (length rpl) 2)))
+       (setq s (1+ s))))
+    string))
+
+(defun org-lparse-export-list-line (line pos struct prevs)
+  "Insert list syntax in export buffer.  Return LINE, maybe modified.
+
+POS is the item position or line position the line had before
+modifications to buffer.  STRUCT is the list structure.  PREVS is
+the alist of previous items."
+  (let* ((get-type
+         (function
+          ;; Translate type of list containing POS to "d", "o" or
+          ;; "u".
+          (lambda (pos struct prevs)
+            (let ((type (org-list-get-list-type pos struct prevs)))
+              (cond
+               ((eq 'ordered type) "o")
+               ((eq 'descriptive type) "d")
+               (t "u"))))))
+        (get-closings
+         (function
+          ;; Return list of all items and sublists ending at POS, in
+          ;; reverse order.
+          (lambda (pos)
+            (let (out)
+              (catch 'exit
+                (mapc (lambda (e)
+                        (let ((end (nth 6 e))
+                              (item (car e)))
+                          (cond
+                           ((= end pos) (push item out))
+                           ((>= item pos) (throw 'exit nil)))))
+                      struct))
+              out)))))
+    ;; First close any previous item, or list, ending at POS.
+    (mapc (lambda (e)
+           (let* ((lastp (= (org-list-get-last-item e struct prevs) e))
+                  (first-item (org-list-get-list-begin e struct prevs))
+                  (type (funcall get-type first-item struct prevs)))
+             (org-lparse-end-paragraph)
+             ;; Ending for every item
+             (org-lparse-end-list-item-1 type)
+             ;; We're ending last item of the list: end list.
+             (when lastp
+               (org-lparse-end-list type)
+               (org-lparse-begin-paragraph))))
+         (funcall get-closings pos))
+    (cond
+     ;; At an item: insert appropriate tags in export buffer.
+     ((assq pos struct)
+      (string-match
+       (concat "[ \t]*\\(\\S-+[ \t]*\\)"
+              "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
+              "\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
+              "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"
+              "\\(.*\\)") line)
+      (let* ((checkbox (match-string 3 line))
+            (desc-tag (or (match-string 4 line) "???"))
+            (body (or (match-string 5 line) ""))
+            (list-beg (org-list-get-list-begin pos struct prevs))
+            (firstp (= list-beg pos))
+            ;; Always refer to first item to determine list type, in
+            ;; case list is ill-formed.
+            (type (funcall get-type list-beg struct prevs))
+            (counter (let ((count-tmp (org-list-get-counter pos struct)))
+                       (cond
+                        ((not count-tmp) nil)
+                        ((string-match "[A-Za-z]" count-tmp)
+                         (- (string-to-char (upcase count-tmp)) 64))
+                        ((string-match "[0-9]+" count-tmp)
+                         count-tmp)))))
+       (when firstp
+         (org-lparse-end-paragraph)
+         (org-lparse-begin-list type))
+
+       (let ((arg (cond ((equal type "d") desc-tag)
+                        ((equal type "o") counter))))
+         (org-lparse-begin-list-item type arg))
+
+       ;; If line had a checkbox, some additional modification is required.
+       (when checkbox
+         (setq body
+               (concat
+                (org-lparse-format
+                 'FONTIFY (concat
+                           "["
+                           (cond
+                            ((string-match "X" checkbox) "X")
+                            ((string-match " " checkbox)
+                             (org-lparse-format 'SPACES 1))
+                            (t "-"))
+                           "]")
+                 'code)
+                " "
+                body)))
+       ;; Return modified line
+       body))
+     ;; At a list ender: go to next line (side-effects only).
+     ((equal "ORG-LIST-END-MARKER" line) (throw 'nextline nil))
+     ;; Not at an item: return line unchanged (side-effects only).
+     (t line))))
+
+(defun org-lparse-bind-local-variables (opt-plist)
+  (mapc (lambda (x)
+         (set (make-local-variable (nth 2 x))
+              (plist-get opt-plist (car x))))
+       org-export-plist-vars))
+
+(defvar org-lparse-table-rowgrp-open)
+(defvar org-lparse-table-cur-rowgrp-is-hdr)
+(defvar org-lparse-footnote-number)
+(defvar org-lparse-footnote-definitions)
+(defvar org-lparse-output-buffer nil
+  "Buffer to which `org-do-lparse' writes to.
+This buffer contains the contents of the to-be-created exported
+document.")
+
+(defcustom org-lparse-debug nil
+  "Enable or Disable logging of `org-lparse' callbacks.
+The parameters passed to the backend-registered ENTITY-CONTROL
+and ENTITY-FORMAT callbacks are logged as comment strings in the
+exported buffer.  (org-lparse-format 'COMMENT fmt args) is used
+for logging.  Customize this variable only if you are an expert
+user.  Valid values of this variable are:
+nil     : Disable logging
+control : Log all invocations of `org-lparse-begin' and
+          `org-lparse-end' callbacks.
+format  : Log invocations of `org-lparse-format' callbacks.
+t       : Log all invocations of `org-lparse-begin', `org-lparse-end'
+          and `org-lparse-format' callbacks,"
+  :group 'org-lparse
+  :type '(choice
+         (const :tag "Disable" nil)
+         (const :tag "Format callbacks" format)
+         (const :tag "Control callbacks" control)
+         (const :tag "Format and Control callbacks" t)))
+
+(defun org-lparse-begin (entity &rest args)
+  "Begin ENTITY in current buffer.  ARGS is entity specific.
+ENTITY can be one of PARAGRAPH, LIST, LIST-ITEM etc.
+
+Use (org-lparse-begin 'LIST \"o\") to begin a list in current
+buffer.
+
+See `org-xhtml-entity-control-callbacks-alist' for more
+information."
+  (when (and (member org-lparse-debug '(t control))
+            (not (eq entity 'DOCUMENT-CONTENT)))
+    (insert (org-lparse-format 'COMMENT "%s BEGIN %S" entity args)))
+
+  (let ((f (cadr (assoc entity org-lparse-entity-control-callbacks-alist))))
+    (unless f (error "Unknown entity: %s" entity))
+    (apply f args)))
+
+(defun org-lparse-end (entity &rest args)
+  "Close ENTITY in current buffer.  ARGS is entity specific.
+ENTITY can be one of PARAGRAPH, LIST, LIST-ITEM
+etc.
+
+Use (org-lparse-end 'LIST \"o\") to close a list in current
+buffer.
+
+See `org-xhtml-entity-control-callbacks-alist' for more
+information."
+  (when (and (member org-lparse-debug '(t control))
+            (not (eq entity 'DOCUMENT-CONTENT)))
+    (insert (org-lparse-format 'COMMENT "%s END %S" entity args)))
+
+  (let ((f (caddr (assoc entity org-lparse-entity-control-callbacks-alist))))
+    (unless f (error "Unknown entity: %s" entity))
+    (apply f args)))
+
+(defun org-lparse-begin-paragraph (&optional style)
+  "Insert <p>, but first close previous paragraph if any."
+  (org-lparse-end-paragraph)
+  (org-lparse-begin 'PARAGRAPH style)
+  (setq org-lparse-par-open t))
+
+(defun org-lparse-end-paragraph ()
+  "Close paragraph if there is one open."
+  (when org-lparse-par-open
+    (org-lparse-end 'PARAGRAPH)
+    (setq org-lparse-par-open nil)))
+
+(defun org-lparse-end-list-item-1 (&optional type)
+  "Close <li> if necessary."
+  (org-lparse-end-paragraph)
+  (org-lparse-end-list-item (or type "u")))
+
+(defun org-lparse-preprocess-after-blockquote-hook ()
+  "Treat `org-lparse-special-blocks' specially."
+  (goto-char (point-min))
+  (while (re-search-forward
+         "^[ \t]*#\\+\\(begin\\|end\\)_\\(\\S-+\\)[ \t]*\\(.*\\)$" nil t)
+    (when (member (downcase (match-string 2)) org-lparse-special-blocks)
+      (replace-match
+       (if (equal (downcase (match-string 1)) "begin")
+          (format "ORG-%s-START %s" (upcase (match-string 2))
+                  (match-string 3))
+        (format "ORG-%s-END %s" (upcase (match-string 2))
+                (match-string 3))) t t))))
+
+(add-hook 'org-export-preprocess-after-blockquote-hook
+         'org-lparse-preprocess-after-blockquote-hook)
+
+(defun org-lparse-strip-experimental-blocks-maybe-hook ()
+  "Strip \"list-table\" and \"annotation\" blocks.
+Stripping happens only when the exported backend is not one of
+\"odt\" or \"xhtml\"."
+  (when (not org-lparse-backend)
+    (message "Stripping following blocks - %S" org-lparse-special-blocks)
+    (goto-char (point-min))
+    (let ((case-fold-search t))
+      (while
+         (re-search-forward
+          "^[ \t]*#\\+begin_\\(\\S-+\\)\\([ \t]+.*\\)?\n\\([^\000]*?\\)\n[ \t]*#\\+end_\\1\\>.*"
+          nil t)
+       (when (member (match-string 1) org-lparse-special-blocks)
+         (replace-match "" t t))))))
+
+(add-hook 'org-export-preprocess-hook
+         'org-lparse-strip-experimental-blocks-maybe-hook)
+
+(defvar org-lparse-list-table-p nil
+  "Non-nil if `org-do-lparse' is within a list-table.")
+
+(defvar org-lparse-dyn-current-environment nil)
+(defun org-lparse-begin-environment (style &optional env-options-plist)
+  (case style
+    (list-table
+     (setq org-lparse-list-table-p t))
+    (t (setq org-lparse-dyn-current-environment style)
+       (org-lparse-begin 'ENVIRONMENT  style env-options-plist))))
+
+(defun org-lparse-end-environment (style &optional env-options-plist)
+  (case style
+    (list-table
+     (setq org-lparse-list-table-p nil))
+    (t (org-lparse-end 'ENVIRONMENT style env-options-plist)
+       (setq org-lparse-dyn-current-environment nil))))
+
+(defun org-lparse-current-environment-p (style)
+  (eq org-lparse-dyn-current-environment style))
+
+(defun org-lparse-begin-footnote-definition (n)
+  (org-lparse-begin-collect)
+  (setq org-lparse-insert-tag-with-newlines nil)
+  (org-lparse-begin 'FOOTNOTE-DEFINITION n))
+
+(defun org-lparse-end-footnote-definition (n)
+  (org-lparse-end 'FOOTNOTE-DEFINITION n)
+  (setq org-lparse-insert-tag-with-newlines 'both)
+  (let ((footnote-def (org-lparse-end-collect)))
+    (push (cons n footnote-def) org-lparse-footnote-definitions)))
+
+(defvar org-lparse-collect-buffer nil
+  "An auxiliary buffer named \"*Org Lparse Collect*\".
+`org-do-lparse' uses this as output buffer while collecting
+footnote definitions and table-cell contents of list-tables.  See
+`org-lparse-begin-collect' and `org-lparse-end-collect'.")
+
+(defvar org-lparse-collect-count nil
+  "Count number of calls to `org-lparse-begin-collect'.
+Use this counter to catch chained collections if they ever
+happen.")
+
+(defun org-lparse-begin-collect ()
+  "Temporarily switch to `org-lparse-collect-buffer'.
+Also erase it's contents."
+  (unless (zerop org-lparse-collect-count)
+    (error "FIXME (org-lparse.el): Encountered chained collections"))
+  (incf org-lparse-collect-count)
+  (unless org-lparse-collect-buffer
+    (setq org-lparse-collect-buffer
+         (get-buffer-create "*Org Lparse Collect*")))
+  (set-buffer org-lparse-collect-buffer)
+  (erase-buffer))
+
+(defun org-lparse-end-collect ()
+  "Switch to `org-lparse-output-buffer'.
+Return contents of `org-lparse-collect-buffer' as a `string'."
+  (assert (> org-lparse-collect-count 0))
+  (decf org-lparse-collect-count)
+  (prog1 (buffer-string)
+    (erase-buffer)
+    (set-buffer org-lparse-output-buffer)))
+
+(defun org-lparse-format (entity &rest args)
+  "Format ENTITY in backend-specific way and return it.
+ARGS is specific to entity being formatted.
+
+Use (org-lparse-format 'HEADING \"text\" 1) to format text as
+level 1 heading.
+
+See `org-xhtml-entity-format-callbacks-alist' for more information."
+  (when (and (member org-lparse-debug '(t format))
+            (not (equal entity 'COMMENT)))
+    (insert (org-lparse-format 'COMMENT "%s: %S" entity args)))
+  (cond
+   ((consp entity)
+    (let ((text (pop args)))
+      (apply 'org-lparse-format 'TAGS entity text args)))
+   (t
+    (let ((f (cdr (assoc entity org-lparse-entity-format-callbacks-alist))))
+      (unless f (error "Unknown entity: %s" entity))
+      (apply f args)))))
+
+(defun org-lparse-insert (entity &rest args)
+  (insert (apply 'org-lparse-format entity args)))
+
+(defun org-lparse-prepare-toc (lines level-offset opt-plist umax-toc)
+  (let* ((quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
+        (org-min-level (org-get-min-level lines level-offset))
+        (org-last-level org-min-level)
+        level)
+    (with-temp-buffer
+      (org-lparse-bind-local-variables opt-plist)
+      (erase-buffer)
+      (org-lparse-begin 'TOC (nth 3 (plist-get opt-plist :lang-words)) umax-toc)
+      (setq
+       lines
+       (mapcar
+       #'(lambda (line)
+           (when (and (string-match org-todo-line-regexp line)
+                      (not (get-text-property 0 'org-protected line))
+                      (<= (setq level (org-tr-level
+                                       (- (match-end 1) (match-beginning 1)
+                                          level-offset)))
+                          umax-toc))
+             (let ((txt (save-match-data
+                          (org-xml-encode-org-text-skip-links
+                           (org-export-cleanup-toc-line
+                            (match-string 3 line)))))
+                   (todo (and
+                          org-export-mark-todo-in-toc
+                          (or (and (match-beginning 2)
+                                   (not (member (match-string 2 line)
+                                                org-done-keywords)))
+                              (and (= level umax-toc)
+                                   (org-search-todo-below
+                                    line lines level)))))
+                   tags)
+               ;; Check for targets
+               (while (string-match org-any-target-regexp line)
+                 (setq line
+                       (replace-match
+                        (let ((org-lparse-encode-pending t))
+                          (org-lparse-format 'FONTIFY
+                                            (match-string 1 line) "target"))
+                        t t line)))
+               (when (string-match
+                      (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
+                 (setq tags (match-string 1 txt)
+                       txt (replace-match "" t nil txt)))
+               (when (string-match quote-re0 txt)
+                 (setq txt (replace-match "" t t txt)))
+               (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
+                 (setq txt (replace-match "" t t txt)))
+               (org-lparse-format
+                'TOC-ITEM
+                (let* ((snumber (org-section-number level))
+                       (href (replace-regexp-in-string
+                              "\\." "-" (format "sec-%s" snumber)))
+                       (href
+                        (or
+                         (cdr (assoc
+                               href org-export-preferred-target-alist))
+                         href))
+                       (href (org-solidify-link-text href)))
+                  (org-lparse-format 'TOC-ENTRY snumber todo txt tags href))
+                level org-last-level)
+               (setq org-last-level level)))
+           line)
+       lines))
+      (org-lparse-end 'TOC)
+      (setq org-lparse-toc (buffer-string))))
+  lines)
+
+(defun org-lparse-format-table-row (fields &optional text-for-empty-fields)
+  (if org-lparse-table-ncols
+      ;; second and subsequent rows of the table
+      (when (and org-lparse-list-table-p
+                (> (length fields) org-lparse-table-ncols))
+       (error "Table row has %d columns but header row claims %d columns"
+              (length fields) org-lparse-table-ncols))
+    ;; first row of the table
+    (setq org-lparse-table-ncols (length fields))
+    (when org-lparse-table-is-styled
+      (setq org-lparse-table-num-numeric-items-per-column
+           (make-vector org-lparse-table-ncols 0))
+      (setq org-lparse-table-colalign-vector
+           (make-vector org-lparse-table-ncols nil))
+      (let ((c -1))
+       (while  (< (incf c) org-lparse-table-ncols)
+         (let* ((col-cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info)))
+                (align (nth 0 col-cookie)))
+           (setf (aref org-lparse-table-colalign-vector c)
+                 (cond
+                  ((string= align "l") "left")
+                  ((string= align "r") "right")
+                  ((string= align "c") "center")
+                  (t nil))))))))
+  (incf org-lparse-table-rownum)
+  (let ((i -1))
+    (org-lparse-format
+     'TABLE-ROW
+     (mapconcat
+      (lambda (x)
+       (when (and (string= x "") text-for-empty-fields)
+         (setq x text-for-empty-fields))
+       (incf i)
+       (let (col-cookie horiz-span)
+         (when org-lparse-table-is-styled
+           (when (and (< i org-lparse-table-ncols)
+                      (string-match org-table-number-regexp x))
+             (incf (aref org-lparse-table-num-numeric-items-per-column i)))
+           (setq col-cookie (cdr (assoc (1+ i) org-lparse-table-colalign-info))
+                 horiz-span (nth 1 col-cookie)))
+         (org-lparse-format
+          'TABLE-CELL x org-lparse-table-rownum i (or horiz-span 0))))
+      fields "\n"))))
+
+(defun org-lparse-get (what &optional opt-plist)
+  "Query for value of WHAT for the current backend `org-lparse-backend'.
+See also `org-lparse-backend-get'."
+  (if (boundp 'org-lparse-backend)
+      (org-lparse-backend-get (symbol-name org-lparse-backend) what opt-plist)
+    (error "org-lparse-backend is not bound yet")))
+
+(defun org-lparse-backend-get (backend what &optional opt-plist)
+  "Query BACKEND for value of WHAT.
+Dispatch the call to `org-<backend>-user-get'.  If that throws an
+error, dispatch the call to `org-<backend>-get'.  See
+`org-xhtml-get' for all known settings queried for by
+`org-lparse' during the course of export."
+  (assert (stringp backend) t)
+  (unless (org-lparse-backend-is-native-p backend)
+    (error "Unknown native backend %s" backend))
+  (let ((backend-get-method (intern (format "org-%s-get" backend)))
+       (backend-user-get-method (intern (format "org-%s-user-get" backend))))
+    (cond
+     ((functionp backend-get-method)
+      (condition-case nil
+         (funcall backend-user-get-method what opt-plist)
+       (error (funcall backend-get-method what opt-plist))))
+     (t
+      (error "Native backend %s doesn't define %s" backend backend-get-method)))))
+
+(defun org-lparse-insert-tag (tag &rest args)
+  (when (member org-lparse-insert-tag-with-newlines '(lead both))
+    (insert  "\n"))
+  (insert (apply 'format tag args))
+  (when (member org-lparse-insert-tag-with-newlines '(trail both))
+    (insert  "\n")))
+
+(defun org-lparse-get-targets-from-title (title)
+  (let* ((target (org-get-text-property-any 0 'target title))
+        (extra-targets (assoc target org-export-target-aliases))
+        (target (or (cdr (assoc target org-export-preferred-target-alist))
+                    target)))
+    (cons target (remove target extra-targets))))
+
+(defun org-lparse-suffix-from-snumber (snumber)
+  (let* ((snu (replace-regexp-in-string "\\." "-" snumber))
+        (href (cdr (assoc (concat "sec-" snu)
+                          org-export-preferred-target-alist))))
+    (org-solidify-link-text (or href snu))))
+
+(defun org-lparse-begin-level (level title umax head-count)
+  "Insert a new LEVEL in HTML export.
+When TITLE is nil, just close all open levels."
+  (org-lparse-end-level level umax)
+  (unless title (error "Why is heading nil"))
+  (let* ((targets (org-lparse-get-targets-from-title title))
+        (target (car targets)) (extra-targets (cdr targets))
+        (target (and target (org-solidify-link-text target)))
+        (extra-class (org-get-text-property-any 0 'html-container-class title))
+        snumber tags level1 class)
+    (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
+      (setq tags (and org-export-with-tags (match-string 1 title)))
+      (setq title (replace-match "" t t title)))
+    (if (> level umax)
+       (progn
+         (if (aref org-levels-open (1- level))
+             (org-lparse-end-list-item-1)
+           (aset org-levels-open (1- level) t)
+           (org-lparse-end-paragraph)
+           (org-lparse-begin-list 'unordered))
+         (org-lparse-begin-list-item
+          'unordered target (org-lparse-format
+                             'HEADLINE title extra-targets tags)))
+      (aset org-levels-open (1- level) t)
+      (setq snumber (org-section-number level))
+      (setq level1 (+ level (or (org-lparse-get 'TOPLEVEL-HLEVEL) 1) -1))
+      (unless (= head-count 1)
+       (org-lparse-end-outline-text-or-outline))
+      (org-lparse-begin-outline-and-outline-text
+       level1 snumber title tags target extra-targets extra-class)
+      (org-lparse-begin-paragraph))))
+
+(defun org-lparse-end-level (level umax)
+  (org-lparse-end-paragraph)
+  (loop for l from org-level-max downto level
+       do (when (aref org-levels-open (1- l))
+            ;; Terminate one level in HTML export
+            (if (<= l umax)
+                (org-lparse-end-outline-text-or-outline)
+              (org-lparse-end-list-item-1)
+              (org-lparse-end-list 'unordered))
+            (aset org-levels-open (1- l) nil))))
+
+(defvar org-lparse-outline-text-open)
+(defun org-lparse-begin-outline-and-outline-text (level1 snumber title tags
+                                                       target extra-targets
+                                                       extra-class)
+  (org-lparse-begin
+   'OUTLINE level1 snumber title tags target extra-targets extra-class)
+  (org-lparse-begin-outline-text level1 snumber extra-class))
+
+(defun org-lparse-end-outline-text-or-outline ()
+  (cond
+   (org-lparse-outline-text-open
+    (org-lparse-end 'OUTLINE-TEXT)
+    (setq org-lparse-outline-text-open nil))
+   (t (org-lparse-end 'OUTLINE))))
+
+(defun org-lparse-begin-outline-text (level1 snumber extra-class)
+  (assert (not org-lparse-outline-text-open) t)
+  (setq org-lparse-outline-text-open t)
+  (org-lparse-begin 'OUTLINE-TEXT level1 snumber extra-class))
+
+(defun org-lparse-html-list-type-to-canonical-list-type (ltype)
+  (cdr (assoc ltype '(("o" . ordered)
+                     ("u" . unordered)
+                     ("d" . description)))))
+
+;; following vars are bound during `org-do-lparse'
+(defvar org-lparse-list-level)
+(defvar org-lparse-list-item-count)
+(defvar org-lparse-list-stack)
+(defvar org-lparse-list-table:table-row)
+(defvar org-lparse-list-table:lines)
+
+;; Notes on LIST-TABLES
+;; ====================
+;; Lists withing "list-table" blocks (as shown below)
+;;
+;; #+begin_list-table
+;; - Row 1
+;;   - 1.1
+;;   - 1.2
+;;   - 1.3
+;; - Row 2
+;;   - 2.1
+;;   - 2.2
+;;   - 2.3
+;; #+end_list-table
+;;
+;; will be exported as though it were a table as shown below.
+;;
+;; | Row 1 | 1.1 | 1.2 | 1.3 |
+;; | Row 2 | 2.1 | 2.2 | 2.3 |
+;;
+;; Note that org-tables are NOT multi-line and each line is mapped to
+;; a unique row in the exported document.  So if an exported table
+;; needs to contain a single paragraph (with copious text) it needs to
+;; be typed up in a single line. Editing such long lines using the
+;; table editor will be a cumbersome task.  Furthermore inclusion of
+;; multi-paragraph text in a table cell is well-nigh impossible.
+;;
+;; LIST-TABLEs are meant to circumvent the above problems with
+;; org-tables.
+;;
+;; Note that in the example above the list items could be paragraphs
+;; themselves and the list can be arbitrarily deep.
+;;
+;; Inspired by following thread:
+;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html
+
+(defun org-lparse-begin-list (ltype)
+  (incf org-lparse-list-level)
+  (push org-lparse-list-item-count org-lparse-list-stack)
+  (setq org-lparse-list-item-count 0)
+  (cond
+   ((not org-lparse-list-table-p)
+    (org-lparse-begin 'LIST ltype))
+   ;; process LIST-TABLE
+   ((= 1 org-lparse-list-level)
+    ;; begin LIST-TABLE
+    (setq org-lparse-list-table:lines nil)
+    (setq org-lparse-list-table:table-row nil))
+   ((= 2 org-lparse-list-level)
+    (ignore))
+   (t
+    (org-lparse-begin 'LIST ltype))))
+
+(defun org-lparse-end-list (ltype)
+  (setq org-lparse-list-item-count (pop org-lparse-list-stack))
+  (decf org-lparse-list-level)
+  (cond
+   ((not org-lparse-list-table-p)
+    (org-lparse-end 'LIST ltype))
+   ;; process LIST-TABLE
+   ((= 0 org-lparse-list-level)
+    ;; end LIST-TABLE
+    (insert (org-lparse-format-list-table
+            (nreverse org-lparse-list-table:lines))))
+   ((= 1 org-lparse-list-level)
+    (ignore))
+   (t
+    (org-lparse-end 'LIST ltype))))
+
+(defun org-lparse-begin-list-item (ltype &optional arg headline)
+  (incf org-lparse-list-item-count)
+  (cond
+   ((not org-lparse-list-table-p)
+    (org-lparse-begin 'LIST-ITEM ltype arg headline))
+   ;; process LIST-TABLE
+   ((and (= 1 org-lparse-list-level)
+        (= 1 org-lparse-list-item-count))
+    ;; begin TABLE-ROW for LIST-TABLE
+    (setq org-lparse-list-table:table-row nil)
+    (org-lparse-begin-list-table:table-cell))
+   ((and (= 2 org-lparse-list-level)
+        (= 1 org-lparse-list-item-count))
+    ;; begin TABLE-CELL for LIST-TABLE
+    (org-lparse-begin-list-table:table-cell))
+   (t
+    (org-lparse-begin 'LIST-ITEM ltype arg headline))))
+
+(defun org-lparse-end-list-item (ltype)
+  (decf org-lparse-list-item-count)
+  (cond
+   ((not org-lparse-list-table-p)
+    (org-lparse-end 'LIST-ITEM ltype))
+   ;; process LIST-TABLE
+   ((and (= 1 org-lparse-list-level)
+        (= 0 org-lparse-list-item-count))
+    ;; end TABLE-ROW for LIST-TABLE
+    (org-lparse-end-list-table:table-cell)
+    (push (nreverse org-lparse-list-table:table-row)
+         org-lparse-list-table:lines))
+   ((= 2 org-lparse-list-level)
+    ;; end TABLE-CELL for LIST-TABLE
+    (org-lparse-end-list-table:table-cell))
+   (t
+    (org-lparse-end 'LIST-ITEM ltype))))
+
+(defvar org-lparse-list-table:table-cell-open)
+(defun org-lparse-begin-list-table:table-cell ()
+  (org-lparse-end-list-table:table-cell)
+  (setq org-lparse-list-table:table-cell-open t)
+  (org-lparse-begin-collect)
+  (org-lparse-begin-paragraph))
+
+(defun org-lparse-end-list-table:table-cell ()
+  (when org-lparse-list-table:table-cell-open
+    (setq org-lparse-list-table:table-cell-open nil)
+    (org-lparse-end-paragraph)
+    (push (org-lparse-end-collect)
+         org-lparse-list-table:table-row)))
+
+(defvar org-lparse-table-rowgrp-info)
+(defun org-lparse-begin-table-rowgroup (&optional is-header-row)
+  (push (cons (1+ org-lparse-table-rownum) :start) org-lparse-table-rowgrp-info)
+  (org-lparse-begin 'TABLE-ROWGROUP is-header-row))
+
+(defun org-lparse-end-table ()
+  (when org-lparse-table-is-styled
+    ;; column groups
+    (unless (car org-table-colgroup-info)
+      (setq org-table-colgroup-info
+           (cons :start (cdr org-table-colgroup-info))))
+
+    ;; column alignment
+    (let ((c -1))
+      (mapc
+       (lambda (x)
+        (incf c)
+        (setf (aref org-lparse-table-colalign-vector c)
+              (or (aref org-lparse-table-colalign-vector c)
+                  (if (> (/ (float x) (1+ org-lparse-table-rownum))
+                         org-table-number-fraction)
+                      "right" "left"))))
+       org-lparse-table-num-numeric-items-per-column)))
+  (org-lparse-end 'TABLE))
+
+(defvar org-lparse-encode-pending nil)
+
+(defun org-lparse-format-tags (tag text prefix suffix &rest args)
+  (cond
+   ((consp tag)
+    (concat prefix (apply 'format (car tag) args) text suffix
+           (format (cdr tag))))
+   ((stringp tag)                      ; singleton tag
+    (concat prefix (apply 'format tag args) text))))
+
+(defun org-xml-fix-class-name (kwd)    ; audit callers of this function
+  "Turn todo keyword into a valid class name.
+Replaces invalid characters with \"_\"."
+  (save-match-data
+    (while (string-match "[^a-zA-Z0-9_]" kwd)
+      (setq kwd (replace-match "_" t t kwd))))
+  kwd)
+
+(defun org-lparse-format-todo (todo)
+  (org-lparse-format 'FONTIFY
+                    (concat
+                     (ignore-errors (org-lparse-get 'TODO-KWD-CLASS-PREFIX))
+                     (org-xml-fix-class-name todo))
+                    (list (if (member todo org-done-keywords) "done" "todo")
+                          todo)))
+
+(defun org-lparse-format-extra-targets (extra-targets)
+  (if (not extra-targets) ""
+      (mapconcat (lambda (x)
+              (setq x (org-solidify-link-text
+                       (if (org-uuidgen-p x) (concat "ID-" x) x)))
+              (org-lparse-format 'ANCHOR "" x))
+            extra-targets "")))
+
+(defun org-lparse-format-org-tags (tags)
+  (if (not tags) ""
+    (org-lparse-format
+     'FONTIFY (mapconcat
+              (lambda (x)
+                (org-lparse-format
+                 'FONTIFY x
+                 (concat
+                  (ignore-errors (org-lparse-get 'TAG-CLASS-PREFIX))
+                  (org-xml-fix-class-name x))))
+              (org-split-string tags ":")
+              (org-lparse-format 'SPACES 1)) "tag")))
+
+(defun org-lparse-format-section-number (&optional snumber level)
+  (and org-export-with-section-numbers
+       (not org-lparse-body-only) snumber level
+       (org-lparse-format 'FONTIFY snumber (format "section-number-%d" level))))
+
+(defun org-lparse-warn (msg)
+  (if (not org-lparse-use-flashy-warning)
+      (message msg)
+    (put-text-property 0 (length msg) 'face 'font-lock-warning-face msg)
+    (message msg)
+    (sleep-for 3)))
+
+(defun org-xml-format-href (s)
+  "Make sure the S is valid as a href reference in an XHTML document."
+  (save-match-data
+    (let ((start 0))
+      (while (string-match "&" s start)
+       (setq start (+ (match-beginning 0) 3)
+             s (replace-match "&amp;" t t s)))))
+  s)
+
+(defun org-xml-format-desc (s)
+  "Make sure the S is valid as a description in a link."
+  (if (and s (not (get-text-property 1 'org-protected s)))
+      (save-match-data
+       (org-xml-encode-org-text s))
+    s))
+
+(provide 'org-lparse)
+
+;;; org-lparse.el ends here
index fc52b92a21d907be80100faefd87ae1b0432568e..8f63a196e880d4063b5c7d8bf0b7fdc8b3c43d0c 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: John Wiegley <johnw@gnu.org>
 ;;         Christopher Suckling <suckling at gmail dot com>
 
-;; Version: 7.7
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
@@ -214,6 +213,4 @@ list of message:// links to flagged mail after heading."
 
 (provide 'org-mac-message)
 
-
-
 ;;; org-mac-message.el ends here
index dc413f4d9939b993d40e6b2f524121e39cd4a870..521f5fd8633e3628c551a8ee0c4e20de7348e645 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-macs.el --- Top-level definitions for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 (declare-function org-add-props "org-compat" (string plist &rest props))
 (declare-function org-string-match-p "org-compat" (&rest args))
 
+(defmacro org-with-gensyms (symbols &rest body)
+  `(let ,(mapcar (lambda (s)
+                  `(,s (make-symbol (concat "--" (symbol-name ',s))))) symbols)
+     ,@body))
+(def-edebug-spec org-with-gensyms (sexp body))
+(put 'org-with-gensyms 'lisp-indent-function 1)
+
 (defmacro org-called-interactively-p (&optional kind)
   (if (featurep 'xemacs)
        `(interactive-p)
                  (>= emacs-minor-version 2)))
         `(with-no-warnings (called-interactively-p ,kind)) ;; defined with no argument in <=23.1
        `(interactive-p))))
+(def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp)))
 
-(if (and (not (fboundp 'with-silent-modifications))
+(when (and (not (fboundp 'with-silent-modifications))
         (or (< emacs-major-version 23)
             (and (= emacs-major-version 23)
                  (< emacs-minor-version 2))))
     (defmacro with-silent-modifications (&rest body)
-      `(org-unmodified ,@body)))
+      `(org-unmodified ,@body))
+    (def-edebug-spec with-silent-modifications (body)))
 
 (defmacro org-bound-and-true-p (var)
   "Return the value of symbol VAR if it is bound, else nil."
   `(and (boundp (quote ,var)) ,var))
+(def-edebug-spec org-bound-and-true-p (symbolp))
 
 (defun org-string-nw-p (s)
   "Is S a string with a non-white character?"
@@ -85,30 +94,36 @@ Also, do not record undo information."
       (let ((buffer-undo-list t)
            before-change-functions after-change-functions)
        ,@body))))
+(def-edebug-spec org-unmodified (body))
+
+(defun org-substitute-posix-classes (re)
+  "Substitute posix classes in regular expression RE."
+  (let ((ss re))
+    (save-match-data
+      (while (string-match "\\[:alnum:\\]" ss)
+       (setq ss (replace-match "a-zA-Z0-9" t t ss)))
+      (while (string-match "\\[:word:\\]" ss)
+       (setq ss (replace-match "a-zA-Z0-9" t t ss)))
+      (while (string-match "\\[:alpha:\\]" ss)
+       (setq ss (replace-match "a-zA-Z" t t ss)))
+      (while (string-match "\\[:punct:\\]" ss)
+       (setq ss (replace-match "\001-@[-`{-~" t t ss)))
+      ss)))
 
 (defmacro org-re (s)
   "Replace posix classes in regular expression."
-  (if (featurep 'xemacs)
-      (let ((ss s))
-       (save-match-data
-         (while (string-match "\\[:alnum:\\]" ss)
-           (setq ss (replace-match "a-zA-Z0-9" t t ss)))
-         (while (string-match "\\[:word:\\]" ss)
-           (setq ss (replace-match "a-zA-Z0-9" t t ss)))
-         (while (string-match "\\[:alpha:\\]" ss)
-           (setq ss (replace-match "a-zA-Z" t t ss)))
-         (while (string-match "\\[:punct:\\]" ss)
-           (setq ss (replace-match "\001-@[-`{-~" t t ss)))
-         ss))
-    s))
+  (if (featurep 'xemacs) `(org-substitute-posix-classes ,s) s))
+(def-edebug-spec org-re (form))
 
 (defmacro org-preserve-lc (&rest body)
-  `(let ((_line (org-current-line))
-        (_col (current-column)))
-     (unwind-protect
-        (progn ,@body)
-       (org-goto-line _line)
-       (org-move-to-column _col))))
+  (org-with-gensyms (line col)
+    `(let ((,line (org-current-line))
+          (,col (current-column)))
+       (unwind-protect
+          (progn ,@body)
+        (org-goto-line ,line)
+        (org-move-to-column ,col)))))
+(def-edebug-spec org-preserve-lc (body))
 
 (defmacro org-without-partial-completion (&rest body)
   `(if (and (boundp 'partial-completion-mode)
@@ -120,7 +135,9 @@ Also, do not record undo information."
           ,@body)
        (partial-completion-mode 1))
      ,@body))
+(def-edebug-spec org-without-partial-completion (body))
 
+;; FIXME: Slated for removal. Current Org mode does not support Emacs < 22
 (defmacro org-maybe-intangible (props)
   "Add '(intangible t) to PROPS if Emacs version is earlier than Emacs 22.
 In Emacs 21, invisible text is not avoided by the command loop, so the
@@ -135,31 +152,37 @@ We use a macro so that the test can happen at compilation time."
 
 (defmacro org-with-point-at (pom &rest body)
   "Move to buffer and point of point-or-marker POM for the duration of BODY."
-  `(let ((pom ,pom))
-     (save-excursion
-       (if (markerp pom) (set-buffer (marker-buffer pom)))
+  (org-with-gensyms (mpom)
+    `(let ((,mpom ,pom))
        (save-excursion
-        (goto-char (or pom (point)))
-        ,@body))))
+        (if (markerp ,mpom) (set-buffer (marker-buffer ,mpom)))
+        (save-excursion
+          (goto-char (or ,mpom (point)))
+          ,@body)))))
+(def-edebug-spec org-with-point-at (form body))
 (put 'org-with-point-at 'lisp-indent-function 1)
 
 (defmacro org-no-warnings (&rest body)
   (cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
+(def-edebug-spec org-no-warnings (body))
 
 (defmacro org-if-unprotected (&rest body)
   "Execute BODY if there is no `org-protected' text property at point."
   `(unless (get-text-property (point) 'org-protected)
      ,@body))
+(def-edebug-spec org-if-unprotected (body))
 
 (defmacro org-if-unprotected-1 (&rest body)
   "Execute BODY if there is no `org-protected' text property at point-1."
   `(unless (get-text-property (1- (point)) 'org-protected)
      ,@body))
+(def-edebug-spec org-if-unprotected-1 (body))
 
 (defmacro org-if-unprotected-at (pos &rest body)
   "Execute BODY if there is no `org-protected' text property at POS."
   `(unless (get-text-property ,pos 'org-protected)
      ,@body))
+(def-edebug-spec org-if-unprotected-at (form body))
 (put 'org-if-unprotected-at 'lisp-indent-function 1)
 
 (defun org-re-search-forward-unprotected (&rest args)
@@ -171,33 +194,37 @@ We use a macro so that the test can happen at compilation time."
       (unless (get-text-property (match-beginning 0) 'org-protected)
        (throw 'exit (point))))))
 
+;; FIXME: Normalize argument names
 (defmacro org-with-remote-undo (_buffer &rest _body)
   "Execute BODY while recording undo information in two buffers."
-  `(let ((_cline (org-current-line))
-        (_cmd this-command)
-        (_buf1 (current-buffer))
-        (_buf2 ,_buffer)
-        (_undo1 buffer-undo-list)
-        (_undo2 (with-current-buffer ,_buffer buffer-undo-list))
-        _c1 _c2)
-     ,@_body
-     (when org-agenda-allow-remote-undo
-       (setq _c1 (org-verify-change-for-undo
-                 _undo1 (with-current-buffer _buf1 buffer-undo-list))
-            _c2 (org-verify-change-for-undo
-                 _undo2 (with-current-buffer _buf2 buffer-undo-list)))
-       (when (or _c1 _c2)
-        ;; make sure there are undo boundaries
-        (and _c1 (with-current-buffer _buf1 (undo-boundary)))
-        (and _c2 (with-current-buffer _buf2 (undo-boundary)))
-        ;; remember which buffer to undo
-        (push (list _cmd _cline _buf1 _c1 _buf2 _c2)
-              org-agenda-undo-list)))))
+  (org-with-gensyms (cline cmd buf1 buf2 undo1 undo2 c1 c2)
+    `(let ((,cline (org-current-line))
+          (,cmd this-command)
+          (,buf1 (current-buffer))
+          (,buf2 ,_buffer)
+          (,undo1 buffer-undo-list)
+          (,undo2 (with-current-buffer ,_buffer buffer-undo-list))
+          ,c1 ,c2)
+       ,@_body
+       (when org-agenda-allow-remote-undo
+        (setq ,c1 (org-verify-change-for-undo
+                   ,undo1 (with-current-buffer ,buf1 buffer-undo-list))
+              ,c2 (org-verify-change-for-undo
+                   ,undo2 (with-current-buffer ,buf2 buffer-undo-list)))
+        (when (or ,c1 ,c2)
+          ;; make sure there are undo boundaries
+          (and ,c1 (with-current-buffer ,buf1 (undo-boundary)))
+          (and ,c2 (with-current-buffer ,buf2 (undo-boundary)))
+          ;; remember which buffer to undo
+          (push (list ,cmd ,cline ,buf1 ,c1 ,buf2 ,c2)
+                org-agenda-undo-list))))))
+(def-edebug-spec org-with-remote-undo (form body))
 (put 'org-with-remote-undo 'lisp-indent-function 1)
 
 (defmacro org-no-read-only (&rest body)
   "Inhibit read-only for BODY."
   `(let ((inhibit-read-only t)) ,@body))
+(def-edebug-spec org-no-read-only (body))
 
 (defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t
                                   rear-nonsticky t mouse-map t fontified t
@@ -245,10 +272,6 @@ we turn off invisibility temporarily.  Use this in a `let' form."
   "Make VAR local in current buffer and set it to VALUE."
   (set (make-local-variable var) value))
 
-(defsubst org-mode-p ()
-  "Check if the current buffer is in Org-mode."
-  (eq major-mode 'org-mode))
-
 (defsubst org-last (list)
   "Return the last element of LIST."
   (car (last list)))
@@ -324,18 +347,20 @@ but it also means that the buffer should stay alive
 during the operation, because otherwise all these markers will
 point nowhere."
   (declare (indent 1))
-  `(let ((data (org-outline-overlay-data ,use-markers))
-        rtn)
-     (unwind-protect
-        (progn
-          (setq rtn (progn ,@body))
-          (org-set-outline-overlay-data data))
-       (when ,use-markers
-        (mapc (lambda (c)
-                (and (markerp (car c)) (move-marker (car c) nil))
-                (and (markerp (cdr c)) (move-marker (cdr c) nil)))
-              data)))
-     rtn))
+  (org-with-gensyms (data rtn)
+    `(let ((,data (org-outline-overlay-data ,use-markers))
+          ,rtn)
+       (unwind-protect
+          (progn
+            (setq ,rtn (progn ,@body))
+            (org-set-outline-overlay-data ,data))
+        (when ,use-markers
+          (mapc (lambda (c)
+                  (and (markerp (car c)) (move-marker (car c) nil))
+                  (and (markerp (cdr c)) (move-marker (cdr c) nil)))
+                ,data)))
+       ,rtn)))
+(def-edebug-spec org-save-outline-visibility (form body))
 
 (defmacro org-with-wide-buffer (&rest body)
  "Execute body while temporarily widening the buffer."
@@ -343,6 +368,7 @@ point nowhere."
     (save-restriction
        (widen)
        ,@body)))
+(def-edebug-spec org-with-wide-buffer (body))
 
 (defmacro org-with-limited-levels (&rest body)
   "Execute BODY with limited number of outline levels."
@@ -350,6 +376,7 @@ point nowhere."
          (outline-regexp org-outline-regexp)
          (org-outline-regexp-at-bol (concat "^" org-outline-regexp)))
      ,@body))
+(def-edebug-spec org-with-limited-levels (body))
 
 (defvar org-outline-regexp) ; defined in org.el
 (defvar org-odd-levels-only) ; defined in org.el
@@ -357,7 +384,7 @@ point nowhere."
 (defun org-get-limited-outline-regexp ()
   "Return outline-regexp with limited number of levels.
 The number of levels is controlled by `org-inlinetask-min-level'"
-  (if (or (not (org-mode-p)) (not (featurep 'org-inlinetask)))
+  (if (or (not (eq major-mode 'org-mode)) (not (featurep 'org-inlinetask)))
       org-outline-regexp
     (let* ((limit-level (1- org-inlinetask-min-level))
           (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level)))
@@ -369,8 +396,20 @@ The number of levels is controlled by `org-inlinetask-min-level'"
       (format-seconds string seconds)
     (format-time-string string (seconds-to-time seconds))))
 
-(provide 'org-macs)
+(defmacro org-eval-in-environment (environment form)
+  `(eval (list 'let ,environment ',form)))
+(def-edebug-spec org-eval-in-environment (form form))
+(put 'org-eval-in-environment 'lisp-indent-function 1)
 
+(defun org-make-parameter-alist (flat)
+  "Return alist based on FLAT.
+FLAT is a list with alternating symbol names and values. The
+returned alist is a list of lists with the symbol name in car and
+the value in cdr."
+  (when flat
+    (cons (list (car flat) (cadr flat))
+         (org-make-parameter-alist (cddr flat)))))
 
+(provide 'org-macs)
 
 ;;; org-macs.el ends here
index 97cad1ae316b4e55973cf187a474de447728c648..8d6f1414150e6454f4b0504e38a06262b0b42d0b 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 
 
 (provide 'org-mew)
 
-
-
 ;;; org-mew.el ends here
index 7075018894f0c9f239197e2187bdc521cee1bf5e..6832a9b91227efd1827f38d5bca450d9d4305cf6 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-mhe.el --- Support for links to MH-E messages from within Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -225,6 +224,4 @@ folders."
 
 (provide 'org-mhe)
 
-
-
 ;;; org-mhe.el ends here
index 5f3ebbb6c817db86ac71e2d46f45d1cf38c921be..55140419734ff4d20afeda701dd49a4e1f1a94ae 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -132,6 +131,4 @@ only the bare key is returned."
 
 (provide 'org-mks)
 
-
-
 ;;; org-mks.el ends here
index f270419877eca4a3eb48208e5e93f32e21874d0f..541ccc8f040d0f20a1f4779d4aec53abd758488a 100644 (file)
@@ -4,7 +4,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -38,6 +37,9 @@
 
 (eval-when-compile (require 'cl))
 
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
+
 (defgroup org-mobile nil
   "Options concerning support for a viewer/editor on a mobile device."
   :tag "Org Mobile"
@@ -909,7 +911,7 @@ If BEG and END are given, only do this in that region."
                                   (buffer-file-name (current-buffer))))))
                (error (setq org-mobile-error msg))))
            (when org-mobile-error
-             (switch-to-buffer (marker-buffer marker))
+             (org-pop-to-buffer-same-window (marker-buffer marker))
              (goto-char marker)
              (incf cnt-error)
              (insert (if (stringp (nth 1 org-mobile-error))
@@ -1096,7 +1098,5 @@ A and B must be strings or nil."
 
 (provide 'org-mobile)
 
-
-
 ;;; org-mobile.el ends here
 
index 8f1e7735693193ae25e0928464c2237210665d67..3a667deee9e87e95f9f4c5bd85c56603079112c1 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 7.7
+
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -70,8 +70,7 @@
 ;;
 ;; Since version 5.10: Changes are listed in the general org-mode docs.
 ;;
-;; Version 5.09
-;; + Version number synchronization with Org-mode.
+;; Version 5.09;; + Version number synchronization with Org-mode.
 ;;
 ;; Version 0.25
 ;; + made compatible with org-mode 4.70 (thanks to Carsten for the patch)
@@ -329,7 +328,6 @@ nor a function, elements of KEYWORDS are used directly."
     (goto-char (match-end (or subexp 0)))
     (just-one-space)))
 
-
 (defun org-mouse-keyword-replace-menu (keywords &optional group itemformat
                                                nosurround)
   "A helper function.
@@ -395,15 +393,6 @@ DEFAULT is returned if no priority is given in the headline."
        (match-string 1)
       (when default (char-to-string org-default-priority)))))
 
-;; (defun org-mouse-at-link ()
-;;   (and (eq (get-text-property (point) 'face) 'org-link)
-;;        (save-excursion
-;;          (goto-char (previous-single-property-change (point) 'face))
-;;          (or (looking-at org-bracket-link-regexp)
-;;              (looking-at org-angle-link-re)
-;;              (looking-at org-plain-link-re)))))
-
-
 (defun org-mouse-delete-timestamp ()
   "Deletes the current timestamp as well as the preceding keyword.
 SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
@@ -454,7 +443,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
      ["Align Tags in Buffer" (org-set-tags t t) t]
      ["Set Tags ..." (org-set-tags) t])))
 
-
 (defun org-mouse-set-tags (tags)
   (save-excursion
     ;; remove existing tags first
@@ -485,7 +473,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
    ('occur-tree "Occur tree: ")
    (t "Agenda command ???")))
 
-
 (defun org-mouse-list-options-menu (alloptions &optional function)
   (let ((options (save-match-data
                   (split-string (match-string-no-properties 1)))))
@@ -571,7 +558,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
      ["Plain List to Outline" org-mouse-transform-to-outline
       :visible (org-at-item-p)])))
 
-
 (defun org-mouse-get-context (contextlist context)
   (let ((contextdata (assq context contextlist)))
     (when contextdata
@@ -599,29 +585,26 @@ This means, between the beginning of line and the point."
      (open-line 1)
      (org-indent-to-column (- (match-end 0) (match-beginning 0)))
      (insert "+ "))
-
     (:middle                   ; insert after
      (end-of-line)
      (newline t)
      (indent-relative)
      (insert "+ "))
-
     (:end                              ; insert text here
      (skip-chars-backward " \t")
      (kill-region (point) (point-at-eol))
      (unless (org-looking-back org-mouse-punctuation)
        (insert (concat org-mouse-punctuation " ")))))
-
   (insert text)
   (beginning-of-line))
 
 (defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate)
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (org-mouse-insert-item text)
     ad-do-it))
 
 (defadvice dnd-open-file (around org-mouse-dnd-open-file activate)
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (org-mouse-insert-item uri)
     ad-do-it))
 
@@ -632,13 +615,6 @@ This means, between the beginning of line and the point."
        (set-match-data ',match)
        (apply ',function rest)))))
 
-(defun org-mouse-match-todo-keyword ()
-  (save-excursion
-    (org-back-to-heading)
-    (if (looking-at org-outline-regexp) (goto-char (match-end 0)))
-    (or (looking-at (concat " +" org-todo-regexp " *"))
-       (looking-at " \\( *\\)"))))
-
 (defun org-mouse-yank-link (click)
   (interactive "e")
   ;; Give temporary modes such as isearch a chance to turn off.
@@ -668,7 +644,6 @@ This means, between the beginning of line and the point."
          (progn (save-excursion (goto-char (region-beginning)) (insert "[["))
                 (save-excursion (goto-char (region-end)) (insert "]]")))]
         ["Insert Link Here" (org-mouse-yank-link ',event)]))))
-
    ((save-excursion (beginning-of-line) (looking-at "#\\+STARTUP: \\(.*\\)"))
     (popup-menu
      `(nil
@@ -879,18 +854,6 @@ This means, between the beginning of line and the point."
    (t
     (org-mouse-popup-global-menu))))))
 
-;; (defun org-mouse-at-regexp (regexp)
-;;   (save-excursion
-;;     (let ((point (point))
-;;       (bol (progn (beginning-of-line) (point)))
-;;       (eol (progn (end-of-line) (point))))
-;;      (goto-char point)
-;;      (re-search-backward regexp bol 1)
-;;      (and (not (eolp))
-;;        (progn (forward-char)
-;;               (re-search-forward regexp eol t))
-;;        (<= (match-beginning 0) point)))))
-
 (defun org-mouse-mark-active ()
   (and mark-active transient-mark-mode))
 
@@ -1146,6 +1109,4 @@ This means, between the beginning of line and the point."
 
 (provide 'org-mouse)
 
-
-
 ;;; org-mouse.el ends here
diff --git a/lisp/org/org-odt.el b/lisp/org/org-odt.el
new file mode 100644 (file)
index 0000000..838a327
--- /dev/null
@@ -0,0 +1,2626 @@
+;;; org-odt.el --- OpenDocumentText export for Org-mode
+
+;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
+
+;; Author: Jambunathan K <kjambunathan at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+;; Homepage: http://orgmode.org
+;;
+;; This file is not (yet) part of GNU Emacs.
+;; However, it is distributed under the same license.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+
+;;; Code:
+(eval-when-compile
+  (require 'cl))
+(require 'org-lparse)
+
+(defgroup org-export-odt nil
+  "Options specific for ODT export of Org-mode files."
+  :tag "Org Export ODT"
+  :group 'org-export)
+
+(defun org-odt-end-export ()
+  (org-odt-fixup-label-references)
+
+  ;; remove empty paragraphs
+  (goto-char (point-min))
+  (while (re-search-forward
+         "<text:p\\( text:style-name=\"Text_20_body\"\\)?>[ \r\n\t]*</text:p>"
+         nil t)
+    (replace-match ""))
+  (goto-char (point-min))
+
+  ;; Convert whitespace place holders
+  (goto-char (point-min))
+  (let (beg end n)
+    (while (setq beg (next-single-property-change (point) 'org-whitespace))
+      (setq n (get-text-property beg 'org-whitespace)
+           end (next-single-property-change beg 'org-whitespace))
+      (goto-char beg)
+      (delete-region beg end)
+      (insert (format "<span style=\"visibility:hidden;\">%s</span>"
+                     (make-string n ?x)))))
+
+  ;; Remove empty lines at the beginning of the file.
+  (goto-char (point-min))
+  (when (looking-at "\\s-+\n") (replace-match ""))
+
+  ;; Remove display properties
+  (remove-text-properties (point-min) (point-max) '(display t)))
+
+(defvar org-odt-suppress-xref nil)
+(defconst org-export-odt-special-string-regexps
+  '(("\\\\-" . "&#x00ad;\\1")          ; shy
+    ("---\\([^-]\\)" . "&#x2014;\\1")  ; mdash
+    ("--\\([^-]\\)" . "&#x2013;\\1")   ; ndash
+    ("\\.\\.\\." . "&#x2026;"))                ; hellip
+  "Regular expressions for special string conversion.")
+
+(defconst org-odt-lib-dir (file-name-directory load-file-name)
+  "Location of ODT exporter.
+Use this to infer values of `org-odt-styles-dir' and
+`org-export-odt-schema-dir'.")
+
+(defvar org-odt-data-dir nil
+  "Data directory for ODT exporter.
+Use this to infer values of `org-odt-styles-dir' and
+`org-export-odt-schema-dir'.")
+
+(defconst org-odt-schema-dir-list
+  (list
+   (and org-odt-data-dir
+       (expand-file-name "./schema/" org-odt-data-dir)) ; bail out
+   (eval-when-compile
+     (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
+         (expand-file-name "./schema/" org-odt-data-dir)))
+   (expand-file-name "../contrib/odt/etc/schema/" org-odt-lib-dir) ; git
+   )
+  "List of directories to search for OpenDocument schema files.
+Use this list to set the default value of
+`org-export-odt-schema-dir'.  The entries in this list are
+populated heuristically based on the values of `org-odt-lib-dir'
+and `org-odt-data-dir'.")
+
+(defcustom org-export-odt-schema-dir
+  (let* ((schema-dir
+         (catch 'schema-dir
+           (message "Debug (org-odt): Searching for OpenDocument schema files...")
+           (mapc
+            (lambda (schema-dir)
+              (when schema-dir
+                (message "Debug (org-odt): Trying %s..." schema-dir)
+                (when (and (file-readable-p
+                            (expand-file-name "od-manifest-schema-v1.2-cs01.rnc"
+                                              schema-dir))
+                           (file-readable-p
+                            (expand-file-name "od-schema-v1.2-cs01.rnc"
+                                              schema-dir))
+                           (file-readable-p
+                            (expand-file-name "schemas.xml" schema-dir)))
+                  (message "Debug (org-odt): Using schema files under %s"
+                           schema-dir)
+                  (throw 'schema-dir schema-dir))))
+            org-odt-schema-dir-list)
+           (message "Debug (org-odt): No OpenDocument schema files installed")
+           nil)))
+    schema-dir)
+  "Directory that contains OpenDocument schema files.
+
+This directory contains:
+1. rnc files for OpenDocument schema
+2. a \"schemas.xml\" file that specifies locating rules needed
+   for auto validation of OpenDocument XML files.
+
+Use the customize interface to set this variable.  This ensures
+that `rng-schema-locating-files' is updated and auto-validation
+of OpenDocument XML takes place based on the value
+`rng-nxml-auto-validate-flag'.
+
+The default value of this variable varies depending on the
+version of org in use and is initialized from
+`org-odt-schema-dir-list'.  The OASIS schema files are available
+only in the org's private git repository.  It is *not* bundled
+with GNU ELPA tar or standard Emacs distribution."
+  :type '(choice
+         (const :tag "Not set" nil)
+         (directory :tag "Schema directory"))
+  :group 'org-export-odt
+  :set
+  (lambda (var value)
+    "Set `org-export-odt-schema-dir'.
+Also add it to `rng-schema-locating-files'."
+    (let ((schema-dir value))
+      (set var
+          (if (and
+               (file-readable-p
+                (expand-file-name "od-manifest-schema-v1.2-cs01.rnc" schema-dir))
+               (file-readable-p
+                (expand-file-name "od-schema-v1.2-cs01.rnc" schema-dir))
+               (file-readable-p
+                (expand-file-name "schemas.xml" schema-dir)))
+              schema-dir
+            (when value
+              (message "Error (org-odt): %s has no OpenDocument schema files"
+                       value))
+            nil)))
+    (when org-export-odt-schema-dir
+      (eval-after-load 'rng-loc
+       '(add-to-list 'rng-schema-locating-files
+                     (expand-file-name "schemas.xml"
+                                       org-export-odt-schema-dir))))))
+
+(defconst org-odt-styles-dir-list
+  (list
+   (and org-odt-data-dir
+       (expand-file-name "./styles/" org-odt-data-dir)) ; bail out
+   (eval-when-compile
+     (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
+         (expand-file-name "./styles/" org-odt-data-dir)))
+   (expand-file-name "../etc/styles/" org-odt-lib-dir) ; git
+   (expand-file-name "./etc/styles/" org-odt-lib-dir)  ; elpa
+   (expand-file-name "./org/" data-directory)         ; system
+   )
+  "List of directories to search for OpenDocument styles files.
+See `org-odt-styles-dir'.  The entries in this list are populated
+heuristically based on the values of `org-odt-lib-dir' and
+`org-odt-data-dir'.")
+
+(defconst org-odt-styles-dir
+  (let* ((styles-dir
+         (catch 'styles-dir
+           (message "Debug (org-odt): Searching for OpenDocument styles files...")
+           (mapc (lambda (styles-dir)
+                   (when styles-dir
+                     (message "Debug (org-odt): Trying %s..." styles-dir)
+                     (when (and (file-readable-p
+                                 (expand-file-name
+                                  "OrgOdtContentTemplate.xml" styles-dir))
+                                (file-readable-p
+                                 (expand-file-name
+                                  "OrgOdtStyles.xml" styles-dir)))
+                       (message "Debug (org-odt): Using styles under %s"
+                                styles-dir)
+                       (throw 'styles-dir styles-dir))))
+                 org-odt-styles-dir-list)
+           nil)))
+    (unless styles-dir
+      (error "Error (org-odt): Cannot find factory styles files. Aborting."))
+    styles-dir)
+  "Directory that holds auxiliary XML files used by the ODT exporter.
+
+This directory contains the following XML files -
+ \"OrgOdtStyles.xml\" and \"OrgOdtContentTemplate.xml\".  These
+ XML files are used as the default values of
+ `org-export-odt-styles-file' and
+ `org-export-odt-content-template-file'.
+
+The default value of this variable varies depending on the
+version of org in use and is initialized from
+`org-odt-styles-dir-list'.  Note that the user could be using org
+from one of: org's own private git repository, GNU ELPA tar or
+standard Emacs.")
+
+(defvar org-odt-file-extensions
+  '(("odt" . "OpenDocument Text")
+    ("ott" . "OpenDocument Text Template")
+    ("odm" . "OpenDocument Master Document")
+    ("ods" . "OpenDocument Spreadsheet")
+    ("ots" . "OpenDocument Spreadsheet Template")
+    ("odg" . "OpenDocument Drawing (Graphics)")
+    ("otg" . "OpenDocument Drawing Template")
+    ("odp" . "OpenDocument Presentation")
+    ("otp" . "OpenDocument Presentation Template")
+    ("odi" . "OpenDocument Image")
+    ("odf" . "OpenDocument Formula")
+    ("odc" . "OpenDocument Chart")))
+
+(mapc
+ (lambda (desc)
+   ;; Let Org open all OpenDocument files using system-registered app
+   (add-to-list 'org-file-apps
+               (cons (concat  "\\." (car desc) "\\'") 'system))
+   ;; Let Emacs open all OpenDocument files in archive mode
+   (add-to-list 'auto-mode-alist
+               (cons (concat  "\\." (car desc) "\\'") 'archive-mode)))
+ org-odt-file-extensions)
+
+;; register the odt exporter with the pre-processor
+(add-to-list 'org-export-backends 'odt)
+
+;; register the odt exporter with org-lparse library
+(org-lparse-register-backend 'odt)
+
+(defun org-odt-unload-function ()
+  (org-lparse-unregister-backend 'odt)
+  (remove-hook 'org-export-preprocess-after-blockquote-hook
+              'org-export-odt-preprocess-latex-fragments)
+  nil)
+
+(defcustom org-export-odt-content-template-file nil
+  "Template file for \"content.xml\".
+The exporter embeds the exported content just before
+\"</office:text>\" element.
+
+If unspecified, the file named \"OrgOdtContentTemplate.xml\"
+under `org-odt-styles-dir' is used."
+  :type 'file
+  :group 'org-export-odt)
+
+(defcustom org-export-odt-styles-file nil
+  "Default styles file for use with ODT export.
+Valid values are one of:
+1. nil
+2. path to a styles.xml file
+3. path to a *.odt or a *.ott file
+4. list of the form (ODT-OR-OTT-FILE (FILE-MEMBER-1 FILE-MEMBER-2
+...))
+
+In case of option 1, an in-built styles.xml is used. See
+`org-odt-styles-dir' for more information.
+
+In case of option 3, the specified file is unzipped and the
+styles.xml embedded therein is used.
+
+In case of option 4, the specified ODT-OR-OTT-FILE is unzipped
+and FILE-MEMBER-1, FILE-MEMBER-2 etc are copied in to the
+generated odt file.  Use relative path for specifying the
+FILE-MEMBERS.  styles.xml must be specified as one of the
+FILE-MEMBERS.
+
+Use options 1, 2 or 3 only if styles.xml alone suffices for
+achieving the desired formatting.  Use option 4, if the styles.xml
+references additional files like header and footer images for
+achieving the desired formattting.
+
+Use \"#+ODT_STYLES_FILE: ...\" directive to set this variable on
+a per-file basis.  For example,
+
+#+ODT_STYLES_FILE: \"/path/to/styles.xml\" or
+#+ODT_STYLES_FILE: (\"/path/to/file.ott\" (\"styles.xml\" \"image/hdr.png\"))."
+  :group 'org-export-odt
+  :type
+  '(choice
+    (const :tag "Factory settings" nil)
+    (file :must-match t :tag "styles.xml")
+    (file :must-match t :tag "ODT or OTT file")
+    (list :tag "ODT or OTT file + Members"
+         (file :must-match t :tag "ODF Text or Text Template file")
+         (cons :tag "Members"
+               (file :tag "    Member" "styles.xml")
+               (repeat (file :tag "Member"))))))
+
+(eval-after-load 'org-exp
+  '(add-to-list 'org-export-inbuffer-options-extra
+               '("ODT_STYLES_FILE" :odt-styles-file)))
+
+(defconst org-export-odt-tmpdir-prefix "%s-")
+(defconst org-export-odt-bookmark-prefix "OrgXref.")
+
+(defvar org-export-odt-embed-images t
+  "Should the images be copied in to the odt file or just linked?")
+
+(defvar org-export-odt-inline-images 'maybe) ; counterpart of
+                                            ; `org-export-html-inline-images'
+
+(defcustom org-export-odt-inline-image-extensions
+  '("png" "jpeg" "jpg" "gif")
+  "Extensions of image files that can be inlined into HTML."
+  :type '(repeat (string :tag "Extension"))
+  :group 'org-export-odt)
+
+(defcustom org-export-odt-pixels-per-inch display-pixels-per-inch
+  ;; FIXME add docstring
+  ""
+  :type 'float
+  :group 'org-export-odt)
+
+(defcustom org-export-odt-create-custom-styles-for-srcblocks t
+  "Whether custom styles for colorized source blocks be automatically created.
+When this option is turned on, the exporter creates custom styles
+for source blocks based on the advice of `htmlfontify'.  Creation
+of custom styles happen as part of `org-odt-hfy-face-to-css'.
+
+When this option is turned off exporter does not create such
+styles.
+
+Use the latter option if you do not want the custom styles to be
+based on your current display settings.  It is necessary that the
+styles.xml already contains needed styles for colorizing to work.
+
+This variable is effective only if
+`org-export-odt-fontify-srcblocks' is turned on."
+  :group 'org-export-odt
+  :type 'boolean)
+
+(defvar org-export-odt-default-org-styles-alist
+  '((paragraph . ((default . "Text_20_body")
+                 (fixedwidth . "OrgFixedWidthBlock")
+                 (verse . "OrgVerse")
+                 (quote . "Quotations")
+                 (blockquote . "Quotations")
+                 (center . "OrgCenter")
+                 (left . "OrgLeft")
+                 (right . "OrgRight")
+                 (title . "OrgTitle")
+                 (subtitle . "OrgSubtitle")
+                 (footnote . "Footnote")
+                 (src . "OrgSrcBlock")
+                 (illustration . "Illustration")
+                 (table . "Table")
+                 (definition-term . "Text_20_body_20_bold")
+                 (horizontal-line . "Horizontal_20_Line")))
+    (character . ((bold . "Bold")
+                 (emphasis . "Emphasis")
+                 (code . "OrgCode")
+                 (verbatim . "OrgCode")
+                 (strike . "Strikethrough")
+                 (underline . "Underline")
+                 (subscript . "OrgSubscript")
+                 (superscript . "OrgSuperscript")))
+    (list . ((ordered . "OrgNumberedList")
+            (unordered . "OrgBulletedList")
+            (description . "OrgDescriptionList"))))
+  "Default styles for various entities.")
+
+(defvar org-export-odt-org-styles-alist org-export-odt-default-org-styles-alist)
+(defun org-odt-get-style-name-for-entity (category &optional entity)
+  (let ((entity (or entity 'default)))
+    (or
+     (cdr (assoc entity (cdr (assoc category
+                                   org-export-odt-org-styles-alist))))
+     (cdr (assoc entity (cdr (assoc category
+                                   org-export-odt-default-org-styles-alist))))
+     (error "Cannot determine style name for entity %s of type %s"
+           entity category))))
+
+(defcustom org-export-odt-preferred-output-format nil
+  "Automatically post-process to this format after exporting to \"odt\".
+Interactive commands `org-export-as-odt' and
+`org-export-as-odt-and-open' export first to \"odt\" format and
+then use `org-export-odt-convert-process' to convert the
+resulting document to this format.  During customization of this
+variable, the list of valid values are populated based on
+`org-export-odt-convert-capabilities'."
+  :group 'org-export-odt
+  :type '(choice :convert-widget
+                (lambda (w)
+                  (apply 'widget-convert (widget-type w)
+                         (eval (car (widget-get w :args)))))
+                `((const :tag "None" nil)
+                  ,@(mapcar (lambda (c)
+                              `(const :tag ,c ,c))
+                            (org-lparse-reachable-formats "odt")))))
+
+;;;###autoload
+(defun org-export-as-odt-and-open (arg)
+  "Export the outline as ODT and immediately open it with a browser.
+If there is an active region, export only the region.
+The prefix ARG specifies how many levels of the outline should become
+headlines.  The default is 3.  Lower levels will become bulleted lists."
+  (interactive "P")
+  (org-lparse-and-open
+   (or org-export-odt-preferred-output-format "odt") "odt" arg))
+
+;;;###autoload
+(defun org-export-as-odt-batch ()
+  "Call the function `org-lparse-batch'.
+This function can be used in batch processing as:
+emacs   --batch
+        --load=$HOME/lib/emacs/org.el
+        --eval \"(setq org-export-headline-levels 2)\"
+        --visit=MyFile --funcall org-export-as-odt-batch"
+  (org-lparse-batch "odt"))
+
+;;;###autoload
+(defun org-export-as-odt-to-buffer (arg)
+  "Call `org-lparse-odt` with output to a temporary buffer.
+No file is created.  The prefix ARG is passed through to `org-lparse-to-buffer'."
+  (interactive "P")
+  (org-lparse-to-buffer "odt" arg))
+
+;;;###autoload
+(defun org-replace-region-by-odt (beg end)
+  "Assume the current region has org-mode syntax, and convert it to ODT.
+This can be used in any buffer.  For example, you could write an
+itemized list in org-mode syntax in an ODT buffer and then use this
+command to convert it."
+  (interactive "r")
+  (org-replace-region-by "odt" beg end))
+
+;;;###autoload
+(defun org-export-region-as-odt (beg end &optional body-only buffer)
+  "Convert region from BEG to END in org-mode buffer to ODT.
+If prefix arg BODY-ONLY is set, omit file header, footer, and table of
+contents, and only produce the region of converted text, useful for
+cut-and-paste operations.
+If BUFFER is a buffer or a string, use/create that buffer as a target
+of the converted ODT.  If BUFFER is the symbol `string', return the
+produced ODT as a string and leave not buffer behind.  For example,
+a Lisp program could call this function in the following way:
+
+  (setq odt (org-export-region-as-odt beg end t 'string))
+
+When called interactively, the output buffer is selected, and shown
+in a window.  A non-interactive call will only return the buffer."
+  (interactive "r\nP")
+  (org-lparse-region "odt" beg end body-only buffer))
+
+;;; org-export-as-odt
+;;;###autoload
+(defun org-export-as-odt (arg &optional hidden ext-plist
+                             to-buffer body-only pub-dir)
+  "Export the outline as a OpenDocumentText file.
+If there is an active region, export only the region.  The prefix
+ARG specifies how many levels of the outline should become
+headlines.  The default is 3.  Lower levels will become bulleted
+lists.  HIDDEN is obsolete and does nothing.
+EXT-PLIST is a property list with external parameters overriding
+org-mode's default settings, but still inferior to file-local
+settings.  When TO-BUFFER is non-nil, create a buffer with that
+name and export to that buffer.  If TO-BUFFER is the symbol
+`string', don't leave any buffer behind but just return the
+resulting XML as a string.  When BODY-ONLY is set, don't produce
+the file header and footer, simply return the content of
+<body>...</body>, without even the body tags themselves.  When
+PUB-DIR is set, use this as the publishing directory."
+  (interactive "P")
+  (org-lparse (or org-export-odt-preferred-output-format "odt")
+             "odt" arg hidden ext-plist to-buffer body-only pub-dir))
+
+(defvar org-odt-entity-control-callbacks-alist
+  `((EXPORT
+     . (org-odt-begin-export org-odt-end-export))
+    (DOCUMENT-CONTENT
+     . (org-odt-begin-document-content org-odt-end-document-content))
+    (DOCUMENT-BODY
+     . (org-odt-begin-document-body org-odt-end-document-body))
+    (TOC
+     . (org-odt-begin-toc org-odt-end-toc))
+    (ENVIRONMENT
+     . (org-odt-begin-environment org-odt-end-environment))
+    (FOOTNOTE-DEFINITION
+     . (org-odt-begin-footnote-definition org-odt-end-footnote-definition))
+    (TABLE
+     . (org-odt-begin-table org-odt-end-table))
+    (TABLE-ROWGROUP
+     . (org-odt-begin-table-rowgroup org-odt-end-table-rowgroup))
+    (LIST
+     . (org-odt-begin-list org-odt-end-list))
+    (LIST-ITEM
+     . (org-odt-begin-list-item org-odt-end-list-item))
+    (OUTLINE
+     . (org-odt-begin-outline org-odt-end-outline))
+    (OUTLINE-TEXT
+     . (org-odt-begin-outline-text org-odt-end-outline-text))
+    (PARAGRAPH
+     . (org-odt-begin-paragraph org-odt-end-paragraph)))
+  "")
+
+(defvar org-odt-entity-format-callbacks-alist
+  `((EXTRA-TARGETS . org-lparse-format-extra-targets)
+    (ORG-TAGS . org-lparse-format-org-tags)
+    (SECTION-NUMBER . org-lparse-format-section-number)
+    (HEADLINE . org-odt-format-headline)
+    (TOC-ENTRY . org-odt-format-toc-entry)
+    (TOC-ITEM . org-odt-format-toc-item)
+    (TAGS . org-odt-format-tags)
+    (SPACES . org-odt-format-spaces)
+    (TABS . org-odt-format-tabs)
+    (LINE-BREAK . org-odt-format-line-break)
+    (FONTIFY . org-odt-format-fontify)
+    (TODO . org-lparse-format-todo)
+    (LINK . org-odt-format-link)
+    (INLINE-IMAGE . org-odt-format-inline-image)
+    (ORG-LINK . org-odt-format-org-link)
+    (HEADING . org-odt-format-heading)
+    (ANCHOR . org-odt-format-anchor)
+    (TABLE . org-lparse-format-table)
+    (TABLE-ROW . org-odt-format-table-row)
+    (TABLE-CELL . org-odt-format-table-cell)
+    (FOOTNOTES-SECTION . ignore)
+    (FOOTNOTE-REFERENCE . org-odt-format-footnote-reference)
+    (HORIZONTAL-LINE . org-odt-format-horizontal-line)
+    (COMMENT . org-odt-format-comment)
+    (LINE . org-odt-format-line)
+    (ORG-ENTITY . org-odt-format-org-entity))
+  "")
+
+;;;_. callbacks
+;;;_. control callbacks
+;;;_ , document body
+(defun org-odt-begin-office-body ()
+  ;; automatic styles
+  (insert-file-contents
+   (or org-export-odt-content-template-file
+       (expand-file-name "OrgOdtContentTemplate.xml"
+                        org-odt-styles-dir)))
+  (goto-char (point-min))
+  (re-search-forward "</office:text>" nil nil)
+  (delete-region (match-beginning 0) (point-max)))
+
+;; Following variable is let bound when `org-do-lparse' is in
+;; progress. See org-html.el.
+(defvar org-lparse-toc)
+(defun org-odt-format-toc ()
+  (if (not org-lparse-toc) "" (concat  "\n" org-lparse-toc "\n")))
+
+(defun org-odt-format-preamble (opt-plist)
+  (let* ((title (plist-get opt-plist :title))
+        (author (plist-get opt-plist :author))
+        (date (plist-get opt-plist :date))
+        (iso-date (org-odt-format-date date))
+        (date (org-odt-format-date date "%d %b %Y"))
+        (email (plist-get opt-plist :email))
+        ;; switch on or off above vars based on user settings
+        (author (and (plist-get opt-plist :author-info) (or author email)))
+        (email (and (plist-get opt-plist :email-info) email))
+        (date (and (plist-get opt-plist :time-stamp-file) date)))
+    (concat
+     ;; title
+     (when title
+       (concat
+       (org-odt-format-stylized-paragraph
+        'title (org-odt-format-tags
+                '("<text:title>" . "</text:title>") title))
+       ;; separator
+       "<text:p text:style-name=\"OrgTitle\"/>"))
+     (cond
+      ((and author (not email))
+       ;; author only
+       (concat
+       (org-odt-format-stylized-paragraph
+        'subtitle
+        (org-odt-format-tags
+         '("<text:initial-creator>" . "</text:initial-creator>")
+         author))
+       ;; separator
+       "<text:p text:style-name=\"OrgSubtitle\"/>"))
+      ((and author email)
+       ;; author and email
+       (concat
+       (org-odt-format-stylized-paragraph
+        'subtitle
+        (org-odt-format-link
+         (org-odt-format-tags
+          '("<text:initial-creator>" . "</text:initial-creator>")
+          author) (concat "mailto:" email)))
+       ;; separator
+       "<text:p text:style-name=\"OrgSubtitle\"/>")))
+     ;; date
+     (when date
+       (concat
+       (org-odt-format-stylized-paragraph
+        'subtitle
+        (org-odt-format-tags
+         '("<text:date style:data-style-name=\"%s\" text:date-value=\"%s\">"
+           . "</text:date>") date "N75" iso-date))
+       ;; separator
+       "<text:p text:style-name=\"OrgSubtitle\"/>"))
+     ;; toc
+     (org-odt-format-toc))))
+
+(defun org-odt-begin-document-body (opt-plist)
+  (org-odt-begin-office-body)
+  (insert (org-odt-format-preamble opt-plist)))
+
+(defvar org-lparse-body-only)          ; let bound during org-do-lparse
+(defvar org-lparse-to-buffer)          ; let bound during org-do-lparse
+(defun org-odt-end-document-body (opt-plist)
+  (unless org-lparse-body-only
+    (org-lparse-insert-tag "</office:text>")
+    (org-lparse-insert-tag "</office:body>")))
+
+(defun org-odt-begin-document-content (opt-plist)
+  (ignore))
+
+(defun org-odt-end-document-content ()
+  (org-lparse-insert-tag "</office:document-content>"))
+
+(defun org-odt-begin-outline (level1 snumber title tags
+                                    target extra-targets class)
+  (org-lparse-insert
+   'HEADING (org-lparse-format
+            'HEADLINE title extra-targets tags snumber level1)
+   level1 target))
+
+(defun org-odt-end-outline ()
+  (ignore))
+
+(defun org-odt-begin-outline-text (level1 snumber class)
+  (ignore))
+
+(defun org-odt-end-outline-text ()
+  (ignore))
+
+(defun org-odt-begin-paragraph (&optional style)
+  (org-lparse-insert-tag
+   "<text:p%s>" (org-odt-get-extra-attrs-for-paragraph-style style)))
+
+(defun org-odt-end-paragraph ()
+  (org-lparse-insert-tag "</text:p>"))
+
+(defun org-odt-get-extra-attrs-for-paragraph-style (style)
+  (let (style-name)
+    (setq style-name
+         (cond
+          ((stringp style) style)
+          ((symbolp style) (org-odt-get-style-name-for-entity
+                            'paragraph style))))
+    (unless style-name
+      (error "Don't know how to handle paragraph style %s" style))
+    (format " text:style-name=\"%s\"" style-name)))
+
+(defun org-odt-format-stylized-paragraph (style text)
+  (org-odt-format-tags
+   '("<text:p%s>" . "</text:p>") text
+   (org-odt-get-extra-attrs-for-paragraph-style style)))
+
+(defvar org-lparse-opt-plist)              ; bound during org-do-lparse
+(defun org-odt-format-author (&optional author)
+  (when (setq author (or author (plist-get org-lparse-opt-plist :author)))
+    (org-odt-format-tags '("<dc:creator>" . "</dc:creator>") author)))
+
+(defun org-odt-format-date (&optional org-ts fmt)
+  (save-match-data
+    (let* ((time
+           (and (stringp org-ts)
+                (string-match org-ts-regexp0 org-ts)
+                (apply 'encode-time
+                       (org-fix-decoded-time
+                        (org-parse-time-string (match-string 0 org-ts) t)))))
+          date)
+      (cond
+       (fmt (format-time-string fmt time))
+       (t (setq date (format-time-string "%Y-%m-%dT%H:%M:%S%z" time))
+         (format "%s:%s" (substring date 0 -2) (substring date -2)))))))
+
+(defun org-odt-begin-annotation (&optional author date)
+  (org-lparse-insert-tag "<office:annotation>")
+  (when (setq author (org-odt-format-author author))
+    (insert author))
+  (insert (org-odt-format-tags
+          '("<dc:date>" . "</dc:date>")
+          (org-odt-format-date
+           (or date (plist-get org-lparse-opt-plist :date)))))
+  (org-lparse-begin-paragraph))
+
+(defun org-odt-end-annotation ()
+  (org-lparse-insert-tag  "</office:annotation>"))
+
+(defun org-odt-begin-environment (style env-options-plist)
+  (case style
+    (annotation
+     (org-lparse-stash-save-paragraph-state)
+     (org-odt-begin-annotation (plist-get env-options-plist 'author)
+                              (plist-get env-options-plist 'date)))
+    ((blockquote verse center quote)
+     (org-lparse-begin-paragraph style)
+     (list))
+    ((fixedwidth native)
+     (org-lparse-end-paragraph)
+     (list))
+    (t (error "Unknown environment %s" style))))
+
+(defun org-odt-end-environment (style env-options-plist)
+  (case style
+    (annotation
+     (org-lparse-end-paragraph)
+     (org-odt-end-annotation)
+     (org-lparse-stash-pop-paragraph-state))
+    ((blockquote verse center quote)
+     (org-lparse-end-paragraph)
+     (list))
+    ((fixedwidth native)
+     (org-lparse-begin-paragraph)
+     (list))
+    (t (error "Unknown environment %s" style))))
+
+(defvar org-lparse-list-level) ; dynamically bound in org-do-lparse
+(defun org-odt-begin-list (ltype)
+  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
+                 ltype))
+  (let* ((style-name (org-odt-get-style-name-for-entity 'list ltype))
+        (extra (concat (when (= org-lparse-list-level 1)
+                         " text:continue-numbering=\"false\"")
+                       (when style-name
+                         (format " text:style-name=\"%s\""  style-name)))))
+    (case ltype
+      ((ordered unordered description)
+       (org-lparse-end-paragraph)
+       (org-lparse-insert-tag "<text:list%s>" extra))
+      (t (error "Unknown list type: %s"  ltype)))))
+
+(defun org-odt-end-list (ltype)
+  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
+                 ltype))
+  (if ltype
+      (org-lparse-insert-tag "</text:list>")
+    (error "Unknown list type: %s" ltype)))
+
+(defun org-odt-begin-list-item (ltype &optional arg headline)
+  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
+                 ltype))
+  (case ltype
+    (ordered
+     (assert (not headline) t)
+     (let* ((counter arg) (extra ""))
+       (org-lparse-insert-tag "<text:list-item>")
+       (org-lparse-begin-paragraph)))
+    (unordered
+     (let* ((id arg) (extra ""))
+       (org-lparse-insert-tag "<text:list-item>")
+       (org-lparse-begin-paragraph)
+       (insert (if headline (org-odt-format-target headline id)
+                (org-odt-format-bookmark "" id)))))
+    (description
+     (assert (not headline) t)
+     (let ((term (or arg "(no term)")))
+       (insert
+       (org-odt-format-tags
+        '("<text:list-item>" . "</text:list-item>")
+        (org-odt-format-stylized-paragraph 'definition-term term)))
+       (org-lparse-begin-list-item 'unordered)
+       (org-lparse-begin-list 'description)
+       (org-lparse-begin-list-item 'unordered)))
+    (t (error "Unknown list type"))))
+
+(defun org-odt-end-list-item (ltype)
+  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
+                 ltype))
+  (case ltype
+    ((ordered unordered)
+     (org-lparse-insert-tag "</text:list-item>"))
+    (description
+     (org-lparse-end-list-item-1)
+     (org-lparse-end-list 'description)
+     (org-lparse-end-list-item-1))
+    (t (error "Unknown list type"))))
+
+;; Following variables are let bound when table emission is in
+;; progress. See org-lparse.el.
+(defvar org-lparse-table-begin-marker)
+(defvar org-lparse-table-ncols)
+(defvar org-lparse-table-rowgrp-open)
+(defvar org-lparse-table-rownum)
+(defvar org-lparse-table-cur-rowgrp-is-hdr)
+(defvar org-lparse-table-is-styled)
+(defvar org-lparse-table-rowgrp-info)
+(defvar org-lparse-table-colalign-vector)
+
+(defvar org-odt-table-style nil
+  "Table style specified by \"#+ATTR_ODT: <style-name>\" line.
+This is set during `org-odt-begin-table'.")
+
+(defvar org-odt-table-style-spec nil
+  "Entry for `org-odt-table-style' in `org-export-odt-table-styles'.")
+
+(defcustom org-export-odt-table-styles
+  '(("OrgEquation" "OrgEquation"
+     ((use-first-column-styles . t)
+      (use-last-column-styles . t))))
+  "Specify how Table Styles should be derived from a Table Template.
+This is a list where each element is of the
+form (TABLE-STYLE-NAME TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS).
+
+TABLE-STYLE-NAME is the style associated with the table through
+`org-odt-table-style'.
+
+TABLE-TEMPLATE-NAME is a set of - upto 9 - automatic
+TABLE-CELL-STYLE-NAMEs and PARAGRAPH-STYLE-NAMEs (as defined
+below) that is included in
+`org-export-odt-content-template-file'.
+
+TABLE-CELL-STYLE-NAME := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
+                         \"TableCell\"
+PARAGRAPH-STYLE-NAME  := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
+                         \"TableParagraph\"
+TABLE-CELL-TYPE       := \"FirstRow\"   | \"LastColumn\" |
+                         \"FirstRow\"   | \"LastRow\"    |
+                         \"EvenRow\"    | \"OddRow\"     |
+                         \"EvenColumn\" | \"OddColumn\"  | \"\"
+where \"+\" above denotes string concatenation.
+
+TABLE-CELL-OPTIONS is an alist where each element is of the
+form (TABLE-CELL-STYLE-SELECTOR . ON-OR-OFF).
+TABLE-CELL-STYLE-SELECTOR := `use-first-row-styles'       |
+                             `use-last-row-styles'        |
+                             `use-first-column-styles'    |
+                             `use-last-column-styles'     |
+                             `use-banding-rows-styles'    |
+                             `use-banding-columns-styles' |
+                             `use-first-row-styles'
+ON-OR-OFF                 := `t' | `nil'
+
+For example, with the following configuration
+
+\(setq org-export-odt-table-styles
+      '\(\(\"TableWithHeaderRowsAndColumns\" \"Custom\"
+         \(\(use-first-row-styles . t\)
+          \(use-first-column-styles . t\)\)\)
+        \(\"TableWithHeaderColumns\" \"Custom\"
+         \(\(use-first-column-styles . t\)\)\)\)\)
+
+1. A table associated with \"TableWithHeaderRowsAndColumns\"
+   style will use the following table-cell styles -
+   \"CustomFirstRowTableCell\", \"CustomFirstColumnTableCell\",
+   \"CustomTableCell\" and the following paragraph styles
+   \"CustomFirstRowTableParagraph\",
+   \"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
+   as appropriate.
+
+2. A table associated with \"TableWithHeaderColumns\" style will
+   use the following table-cell styles -
+   \"CustomFirstColumnTableCell\", \"CustomTableCell\" and the
+   following paragraph styles
+   \"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
+   as appropriate..
+
+Note that TABLE-TEMPLATE-NAME corresponds to the
+\"<table:table-template>\" elements contained within
+\"<office:styles>\".  The entries (TABLE-STYLE-NAME
+TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS) correspond to
+\"table:template-name\" and \"table:use-first-row-styles\" etc
+attributes of \"<table:table>\" element.  Refer ODF-1.2
+specification for more information.  Also consult the
+implementation filed under `org-odt-get-table-cell-styles'.
+
+The TABLE-STYLE-NAME \"OrgEquation\" is used internally for
+formatting of numbered display equations.  Do not delete this
+style from the list."
+  :group 'org-export-odt
+  :type '(choice
+          (const :tag "None" nil)
+          (repeat :tag "Table Styles"
+                  (list :tag "Table Style Specification"
+                       (string :tag "Table Style Name")
+                       (string  :tag "Table Template Name")
+                       (alist :options (use-first-row-styles
+                                        use-last-row-styles
+                                        use-first-column-styles
+                                        use-last-column-styles
+                                        use-banding-rows-styles
+                                        use-banding-columns-styles)
+                              :key-type symbol
+                              :value-type (const :tag "True" t))))))
+
+(defun org-odt-begin-table (caption label attributes)
+  (setq org-odt-table-style attributes)
+  (setq org-odt-table-style-spec
+       (assoc org-odt-table-style org-export-odt-table-styles))
+  (when label
+    (insert
+     (org-odt-format-stylized-paragraph
+      'table (org-odt-format-entity-caption label caption "__Table__"))))
+  (org-lparse-insert-tag
+   "<table:table table:name=\"%s\" table:style-name=\"%s\">"
+   (or label "") (or (nth 1 org-odt-table-style-spec) "OrgTable"))
+  (setq org-lparse-table-begin-marker (point)))
+
+(defvar org-lparse-table-colalign-info)
+(defun org-odt-end-table ()
+  (goto-char org-lparse-table-begin-marker)
+  (loop for level from 0 below org-lparse-table-ncols
+       do (let* ((col-cookie (and org-lparse-table-is-styled
+                                  (cdr (assoc (1+ level)
+                                              org-lparse-table-colalign-info))))
+                 (extra-columns (or (nth 1 col-cookie) 0)))
+            (dotimes (i (1+ extra-columns))
+              (insert
+               (org-odt-format-tags
+                "<table:table-column table:style-name=\"%sColumn\"/>"
+                "" (or (nth 1 org-odt-table-style-spec) "OrgTable"))))
+            (insert "\n")))
+  ;; fill style attributes for table cells
+  (when org-lparse-table-is-styled
+    (while (re-search-forward "@@\\(table-cell:p\\|table-cell:style-name\\)@@\\([0-9]+\\)@@\\([0-9]+\\)@@" nil t)
+      (let* ((spec (match-string 1))
+            (r (string-to-number (match-string 2)))
+            (c (string-to-number (match-string 3)))
+            (cell-styles (org-odt-get-table-cell-styles
+                          r c org-odt-table-style-spec))
+            (table-cell-style (car cell-styles))
+            (table-cell-paragraph-style (cdr cell-styles)))
+       (cond
+        ((equal spec "table-cell:p")
+         (replace-match table-cell-paragraph-style t t))
+        ((equal spec "table-cell:style-name")
+         (replace-match table-cell-style t t))))))
+  (goto-char (point-max))
+  (org-lparse-insert-tag "</table:table>"))
+
+(defun org-odt-begin-table-rowgroup (&optional is-header-row)
+  (when org-lparse-table-rowgrp-open
+    (org-lparse-end 'TABLE-ROWGROUP))
+  (org-lparse-insert-tag (if is-header-row
+                          "<table:table-header-rows>"
+                        "<table:table-rows>"))
+  (setq org-lparse-table-rowgrp-open t)
+  (setq org-lparse-table-cur-rowgrp-is-hdr is-header-row))
+
+(defun org-odt-end-table-rowgroup ()
+  (when org-lparse-table-rowgrp-open
+    (setq org-lparse-table-rowgrp-open nil)
+    (org-lparse-insert-tag
+     (if org-lparse-table-cur-rowgrp-is-hdr
+        "</table:table-header-rows>" "</table:table-rows>"))))
+
+(defun org-odt-format-table-row (row)
+  (org-odt-format-tags
+   '("<table:table-row>" . "</table:table-row>") row))
+
+(defun org-odt-get-table-cell-styles (r c &optional style-spec)
+  "Retrieve styles applicable to a table cell.
+R and C are (zero-based) row and column numbers of the table
+cell.  STYLE-SPEC is an entry in `org-export-odt-table-styles'
+applicable to the current table.  It is `nil' if the table is not
+associated with any style attributes.
+
+Return a cons of (TABLE-CELL-STYLE-NAME . PARAGRAPH-STYLE-NAME).
+
+When STYLE-SPEC is nil, style the table cell the conventional way
+- choose cell borders based on row and column groupings and
+choose paragraph alignment based on `org-col-cookies' text
+property.  See also
+`org-odt-get-paragraph-style-cookie-for-table-cell'.
+
+When STYLE-SPEC is non-nil, ignore the above cookie and return
+styles congruent with the ODF-1.2 specification."
+  (cond
+   (style-spec
+
+    ;; LibreOffice - particularly the Writer - honors neither table
+    ;; templates nor custom table-cell styles.  Inorder to retain
+    ;; inter-operability with LibreOffice, only automatic styles are
+    ;; used for styling of table-cells.  The current implementation is
+    ;; congruent with ODF-1.2 specification and hence is
+    ;; future-compatible.
+
+    ;; Additional Note: LibreOffice's AutoFormat facility for tables -
+    ;; which recognizes as many as 16 different cell types - is much
+    ;; richer. Unfortunately it is NOT amenable to easy configuration
+    ;; by hand.
+
+    (let* ((template-name (nth 1 style-spec))
+          (cell-style-selectors (nth 2 style-spec))
+          (cell-type
+           (cond
+            ((and (cdr (assoc 'use-first-column-styles cell-style-selectors))
+                  (= c 0)) "FirstColumn")
+            ((and (cdr (assoc 'use-last-column-styles cell-style-selectors))
+                  (= c (1- org-lparse-table-ncols))) "LastColumn")
+            ((and (cdr (assoc 'use-first-row-styles cell-style-selectors))
+                  (= r 0)) "FirstRow")
+            ((and (cdr (assoc 'use-last-row-styles cell-style-selectors))
+                  (= r org-lparse-table-rownum))
+             "LastRow")
+            ((and (cdr (assoc 'use-banding-rows-styles cell-style-selectors))
+                  (= (% r 2) 1)) "EvenRow")
+            ((and (cdr (assoc 'use-banding-rows-styles cell-style-selectors))
+                  (= (% r 2) 0)) "OddRow")
+            ((and (cdr (assoc 'use-banding-columns-styles cell-style-selectors))
+                  (= (% c 2) 1)) "EvenColumn")
+            ((and (cdr (assoc 'use-banding-columns-styles cell-style-selectors))
+                  (= (% c 2) 0)) "OddColumn")
+            (t ""))))
+      (cons
+       (concat template-name cell-type "TableCell")
+       (concat template-name cell-type "TableParagraph"))))
+   (t
+    (cons
+     (concat
+      "OrgTblCell"
+      (cond
+       ((= r 0) "T")
+       ((eq (cdr (assoc r org-lparse-table-rowgrp-info))  :start) "T")
+       (t ""))
+      (when (= r org-lparse-table-rownum) "B")
+      (cond
+       ((= c 0) "")
+       ((or (memq (nth c org-table-colgroup-info) '(:start :startend))
+           (memq (nth (1- c) org-table-colgroup-info) '(:end :startend))) "L")
+       (t "")))
+     (capitalize (aref org-lparse-table-colalign-vector c))))))
+
+(defun org-odt-get-paragraph-style-cookie-for-table-cell (r c)
+  (concat
+   (and (not org-odt-table-style-spec)
+       (cond
+        (org-lparse-table-cur-rowgrp-is-hdr "OrgTableHeading")
+        ((and (= c 0) (org-lparse-get 'TABLE-FIRST-COLUMN-AS-LABELS))
+         "OrgTableHeading")
+        (t "OrgTableContents")))
+   (and org-lparse-table-is-styled
+       (format "@@table-cell:p@@%03d@@%03d@@" r c))))
+
+(defun org-odt-get-style-name-cookie-for-table-cell (r c)
+  (when org-lparse-table-is-styled
+    (format "@@table-cell:style-name@@%03d@@%03d@@" r c)))
+
+(defun org-odt-format-table-cell (data r c horiz-span)
+  (concat
+   (let* ((paragraph-style-cookie
+          (org-odt-get-paragraph-style-cookie-for-table-cell r c))
+         (style-name-cookie
+          (org-odt-get-style-name-cookie-for-table-cell r c))
+         (extra (and style-name-cookie
+                     (format " table:style-name=\"%s\""  style-name-cookie)))
+         (extra (concat extra
+                        (and (> horiz-span 0)
+                             (format " table:number-columns-spanned=\"%d\""
+                                     (1+ horiz-span))))))
+     (org-odt-format-tags
+      '("<table:table-cell%s>" . "</table:table-cell>")
+      (if org-lparse-list-table-p data
+       (org-odt-format-stylized-paragraph paragraph-style-cookie data)) extra))
+   (let (s)
+     (dotimes (i horiz-span)
+       (setq s (concat s "\n<table:covered-table-cell/>"))) s)
+   "\n"))
+
+(defun org-odt-begin-footnote-definition (n)
+  (org-lparse-begin-paragraph 'footnote))
+
+(defun org-odt-end-footnote-definition (n)
+  (org-lparse-end-paragraph))
+
+(defun org-odt-begin-toc (lang-specific-heading max-level)
+  (insert
+   (format "
+    <text:table-of-content text:style-name=\"Sect2\" text:protected=\"true\" text:name=\"Table of Contents1\">
+     <text:table-of-content-source text:outline-level=\"%d\">
+      <text:index-title-template text:style-name=\"Contents_20_Heading\">%s</text:index-title-template>
+" max-level lang-specific-heading))
+  (loop for level from 1 upto 10
+       do (insert (format
+                   "
+      <text:table-of-content-entry-template text:outline-level=\"%d\" text:style-name=\"Contents_20_%d\">
+       <text:index-entry-link-start text:style-name=\"Internet_20_link\"/>
+       <text:index-entry-chapter/>
+       <text:index-entry-text/>
+       <text:index-entry-link-end/>
+      </text:table-of-content-entry-template>
+" level level)))
+
+  (insert
+   (format  "
+     </text:table-of-content-source>
+
+     <text:index-body>
+      <text:index-title text:style-name=\"Sect1\" text:name=\"Table of Contents1_Head\">
+       <text:p text:style-name=\"Contents_20_Heading\">%s</text:p>
+      </text:index-title>
+" lang-specific-heading)))
+
+(defun org-odt-end-toc ()
+  (insert "
+     </text:index-body>
+    </text:table-of-content>
+"))
+
+(defun org-odt-format-toc-entry (snumber todo headline tags href)
+  (setq headline (concat
+                 (and org-export-with-section-numbers
+                      (concat snumber ". "))
+                 headline
+                 (and tags
+                   (concat
+                    (org-lparse-format 'SPACES 3)
+                    (org-lparse-format 'FONTIFY tags "tag")))))
+  (when todo
+    (setq headline (org-lparse-format 'FONTIFY headline "todo")))
+
+  (let ((org-odt-suppress-xref t))
+    (org-odt-format-link headline (concat  "#" href))))
+
+(defun org-odt-format-toc-item (toc-entry level org-last-level)
+  (let ((style (format "Contents_20_%d"
+                      (+ level (or (org-lparse-get 'TOPLEVEL-HLEVEL) 1) -1))))
+    (insert "\n" (org-odt-format-stylized-paragraph style toc-entry) "\n")))
+
+;; Following variable is let bound during 'ORG-LINK callback. See
+;; org-html.el
+(defvar org-lparse-link-description-is-image nil)
+(defun org-odt-format-link (desc href &optional attr)
+  (cond
+   ((and (= (string-to-char href) ?#) (not org-odt-suppress-xref))
+    (setq href (concat org-export-odt-bookmark-prefix (substring href 1)))
+    (let ((xref-format "text"))
+      (when (numberp desc)
+       (setq desc (format "%d" desc) xref-format "number"))
+      (org-odt-format-tags
+       '("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
+        "</text:bookmark-ref>")
+       desc xref-format href)))
+   (org-lparse-link-description-is-image
+    (org-odt-format-tags
+     '("<draw:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</draw:a>")
+     desc href (or attr "")))
+   (t
+    (org-odt-format-tags
+     '("<text:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</text:a>")
+     desc href (or attr "")))))
+
+(defun org-odt-format-spaces (n)
+  (cond
+   ((= n 1) " ")
+   ((> n 1) (concat
+            " " (org-odt-format-tags "<text:s text:c=\"%d\"/>" "" (1- n))))
+   (t "")))
+
+(defun org-odt-format-tabs (&optional n)
+  (let ((tab "<text:tab/>")
+       (n (or n 1)))
+    (insert tab)))
+
+(defun org-odt-format-line-break ()
+  (org-odt-format-tags "<text:line-break/>" ""))
+
+(defun org-odt-format-horizontal-line ()
+  (org-odt-format-stylized-paragraph 'horizontal-line ""))
+
+(defun org-odt-encode-plain-text (line &optional no-whitespace-filling)
+  (setq line (org-xml-encode-plain-text line))
+  (if no-whitespace-filling line
+    (org-odt-fill-tabs-and-spaces line)))
+
+(defun org-odt-format-line (line)
+  (case org-lparse-dyn-current-environment
+    (fixedwidth (concat
+                (org-odt-format-stylized-paragraph
+                 'fixedwidth (org-odt-encode-plain-text line)) "\n"))
+    (t (concat line "\n"))))
+
+(defun org-odt-format-comment (fmt &rest args)
+  (let ((comment (apply 'format fmt args)))
+    (format "\n<!-- %s  -->\n" comment)))
+
+(defun org-odt-format-org-entity (wd)
+  (org-entity-get-representation wd 'utf8))
+
+(defun org-odt-fill-tabs-and-spaces (line)
+  (replace-regexp-in-string
+   "\\([\t]\\|\\([ ]+\\)\\)" (lambda (s)
+                              (cond
+                               ((string= s "\t") (org-odt-format-tabs))
+                               (t (org-odt-format-spaces (length s))))) line))
+
+(defcustom org-export-odt-fontify-srcblocks t
+  "Specify whether or not source blocks need to be fontified.
+Turn this option on if you want to colorize the source code
+blocks in the exported file.  For colorization to work, you need
+to make available an enhanced version of `htmlfontify' library."
+  :type 'boolean
+  :group 'org-export-odt)
+
+(defun org-odt-format-source-line-with-line-number-and-label
+  (line rpllbl num fontifier par-style)
+
+  (let ((keep-label (not (numberp rpllbl)))
+       (ref (org-find-text-property-in-string 'org-coderef line)))
+    (setq line (concat line (and keep-label ref (format "(%s)" ref))))
+    (setq line (funcall fontifier line))
+    (when ref
+      (setq line (org-odt-format-target line (concat "coderef-" ref))))
+    (setq line (org-odt-format-stylized-paragraph par-style line))
+    (if (not num) line
+      (org-odt-format-tags '("<text:list-item>" . "</text:list-item>") line))))
+
+(defun org-odt-format-source-code-or-example-plain
+  (lines lang caption textareap cols rows num cont rpllbl fmt)
+  "Format source or example blocks much like fixedwidth blocks.
+Use this when `org-export-odt-fontify-srcblocks' option is turned
+off."
+  (let* ((lines (org-split-string lines "[\r\n]"))
+        (line-count (length lines))
+        (i 0))
+    (mapconcat
+     (lambda (line)
+       (incf i)
+       (org-odt-format-source-line-with-line-number-and-label
+       line rpllbl num 'org-odt-encode-plain-text
+       (if (= i line-count) "OrgFixedWidthBlockLastLine"
+         "OrgFixedWidthBlock")))
+     lines "\n")))
+
+(defvar org-src-block-paragraph-format
+  "<style:style style:name=\"OrgSrcBlock\" style:family=\"paragraph\" style:parent-style-name=\"Preformatted_20_Text\">
+   <style:paragraph-properties fo:background-color=\"%s\" fo:padding=\"0.049cm\" fo:border=\"0.51pt solid #000000\" style:shadow=\"none\">
+    <style:background-image/>
+   </style:paragraph-properties>
+   <style:text-properties fo:color=\"%s\"/>
+  </style:style>"
+  "Custom paragraph style for colorized source and example blocks.
+This style is much the same as that of \"OrgFixedWidthBlock\"
+except that the foreground and background colors are set
+according to the default face identified by the `htmlfontify'.")
+
+(defvar hfy-optimisations)
+(declare-function hfy-face-to-style "htmlfontify" (fn))
+(declare-function hfy-face-or-def-to-name "htmlfontify" (fn))
+
+(defun org-odt-hfy-face-to-css (fn)
+  "Create custom style for face FN.
+When FN is the default face, use it's foreground and background
+properties to create \"OrgSrcBlock\" paragraph style.  Otherwise
+use it's color attribute to create a character style whose name
+is obtained from FN.  Currently all attributes of FN other than
+color are ignored.
+
+The style name for a face FN is derived using the following
+operations on the face name in that order - de-dash, CamelCase
+and prefix with \"OrgSrc\".  For example,
+`font-lock-function-name-face' is associated with
+\"OrgSrcFontLockFunctionNameFace\"."
+  (let* ((css-list (hfy-face-to-style fn))
+        (style-name ((lambda (fn)
+                       (concat "OrgSrc"
+                               (mapconcat
+                                'capitalize (split-string
+                                             (hfy-face-or-def-to-name fn) "-")
+                                ""))) fn))
+        (color-val (cdr (assoc "color" css-list)))
+        (background-color-val (cdr (assoc "background" css-list)))
+        (style (and org-export-odt-create-custom-styles-for-srcblocks
+                    (cond
+                     ((eq fn 'default)
+                      (format org-src-block-paragraph-format
+                              background-color-val color-val))
+                     (t
+                      (format
+                       "
+<style:style style:name=\"%s\" style:family=\"text\">
+  <style:text-properties fo:color=\"%s\"/>
+ </style:style>" style-name color-val))))))
+    (cons style-name style)))
+
+(defun org-odt-insert-custom-styles-for-srcblocks (styles)
+  "Save STYLES used for colorizing of source blocks.
+Update styles.xml with styles that were collected as part of
+`org-odt-hfy-face-to-css' callbacks."
+  (when styles
+    (with-current-buffer
+       (find-file-noselect (expand-file-name "styles.xml") t)
+      (goto-char (point-min))
+      (when (re-search-forward "</office:styles>" nil t)
+       (goto-char (match-beginning 0))
+       (insert "\n<!-- Org Htmlfontify Styles -->\n" styles "\n")))))
+
+(defun org-odt-format-source-code-or-example-colored
+  (lines lang caption textareap cols rows num cont rpllbl fmt)
+  "Format source or example blocks using `htmlfontify-string'.
+Use this routine when `org-export-odt-fontify-srcblocks' option
+is turned on."
+  (let* ((lang-m (and lang (or (cdr (assoc lang org-src-lang-modes)) lang)))
+        (mode (and lang-m (intern (concat (if (symbolp lang-m)
+                                              (symbol-name lang-m)
+                                            lang-m) "-mode"))))
+        (org-inhibit-startup t)
+        (org-startup-folded nil)
+        (lines (with-temp-buffer
+                 (insert lines)
+                 (if (functionp mode) (funcall mode) (fundamental-mode))
+                 (font-lock-fontify-buffer)
+                 (buffer-string)))
+        (hfy-html-quote-regex "\\([<\"&>       ]\\)")
+        (hfy-html-quote-map '(("\"" "&quot;")
+                              ("<" "&lt;")
+                              ("&" "&amp;")
+                              (">" "&gt;")
+                              (" " "<text:s/>")
+                              ("       " "<text:tab/>")))
+        (hfy-face-to-css 'org-odt-hfy-face-to-css)
+        (hfy-optimisations-1 (copy-seq hfy-optimisations))
+        (hfy-optimisations (add-to-list 'hfy-optimisations-1
+                                        'body-text-only))
+        (hfy-begin-span-handler
+         (lambda (style text-block text-id text-begins-block-p)
+           (insert (format "<text:span text:style-name=\"%s\">" style))))
+        (hfy-end-span-handler (lambda nil (insert "</text:span>"))))
+    (when (fboundp 'htmlfontify-string)
+      (let* ((lines (org-split-string lines "[\r\n]"))
+            (line-count (length lines))
+            (i 0))
+       (mapconcat
+        (lambda (line)
+          (incf i)
+          (org-odt-format-source-line-with-line-number-and-label
+           line rpllbl num 'htmlfontify-string
+           (if (= i line-count) "OrgSrcBlockLastLine" "OrgSrcBlock")))
+        lines "\n")))))
+
+(defun org-odt-format-source-code-or-example (lines lang caption textareap
+                                                   cols rows num cont
+                                                   rpllbl fmt)
+  "Format source or example blocks for export.
+Use `org-odt-format-source-code-or-example-plain' or
+`org-odt-format-source-code-or-example-colored' depending on the
+value of `org-export-odt-fontify-srcblocks."
+  (setq lines (org-export-number-lines
+              lines 0 0 num cont rpllbl fmt 'preprocess)
+       lines (funcall
+              (or (and org-export-odt-fontify-srcblocks
+                       (or (featurep 'htmlfontify)
+                           ;; htmlfontify.el was introduced in Emacs 23.2
+                           ;; So load it with some caution
+                           (require 'htmlfontify nil t))
+                       (fboundp 'htmlfontify-string)
+                       'org-odt-format-source-code-or-example-colored)
+                  'org-odt-format-source-code-or-example-plain)
+              lines lang caption textareap cols rows num cont rpllbl fmt))
+  (if (not num) lines
+    (let ((extra (format " text:continue-numbering=\"%s\""
+                        (if cont "true" "false"))))
+      (org-odt-format-tags
+       '("<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>"
+        . "</text:list>") lines extra))))
+
+(defun org-odt-remap-stylenames (style-name)
+  (or
+   (cdr (assoc style-name '(("timestamp-wrapper" . "OrgTimestampWrapper")
+                           ("timestamp" . "OrgTimestamp")
+                           ("timestamp-kwd" . "OrgTimestampKeyword")
+                           ("tag" . "OrgTag")
+                           ("todo" . "OrgTodo")
+                           ("done" . "OrgDone")
+                           ("target" . "OrgTarget"))))
+   style-name))
+
+(defun org-odt-format-fontify (text style &optional id)
+  (let* ((style-name
+         (cond
+          ((stringp style)
+           (org-odt-remap-stylenames style))
+          ((symbolp style)
+           (org-odt-get-style-name-for-entity 'character style))
+          ((listp style)
+           (assert (< 1 (length style)))
+           (let ((parent-style (pop style)))
+             (mapconcat (lambda (s)
+                          ;; (assert (stringp s) t)
+                          (org-odt-remap-stylenames s)) style "")
+             (org-odt-remap-stylenames parent-style)))
+          (t (error "Don't how to handle style %s"  style)))))
+    (org-odt-format-tags
+     '("<text:span text:style-name=\"%s\">" . "</text:span>")
+     text style-name)))
+
+(defun org-odt-relocate-relative-path (path dir)
+  (if (file-name-absolute-p path) path
+    (file-relative-name (expand-file-name path dir)
+                       (expand-file-name "eyecandy" dir))))
+
+(defun org-odt-format-inline-image (thefile)
+  (let* ((thelink (if (file-name-absolute-p thefile) thefile
+                   (org-xml-format-href
+                    (org-odt-relocate-relative-path
+                     thefile org-current-export-file))))
+        (href
+         (org-odt-format-tags
+          "<draw:image xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>" ""
+          (if org-export-odt-embed-images
+              (org-odt-copy-image-file thefile) thelink))))
+    (org-export-odt-format-image thefile href)))
+
+(defun org-export-odt-format-formula (src href &optional embed-as)
+  "Create image tag with source and attributes."
+  (save-match-data
+    (let* ((caption (org-find-text-property-in-string 'org-caption src))
+          (caption (and caption (org-xml-format-desc caption)))
+          (label (org-find-text-property-in-string 'org-label src))
+          (latex-frag (org-find-text-property-in-string 'org-latex-src src))
+          (embed-as (or embed-as
+                        (and latex-frag
+                             (org-find-text-property-in-string
+                              'org-latex-src-embed-type src))
+                        (if (or caption label) 'paragraph 'character)))
+          width height)
+      (when latex-frag
+       (setq href (org-propertize href :title "LaTeX Fragment"
+                                  :description latex-frag)))
+      (cond
+       ((eq embed-as 'character)
+       (org-odt-format-entity "InlineFormula" href width height))
+       (t
+       (org-lparse-end-paragraph)
+       (org-lparse-insert-list-table
+        `((,(org-odt-format-entity
+             (if caption "CaptionedDisplayFormula" "DisplayFormula")
+             href width height :caption caption :label nil)
+           ,(if (not label) ""
+              (org-odt-format-entity-caption label nil "__MathFormula__"))))
+        nil nil nil "OrgEquation" nil '((1 "c" 8) (2 "c" 1)))
+       (throw 'nextline nil))))))
+
+(defvar org-odt-embedded-formulas-count 0)
+(defun org-odt-copy-formula-file (path)
+  "Returns the internal name of the file"
+  (let* ((src-file (expand-file-name
+                   path (file-name-directory org-current-export-file)))
+        (target-dir (format "Formula-%04d/"
+                            (incf org-odt-embedded-formulas-count)))
+        (target-file (concat target-dir "content.xml")))
+    (when (not org-lparse-to-buffer)
+      (message "Embedding %s as %s ..."
+              (substring-no-properties path) target-file)
+
+       (make-directory target-dir)
+       (org-odt-create-manifest-file-entry
+        "application/vnd.oasis.opendocument.formula" target-dir "1.2")
+
+       (case (org-odt-is-formula-link-p src-file)
+         (mathml
+          (copy-file src-file target-file 'overwrite))
+         (odf
+          (org-odt-zip-extract-one src-file "content.xml" target-dir))
+         (t
+          (error "%s is not a formula file" src-file)))
+
+       (org-odt-create-manifest-file-entry "text/xml" target-file))
+    target-file))
+
+(defun org-odt-format-inline-formula (thefile)
+  (let* ((thelink (if (file-name-absolute-p thefile) thefile
+                   (org-xml-format-href
+                    (org-odt-relocate-relative-path
+                     thefile org-current-export-file))))
+        (href
+         (org-odt-format-tags
+          "<draw:object xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>" ""
+          (file-name-directory (org-odt-copy-formula-file thefile)))))
+    (org-export-odt-format-formula thefile href)))
+
+(defun org-odt-is-formula-link-p (file)
+  (let ((case-fold-search nil))
+    (cond
+     ((string-match "\\.\\(mathml\\|mml\\)\\'" file)
+      'mathml)
+     ((string-match "\\.odf\\'" file)
+      'odf))))
+
+(defun org-odt-format-org-link (opt-plist type-1 path fragment desc attr
+                                         descp)
+  "Make a OpenDocument link.
+OPT-PLIST is an options list.
+TYPE-1 is the device-type of the link (THIS://foo.html).
+PATH is the path of the link (http://THIS#location).
+FRAGMENT is the fragment part of the link, if any (foo.html#THIS).
+DESC is the link description, if any.
+ATTR is a string of other attributes of the a element."
+  (declare (special org-lparse-par-open))
+  (save-match-data
+    (let* ((may-inline-p
+           (and (member type-1 '("http" "https" "file"))
+                (org-lparse-should-inline-p path descp)
+                (not fragment)))
+          (type (if (equal type-1 "id") "file" type-1))
+          (filename path)
+          (thefile path))
+      (cond
+       ;; check for inlined images
+       ((and (member type '("file"))
+            (not fragment)
+            (org-file-image-p
+             filename org-export-odt-inline-image-extensions)
+            (or (eq t org-export-odt-inline-images)
+                (and org-export-odt-inline-images (not descp))))
+       (org-odt-format-inline-image thefile))
+       ;; check for embedded formulas
+       ((and (member type '("file"))
+            (not fragment)
+            (org-odt-is-formula-link-p filename)
+            (or (not descp)))
+       (org-odt-format-inline-formula thefile))
+       ((string= type "coderef")
+       (let* ((ref fragment)
+              (lineno-or-ref (cdr (assoc ref org-export-code-refs)))
+              (desc (and descp desc))
+              (org-odt-suppress-xref nil)
+              (href (org-xml-format-href (concat "#coderef-" ref))))
+         (cond
+          ((and (numberp lineno-or-ref) (not desc))
+           (org-odt-format-link lineno-or-ref href))
+          ((and (numberp lineno-or-ref) desc
+                (string-match (regexp-quote (concat "(" ref ")")) desc))
+           (format (replace-match "%s" t t desc)
+                   (org-odt-format-link lineno-or-ref href)))
+          (t
+           (setq desc (format
+                       (if (and desc (string-match
+                                      (regexp-quote (concat "(" ref ")"))
+                                      desc))
+                           (replace-match "%s" t t desc)
+                         (or desc "%s"))
+                       lineno-or-ref))
+           (org-odt-format-link (org-xml-format-desc desc) href)))))
+       (t
+       (when (string= type "file")
+         (setq thefile
+               (cond
+                ((file-name-absolute-p path)
+                 (concat "file://" (expand-file-name path)))
+                (t (org-odt-relocate-relative-path
+                    thefile org-current-export-file)))))
+
+       (when (and (member type '("" "http" "https" "file")) fragment)
+         (setq thefile (concat thefile "#" fragment)))
+
+       (setq thefile (org-xml-format-href thefile))
+
+       (when (not (member type '("" "file")))
+         (setq thefile (concat type ":" thefile)))
+
+       (let ((org-odt-suppress-xref nil))
+         (org-odt-format-link
+          (org-xml-format-desc desc) thefile attr)))))))
+
+(defun org-odt-format-heading (text level &optional id)
+  (let* ((text (if id (org-odt-format-target text id) text)))
+    (org-odt-format-tags
+     '("<text:h text:style-name=\"Heading_20_%s\" text:outline-level=\"%s\">" .
+       "</text:h>") text level level)))
+
+(defun org-odt-format-headline (title extra-targets tags
+                                           &optional snumber level)
+  (concat
+   (org-lparse-format 'EXTRA-TARGETS extra-targets)
+
+   ;; No need to generate section numbers. They are auto-generated by
+   ;; the application
+
+   ;; (concat (org-lparse-format 'SECTION-NUMBER snumber level) " ")
+   title
+   (and tags (concat (org-lparse-format 'SPACES 3)
+                    (org-lparse-format 'ORG-TAGS tags)))))
+
+(defun org-odt-format-anchor (text name &optional class)
+  (org-odt-format-target text name))
+
+(defun org-odt-format-bookmark (text id)
+  (if id
+      (org-odt-format-tags "<text:bookmark text:name=\"%s\"/>" text id)
+    text))
+
+(defun org-odt-format-target (text id)
+  (let ((name (concat org-export-odt-bookmark-prefix id)))
+    (concat
+     (and id (org-odt-format-tags
+             "<text:bookmark-start text:name=\"%s\"/>" "" name))
+     (org-odt-format-bookmark text id)
+     (and id (org-odt-format-tags
+             "<text:bookmark-end text:name=\"%s\"/>" "" name)))))
+
+(defun org-odt-format-footnote (n def)
+  (let ((id (concat  "fn" n))
+       (note-class "footnote")
+       (par-style "Footnote"))
+    (org-odt-format-tags
+     '("<text:note text:id=\"%s\" text:note-class=\"%s\">" .
+       "</text:note>")
+     (concat
+      (org-odt-format-tags
+       '("<text:note-citation>" . "</text:note-citation>")
+       n)
+      (org-odt-format-tags
+       '("<text:note-body>" . "</text:note-body>")
+       def))
+     id note-class)))
+
+(defun org-odt-format-footnote-reference (n def refcnt)
+  (if (= refcnt 1)
+      (org-odt-format-footnote n def)
+    (org-odt-format-footnote-ref n)))
+
+(defun org-odt-format-footnote-ref (n)
+  (let ((note-class "footnote")
+       (ref-format "text")
+       (ref-name (concat "fn" n)))
+    (org-odt-format-tags
+     '("<text:span text:style-name=\"%s\">" . "</text:span>")
+     (org-odt-format-tags
+      '("<text:note-ref text:note-class=\"%s\" text:reference-format=\"%s\" text:ref-name=\"%s\">" . "</text:note-ref>")
+      n note-class ref-format ref-name)
+     "OrgSuperscript")))
+
+(defun org-odt-get-image-name (file-name)
+  (require 'sha1)
+  (file-relative-name
+   (expand-file-name
+    (concat (sha1 file-name) "." (file-name-extension file-name)) "Pictures")))
+
+(defun org-export-odt-format-image (src href)
+  "Create image tag with source and attributes."
+  (save-match-data
+    (let* ((caption (org-find-text-property-in-string 'org-caption src))
+          (caption (and caption (org-xml-format-desc caption)))
+          (attr (org-find-text-property-in-string 'org-attributes src))
+          (label (org-find-text-property-in-string 'org-label src))
+          (latex-frag (org-find-text-property-in-string
+                       'org-latex-src src))
+          (category (and latex-frag "__DvipngImage__"))
+          (attr-plist (org-lparse-get-block-params attr))
+          (user-frame-anchor
+           (car (assoc-string (plist-get attr-plist :anchor)
+                              (if (or caption label)
+                                  '(("paragraph") ("page"))
+                                '(("character") ("paragraph") ("page"))) t)))
+          (user-frame-style
+           (and user-frame-anchor (plist-get attr-plist :style)))
+          (user-frame-attrs
+           (and user-frame-anchor (plist-get attr-plist :attributes)))
+          (user-frame-params
+           (list user-frame-style user-frame-attrs user-frame-anchor))
+          (embed-as (cond
+                     (latex-frag
+                      (symbol-name
+                       (or (org-find-text-property-in-string
+                            'org-latex-src-embed-type src) 'character)))
+                     (user-frame-anchor)
+                     (t "paragraph")))
+          (size (org-odt-image-size-from-file
+                 src (plist-get attr-plist :width)
+                 (plist-get attr-plist :height)
+                 (plist-get attr-plist :scale) nil embed-as))
+          (width (car size)) (height (cdr size)))
+      (when latex-frag
+       (setq href (org-propertize href :title "LaTeX Fragment"
+                                  :description latex-frag)))
+      (let ((frame-style-handle (concat (and (or caption label) "Captioned")
+                                       embed-as "Image")))
+       (org-odt-format-entity
+        frame-style-handle href width height
+        :caption caption :label label :category category
+        :user-frame-params user-frame-params)))))
+
+(defun org-odt-format-object-description (title description)
+  (concat (and title (org-odt-format-tags
+                     '("<svg:title>" . "</svg:title>")
+                     (org-odt-encode-plain-text title t)))
+         (and description (org-odt-format-tags
+                           '("<svg:desc>" . "</svg:desc>")
+                           (org-odt-encode-plain-text description t)))))
+
+(defun org-odt-format-frame (text width height style &optional
+                                 extra anchor-type)
+  (let ((frame-attrs
+        (concat
+         (if width (format " svg:width=\"%0.2fcm\"" width) "")
+         (if height (format " svg:height=\"%0.2fcm\"" height) "")
+         extra
+         (format " text:anchor-type=\"%s\"" (or anchor-type "paragraph")))))
+    (org-odt-format-tags
+     '("<draw:frame draw:style-name=\"%s\"%s>" . "</draw:frame>")
+     (concat text (org-odt-format-object-description
+                  (get-text-property 0 :title text)
+                  (get-text-property 0 :description text)))
+     style frame-attrs)))
+
+(defun org-odt-format-textbox (text width height style &optional
+                                   extra anchor-type)
+  (org-odt-format-frame
+   (org-odt-format-tags
+    '("<draw:text-box %s>" . "</draw:text-box>")
+    text (concat (format " fo:min-height=\"%0.2fcm\"" (or height .2))
+                (format " fo:min-width=\"%0.2fcm\"" (or width .2))))
+   width nil style extra anchor-type))
+
+(defun org-odt-format-inlinetask (heading content
+                                         &optional todo priority tags)
+  (org-odt-format-stylized-paragraph
+   nil (org-odt-format-textbox
+       (concat (org-odt-format-stylized-paragraph
+                "OrgInlineTaskHeading"
+                (org-lparse-format
+                 'HEADLINE (concat (org-lparse-format-todo todo) " " heading)
+                 nil tags))
+               content) nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\"")))
+
+(defvar org-odt-entity-frame-styles
+  '(("CharacterImage" "__Figure__" ("OrgInlineImage" nil "as-char"))
+    ("ParagraphImage" "__Figure__" ("OrgDisplayImage" nil "paragraph"))
+    ("PageImage" "__Figure__" ("OrgPageImage" nil "page"))
+    ("CaptionedParagraphImage" "__Figure__"
+     ("OrgCaptionedImage"
+      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
+     ("OrgImageCaptionFrame" nil "paragraph"))
+    ("CaptionedPageImage" "__Figure__"
+     ("OrgCaptionedImage"
+      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
+     ("OrgPageImageCaptionFrame" nil "page"))
+    ("InlineFormula" "__MathFormula__" ("OrgInlineFormula" nil "as-char"))
+    ("DisplayFormula" "__MathFormula__" ("OrgDisplayFormula" nil "as-char"))
+    ("CaptionedDisplayFormula" "__MathFormula__"
+     ("OrgCaptionedFormula" nil "paragraph")
+     ("OrgFormulaCaptionFrame" nil "as-char"))))
+
+(defun org-odt-merge-frame-params(default-frame-params user-frame-params)
+  (if (not user-frame-params) default-frame-params
+    (assert (= (length default-frame-params) 3))
+    (assert (= (length user-frame-params) 3))
+    (loop for user-frame-param in user-frame-params
+         for default-frame-param in default-frame-params
+         collect (or user-frame-param default-frame-param))))
+
+(defun* org-odt-format-entity (entity href width height
+                                     &key caption label category
+                                     user-frame-params)
+  (let* ((entity-style (assoc-string entity org-odt-entity-frame-styles t))
+        default-frame-params frame-params)
+    (cond
+     ((not (or caption label))
+      (setq default-frame-params (nth 2 entity-style))
+      (setq frame-params (org-odt-merge-frame-params
+                         default-frame-params user-frame-params))
+      (apply 'org-odt-format-frame href width height frame-params))
+     (t
+      (setq default-frame-params (nth 3 entity-style))
+      (setq frame-params (org-odt-merge-frame-params
+                         default-frame-params user-frame-params))
+      (apply 'org-odt-format-textbox
+            (org-odt-format-stylized-paragraph
+             'illustration
+             (concat
+              (apply 'org-odt-format-frame href width height
+                     (nth 2 entity-style))
+              (org-odt-format-entity-caption
+               label caption (or category (nth 1 entity-style)))))
+            width height frame-params)))))
+
+(defvar org-odt-embedded-images-count 0)
+(defun org-odt-copy-image-file (path)
+  "Returns the internal name of the file"
+  (let* ((image-type (file-name-extension path))
+        (media-type (format "image/%s" image-type))
+        (src-file (expand-file-name
+                   path (file-name-directory org-current-export-file)))
+        (target-dir "Images/")
+        (target-file
+         (format "%s%04d.%s" target-dir
+                 (incf org-odt-embedded-images-count) image-type)))
+    (when (not org-lparse-to-buffer)
+      (message "Embedding %s as %s ..."
+              (substring-no-properties path) target-file)
+
+      (when (= 1 org-odt-embedded-images-count)
+       (make-directory target-dir)
+       (org-odt-create-manifest-file-entry "" target-dir))
+
+      (copy-file src-file target-file 'overwrite)
+      (org-odt-create-manifest-file-entry media-type target-file))
+    target-file))
+
+(defvar org-export-odt-image-size-probe-method
+  '(emacs imagemagick force)
+  "Ordered list of methods by for determining size of an embedded
+  image.")
+
+(defvar org-export-odt-default-image-sizes-alist
+  '(("character" . (5 . 0.4))
+    ("paragraph" . (5 . 5)))
+  "Hardcoded image dimensions one for each of the anchor
+  methods.")
+
+;; A4 page size is 21.0 by 29.7 cms
+;; The default page settings has 2cm margin on each of the sides. So
+;; the effective text area is 17.0 by 25.7 cm
+(defvar org-export-odt-max-image-size '(17.0 . 20.0)
+  "Limiting dimensions for an embedded image.")
+
+(defun org-odt-do-image-size (probe-method file &optional dpi anchor-type)
+  (setq dpi (or dpi org-export-odt-pixels-per-inch))
+  (setq anchor-type (or anchor-type "paragraph"))
+  (flet ((size-in-cms (size-in-pixels)
+                     (flet ((pixels-to-cms (pixels)
+                                           (let* ((cms-per-inch 2.54)
+                                                  (inches (/ pixels dpi)))
+                                             (* cms-per-inch inches))))
+                       (and size-in-pixels
+                            (cons (pixels-to-cms (car size-in-pixels))
+                                  (pixels-to-cms (cdr size-in-pixels)))))))
+    (case probe-method
+      (emacs
+       (size-in-cms (ignore-errors (image-size (create-image file) 'pixels))))
+      (imagemagick
+       (size-in-cms
+       (let ((dim (shell-command-to-string
+                   (format "identify -format \"%%w:%%h\" \"%s\"" file))))
+         (when (string-match "\\([0-9]+\\):\\([0-9]+\\)" dim)
+           (cons (string-to-number (match-string 1 dim))
+                 (string-to-number (match-string 2 dim)))))))
+      (t
+       (cdr (assoc-string anchor-type
+                         org-export-odt-default-image-sizes-alist))))))
+
+(defun org-odt-image-size-from-file (file &optional user-width
+                                         user-height scale dpi embed-as)
+  (unless (file-name-absolute-p file)
+    (setq file (expand-file-name
+               file (file-name-directory org-current-export-file))))
+  (let* (size width height)
+    (unless (and user-height user-width)
+      (loop for probe-method in org-export-odt-image-size-probe-method
+           until size
+           do (setq size (org-odt-do-image-size
+                          probe-method file dpi embed-as)))
+      (or size (error "Cannot determine Image size. Aborting ..."))
+      (setq width (car size) height (cdr size)))
+    (cond
+     (scale
+      (setq width (* width scale) height (* height scale)))
+     ((and user-height user-width)
+      (setq width user-width height user-height))
+     (user-height
+      (setq width (* user-height (/ width height)) height user-height))
+     (user-width
+      (setq height (* user-width (/ height width)) width user-width))
+     (t (ignore)))
+    ;; ensure that an embedded image fits comfortably within a page
+    (let ((max-width (car org-export-odt-max-image-size))
+         (max-height (cdr org-export-odt-max-image-size)))
+      (when (or (> width max-width) (> height max-height))
+       (let* ((scale1 (/ max-width width))
+              (scale2 (/ max-height height))
+              (scale (min scale1 scale2)))
+         (setq width (* scale width) height (* scale height)))))
+    (cons width height)))
+
+(defvar org-odt-entity-labels-alist nil
+  "Associate Labels with the Labelled entities.
+Each element of the alist is of the form (LABEL-NAME
+CATEGORY-NAME SEQNO LABEL-STYLE-NAME).  LABEL-NAME is same as
+that specified by \"#+LABEL: ...\" line.  CATEGORY-NAME is the
+type of the entity that LABEL-NAME is attached to.  CATEGORY-NAME
+can be one of \"Table\", \"Figure\" or \"Equation\".  SEQNO is
+the unique number assigned to the referenced entity on a
+per-CATEGORY basis.  It is generated sequentially and is 1-based.
+LABEL-STYLE-NAME is a key `org-odt-label-styles'.
+
+See `org-odt-add-label-definition' and
+`org-odt-fixup-label-references'.")
+
+(defvar org-odt-entity-counts-plist nil
+  "Plist of running counters of SEQNOs for each of the CATEGORY-NAMEs.
+See `org-odt-entity-labels-alist' for known CATEGORY-NAMEs.")
+
+(defvar org-odt-label-styles
+  '(("text" "(%n)" "text" "(%n)")
+    ("category-and-value" "%e %n%c" "category-and-value" "%e %n"))
+  "Specify how labels are applied and referenced.
+This is an alist where each element is of the
+form (LABEL-STYLE-NAME LABEL-ATTACH-FMT LABEL-REF-MODE
+LABEL-REF-FMT).
+
+LABEL-ATTACH-FMT controls how labels and captions are attached to
+an entity.  It may contain following specifiers - %e, %n and %c.
+%e is replaced with the CATEGORY-NAME.  %n is replaced with
+\"<text:sequence ...> SEQNO </text:sequence>\".  %c is replaced
+with CAPTION. See `org-odt-format-label-definition'.
+
+LABEL-REF-MODE and LABEL-REF-FMT controls how label references
+are generated.  The following XML is generated for a label
+reference - \"<text:sequence-ref
+text:reference-format=\"LABEL-REF-MODE\" ...> LABEL-REF-FMT
+</text:sequence-ref>\".  LABEL-REF-FMT may contain following
+specifiers - %e and %n.  %e is replaced with the CATEGORY-NAME.
+%n is replaced with SEQNO. See
+`org-odt-format-label-reference'.")
+
+(defvar org-odt-category-map-alist
+  '(("__Table__" "Table" "category-and-value")
+    ("__Figure__" "Figure" "category-and-value")
+    ("__MathFormula__" "Equation" "text")
+    ("__DvipngImage__" "Equation" "category-and-value"))
+  "Map a CATEGORY-HANDLE to CATEGORY-NAME and LABEL-STYLE.
+This is an alist where each element is of the form
+\\(CATEGORY-HANDLE CATEGORY-NAME LABEL-STYLE\\).  CATEGORY_HANDLE
+could either be one of the internal handles (as seen above) or be
+derived from the \"#+LABEL:<label-name>\" specification.  See
+`org-export-odt-get-category-from-label'.  CATEGORY-NAME and
+LABEL-STYLE are used for generating ODT labels.  See
+`org-odt-label-styles'.")
+
+(defvar org-export-odt-user-categories
+  '("Illustration" "Table" "Text" "Drawing" "Equation" "Figure"))
+
+(defvar org-export-odt-get-category-from-label nil
+  "Should category of label be inferred from label itself.
+When this option is non-nil, a label is parsed in to two
+component parts delimited by a \":\" (colon) as shown here -
+#+LABEL:[CATEGORY-HANDLE:]EXTRA.  The CATEGORY-HANDLE is mapped
+to a CATEGORY-NAME and LABEL-STYLE using
+`org-odt-category-map-alist'.  (If no such map is provided and
+CATEGORY-NAME is set to CATEGORY-HANDLE and LABEL-STYLE is set to
+\"category-and-value\").  If CATEGORY-NAME so obtained is listed
+under `org-export-odt-user-categories' then the user specified
+styles are used.  Otherwise styles as determined by the internal
+CATEGORY-HANDLE is used.  See
+`org-odt-get-label-category-and-style' for details.")
+
+(defun org-odt-get-label-category-and-style (label default-category)
+  "See `org-export-odt-get-category-from-label'."
+  (let ((default-category-map
+         (assoc default-category org-odt-category-map-alist))
+       user-category user-category-map category)
+    (cond
+     ((not org-export-odt-get-category-from-label)
+      default-category-map)
+     ((not (setq user-category
+                (save-match-data
+                  (and (string-match "\\`\\(.*\\):.+" label)
+                       (match-string 1 label)))))
+      default-category-map)
+     (t
+      (setq user-category-map
+           (or (assoc user-category org-odt-category-map-alist)
+               (list nil user-category "category-and-value"))
+           category (nth 1 user-category-map))
+      (if (member category org-export-odt-user-categories)
+         user-category-map
+       default-category-map)))))
+
+(defun org-odt-add-label-definition (label default-category)
+  "Create an entry in `org-odt-entity-labels-alist' and return it."
+  (setq label (substring-no-properties label))
+  (let* ((label-props (org-odt-get-label-category-and-style
+                      label default-category))
+        (category (nth 1 label-props))
+        (counter category)
+        (label-style (nth 2 label-props))
+        (sequence-var (intern (mapconcat
+                               'downcase
+                               (org-split-string counter) "-")))
+        (seqno (1+ (or (plist-get org-odt-entity-counts-plist sequence-var)
+                       0)))
+        (label-props (list label category seqno label-style)))
+    (setq org-odt-entity-counts-plist
+         (plist-put org-odt-entity-counts-plist sequence-var seqno))
+    (push label-props org-odt-entity-labels-alist)
+    label-props))
+
+(defun org-odt-format-label-definition (caption label category seqno label-style)
+  (assert label)
+  (format-spec
+   (cadr (assoc-string label-style org-odt-label-styles t))
+   `((?e . ,category)
+     (?n . ,(org-odt-format-tags
+            '("<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">" . "</text:sequence>")
+            (format "%d" seqno) label category category))
+     (?c . ,(or (and caption (concat ": " caption)) "")))))
+
+(defun org-odt-format-label-reference (label category seqno label-style)
+  (assert label)
+  (save-match-data
+    (let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))
+          (fmt1 (car fmt))
+          (fmt2 (cadr fmt)))
+      (org-odt-format-tags
+       '("<text:sequence-ref text:reference-format=\"%s\" text:ref-name=\"%s\">"
+        . "</text:sequence-ref>")
+       (format-spec fmt2 `((?e . ,category)
+                          (?n . ,(format "%d" seqno)))) fmt1 label))))
+
+(defun org-odt-fixup-label-references ()
+  (goto-char (point-min))
+  (while (re-search-forward
+         "<text:sequence-ref text:ref-name=\"\\([^\"]+\\)\">[ \t\n]*</text:sequence-ref>"
+         nil t)
+    (let* ((label (match-string 1))
+          (label-def (assoc label org-odt-entity-labels-alist))
+          (rpl (and label-def
+                    (apply 'org-odt-format-label-reference label-def))))
+      (if rpl (replace-match rpl t t)
+       (org-lparse-warn
+        (format "Unable to resolve reference to label \"%s\"" label))))))
+
+(defun org-odt-format-entity-caption (label caption category)
+  (or (and label
+          (apply 'org-odt-format-label-definition
+                 caption (org-odt-add-label-definition label category)))
+      caption ""))
+
+(defun org-odt-format-tags (tag text &rest args)
+  (let ((prefix (when org-lparse-encode-pending "@"))
+       (suffix (when org-lparse-encode-pending "@")))
+    (apply 'org-lparse-format-tags tag text prefix suffix args)))
+
+(defvar org-odt-manifest-file-entries nil)
+(defun org-odt-init-outfile (filename)
+  (unless (executable-find "zip")
+    ;; Not at all OSes ship with zip by default
+    (error "Executable \"zip\" needed for creating OpenDocument files"))
+
+  (let* ((outdir (make-temp-file
+                 (format org-export-odt-tmpdir-prefix org-lparse-backend) t))
+        (content-file (expand-file-name "content.xml" outdir)))
+
+    ;; init conten.xml
+    (with-current-buffer (find-file-noselect content-file t))
+
+    ;; reset variables
+    (setq org-odt-manifest-file-entries nil
+         org-odt-embedded-images-count 0
+         org-odt-embedded-formulas-count 0
+         org-odt-entity-labels-alist nil
+         org-odt-entity-counts-plist nil)
+    content-file))
+
+(defcustom org-export-odt-prettify-xml nil
+  "Specify whether or not the xml output should be prettified.
+When this option is turned on, `indent-region' is run on all
+component xml buffers before they are saved.  Turn this off for
+regular use.  Turn this on if you need to examine the xml
+visually."
+  :group 'org-export-odt
+  :type 'boolean)
+
+(defvar hfy-user-sheet-assoc)          ; bound during org-do-lparse
+(defun org-odt-save-as-outfile (target opt-plist)
+  ;; write meta file
+  (org-odt-update-meta-file opt-plist)
+
+  ;; write styles file
+  (when (equal org-lparse-backend 'odt)
+    (org-odt-update-styles-file opt-plist))
+
+  ;; create mimetype file
+  (let ((mimetype (org-odt-write-mimetype-file org-lparse-backend)))
+    (org-odt-create-manifest-file-entry mimetype "/" "1.2"))
+
+  ;; create a manifest entry for content.xml
+  (org-odt-create-manifest-file-entry "text/xml" "content.xml")
+
+  ;; write out the manifest entries before zipping
+  (org-odt-write-manifest-file)
+
+  (let ((xml-files '("mimetype" "META-INF/manifest.xml" "content.xml"
+                    "meta.xml"))
+       (zipdir default-directory))
+    (when (equal org-lparse-backend 'odt)
+      (push "styles.xml" xml-files))
+    (message "Switching to directory %s" (expand-file-name zipdir))
+
+    ;; save all xml files
+    (mapc (lambda (file)
+           (with-current-buffer
+               (find-file-noselect (expand-file-name file) t)
+             ;; prettify output if needed
+             (when org-export-odt-prettify-xml
+               (indent-region (point-min) (point-max)))
+             (save-buffer 0)))
+         xml-files)
+
+    (let* ((target-name (file-name-nondirectory target))
+          (target-dir (file-name-directory target))
+          (cmds `(("zip" "-mX0" ,target-name "mimetype")
+                  ("zip" "-rmTq" ,target-name "."))))
+      (when (file-exists-p target)
+       ;; FIXME: If the file is locked this throws a cryptic error
+       (delete-file target))
+
+      (let ((coding-system-for-write 'no-conversion) exitcode err-string)
+       (message "Creating odt file...")
+       (mapc
+        (lambda (cmd)
+          (message "Running %s" (mapconcat 'identity cmd " "))
+          (setq err-string
+                (with-output-to-string
+                  (setq exitcode
+                        (apply 'call-process (car cmd)
+                               nil standard-output nil (cdr cmd)))))
+          (or (zerop exitcode)
+              (ignore (message "%s" err-string))
+              (error "Unable to create odt file (%S)" exitcode)))
+        cmds))
+
+      ;; move the file from outdir to target-dir
+      (rename-file target-name target-dir)
+
+      ;; kill all xml buffers
+      (mapc (lambda (file)
+             (kill-buffer
+              (find-file-noselect (expand-file-name file zipdir) t)))
+           xml-files)
+
+      (delete-directory zipdir)))
+  (message "Created %s" target)
+  (set-buffer (find-file-noselect target t)))
+
+(defconst org-odt-manifest-file-entry-tag
+  "
+<manifest:file-entry manifest:media-type=\"%s\" manifest:full-path=\"%s\"%s/>")
+
+(defun org-odt-create-manifest-file-entry (&rest args)
+  (push args org-odt-manifest-file-entries))
+
+(defun org-odt-write-manifest-file ()
+  (make-directory "META-INF")
+  (let ((manifest-file (expand-file-name "META-INF/manifest.xml")))
+    (with-current-buffer
+       (find-file-noselect manifest-file t)
+      (insert
+       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+     <manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\" manifest:version=\"1.2\">\n")
+      (mapc
+       (lambda (file-entry)
+        (let* ((version (nth 2 file-entry))
+               (extra (if version
+                          (format  " manifest:version=\"%s\"" version)
+                        "")))
+          (insert
+           (format org-odt-manifest-file-entry-tag
+                   (nth 0 file-entry) (nth 1 file-entry) extra))))
+       org-odt-manifest-file-entries)
+      (insert "\n</manifest:manifest>"))))
+
+(defun org-odt-update-meta-file (opt-plist)
+  (let ((date (org-odt-format-date (plist-get opt-plist :date)))
+       (author (or (plist-get opt-plist :author) ""))
+       (email (plist-get opt-plist :email))
+       (keywords (plist-get opt-plist :keywords))
+       (description (plist-get opt-plist :description))
+       (title (plist-get opt-plist :title)))
+    (write-region
+     (concat
+      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+     <office:document-meta
+         xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"
+         xmlns:xlink=\"http://www.w3.org/1999/xlink\"
+         xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
+         xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"
+         xmlns:ooo=\"http://openoffice.org/2004/office\"
+         office:version=\"1.2\">
+       <office:meta>" "\n"
+      (org-odt-format-author)
+      (org-odt-format-tags
+       '("\n<meta:initial-creator>" . "</meta:initial-creator>") author)
+      (org-odt-format-tags '("\n<dc:date>" . "</dc:date>") date)
+      (org-odt-format-tags
+       '("\n<meta:creation-date>" . "</meta:creation-date>") date)
+      (org-odt-format-tags '("\n<meta:generator>" . "</meta:generator>")
+                          (when org-export-creator-info
+                            (format "Org-%s/Emacs-%s"
+                                    org-version emacs-version)))
+      (org-odt-format-tags '("\n<meta:keyword>" . "</meta:keyword>") keywords)
+      (org-odt-format-tags '("\n<dc:subject>" . "</dc:subject>") description)
+      (org-odt-format-tags '("\n<dc:title>" . "</dc:title>") title)
+      "\n"
+      "  </office:meta>" "</office:document-meta>")
+     nil (expand-file-name "meta.xml")))
+
+  ;; create a manifest entry for meta.xml
+  (org-odt-create-manifest-file-entry "text/xml" "meta.xml"))
+
+(defun org-odt-update-styles-file (opt-plist)
+  ;; write styles file
+  (let ((styles-file (plist-get opt-plist :odt-styles-file)))
+    (org-odt-copy-styles-file (and styles-file
+                                  (read (org-trim styles-file)))))
+
+  ;; Update styles.xml - take care of outline numbering
+  (with-current-buffer
+      (find-file-noselect (expand-file-name "styles.xml") t)
+    ;; Don't make automatic backup of styles.xml file. This setting
+    ;; prevents the backedup styles.xml file from being zipped in to
+    ;; odt file. This is more of a hackish fix. Better alternative
+    ;; would be to fix the zip command so that the output odt file
+    ;; includes only the needed files and excludes any auto-generated
+    ;; extra files like backups and auto-saves etc etc. Note that
+    ;; currently the zip command zips up the entire temp directory so
+    ;; that any auto-generated files created under the hood ends up in
+    ;; the resulting odt file.
+    (set (make-local-variable 'backup-inhibited) t)
+
+    ;; Import local setting of `org-export-with-section-numbers'
+    (org-lparse-bind-local-variables opt-plist)
+    (org-odt-configure-outline-numbering
+     (if org-export-with-section-numbers org-export-headline-levels 0)))
+
+  ;; Write custom stlyes for source blocks
+  (org-odt-insert-custom-styles-for-srcblocks
+   (mapconcat
+    (lambda (style)
+      (format " %s\n" (cddr style)))
+    hfy-user-sheet-assoc "")))
+
+(defun org-odt-write-mimetype-file (format)
+  ;; create mimetype file
+  (let ((mimetype
+        (case format
+          (odt "application/vnd.oasis.opendocument.text")
+          (odf "application/vnd.oasis.opendocument.formula")
+          (t (error "Unknown OpenDocument backend %S" org-lparse-backend)))))
+    (write-region mimetype nil (expand-file-name "mimetype"))
+    mimetype))
+
+(defun org-odt-finalize-outfile ()
+  (org-odt-delete-empty-paragraphs))
+
+(defun org-odt-delete-empty-paragraphs ()
+  (goto-char (point-min))
+  (let ((open "<text:p[^>]*>")
+       (close "</text:p>"))
+    (while (re-search-forward (format "%s[ \r\n\t]*%s" open close) nil t)
+      (replace-match ""))))
+
+(defcustom org-export-odt-convert-processes
+  '(("BasicODConverter"
+     ("soffice" "-norestore" "-invisible" "-headless"
+      "\"macro:///BasicODConverter.Main.Convert(%I,%f,%O)\""))
+    ("unoconv"
+     ("unoconv" "-f" "%f" "-o" "%d" "%i")))
+  "Specify a list of document converters and their usage.
+The converters in this list are offered as choices while
+customizing `org-export-odt-convert-process'.
+
+This variable is an alist where each element is of the
+form (CONVERTER-NAME CONVERTER-PROCESS).  CONVERTER-NAME is name
+of the converter.  CONVERTER-PROCESS specifies the command-line
+syntax of the converter and is of the form (CONVERTER-PROGRAM
+ARG1 ARG2 ...).  CONVERTER-PROGRAM is the name of the executable.
+ARG1, ARG2 etc are command line options that are passed to
+CONVERTER-PROGRAM.  Format specifiers can be used in the ARGs and
+they are interpreted as below:
+
+%i input file name in full
+%I input file name as a URL
+%f format of the output file
+%o output file name in full
+%O output file name as a URL
+%d output dir in full
+%D output dir as a URL."
+  :group 'org-export-odt
+  :type
+  '(choice
+    (const :tag "None" nil)
+    (alist :tag "Converters"
+          :key-type (string :tag "Converter Name")
+          :value-type (group (cons (string :tag "Executable")
+                                   (repeat (string :tag "Command line args")))))))
+
+(defcustom org-export-odt-convert-process nil
+  "Use this converter to convert from \"odt\" format to other formats.
+During customization, the list of converter names are populated
+from `org-export-odt-convert-processes'."
+  :group 'org-export-odt
+  :type '(choice :convert-widget
+                (lambda (w)
+                  (apply 'widget-convert (widget-type w)
+                         (eval (car (widget-get w :args)))))
+                `((const :tag "None" nil)
+                  ,@(mapcar (lambda (c)
+                              `(const :tag ,(car c) ,(car c)))
+                            org-export-odt-convert-processes))))
+
+(defcustom org-export-odt-convert-capabilities
+  '(("Text"
+     ("odt" "ott" "doc" "rtf")
+     (("pdf" "pdf") ("odt" "odt") ("xhtml" "html") ("rtf" "rtf")
+      ("ott" "ott") ("doc" "doc") ("ooxml" "xml") ("html" "html")))
+    ("Web"
+     ("html" "xhtml") (("pdf" "pdf") ("odt" "txt") ("html" "html")))
+    ("Spreadsheet"
+     ("ods" "ots" "xls" "csv")
+     (("pdf" "pdf") ("ots" "ots") ("html" "html") ("csv" "csv")
+      ("ods" "ods") ("xls" "xls") ("xhtml" "xhtml") ("ooxml" "xml")))
+    ("Presentation"
+     ("odp" "otp" "ppt")
+     (("pdf" "pdf") ("swf" "swf") ("odp" "odp") ("xhtml" "xml")
+      ("otp" "otp") ("ppt" "ppt") ("odg" "odg") ("html" "html"))))
+  "Specify input and output formats of `org-export-odt-convert-process'.
+More correctly, specify the set of input and output formats that
+the user is actually interested in.
+
+This variable is an alist where each element is of the
+form (DOCUMENT-CLASS INPUT-FMT-LIST OUTPUT-FMT-ALIST).
+INPUT-FMT-LIST is a list of INPUT-FMTs.  OUTPUT-FMT-ALIST is an
+alist where each element is of the form (OUTPUT-FMT
+OUTPUT-FILE-EXTENSION).
+
+The variable is interpreted as follows:
+`org-export-odt-convert-process' can take any document that is in
+INPUT-FMT-LIST and produce any document that is in the
+OUTPUT-FMT-LIST.  A document converted to OUTPUT-FMT will have
+OUTPUT-FILE-EXTENSION as the file name extension.  OUTPUT-FMT
+serves dual purposes:
+- It is used for populating completion candidates during
+  `org-export-odt-convert' commands.
+- It is used as the value of \"%f\" specifier in
+  `org-export-odt-convert-process'.
+
+DOCUMENT-CLASS is used to group a set of file formats in
+INPUT-FMT-LIST in to a single class.
+
+Note that this variable inherently captures how LibreOffice based
+converters work.  LibreOffice maps documents of various formats
+to classes like Text, Web, Spreadsheet, Presentation etc and
+allow document of a given class (irrespective of it's source
+format) to be converted to any of the export formats associated
+with that class.
+
+See default setting of this variable for an typical
+configuration."
+  :group 'org-export-odt
+  :type
+  '(choice
+    (const :tag "None" nil)
+    (alist :key-type (string :tag "Document Class")
+          :value-type
+          (group (repeat :tag "Input formats" (string :tag "Input format"))
+                 (alist :tag "Output formats"
+                        :key-type (string :tag "Output format")
+                        :value-type
+                        (group (string :tag "Output file extension")))))))
+
+(declare-function org-create-math-formula "org"
+                 (latex-frag &optional mathml-file))
+
+;;;###autoload
+(defun org-export-odt-convert (&optional in-file out-fmt prefix-arg)
+  "Convert IN-FILE to format OUT-FMT using a command line converter.
+IN-FILE is the file to be converted.  If unspecified, it defaults
+to variable `buffer-file-name'.  OUT-FMT is the desired output
+format.  Use `org-export-odt-convert-process' as the converter.
+If PREFIX-ARG is non-nil then the newly converted file is opened
+using `org-open-file'."
+  (interactive
+   (append (org-lparse-convert-read-params) current-prefix-arg))
+  (org-lparse-do-convert in-file out-fmt prefix-arg))
+
+(defun org-odt-get (what &optional opt-plist)
+  (case what
+    (BACKEND 'odt)
+    (EXPORT-DIR (org-export-directory :html opt-plist))
+    (FILE-NAME-EXTENSION "odt")
+    (EXPORT-BUFFER-NAME "*Org ODT Export*")
+    (ENTITY-CONTROL org-odt-entity-control-callbacks-alist)
+    (ENTITY-FORMAT org-odt-entity-format-callbacks-alist)
+    (INIT-METHOD 'org-odt-init-outfile)
+    (FINAL-METHOD 'org-odt-finalize-outfile)
+    (SAVE-METHOD 'org-odt-save-as-outfile)
+    (CONVERT-METHOD
+     (and org-export-odt-convert-process
+         (cadr (assoc-string org-export-odt-convert-process
+                             org-export-odt-convert-processes t))))
+    (CONVERT-CAPABILITIES
+     (and org-export-odt-convert-process
+         (cadr (assoc-string org-export-odt-convert-process
+                             org-export-odt-convert-processes t))
+         org-export-odt-convert-capabilities))
+    (TOPLEVEL-HLEVEL 1)
+    (SPECIAL-STRING-REGEXPS org-export-odt-special-string-regexps)
+    (INLINE-IMAGES 'maybe)
+    (INLINE-IMAGE-EXTENSIONS '("png" "jpeg" "jpg" "gif" "svg"))
+    (PLAIN-TEXT-MAP '(("&" . "&amp;") ("<" . "&lt;") (">" . "&gt;")))
+    (TABLE-FIRST-COLUMN-AS-LABELS nil)
+    (FOOTNOTE-SEPARATOR (org-lparse-format 'FONTIFY "," 'superscript))
+    (CODING-SYSTEM-FOR-WRITE 'utf-8)
+    (CODING-SYSTEM-FOR-SAVE 'utf-8)
+    (t (error "Unknown property: %s"  what))))
+
+(defvar org-lparse-latex-fragment-fallback) ; set by org-do-lparse
+(defun org-export-odt-do-preprocess-latex-fragments ()
+  "Convert LaTeX fragments to images."
+  (let* ((latex-frag-opt (plist-get org-lparse-opt-plist :LaTeX-fragments))
+        (latex-frag-opt                ;  massage the options
+         (or (and (member latex-frag-opt '(mathjax t))
+                  (not (and (fboundp 'org-format-latex-mathml-available-p)
+                            (org-format-latex-mathml-available-p)))
+                  (prog1 org-lparse-latex-fragment-fallback
+                    (org-lparse-warn
+                     (concat
+                      "LaTeX to MathML converter not available. "
+                      (format "Using %S instead."
+                              org-lparse-latex-fragment-fallback)))))
+             latex-frag-opt))
+        cache-dir display-msg)
+    (cond
+     ((eq latex-frag-opt 'dvipng)
+      (setq cache-dir "ltxpng/")
+      (setq display-msg "Creating LaTeX image %s"))
+     ((member latex-frag-opt '(mathjax t))
+      (setq latex-frag-opt 'mathml)
+      (setq cache-dir "ltxmathml/")
+      (setq display-msg "Creating MathML formula %s")))
+    (when (and org-current-export-file)
+      (org-format-latex
+       (concat cache-dir (file-name-sans-extension
+                         (file-name-nondirectory org-current-export-file)))
+       org-current-export-dir nil display-msg
+       nil nil latex-frag-opt))))
+
+(defadvice org-format-latex-as-mathml
+  (after org-odt-protect-latex-fragment activate)
+  "Encode LaTeX fragment as XML.
+Do this when translation to MathML fails."
+  (when (or (not (> (length ad-return-value) 0))
+           (get-text-property 0 'org-protected ad-return-value))
+    (setq ad-return-value
+         (org-propertize (org-odt-encode-plain-text (ad-get-arg 0))
+                         'org-protected t))))
+
+(defun org-export-odt-preprocess-latex-fragments ()
+  (when (equal org-export-current-backend 'odt)
+    (org-export-odt-do-preprocess-latex-fragments)))
+
+(defun org-export-odt-preprocess-label-references ()
+  (goto-char (point-min))
+  (let (label label-components category value pretty-label)
+    (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
+      (org-if-unprotected-at (match-beginning 1)
+       (replace-match
+        (let ((org-lparse-encode-pending t)
+              (label (match-string 1)))
+          ;; markup generated below is mostly an eye-candy.  At
+          ;; pre-processing stage, there is no information on which
+          ;; entity a label reference points to.  The actual markup
+          ;; is generated as part of `org-odt-fixup-label-references'
+          ;; which gets called at the fag end of export.  By this
+          ;; time we would have seen and collected all the label
+          ;; definitions in `org-odt-entity-labels-alist'.
+          (org-odt-format-tags
+           '("<text:sequence-ref text:ref-name=\"%s\">" .
+             "</text:sequence-ref>")
+           "" (org-add-props label '(org-protected t)))) t t)))))
+
+;; process latex fragments as part of
+;; `org-export-preprocess-after-blockquote-hook'. Note that this hook
+;; is the one that is closest and well before the call to
+;; `org-export-attach-captions-and-attributes' in
+;; `org-export-preprocess-stirng'.  The above arrangement permits
+;; captions, labels and attributes to be attached to png images
+;; generated out of latex equations.
+(add-hook 'org-export-preprocess-after-blockquote-hook
+         'org-export-odt-preprocess-latex-fragments)
+
+(defun org-export-odt-preprocess (parameters)
+  (org-export-odt-preprocess-label-references))
+
+(declare-function archive-zip-extract "arc-mode.el" (archive name))
+(defun org-odt-zip-extract-one (archive member &optional target)
+  (require 'arc-mode)
+  (let* ((target (or target default-directory))
+        (archive (expand-file-name archive))
+        (archive-zip-extract
+         (list "unzip" "-qq" "-o" "-d" target))
+        exit-code command-output)
+    (setq command-output
+         (with-temp-buffer
+           (setq exit-code (archive-zip-extract archive member))
+           (buffer-string)))
+    (unless (zerop exit-code)
+      (message command-output)
+      (error "Extraction failed"))))
+
+(defun org-odt-zip-extract (archive members &optional target)
+  (when (atom members) (setq members (list members)))
+  (mapc (lambda (member)
+         (org-odt-zip-extract-one archive member target))
+       members))
+
+(defun org-odt-copy-styles-file (&optional styles-file)
+  ;; Non-availability of styles.xml is not a critical error. For now
+  ;; throw an error purely for aesthetic reasons.
+  (setq styles-file (or styles-file
+                       org-export-odt-styles-file
+                       (expand-file-name "OrgOdtStyles.xml"
+                                         org-odt-styles-dir)
+                       (error "org-odt: Missing styles file?")))
+  (cond
+   ((listp styles-file)
+    (let ((archive (nth 0 styles-file))
+         (members (nth 1 styles-file)))
+      (org-odt-zip-extract archive members)
+      (mapc
+       (lambda (member)
+        (when (org-file-image-p member)
+          (let* ((image-type (file-name-extension member))
+                 (media-type (format "image/%s" image-type)))
+            (org-odt-create-manifest-file-entry media-type member))))
+       members)))
+   ((and (stringp styles-file) (file-exists-p styles-file))
+    (let ((styles-file-type (file-name-extension styles-file)))
+      (cond
+       ((string= styles-file-type "xml")
+       (copy-file styles-file "styles.xml" t))
+       ((member styles-file-type '("odt" "ott"))
+       (org-odt-zip-extract styles-file "styles.xml")))))
+   (t
+    (error (format "Invalid specification of styles.xml file: %S"
+                  org-export-odt-styles-file))))
+
+  ;; create a manifest entry for styles.xml
+  (org-odt-create-manifest-file-entry "text/xml" "styles.xml"))
+
+(defvar org-export-odt-factory-settings
+  "d4328fb9d1b6cb211d4320ff546829f26700dc5e"
+  "SHA1 hash of OrgOdtStyles.xml.")
+
+(defun org-odt-configure-outline-numbering (level)
+  "Outline numbering is retained only upto LEVEL.
+To disable outline numbering pass a LEVEL of 0."
+  (goto-char (point-min))
+  (let ((regex
+        "<text:outline-level-style\\([^>]*\\)text:level=\"\\([^\"]*\\)\"\\([^>]*\\)>")
+       (replacement
+        "<text:outline-level-style\\1text:level=\"\\2\" style:num-format=\"\">"))
+    (while (re-search-forward regex nil t)
+      (when (> (string-to-number (match-string 2)) level)
+       (replace-match replacement t nil))))
+  (save-buffer 0))
+
+;;;###autoload
+(defun org-export-as-odf (latex-frag &optional odf-file)
+  "Export LATEX-FRAG as OpenDocument formula file ODF-FILE.
+Use `org-create-math-formula' to convert LATEX-FRAG first to
+MathML.  When invoked as an interactive command, use
+`org-latex-regexps' to infer LATEX-FRAG from currently active
+region.  If no LaTeX fragments are found, prompt for it.  Push
+MathML source to kill ring, if `org-export-copy-to-kill-ring' is
+non-nil."
+  (interactive
+   `(,(let (frag)
+       (setq frag (and (setq frag (and (region-active-p)
+                                       (buffer-substring (region-beginning)
+                                                         (region-end))))
+                       (loop for e in org-latex-regexps
+                             thereis (when (string-match (nth 1 e) frag)
+                                       (match-string (nth 2 e) frag)))))
+       (read-string "LaTeX Fragment: " frag nil frag))
+     ,(let ((odf-filename (expand-file-name
+                          (concat
+                           (file-name-sans-extension
+                            (or (file-name-nondirectory buffer-file-name)))
+                           "." "odf")
+                          (file-name-directory buffer-file-name))))
+       (message "default val is %s"  odf-filename)
+       (read-file-name "ODF filename: " nil odf-filename nil
+                       (file-name-nondirectory odf-filename)))))
+  (let* ((org-lparse-backend 'odf)
+        org-lparse-opt-plist
+        (filename (or odf-file
+                      (expand-file-name
+                       (concat
+                        (file-name-sans-extension
+                         (or (file-name-nondirectory buffer-file-name)))
+                        "." "odf")
+                       (file-name-directory buffer-file-name))))
+        (buffer (find-file-noselect (org-odt-init-outfile filename)))
+        (coding-system-for-write 'utf-8)
+        (save-buffer-coding-system 'utf-8))
+    (set-buffer buffer)
+    (set-buffer-file-coding-system coding-system-for-write)
+    (let ((mathml (org-create-math-formula latex-frag)))
+      (unless mathml (error "No Math formula created"))
+      (insert mathml)
+      (or (org-export-push-to-kill-ring
+          (upcase (symbol-name org-lparse-backend)))
+         (message "Exporting... done")))
+    (org-odt-save-as-outfile filename nil)))
+
+;;;###autoload
+(defun org-export-as-odf-and-open ()
+ "Export LaTeX fragment as OpenDocument formula and immediately open it.
+Use `org-export-as-odf' to read LaTeX fragment and OpenDocument
+formula file."
+  (interactive)
+  (org-lparse-and-open
+   nil nil nil (call-interactively 'org-export-as-odf)))
+
+(provide 'org-odt)
+
+;;; org-odt.el ends here
index cede736d92908788d7847731c0d1924647d7351a..44c51f95a5aaeacd7f026583ab2fc5075e2911a9 100644 (file)
@@ -6,7 +6,6 @@
 ;;         John Wiegley <johnw at gnu dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -276,6 +275,4 @@ Complete a language in the first field, the header arguments and switches."
 
 (provide 'org-pcomplete)
 
-
-
 ;;; org-pcomplete.el ends here
index 419467226c93483c8b387ac9e8d973929a3e0fe7..6238d49c3c6a7de526f8896d820cb6f326fa74a8 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -136,7 +135,7 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
   "Export the data in TABLE to DATA-FILE for gnuplot.
 This means in a format appropriate for grid plotting by gnuplot.
 PARAMS specifies which columns of TABLE should be plotted as independent
-and dependent variables."
+and dependant variables."
   (interactive)
   (let* ((ind (- (plist-get params :ind) 1))
         (deps (if (plist-member params :deps)
@@ -350,5 +349,4 @@ line directly before or after the table."
 
 (provide 'org-plot)
 
-
 ;;; org-plot.el ends here
index bbb93b07fc9d959ebbe18ed3c15e690b6e952681..8bda9556ab51b92b1a40b207a4cbcb180c9fd62a 100644 (file)
@@ -1,14 +1,14 @@
 ;;; org-protocol.el --- Intercept calls from emacsclient to trigger custom actions.
 ;;
-;; Copyright (C) 2008-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2008-2011
+;;          Free Software Foundation, Inc.
 ;;
-;; Author: Bastien Guerry <bzg AT altern DOT org>
+;; Author: Bastien Guerry <bzg AT gnu DOT org>
 ;; Author: Daniel M German <dmg AT uvic DOT org>
 ;; Author: Sebastian Rose <sebastian_rose AT gmx DOT de>
 ;; Author: Ross Patterson <me AT rpatterson DOT net>
 ;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
 ;; Keywords: org, emacsclient, wp
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 ;;
 (defgroup org-protocol nil
   "Intercept calls from emacsclient to trigger custom actions.
 
-This is done by advising `server-visit-files' to scan the list of filenames
-for `org-protocol-the-protocol' and sub-protocols defined in
+This is done by advising `server-visit-files' to scann the list of filenames
+for `org-protocol-the-protocol' and sub-procols defined in
 `org-protocol-protocol-alist' and `org-protocol-protocol-alist-default'."
   :version "22.1"
   :group 'convenience
@@ -644,5 +644,4 @@ project-plist is the CDR of an element in `org-publish-project-alist', reuse
 
 (provide 'org-protocol)
 
-
 ;;; org-protocol.el ends here
index 7a0d7b56e22c378d10e8a5b14008fba87582fe1e..228666b9724986fe7bd497108f56f8851c948e3b 100644 (file)
@@ -1,10 +1,9 @@
 ;;; org-publish.el --- publish related org-mode files as a website
-;; Copyright (C) 2006-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2006-2011 Free Software Foundation, Inc.
 
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 7.7
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -191,7 +190,7 @@ sitemap of files or summary page for a given project.
                            display folders first or last, respectively.
                            Any other value will mix files and folders.
   :sitemap-sort-files      The site map is normally sorted alphabetically.
-                           You can change this behavior setting this to
+                           You can change this behaviour setting this to
                            `chronologically', `anti-chronologically' or nil.
   :sitemap-ignore-case     Should sorting be case-sensitive?  Default nil.
 
@@ -278,12 +277,12 @@ in the sitemap."
   :type 'string)
 
 (defcustom org-publish-sitemap-file-entry-format "%t"
-  "How a sitemap file entry is formatted.
+  "How a sitemap file entry is formated.
 You could use brackets to delimit on what part the link will be.
 
 %t is the title.
 %a is the author.
-%d is the date formatted using `org-publish-sitemap-date-format'."
+%d is the date formated using `org-publish-sitemap-date-format'."
   :group 'org-publish
   :type 'string)
 
@@ -369,6 +368,8 @@ This is a compatibility function for Emacsen without `delete-dups'."
 
 (declare-function org-publish-delete-dups "org-publish" (list))
 (declare-function find-lisp-find-files "find-lisp" (directory regexp))
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Getting project information out of org-publish-project-alist
@@ -559,7 +560,7 @@ PUB-DIR is the publishing directory."
     (make-directory pub-dir t))
   (let ((visiting (find-buffer-visiting filename)))
     (save-excursion
-      (switch-to-buffer (or visiting (find-file filename)))
+      (org-pop-to-buffer-same-window (or visiting (find-file filename)))
       (let* ((plist (cons :buffer-will-be-killed (cons t plist)))
             (init-buf (current-buffer))
             (init-point (point))
@@ -599,6 +600,7 @@ PUB-DIR is the publishing directory."
                   org-export-preprocess-after-headline-targets-hook)
           org-export-preprocess-after-headline-targets-hook)))
      ,@body))
+(def-edebug-spec org-publish-with-aux-preprocess-maybe (body))
 
 (defvar project-plist)
 (defun org-publish-org-to-latex (plist filename pub-dir)
@@ -682,7 +684,7 @@ See `org-publish-projects'."
         (pub-dir
          (file-name-as-directory
           (file-truename
-           (or (plist-get project-plist :publishing-directory)
+           (or (eval (plist-get project-plist :publishing-directory))
                (error "Project %s does not have :publishing-directory defined"
                       (car project))))))
         tmp-pub-dir)
@@ -860,7 +862,7 @@ system's modification time.
 It returns time in `current-time' format."
   (let ((visiting (find-buffer-visiting file)))
     (save-excursion
-      (switch-to-buffer (or visiting (find-file-noselect file nil t)))
+      (org-pop-to-buffer-same-window (or visiting (find-file-noselect file nil t)))
       (let* ((plist (org-infile-export-plist))
             (date (plist-get plist :date)))
        (unless visiting
@@ -982,7 +984,9 @@ the project."
         main last-main letter last-letter file sub link tgext)
     ;; `files' contains the list of relative file names
     (dolist (file files)
-      (setq origfile (substring file 1 -1))
+      (setq origfile
+           (concat (file-name-directory file)
+                   (substring (file-name-nondirectory file) 1 -1)))
       (setq buf (find-file-noselect file))
       (with-current-buffer buf
        (goto-char (point-min))
@@ -993,7 +997,7 @@ the project."
       (kill-buffer buf))
     (setq index (sort index (lambda (a b) (string< (downcase (car a))
                                                   (downcase (car b))))))
-    (setq ibuffer (find-file-noselect (expand-file-name "theindex.org" directory)))
+    (setq ibuffer (find-file-noselect (expand-file-name "theindex.inc" directory)))
     (with-current-buffer ibuffer
       (erase-buffer)
       (insert "* Index\n")
@@ -1020,7 +1024,16 @@ the project."
            (insert "     - " link "\n")
          (insert "   - " link "\n")))
       (save-buffer))
-    (kill-buffer ibuffer)))
+    (kill-buffer ibuffer)
+    ;; Create theindex.org if it doesn't exist already
+    (let ((index-file (expand-file-name "theindex.org" directory)))
+      (unless (file-exists-p index-file)
+       (setq ibuffer (find-file-noselect index-file))
+       (with-current-buffer ibuffer
+         (erase-buffer)
+         (insert "\n\n#+include: \"theindex.inc\"\n\n")
+         (save-buffer))
+       (kill-buffer ibuffer)))))
 
 ;; Caching functions:
 
@@ -1103,7 +1116,7 @@ so that the file including them will be republished as well."
       (setq buf (find-file (expand-file-name filename)))
       (with-current-buffer buf
        (goto-char (point-min))
-       (while (re-search-forward "^#\\+INCLUDE:[ \t]+\"?\\([^ \t\"]*\\)\"?[ \t]*.*$" nil t)
+       (while (re-search-forward "^#\\+INCLUDE:[ \t]+\"?\\([^ \t\n\r\"]*\\)\"?[ \t]*.*$" nil t)
          (let* ((included-file (expand-file-name (match-string 1))))
            (add-to-list 'included-files-ctime
                         (org-publish-cache-ctime-of-src included-file) t))))
@@ -1114,7 +1127,7 @@ so that the file including them will be republished as well."
       (let ((ctime (org-publish-cache-ctime-of-src filename)))
        (or (< pstamp ctime)
            (when included-files-ctime
-             (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
+             (not (null (delq nil (mapcar (lambda(ct) (< ctime ct)) 
                                           included-files-ctime))))))))))
 
 (defun org-publish-cache-set-file-property (filename property value &optional project-name)
@@ -1180,6 +1193,4 @@ Returns value on success, else nil."
 
 (provide 'org-publish)
 
-
-
 ;;; org-publish.el ends here
index 8819f416f1d0fb2c8b8f5f0df990796bd71f4a45..f56b0723dbf8432fb13168cc68c7560f7395660f 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-remember.el --- Fast note taking in Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -40,6 +39,8 @@
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
 (declare-function remember-finalize "remember" ())
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 (defvar remember-save-after-remembering)
 (defvar remember-register)
@@ -63,7 +64,7 @@ and `org-remember-default-headline'.  To force prompting anyway, use
 \\[universal-argument] \\[org-remember-finalize] to file the note.
 
 When this variable is nil, \\[org-remember-finalize] gives you the prompts, and
-\\[universal-argument] \\[org-remember-finalize] triggers the fast track."
+\\[universal-argument] \\[org-remember-finalize] triggers the fasttrack."
   :group 'org-remember
   :type 'boolean)
 
@@ -786,7 +787,7 @@ The user is queried for the template."
       (setq heading org-remember-default-headline))
     (setq visiting (org-find-base-buffer-visiting file))
     (if (not visiting) (find-file-noselect file))
-    (switch-to-buffer (or visiting (get-file-buffer file)))
+    (org-pop-to-buffer-same-window (or visiting (get-file-buffer file)))
     (widen)
     (goto-char (point-min))
     (if (re-search-forward
@@ -942,7 +943,7 @@ See also the variable `org-reverse-note-order'."
        (throw 'quit t))
       ;; Find the file
       (with-current-buffer (or visiting (find-file-noselect file))
-       (unless (or (org-mode-p) (member heading '(top bottom)))
+       (unless (or (eq major-mode 'org-mode) (member heading '(top bottom)))
          (error "Target files for notes must be in Org-mode if not filing to top/bottom"))
        (save-excursion
          (save-restriction
@@ -952,7 +953,7 @@ See also the variable `org-reverse-note-order'."
            ;; Find the default location
            (when heading
              (cond
-              ((not (org-mode-p))
+              ((not (eq major-mode 'org-mode))
                (if (eq heading 'top)
                    (goto-char (point-min))
                  (goto-char (point-max))
@@ -1013,7 +1014,7 @@ See also the variable `org-reverse-note-order'."
                                        ; 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)
+           (cond ((org-at-heading-p t)
                   (org-back-to-heading t)
                   (setq level (funcall outline-level))
                   (cond
@@ -1122,7 +1123,7 @@ See also the variable `org-reverse-note-order'."
   (condition-case nil
       (require 'remember)
     (error
-     ;; Let's install our own micro version of remember
+     ;; Lets install our own micro version of remember
      (defvar remember-register ?R)
      (defvar remember-mode-hook nil)
      (defvar remember-handler-functions nil)
@@ -1150,6 +1151,5 @@ See also the variable `org-reverse-note-order'."
 
 (provide 'org-remember)
 
-
-
 ;;; org-remember.el ends here
+
index 1169c20698148929eb564e347a6822018e22cbbc..0437ce32ff19b0da5316ed3a20e1a36d502a8470 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-rmail.el --- Support for links to Rmail messages from within Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 
 (provide 'org-rmail)
 
-
-
 ;;; org-rmail.el ends here
index c09b27de895381e02439be6e2d5f1780e3db6b18..86caa4d4f09da0c16f25aade61e0fe3ec2a8cbc8 100644 (file)
@@ -1,6 +1,4 @@
-;;; org-special-blocks.el --- Turn blocks into LaTeX envs and HTML divs
-
-;; Copyright (C) 2009, 2011  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2011  Free Software Foundation, Inc.
 
 ;; Author: Chris Gray <chrismgray@gmail.com>
 
 ;; user to add this class to his or her stylesheet if this div is to
 ;; mean anything.
 
+(require 'org-html)
 (require 'org-compat)
 
+(declare-function org-open-par "org-html" ())
+(declare-function org-close-par-maybe "org-html" ())
+
 (defvar org-special-blocks-ignore-regexp "^\\(LaTeX\\|HTML\\)$"
   "A regexp indicating the names of blocks that should be ignored
 by org-special-blocks.  These blocks will presumably be
@@ -82,11 +84,15 @@ seen.  This is run after a few special cases are taken care of."
   "Converts the special cookies into div blocks."
   ;; Uses the dynamically-bound variable `line'.
   (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line)
-;    (org-close-par-maybe)
     (message "%s" (match-string 1))
-    (if (equal (match-string 2 line) "START")
-       (insert "<div class=\"" (match-string 1 line) "\">\n")
-      (insert "</div>\n"))
+    (when (equal (match-string 2 line) "START")
+      (org-close-par-maybe)
+      (insert "\n<div class=\"" (match-string 1 line) "\">")
+      (org-open-par))
+    (when (equal (match-string 2 line) "END")
+      (org-close-par-maybe)
+      (insert "\n</div>")
+      (org-open-par))
     (throw 'nextline nil)))
 
 (add-hook 'org-export-html-after-blockquotes-hook
index 5de55fa455fe61a086547ea0cc4526b6965b19c9..d605fb7525101199122ef2db9208641c56fc3f09 100644 (file)
@@ -1,13 +1,12 @@
 ;;; org-src.el --- Source code examples in Org
 ;;
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
-;;        Bastien Guerry <bzg AT altern DOT org>
+;;        Bastien Guerry <bzg AT gnu DOT org>
 ;;         Dan Davison <davison at stats dot ox dot ac dot uk>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -42,6 +41,8 @@
 (declare-function org-at-table.el-p "org" ())
 (declare-function org-get-indentation "org" (&optional line))
 (declare-function org-switch-to-buffer-other-window "org" (&rest args))
+(declare-function org-pop-to-buffer-same-window 
+                 "org-compat" (&optional buffer-or-name norecord label))
 
 (defcustom org-edit-src-region-extra nil
   "Additional regexps to identify regions for editing with `org-edit-src-code'.
@@ -152,7 +153,7 @@ but which mess up the display of a snippet in Org exported files.")
 (defcustom org-src-lang-modes
   '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist)
     ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql)
-    ("calc" . fundamental) ("C" . c))
+    ("calc" . fundamental) ("C" . c) ("cpp" . c++))
   "Alist mapping languages to their major mode.
 The key is the language name, the value is the string that should
 be inserted as the name of the major mode.  For many languages this is
@@ -214,7 +215,7 @@ buffer."
        (case-fold-search t)
        (info (org-edit-src-find-region-and-lang))
        (full-info (org-babel-get-src-block-info))
-       (org-mode-p (or (org-mode-p) (derived-mode-p 'org-mode)))
+       (org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
        (beg (make-marker))
        (end (make-marker))
        (allow-write-back-p (null code))
@@ -305,7 +306,7 @@ buffer."
             (error "Language mode `%s' fails with: %S" lang-f (nth 1 e)))))
        (dolist (pair transmitted-variables)
          (org-set-local (car pair) (cadr pair)))
-       (when org-mode-p
+       (when (eq major-mode 'org-mode)
          (goto-char (point-min))
          (while (re-search-forward "^," nil t)
            (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent)))
@@ -339,7 +340,7 @@ buffer."
 (defun org-src-switch-to-buffer (buffer context)
   (case org-src-window-setup
     ('current-window
-     (switch-to-buffer buffer))
+     (org-pop-to-buffer-same-window buffer))
     ('other-window
      (switch-to-buffer-other-window buffer))
     ('other-frame
@@ -350,7 +351,7 @@ buffer."
          (delete-frame frame)))
        ('save
        (kill-buffer (current-buffer))
-       (switch-to-buffer buffer))
+       (org-pop-to-buffer-same-window buffer))
        (t
        (switch-to-buffer-other-frame buffer))))
     ('reorganize-frame
@@ -362,7 +363,7 @@ buffer."
     (t
      (message "Invalid value %s for org-src-window-setup"
              (symbol-name org-src-window-setup))
-     (switch-to-buffer buffer))))
+     (org-pop-to-buffer-same-window buffer))))
 
 (defun org-src-construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer."
@@ -397,7 +398,7 @@ the fragment in the Org-mode buffer."
        (case-fold-search t)
        (msg (substitute-command-keys
              "Edit, then exit with C-c ' (C-c and single quote)"))
-       (org-mode-p (org-mode-p))
+       (org-mode-p (eq major-mode 'org-mode))
        (beg (make-marker))
        (end (make-marker))
        (preserve-indentation org-src-preserve-indentation)
@@ -422,7 +423,7 @@ the fragment in the Org-mode buffer."
            begline (save-excursion (goto-char beg) (org-current-line)))
       (if (and (setq buffer (org-edit-src-find-buffer beg end))
               (y-or-n-p "Return to existing edit buffer? [n] will revert changes: "))
-         (switch-to-buffer buffer)
+         (org-pop-to-buffer-same-window buffer)
        (when buffer
          (with-current-buffer buffer
            (if (boundp 'org-edit-src-overlay)
@@ -442,7 +443,7 @@ the fragment in the Org-mode buffer."
                           (define-key map [mouse-1] 'org-edit-src-continue)
                           map))
        (overlay-put ovl :read-only "Leave me alone")
-       (switch-to-buffer buffer)
+       (org-pop-to-buffer-same-window buffer)
        (insert code)
        (remove-text-properties (point-min) (point-max)
                                '(display nil invisible nil intangible nil))
@@ -616,7 +617,7 @@ the language, a switch telling if the content should be in a single line."
       (when (org-bound-and-true-p org-edit-src-from-org-mode)
        (goto-char (point-min))
        (while (re-search-forward
-               (if (org-mode-p) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
+               (if (eq major-mode 'org-mode) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
          (if (eq (org-current-line) line) (setq delta (1+ delta)))
          (replace-match ",\\1")))
       (when (org-bound-and-true-p org-edit-src-picture)
@@ -715,6 +716,7 @@ the language, a switch telling if the content should be in a single line."
         (with-current-buffer (marker-buffer beg-marker)
           (goto-char (marker-position beg-marker))
           ,@body))))
+(def-edebug-spec org-src-do-at-code-block (body))
 
 (defun org-src-do-key-sequence-at-code-block (&optional key)
   "Execute key sequence at code block in the source Org buffer.
@@ -811,5 +813,4 @@ LANG is a string, and the returned major mode is a symbol."
 
 (provide 'org-src)
 
-
 ;;; org-src.el ends here
index cf28a5e80ae95a8f2e48eea723b97969c8940f4c..3bb645bbd2b8f5a43122d7e1131e1bbc6736edf9 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-table.el --- The table editor for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -51,7 +50,7 @@
 (defvar orgtbl-after-send-table-hook nil
   "Hook for functions attaching to `C-c C-c', if the table is sent.
 This can be used to add additional functionality after the table is sent
-to the receiver position, otherwise, if table is not sent, the functions
+to the receiver position, othewise, if table is not sent, the functions
 are not run.")
 
 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
@@ -242,6 +241,14 @@ days."
                 (symbol :tag "Hours  " 'hours)
                 (symbol :tag "Days   " 'days)))
 
+(defcustom org-table-formula-field-format "%s"
+  "Format for fields which contain the result of a formula.
+For example, using \"~%s~\" will display the result within tilde
+characters.  Beware that modifying the display can prevent the
+field from being used in another formula."
+  :group 'org-table-settings
+  :type 'string)
+
 (defcustom org-table-formula-evaluate-inline t
   "Non-nil means TAB and RET evaluate a formula in current table field.
 If the current field starts with an equal sign, it is assumed to be a formula
@@ -816,23 +823,13 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
                              (append (pop fields) emptystrings))
                   hfmt))
               lines ""))
-    (if (equal (char-before) ?\n)
-       ;; This hack is for org-indent, to force redisplay of the
-       ;; line prefix of the first line. Apparently the redisplay
-       ;; is tied to the newline, which is, I think, a bug.
-       ;; To force this redisplay, we remove and re-insert the
-       ;; newline, so that the redisplay engine thinks it belongs
-       ;; to the changed text.
-       (progn
-         (backward-delete-char 1)
-         (insert "\n")))
     (move-marker org-table-aligned-begin-marker (point))
     (insert new)
     ;; Replace the old one
     (delete-region (point) end)
     (move-marker end nil)
     (move-marker org-table-aligned-end-marker (point))
-    (when (and orgtbl-mode (not (org-mode-p)))
+    (when (and orgtbl-mode (not (eq major-mode 'org-mode)))
       (goto-char org-table-aligned-begin-marker)
       (while (org-hide-wide-columns org-table-aligned-end-marker)))
     ;; Try to move to the old location
@@ -1302,7 +1299,7 @@ However, when FORCE is non-nil, create new columns if necessary."
 (defun org-table-line-to-dline (line &optional above)
   "Turn a buffer line number into a data line number.
 If there is no data line in this line, return nil.
-If there is no matching dline (most likely the reference was a hline), the
+If there is no matchin dline (most likely te refrence was a hline), the
 first dline below it is used.  When ABOVE is non-nil, the one above is used."
   (catch 'exit
     (let ((ll (length org-table-dlines))
@@ -1729,6 +1726,34 @@ blindly applies a recipe that works for simple tables."
            (replace-match "-+"))
          (goto-char beg)))))
 
+(defun org-table-transpose-table-at-point ()
+  "Transpose orgmode table at point and eliminate hlines.
+So a table like
+
+| 1 | 2 | 4 | 5 |
+|---+---+---+---|
+| a | b | c | d |
+| e | f | g | h |
+
+will be transposed as
+
+| 1 | a | e |
+| 2 | b | f |
+| 4 | c | g |
+| 5 | d | h |
+
+Note that horizontal lines disappeared."
+  (interactive)
+  (let ((contents
+         (apply #'mapcar* #'list
+                ;; remove 'hline from list
+               (delq nil (mapcar (lambda (x) (when (listp x) x))
+                                 (org-table-to-lisp))))))
+    (delete-region (org-table-begin) (org-table-end))
+    (insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) "  |\n" ))
+                       contents ""))
+    (org-table-align)))
+
 (defun org-table-wrap-region (arg)
   "Wrap several fields in a column like a paragraph.
 This is useful if you'd like to spread the contents of a field over several
@@ -2147,7 +2172,10 @@ For all numbers larger than LIMIT, shift them by DELTA."
        (when remove
          (while (re-search-forward re2 (point-at-eol) t)
            (unless (save-match-data (org-in-regexp "remote([^)]+?)"))
-             (replace-match ""))))
+             (if (equal (char-before (match-beginning 0)) ?.)
+                 (error "Change makes TBLFM term %s invalid.  Use undo to recover."
+                        (match-string 0))
+               (replace-match "")))))
        (while (re-search-forward re (point-at-eol) t)
          (unless (save-match-data (org-in-regexp "remote([^)]+?)"))
            (setq s (match-string 1) n (string-to-number s))
@@ -2177,7 +2205,7 @@ For all numbers larger than LIMIT, shift them by DELTA."
              cnt 1)
        (while (setq name (pop names))
          (setq cnt (1+ cnt))
-         (if (string-match "^[a-zA-Z][a-zA-Z0-9]*$" name)
+         (if (string-match "^[a-zA-Z][_a-zA-Z0-9]*$" name)
              (push (cons name (int-to-string cnt)) org-table-column-names))))
       (setq org-table-column-names (nreverse org-table-column-names))
       (setq org-table-column-name-regexp
@@ -2201,10 +2229,10 @@ For all numbers larger than LIMIT, shift them by DELTA."
        (while (and fields1 (setq field (pop fields)))
          (setq v (pop fields1) col (1+ col))
          (when (and (stringp field) (stringp v)
-                    (string-match "^[a-zA-Z][a-zA-Z0-9]*$" field))
+                    (string-match "^[a-zA-Z][_a-zA-Z0-9]*$" field))
              (push (cons field v) org-table-local-parameters)
              (push (list field line col) org-table-named-field-locations))))
-      ;; Analyze the line types
+      ;; Analyse the line types
       (goto-char beg)
       (setq org-table-current-begin-line (org-current-line)
            org-table-current-begin-pos (point)
@@ -2408,7 +2436,8 @@ not overwrite the stored one."
           (modes (copy-sequence org-calc-default-modes))
           (numbers nil) ; was a variable, now fixed default
           (keep-empty nil)
-          n form form0 formrpl formrg bw fmt x ev orig c lispp literal duration)
+          n form form0 formrpl formrg bw fmt x ev orig c lispp literal 
+          duration duration-output-format)
       ;; Parse the format string.  Since we have a lot of modes, this is
       ;; a lot of work.  However, I think calc still uses most of the time.
       (if (string-match ";" formula)
@@ -2432,7 +2461,7 @@ not overwrite the stored one."
                      duration-output-format nil
                      fmt (replace-match "" t t fmt)))
            (if (string-match "t" fmt)
-               (setq duration t
+               (setq duration t 
                      duration-output-format org-table-duration-custom-format
                      numbers t
                      fmt (replace-match "" t t fmt)))
@@ -2500,7 +2529,7 @@ not overwrite the stored one."
        ;; Insert complex ranges
        (while (and (string-match org-table-range-regexp form)
                    (> (length (match-string 0 form)) 1))
-         (setq formrg (save-match-data
+         (setq formrg (save-match-data 
                         (org-table-get-range (match-string 0 form) nil n0)))
          (setq formrpl
                (save-match-data
@@ -2579,7 +2608,8 @@ $1->    %s\n" orig formula form0 form))
            (message "")))
        (if (listp ev) (setq fmt nil ev "#ERROR"))
        (org-table-justify-field-maybe
-        (if fmt (format fmt (string-to-number ev)) ev))
+        (format org-table-formula-field-format
+                (if fmt (format fmt (string-to-number ev)) ev)))
        (if (and down (> ndown 0) (looking-at ".*\n[ \t]*|[^-]"))
            (call-interactively 'org-return)
          (setq ndown 0)))
@@ -2641,7 +2671,7 @@ in the buffer and column1 and column2 are table column numbers."
            (prog1 (org-trim (org-table-get-field c1))
              (if highlight (org-table-highlight-rectangle (point) (point)))))
        ;; A range, return a vector
-       ;; First sort the numbers to get a regular rectangle
+       ;; First sort the numbers to get a regular ractangle
        (if (< r2 r1) (setq tmp r1 r1 r2 r2 tmp))
        (if (< c2 c1) (setq tmp c1 c1 c2 c2 tmp))
        (if corners-only
@@ -2901,7 +2931,7 @@ known that the table will be realigned a little later anyway."
 
 (defun org-table-iterate (&optional arg)
   "Recalculate the table until it does not change anymore.
-The maximum number of iterations is 10, but you can chose a different value
+The maximun number of iterations is 10, but you can chose a different value
 with the prefix ARG."
   (interactive "P")
   (let ((imax (if arg (prefix-numeric-value arg) 10))
@@ -2962,7 +2992,7 @@ them to individual field equations for each field."
        ((string-match "^@-?[-+I0-9]+\\$-?[0-9]+$" lhs)
        ;; This just refers to one fixed field
        (push e res))
-       ((string-match "^[a-zA-Z][a-zA-Z0-9]*$" lhs)
+       ((string-match "^[a-zA-Z][_a-zA-Z0-9]*$" lhs)
        ;; This just refers to one fixed named field
        (push e res))
        ((string-match "^@[0-9]+$" lhs)
@@ -2993,20 +3023,24 @@ when a line/row is swapped out of that privileged position.  So for
 formulas that use a range of rows or columns, it may often be better
 to anchor the formula with \"I\" row markers, or to offset from the
 borders of the table using the @< @> $< $> makers."
-  (let (n nmax len char)
-    (while (string-match "\\([@$]\\)\\(<+\\|>+\\)" s)
-      (setq nmax (if (equal (match-string 1 s) "@")
-                    (1- (length org-table-dlines))
-                  org-table-current-ncol)
-           len (- (match-end 2) (match-beginning 2))
-           char (string-to-char (match-string 2 s))
-           n (if (= char ?<)
-                 len
-               (- nmax len -1)))
-      (if (or (< n 1) (> n nmax))
-         (error "Reference \"%s\" in expression \"%s\" points outside table"
-                (match-string 0 s) s))
-      (setq s (replace-match (format "%s%d" (match-string 1 s) n) t t s))))
+  (let (n nmax len char (start 0))
+    (while (string-match "\\([@$]\\)\\(<+\\|>+\\)\\|\\(remote([^\)]+)\\)"
+                        s start)
+      (if (match-end 3)
+         (setq start (match-end 3))
+       (setq nmax (if (equal (match-string 1 s) "@")
+                      (1- (length org-table-dlines))
+                    org-table-current-ncol)
+             len (- (match-end 2) (match-beginning 2))
+             char (string-to-char (match-string 2 s))
+             n (if (= char ?<)
+                   len
+                 (- nmax len -1)))
+       (if (or (< n 1) (> n nmax))
+           (error "Reference \"%s\" in expression \"%s\" points outside table"
+                  (match-string 0 s) s))
+       (setq start (match-beginning 0))
+       (setq s (replace-match (format "%s%d" (match-string 1 s) n) t t s)))))
   s)
 
 (defun org-table-formula-substitute-names (f)
@@ -3241,7 +3275,7 @@ For example:  28 -> AB."
   "Convert a time string into numerical duration in seconds.
 S can be a string matching either -?HH:MM:SS or -?HH:MM.
 If S is a string representing a number, keep this number."
-  (let (hour min sec res)
+  (let (hour minus min sec res)
     (cond
      ((and (string-match "\\(-?\\)\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\)" s))
       (setq minus (< 0 (length (match-string 1 s)))
@@ -3806,7 +3840,7 @@ Use COMMAND to do the motion, repeat if necessary to end up in a data line."
   :lighter " OrgTbl" :keymap orgtbl-mode-map
   (org-load-modules-maybe)
   (cond
-   ((org-mode-p)
+   ((eq major-mode 'org-mode)
     ;; Exit without error, in case some hook functions calls this
     ;; by accident in org-mode.
     (message "Orgtbl-mode is not useful in org-mode, command ignored"))
@@ -3901,6 +3935,7 @@ to execute outside of tables."
           ("\C-c\C-w"           org-table-cut-region)
           ("\C-c\M-w"           org-table-copy-region)
           ("\C-c\C-y"           org-table-paste-rectangle)
+          ("\C-c\C-w"           org-table-wrap-region)
           ("\C-c-"              org-table-insert-hline)
           ("\C-c}"              org-table-toggle-coordinate-overlays)
           ("\C-c{"              org-table-toggle-formula-debugger)
@@ -4675,6 +4710,8 @@ The return value is either a single string for a single field, or a
 list of the fields in the rectangle ."
   (save-match-data
     (let ((id-loc nil)
+         ;; Protect a bunch of variables from being overwritten
+         ;; by the context of the remote table
          org-table-column-names org-table-column-name-regexp
          org-table-local-parameters org-table-named-field-locations
          org-table-current-line-types org-table-current-begin-line
@@ -4711,7 +4748,8 @@ list of the fields in the rectangle ."
                  (error "Cannot find a table at NAME or ID %s" name-or-id))
                (setq tbeg (point-at-bol))
                (org-table-get-specials)
-               (setq form (org-table-formula-substitute-names form))
+               (setq form (org-table-formula-substitute-names
+                           (org-table-formula-handle-first/last-rc form)))
                (if (and (string-match org-table-range-regexp form)
                         (> (length (match-string 0 form)) 1))
                    (save-match-data
@@ -4720,6 +4758,5 @@ list of the fields in the rectangle ."
 
 (provide 'org-table)
 
-
-
 ;;; org-table.el ends here
+
index 45b16aecf1232832b7d47c5408703c7c5e1758a0..78b38be57ab7976d7f7b153420bbba2c23c9ee6a 100644 (file)
@@ -4,7 +4,6 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-taskjuggler.el
-;; Version: 7.7
 ;; Author: Christian Egli
 ;; Maintainer: Christian Egli
 ;; Keywords: org, taskjuggler, project planning
@@ -70,7 +69,7 @@
 ;; "taskjuggler_project" (or whatever you customized
 ;; `org-export-taskjuggler-project-tag' to). You are now ready to
 ;; export the project plan with `org-export-as-taskjuggler-and-open'
-;; which will export the project plan and open a Gantt chart in
+;; which will export the project plan and open a gant chart in
 ;; TaskJugglerUI.
 ;;
 ;; * Resources
@@ -278,6 +277,7 @@ defined in `org-export-taskjuggler-default-reports'."
                      (file-name-nondirectory buffer-file-name))
                     org-export-taskjuggler-extension)))
         (buffer (find-file-noselect filename))
+        (old-buffer (current-buffer))
         (org-export-taskjuggler-old-level 0)
         task resource)
     (unless tasks
@@ -305,6 +305,7 @@ defined in `org-export-taskjuggler-default-reports'."
        (setcar tasks (push (cons "version" version) task))))
     (with-current-buffer buffer
       (erase-buffer)
+      (org-clone-local-variables old-buffer "^org-")
       (org-taskjuggler-open-project (car tasks))
       (insert org-export-taskjuggler-default-global-properties)
       (insert "\n")
@@ -354,8 +355,8 @@ information, all the properties, etc."
   (let* ((props (org-entry-properties))
         (components (org-heading-components))
         (level (nth 1 components))
-        (headline
-         (replace-regexp-in-string
+        (headline 
+         (replace-regexp-in-string 
           "\"" "\\\"" (nth 4 components) t t)) ; quote double quotes in headlines
         (parent-ordered (org-taskjuggler-parent-is-ordered-p)))
     (push (cons "level" level) props)
@@ -405,10 +406,10 @@ deeper), then it's not a leaf."
            (successor (car (cdr tasks))))
        (cond
         ;; if a task has no successors it is a leaf
-        ((null successor)
+        ((null successor) 
          (push (cons (cons "leaf-node" t) task) new-list))
         ;; if the successor has a lower level than task it is a leaf
-        ((<= (cdr (assoc "level" successor)) (cdr (assoc "level" task)))
+        ((<= (cdr (assoc "level" successor)) (cdr (assoc "level" task))) 
          (push (cons (cons "leaf-node" t) task) new-list))
         ;; otherwise examine the rest of the tasks
         (t (push task new-list))))
@@ -571,7 +572,7 @@ with separator \"\n\"."
     (and filtered-items (mapconcat 'identity filtered-items "\n"))))
 
 (defun org-taskjuggler-get-attributes (item attributes)
-  "Return all attributes as a single formatted string. ITEM is an
+  "Return all attribute as a single formated string. ITEM is an
 alist representing either a resource or a task. ATTRIBUTES is a
 list of symbols. Only entries from ITEM are considered that are
 listed in ATTRIBUTES."
index b8fbc4ff3886c55913e86d274d31ef8f4ec70b8c..ef5dba68afe7fd9080534e354d673aa371d010f3 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -373,7 +372,7 @@ replace any running timer."
                     (org-show-entry)
                     (or (ignore-errors (org-get-heading))
                         (concat "File:" (file-name-nondirectory (buffer-file-name)))))))
-               ((org-mode-p)
+               ((eq major-mode 'org-mode)
                 (or (ignore-errors (org-get-heading))
                     (concat "File:" (file-name-nondirectory (buffer-file-name)))))
                (t (error "Not in an Org buffer"))))
@@ -403,6 +402,4 @@ replace any running timer."
 
 (provide 'org-timer)
 
-
-
 ;;; org-timer.el ends here
index d0991b8111672248f8a5661cc3fe628d89323ecd..42870e9ebf801a8079a7fa0e7768035554844430 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-vm.el --- Support for links to VM messages from within Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 
 (provide 'org-vm)
 
-
-
 ;;; org-vm.el ends here
index bce90092e6e99554220b7584b4d58190d7a191b8..89128dd217a5e9b48d2d7e3e60f1c175e864e9ed 100644 (file)
@@ -5,7 +5,6 @@
 ;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -168,6 +167,4 @@ Return t if there is no previous link; otherwise, return nil."
 
 (provide 'org-w3m)
 
-
-
 ;;; org-w3m.el ends here
index 9bc49c8b91ab801232ef7820e655b42975524704..7457cfe855b766695d157815e308acc8c8f99ef8 100644 (file)
@@ -1,12 +1,11 @@
 ;;; org-wl.el --- Support for links to Wanderlust messages from within Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;;         David Maus <dmaus at ictsoc dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -309,6 +308,4 @@ for namazu index."
 
 (provide 'org-wl)
 
-
-
 ;;; org-wl.el ends here
index 02f351fe724944c8b0a5f26830011d5d9178f9d5..4cb3840d32b1b9b8b1b9ab4cea0b2d749efb4820 100644 (file)
@@ -1,11 +1,10 @@
 ;;; org-xoxo.el --- XOXO export for Org-mode
 
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -123,5 +122,4 @@ The XOXO buffer is named *xoxo-<source buffer name>*"
 
 (provide 'org-xoxo)
 
-
 ;;; org-xoxo.el ends here
index 8aca74e69cc0eccd33bc3b8f6674b99629fbbc37..7163e8f03fc455741f744c1717d4eb33348f09e8 100644 (file)
@@ -1,11 +1,12 @@
 ;;; org.el --- Outline-based notes management and organizer
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2004-2011 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
+;; Maintainer: Bastien Guerry <bzg at gnu dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.7
+;; Version: 7.8.02
 ;;
 ;; This file is part of GNU Emacs.
 ;;
 (declare-function org-inlinetask-at-task-p "org-inlinetask" ())
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function org-inlinetask-toggle-visibility "org-inlinetask" ())
+(declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
 (declare-function org-at-clock-log-p "org-clock" ())
 (declare-function org-clock-timestamps-up "org-clock" ())
 (declare-function org-clock-timestamps-down "org-clock" ())
@@ -162,6 +164,7 @@ requirements) is loaded."
                 (const :tag "Ditaa" ditaa)
                 (const :tag "Dot" dot)
                 (const :tag "Emacs Lisp" emacs-lisp)
+                (const :tag "Fortran" fortran)
                 (const :tag "Gnuplot" gnuplot)
                 (const :tag "Haskell" haskell)
                 (const :tag "Java" java)
@@ -176,6 +179,7 @@ requirements) is loaded."
                 (const :tag "Octave" octave)
                 (const :tag "Org" org)
                 (const :tag "Perl" perl)
+                (const :tag "Pico Lisp" picolisp)
                 (const :tag "PlantUML" plantuml)
                 (const :tag "Python" python)
                 (const :tag "Ruby" ruby)
@@ -183,6 +187,7 @@ requirements) is loaded."
                 (const :tag "Scheme" scheme)
                 (const :tag "Screen" screen)
                 (const :tag "Shell Script" sh)
+                (const :tag "Shen" shen)
                 (const :tag "Sql" sql)
                 (const :tag "Sqlite" sqlite))
                :value-type (boolean :tag "Activate" :value t)))
@@ -198,7 +203,7 @@ identifier."
 
 ;;; Version
 
-(defconst org-version "7.7"
+(defconst org-version "7.8.02"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -249,6 +254,11 @@ With prefix arg HERE, insert it at point."
   :group 'org
   :type 'hook)
 
+(defcustom org-log-buffer-setup-hook nil
+  "Hook that is run after an Org log buffer is created."
+  :group 'org
+  :type 'hook)
+
 (defvar org-modules)  ; defined below
 (defvar org-modules-loaded nil
   "Have the modules been loaded already?")
@@ -338,7 +348,6 @@ to add the symbol `xyz', and the package must have a call to
        (const :tag "C  mac-link-grabber   Grab links and URLs from various Mac applications" org-mac-link-grabber)
        (const :tag "C  man:               Support for links to manpages in Org-mode" org-man)
        (const :tag "C  mtags:             Support for muse-like tags" org-mtags)
-       (const :tag "C  odt:               OpenDocumentText exporter for Org-mode" org-odt)
        (const :tag "C  panel:             Simple routines for us with bad memory" org-panel)
        (const :tag "C  registry:          A registry for Org-mode links" org-registry)
        (const :tag "C  org2rem:           Convert org appointments into reminders" org2rem)
@@ -354,12 +363,12 @@ to add the symbol `xyz', and the package must have a call to
 (defcustom org-support-shift-select nil
   "Non-nil means make shift-cursor commands select text when possible.
 
-In Emacs 23, when `shift-select-mode' is on, shifted cursor keys start
-selecting a region, or enlarge regions started in this way.
-In Org-mode, in special contexts, these same keys are used for other
-purposes, important enough to compete with shift selection.  Org tries
-to balance these needs by supporting `shift-select-mode' outside these
-special contexts, under control of this variable.
+In Emacs 23, when `shift-select-mode' is on, shifted cursor keys
+start selecting a region, or enlarge regions started in this way.
+In Org-mode, in special contexts, these same keys are used for
+other purposes, important enough to compete with shift selection.
+Org tries to balance these needs by supporting `shift-select-mode'
+outside these special contexts, under control of this variable.
 
 The default of this variable is nil, to avoid confusing behavior.  Shifted
 cursor keys will then execute Org commands in the following contexts:
@@ -370,30 +379,56 @@ cursor keys will then execute Org commands in the following contexts:
 - in the BEGIN line of a clock table (changing the time block).
 Outside these contexts, the commands will throw an error.
 
-When this variable is t and the cursor is not in a special context,
-Org-mode will support shift-selection for making and enlarging regions.
-To make this more effective, the bullet cycling will no longer happen
-anywhere in an item line, but only if the cursor is exactly on the bullet.
+When this variable is t and the cursor is not in a special
+context, Org-mode will support shift-selection for making and
+enlarging regions.  To make this more effective, the bullet
+cycling will no longer happen anywhere in an item line, but only
+if the cursor is exactly on the bullet.
 
 If you set this variable to the symbol `always', then the keys
-will not be special in headlines, property lines, and item lines, to make
-shift selection work there as well.  If this is what you want, you can
-use the following alternative commands: `C-c C-t' and `C-c ,' to
-change TODO state and priority, `C-u C-u C-c C-t' can be used to switch
-TODO sets, `C-c -' to cycle item bullet types, and properties can be
-edited by hand or in column view.
+will not be special in headlines, property lines, and item lines,
+to make shift selection work there as well.  If this is what you
+want, you can use the following alternative commands: `C-c C-t'
+and `C-c ,' to change TODO state and priority, `C-u C-u C-c C-t'
+can be used to switch TODO sets, `C-c -' to cycle item bullet
+types, and properties can be edited by hand or in column view.
 
 However, when the cursor is on a timestamp, shift-cursor commands
 will still edit the time stamp - this is just too good to give up.
 
-XEmacs user should have this variable set to nil, because shift-select-mode
-is Emacs 23 only."
+XEmacs user should have this variable set to nil, because
+`shift-select-mode' is in Emacs 23 or later only."
   :group 'org
   :type '(choice
          (const :tag "Never" nil)
          (const :tag "When outside special context" t)
          (const :tag "Everywhere except timestamps" always)))
 
+(defcustom org-loop-over-headlines-in-active-region nil
+  "Shall some commands act upon headlines in the active region?
+
+When set to `t', some commands will be performed in all headlines
+within the active region.
+
+When set to `start-level', some commands will be performed in all
+headlines within the active region, provided that these headlines
+are of the same level than the first one.
+
+When set to a string, those commands will be performed on the
+matching headlines within the active region.  Such string must be
+a tags/property/todo match as it is used in the agenda tags view.
+
+The list of commands is: `org-schedule', `org-deadline',
+`org-todo', `org-archive-subtree', `org-archive-set-tag' and
+`org-archive-to-archive-sibling'.  The archiving commands skip
+already archived entries."
+  :type '(choice (const :tag "Don't loop" nil)
+                (const :tag "All headlines in active region" t)
+                (const :tag "In active region, headlines at the same level than the first one" 'start-level)
+                (string :tag "Tags/Property/Todo matcher"))
+  :group 'org-todo
+  :group 'org-archive)
+
 (defgroup org-startup nil
   "Options concerning startup of Org-mode."
   :tag "Org Startup"
@@ -817,7 +852,7 @@ than its value."
          (const :tag "No limit" nil)
          (integer :tag "Maximum level")))
 
-(defcustom org-drawers '("PROPERTIES" "CLOCK" "LOGBOOK")
+(defcustom org-drawers '("PROPERTIES" "CLOCK" "LOGBOOK" "RESULTS")
   "Names of drawers.  Drawers are not opened by cycling on the headline above.
 Drawers only open with a TAB on the drawer line itself.  A drawer looks like
 this:
@@ -1037,6 +1072,28 @@ OK to kill that hidden subtree.  When nil, kill without remorse."
          (const :tag "Protect hidden subtrees with a security query" t)
          (const :tag "Never kill a hidden subtree with C-k" error)))
 
+(defcustom org-catch-invisible-edits nil
+  "Check if in invisible region before inserting or deleting a character.
+Valid values are:
+
+nil              Do not check, so just do invisible edits.
+error            Throw an error and do nothing.
+show             Make point visible, and do the requested edit.
+show-and-error   Make point visible, then throw an error and abort the edit.
+smart            Make point visible, and do insertion/deletion if it is
+                 adjacent to visible text and the change feels predictable.
+                 Never delete a previously invisible character or add in the
+                 middle or right after an invisible region.  Basically, this
+                 allows insertion and backward-delete right before ellipses.
+                 FIXME: maybe in this case we should not even show?"
+  :group 'org-edit-structure
+  :type '(choice
+         (const :tag "Do not check" nil)
+         (const :tag "Throw error when trying to edit" error)
+         (const :tag "Unhide, but do not do the edit" show-and-error)
+         (const :tag "Show invisible part and do the edit" show)
+         (const :tag "Be smart and do the right thing" smart)))
+
 (defcustom org-yank-folded-subtrees t
   "Non-nil means when yanking subtrees, fold them.
 If the kill is a single subtree, or a sequence of subtrees, i.e. if
@@ -1260,10 +1317,14 @@ See the manual for examples."
            (function)))))
 
 (defcustom org-descriptive-links t
-  "Non-nil means hide link part and only show description of bracket links.
-Bracket links are like [[link][description]].  This variable sets the initial
-state in new org-mode buffers.  The setting can then be toggled on a
-per-buffer basis from the Org->Hyperlinks menu."
+  "Non-nil means Org will display descriptive links.
+E.g. [[http://orgmode.org][Org website]] will be displayed as
+\"Org Website\", hiding the link itself and just displaying its
+description.  When set to `nil', Org will display the full links
+literally.
+
+You can interactively set the value of this variable by calling
+`org-toggle-link-display' or from the menu Org>Hyperlinks menu."
   :group 'org-link
   :type 'boolean)
 
@@ -1401,8 +1462,8 @@ nil   Never use an ID to make a link, instead link using a text search for
   "Non-nil means file links from `org-store-link' contain context.
 A search string will be added to the file name with :: as separator and
 used to find the context when the link is activated by the command
-`org-open-at-point'. When this option is t, the entire active region
-will be placed in the search string of the file link. If set to a
+`org-open-at-point'.  When this option is t, the entire active region
+will be placed in the search string of the file link.  If set to a
 positive integer, only the first n lines of context will be stored.
 
 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
@@ -1852,7 +1913,7 @@ will temporarily be changed to `time'."
 
 (defcustom org-refile-targets nil
   "Targets for refiling entries with \\[org-refile].
-This is list of cons cells.  Each cell contains:
+This is list of cons cells.  Each cell contains:
 - a specification of the files to be considered, either a list of files,
   or a symbol whose function or variable value will be used to retrieve
   a file name or a list of file names.  If you use `org-agenda-files' for
@@ -1870,10 +1931,14 @@ This is list of cons cells.  Each cell contains:
   - a cons cell (:level . N).  Any headline of level N is considered a target.
     Note that, when `org-odd-levels-only' is set, level corresponds to
     order in hierarchy, not to the number of stars.
-  - a cons cell (:maxlevel . N). Any headline with level <= N is a target.
+  - a cons cell (:maxlevel . N).  Any headline with level <= N is a target.
     Note that, when `org-odd-levels-only' is set, level corresponds to
     order in hierarchy, not to the number of stars.
 
+Each element of this list generates a set of possible targets.
+The union of these sets is presented (with completion) to
+the user by `org-refile'.
+
 You can set the variable `org-refile-target-verify-function' to a function
 to verify each headline found by the simple criteria above.
 
@@ -1963,6 +2028,16 @@ heading."
          (const :tag "Always" t)
          (const :tag "Prompt for confirmation" confirm)))
 
+(defcustom org-refile-active-region-within-subtree nil
+  "Non-nil means also refile active region within a subtree.
+
+By default `org-refile' doesn't allow refiling regions if they
+don't contain a set of subtrees, but it might be convenient to
+do so sometimes: in that case, the first line of the region is
+converted to a headline before refiling."
+  :group 'org-refile
+  :type 'boolean)
+
 (defgroup org-todo nil
   "Options concerning TODO items in Org-mode."
   :tag "Org TODO"
@@ -2348,6 +2423,8 @@ context, and the cdr is the heading to be used.  The heading may also be the
 empty string.
 %t in the heading will be replaced by a time stamp.
 %T will be an active time stamp instead the default inactive one
+%d will be replaced by a short-format time stamp.
+%D will be replaced by an active short-format time stamp.
 %s will be replaced by the new TODO state, in double quotes.
 %S will be replaced by the old TODO state, in double quotes.
 %u will be replaced by the user name.
@@ -2444,7 +2521,7 @@ An auto-repeating task 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 set `org-log-done' to
 record a closing note, there will be no record of the task moving
-through DONE. This variable forces taking a note anyway.
+through DONE.  This variable forces taking a note anyway.
 
 nil     Don't force a record
 time    Record a time stamp
@@ -2681,7 +2758,7 @@ When this variable is set to t, the date/time prompt will not let
 you specify dates outside the 1970-2037 range, so it is certain that
 these dates will work in whatever version of Emacs you are
 running, and also that you can move a file from one Emacs implementation
-to another.  Whenever Org is forcing the year for you, it will display
+to another.  WHenever Org is forcing the year for you, it will display
 a message and beep.
 
 When this variable is nil, Org will check if the date is
@@ -2735,6 +2812,14 @@ be the favorite working time of John Wiegley :-)"
   :group 'org-time
   :type 'integer)
 
+(defcustom org-use-effective-time nil
+  "If non-nil, consider `org-extend-today-until' when creating timestamps.
+For example, if `org-extend-today-until' is 8, and it's 4am, then the
+\"effective time\" of any timestamps between midnight and 8am will be
+23:59 of the previous day."
+  :group 'boolean
+  :type 'integer)
+
 (defcustom org-edit-timestamp-down-means-later nil
   "Non-nil means S-down will increase the time in a time stamp.
 When nil, S-up will increase."
@@ -2849,7 +2934,9 @@ This is an undocumented feature, you should not rely on it.")
   "The column to which tags should be indented in a headline.
 If this number is positive, it specifies the column.  If it is negative,
 it means that the tags should be flushright to that column.  For example,
--80 works well for a normal 80 character screen."
+-80 works well for a normal 80 character screen.
+When 0, place tags directly after headline text, with only one space in
+between."
   :group 'org-tags
   :type 'integer)
 
@@ -2924,7 +3011,7 @@ is better to limit inheritance to certain tags using the variables
          (const :tag "List them, indented with leading dots" indented)))
 
 (defcustom org-tags-sort-function nil
-  "When set, tags are sorted using this comparison function."
+  "When set, tags are sorted using this function as a comparator."
   :group 'org-tags
   :type '(choice
          (const :tag "No sorting" nil)
@@ -2952,6 +3039,28 @@ lined-up with respect to each other."
   :group 'org-properties
   :type 'string)
 
+(defcustom org-properties-postprocess-alist nil
+  "Alist of properties and functions to adjust inserted values.
+Elements of this alist must be of the form
+
+  ([string] [function])
+
+where [string] must be a property name and [function] must be a
+lambda expression: this lambda expression must take one argument,
+the value to adjust, and return the new value as a string.
+
+For example, this element will allow the property \"Remaining\"
+to be updated wrt the relation between the \"Effort\" property
+and the clock summary:
+
+ ((\"Remaining\" (lambda(value)
+                   (let ((clocksum (org-clock-sum-current-item))
+                         (effort (org-duration-string-to-minutes
+                                   (org-entry-get (point) \"Effort\"))))
+                     (org-minutes-to-hh:mm-string (- effort clocksum))))))"
+  :group 'org-properties
+  :type 'alist)
+
 (defcustom org-use-property-inheritance nil
   "Non-nil means properties apply also for sublevels.
 
@@ -3222,6 +3331,46 @@ This is a property list with the following properties:
 When nil, just push out a message."
   :group 'org-latex
   :type 'boolean)
+(defcustom org-latex-to-mathml-jar-file nil
+  "Value of\"%j\" in `org-latex-to-mathml-convert-command'.
+Use this to specify additional executable file say a jar file.
+
+When using MathToWeb as the converter, specify the full-path to
+your mathtoweb.jar file."
+  :group 'org-latex
+  :type '(choice
+         (const :tag "None" nil)
+         (file :tag "JAR file" :must-match t)))
+
+(defcustom org-latex-to-mathml-convert-command nil
+  "Command to convert LaTeX fragments to MathML.
+Replace format-specifiers in the command as noted below and use
+`shell-command' to convert LaTeX to MathML.
+%j:     Executable file in fully expanded form as specified by
+        `org-latex-to-mathml-jar-file'.
+%I:     Input LaTeX file in fully expanded form
+%o:     Output MathML file
+This command is used by `org-create-math-formula'.
+
+When using MathToWeb as the converter, set this to
+\"java -jar %j -unicode -force -df %o %I\"."
+  :group 'org-latex
+  :type '(choice
+         (const :tag "None" nil)
+         (string :tag "\nShell command")))
+
+(defun org-format-latex-mathml-available-p ()
+  "Return t if `org-latex-to-mathml-convert-command' is usable."
+  (save-match-data
+    (when (and (boundp 'org-latex-to-mathml-convert-command)
+              org-latex-to-mathml-convert-command)
+      (let ((executable (car (split-string
+                             org-latex-to-mathml-convert-command))))
+       (when (executable-find executable)
+         (if (string-match
+              "%j" org-latex-to-mathml-convert-command)
+             (file-readable-p org-latex-to-mathml-jar-file)
+           t))))))
 
 (defcustom org-format-latex-header "\\documentclass{article}
 \\usepackage[usenames]{color}
@@ -3609,6 +3758,7 @@ Normal means, no org-mode-specific context."
 (defvar calc-embedded-close-formula)
 (defvar calc-embedded-open-formula)
 (declare-function cdlatex-tab "ext:cdlatex" ())
+(declare-function cdlatex-compute-tables "ext:cdlatex" ())
 (declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
 (defvar font-lock-unfontify-region-function)
 (declare-function iswitchb-read-buffer "iswitchb"
@@ -3618,7 +3768,7 @@ Normal means, no org-mode-specific context."
 (defvar org-agenda-tags-todo-honor-ignore-options)
 (declare-function org-agenda-skip "org-agenda" ())
 (declare-function
- org-format-agenda-item "org-agenda"
+ org-agenda-format-item "org-agenda"
  (extra txt &optional category tags dotime noprefix remove-re habitp))
 (declare-function org-agenda-new-marker "org-agenda" (&optional pos))
 (declare-function org-agenda-change-all-lines "org-agenda"
@@ -3986,7 +4136,7 @@ Here are a few examples:
 \"~/org/archive.org::\"
        Archive in file ~/org/archive.org (absolute path), as top-level trees.
 
-\"~/org/archive.org::From %s\"
+\"~/org/archive.org::From %s\"
        Archive in file ~/org/archive.org (absolute path), under headlines
         \"From FILENAME\" where file name is the current file name.
 
@@ -4074,7 +4224,7 @@ collapsed state."
     (let* ((re (concat ":" org-archive-tag ":")))
       (goto-char beg)
       (while (re-search-forward re end t)
-       (when (org-on-heading-p)
+       (when (org-at-heading-p)
          (org-flag-subtree t)
          (org-end-of-subtree t))))))
 
@@ -4150,20 +4300,14 @@ group 5: Tags")
 (make-variable-buffer-local 'org-complex-heading-regexp)
 (defvar org-complex-heading-regexp-format nil
   "Printf format to make regexp to match an exact headline.
-This regexp will match the headline of any node which hase the exact
-headline text that is put into the format, but may have any TODO state,
-priority and tags.")
+This regexp will match the headline of any node which has the
+exact headline text that is put into the format, but may have any
+TODO state, priority and tags.")
 (make-variable-buffer-local 'org-complex-heading-regexp-format)
 (defvar org-todo-line-tags-regexp nil
   "Matches a headline and puts TODO state into group 2 if present.
 Also put tags into group 4 if tags are present.")
 (make-variable-buffer-local 'org-todo-line-tags-regexp)
-(defvar org-nl-done-regexp nil
-  "Matches newline followed by a headline with the DONE keyword.")
-(make-variable-buffer-local 'org-nl-done-regexp)
-(defvar org-looking-at-done-regexp nil
-  "Matches the DONE keyword a point.")
-(make-variable-buffer-local 'org-looking-at-done-regexp)
 (defvar org-ds-keyword-length 12
   "Maximum length of the Deadline and SCHEDULED keywords.")
 (make-variable-buffer-local 'org-ds-keyword-length)
@@ -4300,9 +4444,34 @@ in the #+STARTUP line, the corresponding variable, and the value to
 set this variable to if the option is found.  An optional forth element PUSH
 means to push this value onto the list in the variable.")
 
+(defun org-update-property-plist (key val props)
+  "Update PROPS with KEY and VAL."
+  (if (string= "+" (substring key (- (length key) 1)))
+      (let* ((key (substring key 0 (- (length key) 1)))
+            (previous (cdr (assoc key props))))
+       (cons (cons key (concat previous " " val))
+             (org-remove-if (lambda (p) (string= (car p) key)) props)))
+    (cons (cons key val) props)))
+
+(defconst org-block-regexp
+  "^[ \t]*#\\+begin_?\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$"
+  "Regular expression for hiding blocks.")
+(defconst org-heading-keyword-regexp-format
+  "^\\(\\*+\\)\\(?: +%s\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
+  "Printf format for a regexp matching an headline with some keyword.
+This regexp will match the headline of any node which has the
+exact keyword that is put into the format.  The keyword isn't in
+any group by default, but the stars and the body are.")
+(defconst org-heading-keyword-maybe-regexp-format
+  "^\\(\\*+\\)\\(?: +%s\\)?\\(?: +\\(.*?\\)\\)?[ \t]*$"
+  "Printf format for a regexp matching an headline, possibly with some keyword.
+This regexp can match any headline with the specified keyword, or
+without a keyword.  The keyword isn't in any group by default,
+but the stars and the body are.")
+
 (defun org-set-regexps-and-options ()
   "Precompute regular expressions for current buffer."
-  (when (org-mode-p)
+  (when (eq major-mode 'org-mode)
     (org-set-local 'org-todo-kwd-alist nil)
     (org-set-local 'org-todo-key-alist nil)
     (org-set-local 'org-todo-key-trigger nil)
@@ -4361,8 +4530,9 @@ means to push this value onto the list in the variable.")
              (setq prio (org-split-string value " +")))
             ((equal key "PROPERTY")
              (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value)
-               (push (cons (match-string 1 value) (match-string 2 value))
-                     props)))
+               (setq props (org-update-property-plist (match-string 1 value)
+                                                      (match-string 2 value)
+                                                      props))))
             ((equal key "FILETAGS")
              (when (string-match "\\S-" value)
                (setq ftags
@@ -4406,8 +4576,17 @@ means to push this value onto the list in the variable.")
                (setq ext-setup-or-nil
                      (concat (substring ext-setup-or-nil 0 start)
                              "\n" setup-contents "\n"
-                             (substring ext-setup-or-nil start)))))
-            ))))
+                             (substring ext-setup-or-nil start)))))))
+         ;; search for property blocks
+         (goto-char (point-min))
+         (while (re-search-forward org-block-regexp nil t)
+           (when (equal "PROPERTY" (upcase (match-string 1)))
+             (setq value (replace-regexp-in-string
+                          "[\n\r]" " " (match-string 4)))
+             (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value)
+               (setq props (org-update-property-plist (match-string 1 value)
+                                                      (match-string 2 value)
+                                                      props)))))))
       (org-set-local 'org-use-sub-superscripts scripts)
       (when cat
        (org-set-local 'org-category (intern cat))
@@ -4498,7 +4677,9 @@ means to push this value onto the list in the variable.")
                     (assoc (car e) org-tag-alist))
                (push e org-tag-alist)))))
 
-      ;; Compute the regular expressions and other local variables
+      ;; Compute the regular expressions and other local variables.
+      ;; Using `org-outline-regexp-bol' would complicate them much,
+      ;; because of the fixed white space at the end of that string.
       (if (not org-done-keywords)
          (setq org-done-keywords (and org-todo-keywords-1
                                       (list (org-last org-todo-keywords-1)))))
@@ -4513,47 +4694,42 @@ means to push this value onto the list in the variable.")
            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
-                                       "\\|") "\\)\\>")
+           (concat "\\("
+                   (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
+                   "\\)")
            org-not-done-regexp
-           (concat "\\<\\("
+           (concat "\\("
                    (mapconcat 'regexp-quote org-not-done-keywords "\\|")
-                   "\\)\\>")
+                   "\\)")
            org-not-done-heading-regexp
-           (concat "^\\(\\*+\\)[ \t]+\\("
-                   (mapconcat 'regexp-quote org-not-done-keywords "\\|")
-                   "\\)\\>")
+           (format org-heading-keyword-regexp-format org-not-done-regexp)
            org-todo-line-regexp
-           (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
-                   (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
-                   "\\)\\>\\)?[ \t]*\\(.*\\)")
+           (format org-heading-keyword-maybe-regexp-format org-todo-regexp)
            org-complex-heading-regexp
-           (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
-                   (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
-                   "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
-                   "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$")
+           (concat "^\\(\\*+\\)"
+                   "\\(?: +" org-todo-regexp "\\)?"
+                   "\\(?: +\\(\\[#.\\]\\)\\)?"
+                   "\\(?: +\\(.*?\\)\\)?"
+                   (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?")
+                   "[ \t]*$")
            org-complex-heading-regexp-format
-           (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
-                   (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
-                   "\\)\\>\\)?"
-                   "\\(?:[ \t]*\\(\\[#.\\]\\)\\)?"
-                   "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie
-                   "[ \t]*\\(%s\\)"
-                   "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie
-                   "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?[ \t]*$")
-           org-nl-done-regexp
-           (concat "\n\\*+[ \t]+"
-                   "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
-                   "\\)" "\\>")
+           (concat "^\\(\\*+\\)"
+                   "\\(?: +" org-todo-regexp "\\)?"
+                   "\\(?: +\\(\\[#.\\]\\)\\)?"
+                   "\\(?: +"
+                   ;; Stats cookies can be sticked to body.
+                   "\\(?:\\[[0-9%%/]+\\] *\\)?"
+                   "\\(%s\\)"
+                   "\\(?: *\\[[0-9%%/]+\\]\\)?"
+                   "\\)"
+                   (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?")
+                   "[ \t]*$")
            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 "\\|") "\\)"
-                   "\\>")
+           (concat "^\\(\\*+\\)"
+                   "\\(?: +" org-todo-regexp "\\)?"
+                   "\\(?: +\\(.*?\\)\\)?"
+                   (org-re "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?")
+                   "[ \t]*$")
            org-deadline-regexp (concat "\\<" org-deadline-string)
            org-deadline-time-regexp
            (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
@@ -4582,7 +4758,7 @@ means to push this value onto the list in the variable.")
                    "\\|" org-deadline-string
                    "\\|" org-closed-string
                    "\\|" org-clock-string "\\)\\)?"
-                   " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
+                   " *\\([[<][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
@@ -4698,10 +4874,23 @@ This variable is set by `org-before-change-function'.
 (defvar org-inhibit-blocking nil)       ; Dynamically-scoped param.
 (defvar org-table-buffer-is-an nil)
 
-;; org-outline-regexp ought to be a defconst but is let-binding
-;; in some places -- e.g. see the macro org-with-limited-levels
-(defvar org-outline-regexp "\\*+ ")
-(defconst org-outline-regexp-bol "^\\*+ ")
+;; `org-outline-regexp' ought to be a defconst but is let-binding in
+;; some places -- e.g. see the macro org-with-limited-levels.
+;;
+;; In Org buffers, the value of `outline-regexp' is that of
+;; `org-outline-regexp'.  The only function still directly relying on
+;; `outline-regexp' is `org-overview' so that `org-cycle' can do its
+;; job when `orgstruct-mode' is active.
+(defvar org-outline-regexp "\\*+ "
+  "Regexp to match Org headlines.")
+(defconst org-outline-regexp-bol "^\\*+ "
+  "Regexp to match Org headlines.
+This is similar to `org-outline-regexp' but additionally makes
+sure that we are at the beginning of the line.")
+
+(defconst org-heading-regexp "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
+  "Matches an headline, putting stars and text into groups.
+Stars are put in group 1 and the trimmed body in group 2.")
 
 ;;;###autoload
 (define-derived-mode org-mode outline-mode "Org"
@@ -4948,7 +5137,7 @@ stacked delimiters is N.  Escaping delimiters is not possible."
 
 (defvar org-match-substring-regexp
   (concat
-   "\\([^\\]\\)\\([_^]\\)\\("
+   "\\([^\\]\\|^\\)\\([_^]\\)\\("
    "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
    "\\|"
    "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
@@ -4958,7 +5147,7 @@ stacked delimiters is N.  Escaping delimiters is not possible."
 
 (defvar org-match-substring-with-braces-regexp
   (concat
-   "\\([^\\]\\)\\([_^]\\)\\("
+   "\\([^\\]\\|^\\)\\([_^]\\)\\("
    "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
    "\\)")
   "The regular expression matching a sub- or superscript, forcing braces.")
@@ -5022,15 +5211,15 @@ This should be called after the variable `org-link-types' has changed."
 
 (org-make-link-regexps)
 
-(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^\r\n>]*?\\)>"
+(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)>"
   "Regular expression for fast time stamp matching.")
-(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?\\)[]>]"
+(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?\\)[]>]"
   "Regular expression for fast time stamp matching.")
-(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
+(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.
 This one does not require the space after the date, so it can be used
 on a string that terminates immediately after the date.")
-(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) +\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
+(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.")
 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
   "Regular expression matching time stamps, with groups.")
@@ -5052,7 +5241,7 @@ The time stamps may be either active or inactive.")
 (defvar org-emph-face nil)
 
 (defun org-do-emphasis-faces (limit)
-  "Run through the buffer and add overlays to emphasized strings."
+  "Run through the buffer and add overlays to emphasised strings."
   (let (rtn a)
     (while (and (not rtn) (re-search-forward org-emph-re limit t))
       (if (not (= (char-after (match-beginning 3))
@@ -5154,7 +5343,7 @@ will be prompted for."
            t)))))
 
 (defun org-activate-code (limit)
-  (if (re-search-forward "^[ \t]*\\(: .*\n?\\)" limit t)
+  (if (re-search-forward "^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)" limit t)
       (progn
        (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
        (remove-text-properties (match-beginning 0) (match-end 0)
@@ -5257,9 +5446,8 @@ will be prompted for."
             '(font-lock-fontified t face org-meta-line))
            t)
           ((or (member dc1 '("begin:" "end:" "caption:" "label:"
-                             "orgtbl:" "tblfm:" "tblname:" "result:"
-                             "results:" "source:" "srcname:" "call:"
-                             "data:" "header:" "headers:"))
+                             "orgtbl:" "tblfm:" "tblname:" "results:"
+                             "call:" "header:" "headers:" "name:"))
                (and (match-end 4) (equal dc3 "attr")))
            (add-text-properties
             beg (match-end 0)
@@ -5541,7 +5729,7 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
 
 (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
@@ -5549,7 +5737,7 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
 
 (defvar org-font-lock-set-keywords-hook nil
   "Functions that can manipulate `org-font-lock-extra-keywords'.
-This is called after `org-font-lock-extra-keywords' is defined, but before
+This is calles after `org-font-lock-extra-keywords' is defined, but before
 it is installed to be used by font lock.  This can be useful if something
 needs to be inserted at a specific position in the font-lock sequence.")
 
@@ -5595,14 +5783,17 @@ needs to be inserted at a specific position in the font-lock sequence.")
           (if (memq 'footnote lk) '(org-activate-footnote-links))
           '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
           '(org-hide-wide-columns (0 nil append))
-          ;; TODO lines
-          (list (concat "^\\*+[ \t]+" org-todo-regexp "\\([ \t]\\|$\\)")
-                '(1 (org-get-todo-face 1) t))
+          ;; TODO keyword
+          (list (format org-heading-keyword-regexp-format
+                        org-todo-regexp)
+                '(2 (org-get-todo-face 2) t))
           ;; DONE
           (if org-fontify-done-headline
-              (list (concat "^[*]+ +\\<\\("
-                            (mapconcat 'regexp-quote org-done-keywords "\\|")
-                            "\\)\\(.*\\)")
+              (list (format org-heading-keyword-regexp-format
+                            (concat
+                             "\\("
+                             (mapconcat 'regexp-quote org-done-keywords "\\|")
+                             "\\)"))
                     '(2 'org-headline-done t))
             nil)
           ;; Priorities
@@ -5640,9 +5831,11 @@ needs to be inserted at a specific position in the font-lock sequence.")
           ;; Code
           '(org-activate-code (1 'org-code t))
           ;; COMMENT
-          (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string
-                        "\\|" org-quote-string "\\)\\>")
-                '(1 'org-special-keyword t))
+          (list (format org-heading-keyword-regexp-format
+                        (concat "\\("
+                                org-comment-string "\\|" org-quote-string
+                                "\\)"))
+                '(2 'org-special-keyword t))
           '("^#.*" (0 'font-lock-comment-face t))
           ;; Blocks and meta lines
           '(org-fontify-meta-lines-and-blocks)
@@ -5661,7 +5854,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
   (org-set-local 'org-pretty-entities (not org-pretty-entities))
   (org-restart-font-lock)
   (if org-pretty-entities
-      (message "Entities are displayed as UTF8 characters")
+      (message "Entities are displayed as UTF8 characers")
     (save-restriction
       (widen)
       (org-decompose-region (point-min) (point-max))
@@ -5673,7 +5866,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
     (when org-pretty-entities
       (catch 'match
        (while (re-search-forward
-               "\\\\\\([a-zA-Z][a-zA-Z0-9]*\\)\\($\\|[^[:alnum:]\n]\\)"
+               "\\\\\\(frac[13][24]\\|[a-zA-Z]+\\)\\($\\|[^[:alpha:]\n]\\)"
                limit t)
          (if (and (not (org-in-indented-comment-line))
                   (setq ee (org-entity-get (match-string 1)))
@@ -5768,17 +5961,10 @@ If KWD is a number, get the corresponding match group."
         (inhibit-modification-hooks t)
         deactivate-mark buffer-file-name buffer-file-truename)
     (org-decompose-region beg end)
-    (remove-text-properties
-     beg end
-     (if org-indent-mode
-        ;; also remove line-prefix and wrap-prefix properties
-        '(mouse-face t keymap t org-linked-text t
-                     invisible t intangible t
-                     line-prefix t wrap-prefix t
-                     org-no-flyspell t org-emphasis t)
-       '(mouse-face t keymap t org-linked-text t
-                   invisible t intangible t
-                   org-no-flyspell t org-emphasis t)))
+    (remove-text-properties beg end
+     '(mouse-face t keymap t org-linked-text t
+                 invisible t intangible t
+                 org-no-flyspell t org-emphasis t))
     (org-remove-font-lock-display-properties beg end)))
 
 (defconst org-script-display  '(((raise -0.3) (height 0.7))
@@ -5915,7 +6101,7 @@ in special contexts.
                          (and limit-level (1- (* limit-level 2)))
                        limit-level)))
           (org-outline-regexp
-           (if (not (org-mode-p))
+           (if (not (eq major-mode 'org-mode))
                outline-regexp
              (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ "))))
           (bob-special (and org-cycle-global-at-bob (not arg) (bobp)
@@ -5978,6 +6164,8 @@ in special contexts.
             (or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))
        (org-inlinetask-toggle-visibility))
 
+       ((org-try-cdlatex-tab))
+
        ;; At an item/headline: delegate to `org-cycle-internal-local'.
        ((and (or (and org-cycle-include-plain-lists (org-at-item-p))
                 (save-excursion (beginning-of-line 1)
@@ -5993,8 +6181,6 @@ in special contexts.
 
        ((org-try-structure-completion))
 
-       ((org-try-cdlatex-tab))
-
        ((run-hook-with-args-until-success
         'org-tab-before-tab-emulation-hook))
 
@@ -6154,7 +6340,7 @@ With \\[universal-argument] 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 (eq major-mode 'org-mode) org-cycle-include-plain-lists nil)))
     (cond
      ((integerp arg)
       (show-all)
@@ -6213,6 +6399,9 @@ With a numeric prefix, show all headlines up to that level."
        (org-cycle-hide-drawers 'all)
        (org-cycle-show-empty-lines 'all)))))
 
+;; This function uses outline-regexp instead of the more fundamental
+;; org-outline-regexp so that org-cycle-global works outside of Org
+;; buffers, where outline-regexp is needed.
 (defun org-overview ()
   "Switch to overview mode, showing only top-level headlines.
 Really, this shows all headlines with level equal or greater than the level
@@ -6222,7 +6411,7 @@ results."
   (interactive)
   (let ((level (save-excursion
                 (goto-char (point-min))
-                (if (re-search-forward org-outline-regexp-bol nil t)
+                (if (re-search-forward (concat "^" outline-regexp) nil t)
                     (progn
                       (goto-char (match-beginning 0))
                       (funcall outline-level))))))
@@ -6334,7 +6523,7 @@ are at least `org-cycle-separator-lines' empty lines before the headline."
                            (org-back-over-empty-lines)
                            (if (save-excursion
                                  (goto-char (max (point-min) (1- (point))))
-                                 (org-on-heading-p))
+                                 (org-at-heading-p))
                                (1- (point))
                              (point))))
                (setq b (match-beginning 1)))
@@ -6361,7 +6550,7 @@ open and agenda-wise Org files."
   (let ((files (mapcar 'expand-file-name (org-agenda-files))))
     (dolist (buf (buffer-list))
       (with-current-buffer buf
-       (if (and (org-mode-p) (buffer-file-name))
+       (if (and (eq major-mode 'org-mode) (buffer-file-name))
            (let ((file (expand-file-name (buffer-file-name))))
              (unless (member file files)
                (push file files))))))
@@ -6377,7 +6566,7 @@ open and agenda-wise Org files."
 
 (defun org-cycle-hide-drawers (state)
   "Re-hide all drawers after a visibility state change."
-  (when (and (org-mode-p)
+  (when (and (eq major-mode 'org-mode)
             (not (memq state '(overview folded contents))))
     (save-excursion
       (let* ((globalp (memq state '(contents all)))
@@ -6447,16 +6636,11 @@ DATA should have been made by `org-outline-overlay-data'."
        (widen)
        (show-all)
        (mapc (lambda (c)
-               (setq o (make-overlay (car c) (cdr c)))
-               (overlay-put o 'invisible 'outline))
+               (outline-flag-region (car c) (cdr c) t))
              data)))))
 
 ;;; Folding of blocks
 
-(defconst org-block-regexp
-  "^[ \t]*#\\+begin_?\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$"
-  "Regular expression for hiding blocks.")
-
 (defvar org-hide-block-overlays nil
   "Overlays hiding blocks.")
 (make-variable-buffer-local 'org-hide-block-overlays)
@@ -6651,7 +6835,7 @@ or nil."
       (save-window-excursion
        (delete-other-windows)
        (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*"))
-       (switch-to-buffer
+       (org-pop-to-buffer-same-window
         (condition-case nil
             (make-indirect-buffer (current-buffer) "*org-goto*")
           (error (make-indirect-buffer (current-buffer) "*org-goto*"))))
@@ -6716,7 +6900,7 @@ or nil."
 (defun org-goto-left ()
   "Finish `org-goto' by going to the new location."
   (interactive)
-  (if (org-on-heading-p)
+  (if (org-at-heading-p)
       (progn
        (beginning-of-line 1)
        (setq org-goto-selected-point (point)
@@ -6727,7 +6911,7 @@ or nil."
 (defun org-goto-right ()
   "Finish `org-goto' by going to the new location."
   (interactive)
-  (if (org-on-heading-p)
+  (if (org-at-heading-p)
       (progn
        (setq org-goto-selected-point (point)
              org-goto-exit-command 'right)
@@ -6776,7 +6960,7 @@ frame is not changed."
       (setq beg (point)
            heading (org-get-heading))
       (org-end-of-subtree t t)
-      (if (org-on-heading-p) (backward-char 1))
+      (if (org-at-heading-p) (backward-char 1))
       (setq end (point)))
     (if (and (buffer-live-p org-last-indirect-buffer)
             (not (eq org-indirect-buffer-display 'new-frame))
@@ -6789,7 +6973,7 @@ frame is not changed."
          (and arg (eq org-indirect-buffer-display 'dedicated-frame)))
       (select-frame (make-frame))
       (delete-other-windows)
-      (switch-to-buffer ibuf)
+      (org-pop-to-buffer-same-window ibuf)
       (org-set-frame-title heading))
      ((eq org-indirect-buffer-display 'dedicated-frame)
       (raise-frame
@@ -6798,10 +6982,10 @@ frame is not changed."
                              org-indirect-dedicated-frame)
                         (setq org-indirect-dedicated-frame (make-frame)))))
       (delete-other-windows)
-      (switch-to-buffer ibuf)
+      (org-pop-to-buffer-same-window ibuf)
       (org-set-frame-title (concat "Indirect: " heading)))
      ((eq org-indirect-buffer-display 'current-window)
-      (switch-to-buffer ibuf))
+      (org-pop-to-buffer-same-window ibuf))
      ((eq org-indirect-buffer-display 'other-window)
       (pop-to-buffer ibuf))
      (t (error "Invalid value")))
@@ -6810,6 +6994,7 @@ frame is not changed."
     (narrow-to-region beg end)
     (show-all)
     (goto-char pos)
+    (run-hook-with-args 'org-cycle-hook 'all)
     (and (window-live-p cwin) (select-window cwin))))
 
 (defun org-get-indirect-buffer (&optional buffer)
@@ -6853,15 +7038,15 @@ This is important for non-interactive uses of the command."
   (if (or (= (buffer-size) 0)
          (and (not (save-excursion
                      (and (ignore-errors (org-back-to-heading invisible-ok))
-                          (org-on-heading-p))))
-              (not (org-in-item-p))))
+                          (org-at-heading-p))))
+              (or force-heading (not (org-in-item-p)))))
       (progn
        (insert "\n* ")
        (run-hooks 'org-insert-heading-hook))
     (when (or force-heading (not (org-insert-item)))
       (let* ((empty-line-p nil)
             (level nil)
-            (on-heading (org-on-heading-p))
+            (on-heading (org-at-heading-p))
             (head (save-excursion
                     (condition-case nil
                         (progn
@@ -6874,7 +7059,7 @@ This is important for non-interactive uses of the command."
                             ;; Find a heading level before the inline task
                             (while (and (setq level (org-up-heading-safe))
                                         (>= level org-inlinetask-min-level)))
-                            (if (org-on-heading-p)
+                            (if (org-at-heading-p)
                                 (org-back-to-heading invisible-ok)
                               (error "This should not happen")))
                           (setq empty-line-p (org-previous-line-empty-p))
@@ -6884,7 +7069,7 @@ This is important for non-interactive uses of the command."
             (blank (if (eq blank-a 'auto) empty-line-p blank-a))
             pos hide-previous previous-pos)
        (cond
-        ((and (org-on-heading-p) (bolp)
+        ((and (org-at-heading-p) (bolp)
               (or (bobp)
                   (save-excursion (backward-char 1) (not (outline-invisible-p)))))
          ;; insert before the current line
@@ -6909,6 +7094,7 @@ This is important for non-interactive uses of the command."
                        (let ((p (point)))
                          (goto-char (point-at-bol))
                          (and (looking-at org-complex-heading-regexp)
+                              (match-beginning 4)
                               (> p (match-beginning 4)))))))
                tags pos)
            (cond
@@ -6924,7 +7110,7 @@ This is important for non-interactive uses of the command."
              (or (org-previous-line-empty-p)
                  (and blank (newline)))
              (open-line 1))
-            ((org-on-heading-p)
+            ((org-at-heading-p)
              (when hide-previous
                (show-children)
                (org-show-entry))
@@ -6969,14 +7155,15 @@ When NO-TODO is non-nil, don't include TODO keywords."
       (looking-at org-complex-heading-regexp)
       (match-string 4))
      (no-tags
-      (looking-at "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$")
+      (looking-at (concat org-outline-regexp
+                         "\\(.*?\\)"
+                         "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$"))
       (match-string 1))
      (no-todo
-      (looking-at (concat "\\*+[ \t]+" org-todo-regexp " +"
-                         "\\([^\n\r]*?[ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$"))
-      (match-string 2))
-     (t (looking-at "\\*+[ \t]+\\([^\r\n]*\\)")
-       (match-string 1)))))
+      (looking-at org-todo-line-regexp)
+      (match-string 3))
+     (t (looking-at org-heading-regexp)
+       (match-string 2)))))
 
 (defun org-heading-components ()
   "Return the components of the current heading.
@@ -7058,7 +7245,7 @@ Works for outline headings and for plain lists alike."
   (interactive "P")
   (org-insert-heading arg)
   (cond
-   ((org-on-heading-p) (org-do-demote))
+   ((org-at-heading-p) (org-do-demote))
    ((org-at-item-p) (org-indent-item))))
 
 (defun org-insert-todo-subheading (arg)
@@ -7067,7 +7254,7 @@ Works for outline headings and for plain lists alike."
   (interactive "P")
   (org-insert-todo-heading arg)
   (cond
-   ((org-on-heading-p) (org-do-demote))
+   ((org-at-heading-p) (org-do-demote))
    ((org-at-item-p) (org-indent-item))))
 
 ;;; Promotion and Demotion
@@ -7137,9 +7324,8 @@ in the region."
 The level is the number of stars at the beginning of the headline."
   (save-excursion
     (org-with-limited-levels
-     (ignore-errors
-       (org-back-to-heading t)
-       (funcall outline-level)))))
+     (if (ignore-errors (org-back-to-heading t))
+        (funcall outline-level)))))
 
 (defun org-get-previous-line-level ()
   "Return the outline depth of the last headline before the current line.
@@ -7196,7 +7382,7 @@ in the region."
                                          after-change-functions))
         (up-head (concat (make-string (org-get-valid-level level -1) ?*) " "))
         (diff (abs (- level (length up-head) -1))))
-    (if (= level 1) (error "Cannot promote to level 0. UNDO to recover if necessary"))
+    (if (= level 1) (error "Cannot promote to level 0.  UNDO to recover if necessary"))
     (replace-match up-head nil t)
     ;; Fixup tag positioning
     (and org-auto-align-tags (org-set-tags nil t))
@@ -7282,6 +7468,7 @@ After top level, it switches back to sibling level."
                  (not (eobp)))
        (funcall fun)))))
 
+(defvar org-property-end-re) ; silence byte-compiler
 (defun org-fixup-indentation (diff)
   "Change the indentation in the current entry by DIFF.
 However, if any line in the current entry has no indentation, or if it
@@ -7517,15 +7704,15 @@ the inserted text when done."
   (org-with-limited-levels
    (let* ((visp (not (outline-invisible-p)))
          (txt tree)
-         (^re_ (concat "\\(\\*+\\)[  \t]*")) ;FIXME: Why `concat'?
+         (^re_ "\\(\\*+\\)[  \t]*")
          (old-level (if (string-match org-outline-regexp-bol txt)
                         (- (match-end 0) (match-beginning 0) 1)
                       -1))
          (force-level (cond (level (prefix-numeric-value level))
                             ((and (looking-at "[ \t]*$")
                                   (string-match
-                                   ^re_ (buffer-substring
-                                         (point-at-bol) (point))))
+                                   "^\\*+$" (buffer-substring
+                                             (point-at-bol) (point))))
                              (- (match-end 1) (match-beginning 1)))
                             ((and (bolp)
                                   (looking-at org-outline-regexp))
@@ -7535,7 +7722,7 @@ the inserted text when done."
                            (condition-case nil
                                (progn
                                  (outline-previous-visible-heading 1)
-                                 (if (looking-at re) ;FIXME: What's `re'?
+                                 (if (looking-at ^re_)
                                      (- (match-end 0) (match-beginning 0) 1)
                                    1))
                              (error 1))))
@@ -7544,7 +7731,7 @@ the inserted text when done."
                            (progn
                              (or (looking-at org-outline-regexp)
                                  (outline-next-visible-heading 1))
-                             (if (looking-at re) ;FIXME: What's `re'?
+                             (if (looking-at ^re_)
                                  (- (match-end 0) (match-beginning 0) 1)
                                1))
                          (error 1))))
@@ -7562,7 +7749,7 @@ the inserted text when done."
      (if force-level
         (delete-region (point-at-bol) (point)))
      ;; Paste
-     (beginning-of-line 1)
+     (beginning-of-line (if (bolp) 1 2))
      (unless for-yank (org-back-over-empty-lines))
      (setq beg (point))
      (and (fboundp 'org-id-paste-tracker) (org-id-paste-tracker txt))
@@ -7663,23 +7850,17 @@ If yes, remember the marker and the distance to BEG."
        (narrow-to-region
        (progn (org-back-to-heading t) (point))
        (progn (org-end-of-subtree t t)
-              (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
+              (if (and (org-at-heading-p) (not (eobp))) (backward-char 1))
               (point)))))))
 
 (defun org-narrow-to-block ()
   "Narrow buffer to the current block."
   (interactive)
-  (let ((bstart "^[ \t]*#\\+begin")
-       (bend "[ \t]*#\\+end")
-       (case-fold-search t) ;; allow #+BEGIN
-       b_start b_end)
-    (if (org-in-regexps-block-p bstart bend)
-       (progn
-         (save-excursion (re-search-backward bstart nil t)
-                         (setq b_start (match-beginning 0)))
-         (save-excursion (re-search-forward  bend nil t)
-                         (setq b_end (match-end 0)))
-         (narrow-to-region b_start b_end))
+  (let* ((case-fold-search t)
+        (blockp (org-between-regexps-p "^[ \t]*#\\+begin_.*"
+                                        "^[ \t]*#\\+end_.*")))
+    (if blockp
+       (narrow-to-region (car blockp) (cdr blockp))
       (error "Not in a block"))))
 
 (eval-when-compile
@@ -7713,7 +7894,8 @@ I this way you can spell out a number of instances of a repeating task,
 and still retain the repeater to cover future instances of the task."
   (interactive "nNumber of clones to produce: \nsDate shift per clone (e.g. +1w, empty to copy unchanged): ")
   (let (beg end template task idprop
-           shift-n shift-what doshift nmin nmax (n-no-remove -1))
+           shift-n shift-what doshift nmin nmax (n-no-remove -1)
+           (drawer-re org-drawer-regexp))
     (if (not (and (integerp n) (> n 0)))
        (error "Invalid number of replications %s" n))
     (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift)))
@@ -7734,19 +7916,6 @@ and still retain the repeater to cover future instances of the task."
     (or (bolp) (insert "\n"))
     (setq end (point))
     (setq template (buffer-substring beg end))
-    ;; Remove clocks and empty drawers
-    (with-temp-buffer
-      (insert template)
-      (goto-char (point-min))
-      (while (re-search-forward
-             "^[ \t]*CLOCK:.*$" (save-excursion (org-end-of-subtree t t)) t)
-       (replace-match "")
-       (kill-whole-line))
-      (goto-char (point-min))
-      (while (re-search-forward
-             (concat "^[ \t]*:" (regexp-opt org-drawers) ":[ \t]*$") nil t)
-       (mapc (lambda(d) (org-remove-empty-drawer-at d (point))) org-drawers))
-      (setq template (buffer-substring (point-min) (point-max))))
     (when (and doshift
               (string-match "<[^<>\n]+ \\+[0-9]+[dwmy][^<>\n]*>" template))
       (delete-region beg end)
@@ -7759,11 +7928,17 @@ and still retain the repeater to cover future instances of the task."
            (insert template)
            (org-mode)
            (goto-char (point-min))
+           (org-show-subtree)
            (and idprop (if org-clone-delete-id
                            (org-entry-delete nil "ID")
                          (org-id-get-create t)))
-           (while (re-search-forward org-property-start-re nil t)
-             (org-remove-empty-drawer-at "PROPERTIES" (point)))
+           (unless (= n 0)
+             (while (re-search-forward "^[ \t]*CLOCK:.*$" nil t)
+               (kill-whole-line))
+             (goto-char (point-min))
+             (while (re-search-forward drawer-re nil t)
+               (mapc (lambda (d)
+                       (org-remove-empty-drawer-at d (point))) org-drawers)))
            (goto-char (point-min))
            (when doshift
              (while (re-search-forward org-ts-regexp-both nil t)
@@ -7853,9 +8028,9 @@ WITH-CASE, the sorting considers case as well."
       (setq end (region-end)
             what "region")
       (goto-char (region-beginning))
-      (if (not (org-on-heading-p)) (outline-next-heading))
+      (if (not (org-at-heading-p)) (outline-next-heading))
       (setq start (point)))
-     ((or (org-on-heading-p)
+     ((or (org-at-heading-p)
           (condition-case nil (progn (org-back-to-heading) t) (error nil)))
       ;; we will sort the children of the current headline
       (org-back-to-heading)
@@ -7871,7 +8046,7 @@ WITH-CASE, the sorting considers case as well."
      (t
       ;; we will sort the top-level entries in this file
       (goto-char (point-min))
-      (or (org-on-heading-p) (outline-next-heading))
+      (or (org-at-heading-p) (outline-next-heading))
       (setq start (point))
       (goto-char (point-max))
       (beginning-of-line 1)
@@ -8335,6 +8510,7 @@ call CMD."
             (org-back-to-heading t)
             (setq beg (point) end (org-end-of-subtree t t)))
           (put-text-property beg end 'org-category cat)
+          (put-text-property beg end 'org-category-position beg)
           (goto-char pos)))))))
 
 
@@ -8525,7 +8701,7 @@ For file links, arg negates `org-context-in-file-links'."
         (setq cpltxt (concat "file:" file)
               link (org-make-link cpltxt))))
 
-      ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+      ((and (buffer-file-name (buffer-base-buffer)) (eq major-mode 'org-mode))
        (setq custom-id (org-entry-get nil "CUSTOM_ID"))
        (cond
        ((org-in-regexp "<<\\(.*?\\)>>")
@@ -8563,7 +8739,7 @@ For file links, arg negates `org-context-in-file-links'."
         ;; Add a context search string
         (when (org-xor org-context-in-file-links arg)
           (setq txt (cond
-                     ((org-on-heading-p) nil)
+                     ((org-at-heading-p) nil)
                      ((org-region-active-p)
                       (buffer-substring (region-beginning) (region-end)))
                      (t nil)))
@@ -8853,7 +9029,7 @@ This command can be called in any mode to insert a link in Org-mode syntax."
   (org-load-modules-maybe)
   (org-run-like-in-org-mode 'org-insert-link))
 
-(defun org-insert-link (&optional complete-file link-location)
+(defun org-insert-link (&optional complete-file link-location default-description)
   "Insert a link.  At the prompt, enter the link.
 
 Completion can be used to insert any of the link protocol prefixes like
@@ -8871,8 +9047,8 @@ be displayed in the buffer instead of the link.
 If there is already a link at point, this command will allow you to edit link
 and description parts.
 
-With a \\[universal-argument] prefix, prompts for a file to link to. The file name can
-be selected using completion. The path to the file will be relative to the
+With a \\[universal-argument] prefix, prompts for a file to link to.  The file name can
+be selected using completion.  The path to the file will be relative to the
 current directory if the file is in the current directory or a subdirectory.
 Otherwise, the link will be the absolute path as completed in the minibuffer
 \(i.e. normally ~/path/to/file).  You can configure this behavior using the
@@ -8889,7 +9065,10 @@ called with the link target, and the result will be the default
 link description.
 
 If the LINK-LOCATION parameter is non-nil, this value will be
-used as the link location instead of reading one interactively."
+used as the link location instead of reading one interactively.
+
+If the DEFAULT-DESCRIPTION parameter is non-nil, this value will
+be used as the default description."
   (interactive "P")
   (let* ((wcf (current-window-configuration))
         (region (if (org-region-active-p)
@@ -8930,7 +9109,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
                  (reverse org-stored-links) "\n"))))
       (let ((cw (selected-window)))
        (select-window (get-buffer-window "*Org Links*" 'visible))
-       (with-current-buffer "*Org Links*" (setq truncate-lines) t)
+       (with-current-buffer "*Org Links*" (setq truncate-lines t))
        (unless (pos-visible-in-window-p (point-max))
          (org-fit-window-to-buffer))
        (and (window-live-p cw) (select-window cw)))
@@ -9017,7 +9196,8 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
            (setq desc path))))
 
     (if org-make-link-description-function
-       (setq desc (funcall org-make-link-description-function link desc)))
+       (setq desc (funcall org-make-link-description-function link desc))
+      (if default-description (setq desc default-description)))
 
     (setq desc (read-string "Description: " desc))
     (unless (string-match "\\S-" desc) (setq desc nil))
@@ -9054,10 +9234,12 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 
 (defun org-completing-read (&rest args)
   "Completing-read with SPACE being a normal character."
-  (let ((minibuffer-local-completion-map
+  (let ((enable-recursive-minibuffers t)
+       (minibuffer-local-completion-map
         (copy-keymap minibuffer-local-completion-map)))
     (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
     (org-defkey minibuffer-local-completion-map "?" 'self-insert-command)
+    (org-defkey minibuffer-local-completion-map (kbd "C-c !") 'org-time-stamp-inactive)
     (apply 'org-icompleting-read args)))
 
 (defun org-completing-read-no-i (&rest args)
@@ -9228,7 +9410,8 @@ This is still an experimental function, your mileage may vary."
   (org-open-at-point 'in-emacs))
 
 (defun org-open-at-mouse (ev)
-  "Open file link or URL at mouse."
+  "Open file link or URL at mouse.
+See the docstring of `org-open-file' for details."
   (interactive "e")
   (mouse-set-point ev)
   (if (eq major-mode 'org-agenda-mode)
@@ -9289,7 +9472,7 @@ application the system uses for this file type."
   (setq org-window-config-before-follow-link (current-window-configuration))
   (org-remove-occur-highlights nil nil t)
   (cond
-   ((and (org-on-heading-p)
+   ((and (org-at-heading-p)
         (not (org-in-regexp
               (concat org-plain-link-re "\\|"
                       org-bracket-link-regexp "\\|"
@@ -9337,7 +9520,8 @@ application the system uses for this file type."
        (save-excursion
          (when (or (org-in-regexp org-angle-link-re)
                    (org-in-regexp org-plain-link-re))
-           (setq type (match-string 1) path (match-string 2))
+           (setq type (match-string 1)
+                 path (org-link-unescape (match-string 2)))
            (throw 'match t)))
        (save-excursion
          (when (org-in-regexp (org-re "\\(:[[:alnum:]_@#%:]+\\):[ \t]*$"))
@@ -9391,13 +9575,16 @@ application the system uses for this file type."
            (apply cmd (nreverse args1))))
 
         ((member type '("http" "https" "ftp" "news"))
-         (browse-url (concat type ":" (org-link-escape
-                                       path org-link-escape-chars-browser))))
+         (browse-url (concat type ":" (if (org-string-match-p "[[:nonascii:] ]" path)
+                                          (org-link-escape
+                                           path org-link-escape-chars-browser)
+                                        path))))
 
         ((string= type "doi")
-         (browse-url (concat "http://dx.doi.org/"
-                              (org-link-escape
-                               path org-link-escape-chars-browser))))
+         (browse-url (concat "http://dx.doi.org/" (if (org-string-match-p "[[:nonascii:] ]" path)
+                                                      (org-link-escape
+                                                       path org-link-escape-chars-browser)
+                                                    path))))
 
         ((member type '("message"))
          (browse-url (concat type ":" path)))
@@ -9463,7 +9650,8 @@ application the system uses for this file type."
                              ((equal arg '(16)) ''org-occur)
                              (t nil))
                       ,pos)))
-           (condition-case nil (eval cmd)
+           (condition-case nil (let ((org-link-search-inhibit-query t))
+                                 (eval cmd))
              (error (progn (widen) (eval cmd))))))
 
         (t
@@ -9499,7 +9687,7 @@ there is one, offer it as link number zero."
      ((equal (length links) 1)
       (setq link (list (car links))))
      ((and (integerp nth) (>= (length links) (if have-zero (1+ nth) nth)))
-      (setq link (nth (if have-zero nth (1- nth)) links)))
+      (setq link (list (nth (if have-zero nth (1- nth)) links))))
      (t ; we have to select a link
       (save-excursion
        (save-window-excursion
@@ -9607,13 +9795,18 @@ the window configuration before `org-open-at-point' was called using:
     (set-window-configuration org-window-config-before-follow-link)")
 
 (defvar org-link-search-inhibit-query nil) ;; dynamically scoped
-(defun org-link-search (s &optional type avoid-pos)
+(defun org-link-search (s &optional type avoid-pos stealth)
   "Search for a link search option.
 If S is surrounded by forward slashes, it is interpreted as a
 regular expression.  In org-mode files, this will create an `org-occur'
 sparse tree.  In ordinary files, `occur' will be used to list matches.
 If the current buffer is in `dired-mode', grep will be used to search
-in all files.  If AVOID-POS is given, ignore matches near that position."
+in all files.  If AVOID-POS is given, ignore matches near that position.
+
+When optional argument STEALTH is non-nil, do not modify
+visibility around point, thus ignoring
+`org-show-hierarchy-above', `org-show-following-heading' and
+`org-show-siblings' variables."
   (let ((case-fold-search t)
        (s0 (mapconcat 'identity (org-split-string s "[ \t\r\n]+") " "))
        (markers (concat "\\(?:" (mapconcat (lambda (x) (regexp-quote (car x)))
@@ -9664,12 +9857,12 @@ in all files.  If AVOID-POS is given, ignore matches near that position."
      ((string-match "^/\\(.*\\)/$" s)
       ;; A regular expression
       (cond
-       ((org-mode-p)
+       ((eq major-mode 'org-mode)
        (org-occur (match-string 1 s)))
        ;;((eq major-mode 'dired-mode)
        ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *")))
        (t (org-do-occur (match-string 1 s)))))
-     ((and (org-mode-p) org-link-search-must-match-exact-headline)
+     ((and (eq major-mode 'org-mode) org-link-search-must-match-exact-headline)
       (and (equal (string-to-char s) ?*) (setq s (substring s 1)))
       (goto-char (point-min))
       (cond
@@ -9737,7 +9930,9 @@ in all files.  If AVOID-POS is given, ignore matches near that position."
              (goto-char (match-beginning 1))
            (goto-char pos)
            (error "No match"))))))
-    (and (org-mode-p) (org-show-context 'link-search))
+    (and (eq major-mode 'org-mode)
+        (not stealth)
+        (org-show-context 'link-search))
     type))
 
 (defun org-search-not-self (group &rest args)
@@ -9833,7 +10028,7 @@ onto the ring."
       (setq p org-mark-ring))
     (setq org-mark-ring-last-goto p)
     (setq m (car p))
-    (switch-to-buffer (marker-buffer m))
+    (org-pop-to-buffer-same-window (marker-buffer m))
     (goto-char m)
     (if (or (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto))))
 
@@ -9891,6 +10086,10 @@ Optional LINE specifies a line to go to, optional SEARCH a string
 to search for.  If LINE or SEARCH is given, the file will be
 opened in Emacs, unless an entry from org-file-apps that makes
 use of groups in a regexp matches.
+
+If you want to change the way frames are used when following a
+link, please customize `org-link-frame-setup'.
+
 If the file does not exist, an error is thrown."
   (let* ((file (if (equal path "")
                   buffer-file-name
@@ -9940,8 +10139,8 @@ If the file does not exist, an error is thrown."
                                 match)
                        (progn (setq in-emacs (or in-emacs line search))
                               nil))) ; if we have no match in apps-dlink,
-                                     ; always open the file in emacs if line or search
-                                     ; is given (for backwards compatibility)
+                                     ; always open the file in emacs if line or search
+                                     ; is given (for backwards compatibility)
                    (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p)
                                   'string-match)
                    (cdr (assoc ext apps))
@@ -10002,7 +10201,7 @@ If the file does not exist, an error is thrown."
          (set-match-data link-match-data)
          (eval cmd))))
      (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
-    (and (org-mode-p) (eq old-mode 'org-mode)
+    (and (eq major-mode 'org-mode) (eq old-mode 'org-mode)
         (or (not (equal old-buffer (current-buffer)))
             (not (equal old-pos (point))))
         (org-mark-ring-push old-pos old-buffer))))
@@ -10215,7 +10414,8 @@ on the system \"/user@host:\"."
                           (or (funcall org-refile-target-verify-function)
                               (throw 'next t))))
                       (when (and (looking-at org-complex-heading-regexp)
-                                 (not (member (match-string 4) excluded-entries)))
+                                 (not (member (match-string 4) excluded-entries))
+                                 (match-string 4))
                         (setq level (org-reduced-level
                                      (- (match-end 1) (match-beginning 1)))
                               txt (org-link-display-format (match-string 4))
@@ -10325,7 +10525,7 @@ such as the file name."
   (interactive "P")
   (let* ((bfn (buffer-file-name (buffer-base-buffer)))
         (case-fold-search nil)
-        (path (and (org-mode-p) (org-get-outline-path))))
+        (path (and (eq major-mode 'org-mode) (org-get-outline-path))))
     (if current (setq path (append path
                                   (save-excursion
                                     (org-back-to-heading t)
@@ -10391,8 +10591,10 @@ prefix argument (`C-u C-u C-u C-c C-w')."
        (goto-char region-start)
        (or (bolp) (goto-char (point-at-bol)))
        (setq region-start (point))
-       (unless (org-kill-is-subtree-p
-                (buffer-substring region-start region-end))
+       (unless (or (org-kill-is-subtree-p
+                    (buffer-substring region-start region-end))
+                   (prog1 org-refile-active-region-within-subtree
+                     (org-toggle-heading)))
          (error "The region is not a (sequence of) subtree(s)")))
       (if (equal goto '(16))
          (org-refile-goto-last-stored)
@@ -10407,10 +10609,20 @@ prefix argument (`C-u C-u C-u C-c C-w')."
                                       (marker-position org-clock-hd-marker)))
                      (setq goto nil)))
               (setq it (or rfloc
-                           (save-excursion
-                             (org-refile-get-location
-                              (if goto "Goto" "Refile to") default-buffer
-                              org-refile-allow-creating-parent-nodes)))))
+                           (let (heading-text)
+                             (save-excursion
+                               (unless goto
+                                 (org-back-to-heading t)
+                                 (setq heading-text
+                                       (nth 4 (org-heading-components))))
+                               (org-refile-get-location
+                                (cond (goto "Goto")
+                                      (regionp "Refile region to")
+                                      (t (concat "Refile subtree \""
+                                                 heading-text "\" to")))
+                                default-buffer
+                                org-refile-allow-creating-parent-nodes
+                                goto))))))
          (setq file (nth 1 it)
                re (nth 2 it)
                pos (nth 3 it))
@@ -10429,7 +10641,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
                         (find-file-noselect file)))
          (if goto
              (progn
-               (switch-to-buffer nbuf)
+               (org-pop-to-buffer-same-window nbuf)
                (goto-char pos)
                (org-show-context 'org-goto))
            (if regionp
@@ -10489,16 +10701,20 @@ prefix argument (`C-u C-u C-u C-c C-w')."
   (bookmark-jump "org-refile-last-stored")
   (message "This is the location of the last refile"))
 
-(defun org-refile-get-location (&optional prompt default-buffer new-nodes)
+(defun org-refile-get-location (&optional prompt default-buffer new-nodes
+                                         no-exclude)
   "Prompt the user for a refile location, using PROMPT.
 PROMPT should not be suffixed with a colon and a space, because
 this function appends the default value from
-`org-refile-history' automatically, if that is not empty."
+`org-refile-history' automatically, if that is not empty.
+When NO-EXCLUDE is set, do not exclude headlines in the current subtree,
+this is used for the GOTO interface."
   (let ((org-refile-targets org-refile-targets)
        (org-refile-use-outline-path org-refile-use-outline-path)
        excluded-entries)
     (when (and (eq major-mode 'org-mode)
-              (not org-refile-use-cache))
+              (not org-refile-use-cache)
+              (not no-exclude))
       (org-map-tree
        (lambda()
         (setq excluded-entries
@@ -10776,7 +10992,7 @@ Error if there is no such block at point."
   "Update all dynamic blocks in the buffer.
 This function can be used in a hook."
   (interactive)
-  (when (org-mode-p)
+  (when (eq major-mode 'org-mode)
     (org-map-dblocks 'org-update-dblock)))
 
 
@@ -10795,10 +11011,8 @@ This function can be used in a hook."
     "BEGIN_CENTER" "END_CENTER"
     "BEGIN_SRC" "END_SRC"
     "BEGIN_RESULT" "END_RESULT"
-    "SOURCE:" "SRCNAME:" "FUNCTION:"
-    "RESULTS:" "DATA:"
+    "NAME:" "RESULTS:"
     "HEADER:" "HEADERS:"
-    "BABEL:"
     "CATEGORY:" "COLUMNS:" "PROPERTY:"
     "CAPTION:" "LABEL:"
     "SETUPFILE:"
@@ -10897,13 +11111,16 @@ expands them."
   (save-excursion
     (org-back-to-heading)
     (let (case-fold-search)
-      (if (looking-at (concat org-outline-regexp
-                             "\\( *\\<" org-comment-string "\\>[ \t]*\\)"))
-         (replace-match "" t t nil 1)
-       (if (looking-at org-outline-regexp)
-           (progn
-             (goto-char (match-end 0))
-             (insert org-comment-string " ")))))))
+      (cond
+       ((looking-at (format org-heading-keyword-regexp-format
+                           org-comment-string))
+       (goto-char (match-end 1))
+       (looking-at (concat " +" org-comment-string))
+       (replace-match "" t t)
+       (when (eolp) (insert " ")))
+       ((looking-at org-outline-regexp)
+       (goto-char (match-end 0))
+       (insert org-comment-string " "))))))
 
 (defvar org-last-todo-state-is-todo nil
   "This is non-nil when the last TODO state change led to a TODO state.
@@ -10929,26 +11146,21 @@ nil or a string to be used for the todo mark." )
   (let* ((ct (org-current-time))
          (dct (decode-time ct))
          (ct1
-          (if (< (nth 2 dct) org-extend-today-until)
+          (if (and org-use-effective-time
+                   (< (nth 2 dct) org-extend-today-until))
               (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))
             ct)))
     ct1))
 
 (defun org-todo-yesterday (&optional arg)
-  "Like `org-todo' but the time of change will be 23:59 of yesterday"
+  "Like `org-todo' but the time of change will be 23:59 of yesterday."
   (interactive "P")
-  (let* ((hour (third (decode-time
-                       (org-current-time))))
-         (org-extend-today-until (1+ hour)))
-    (org-todo arg)))
-
-(defun org-agenda-todo-yesterday (&optional arg)
-  "Like `org-agenda-todo' but the time of change will be 23:59 of yesterday"
-  (interactive "P")
-  (let* ((hour (third (decode-time
-                       (org-current-time))))
-         (org-extend-today-until (1+ hour)))
-    (org-agenda-todo arg)))
+  (if (eq major-mode 'org-agenda-mode)
+      (apply 'org-agenda-todo-yesterday arg)
+    (let* ((hour (third (decode-time
+                        (org-current-time))))
+          (org-extend-today-until (1+ hour)))
+      (org-todo arg))))
 
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
@@ -10969,6 +11181,7 @@ With numeric prefix arg, switch to that state.
 With a double \\[universal-argument] prefix, switch to the next set of TODO \
 keywords (nextset).
 With a triple \\[universal-argument] prefix, circumvent any state blocking.
+With a numeric prefix arg of 0, inhibit note taking for the change.
 
 For calling through lisp, arg is also interpreted in the following way:
 'none             -> empty state
@@ -10979,191 +11192,202 @@ For calling through lisp, arg is also interpreted in the following way:
 \"WAITING\"         -> switch to the specified keyword, but only if it
                      really is a member of `org-todo-keywords'."
   (interactive "P")
-  (if (equal arg '(16)) (setq arg 'nextset))
-  (let ((org-blocker-hook org-blocker-hook)
-       (case-fold-search nil))
-    (when (equal arg '(64))
-      (setq arg nil org-blocker-hook nil))
-    (when (and org-blocker-hook
-              (or org-inhibit-blocking
-                  (org-entry-get nil "NOBLOCKING")))
-      (setq org-blocker-hook nil))
-    (save-excursion
-      (catch 'exit
-       (org-back-to-heading t)
-       (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0))))
-       (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)"))
-           (looking-at " *"))
-       (let* ((match-data (match-data))
-              (startpos (point-at-bol))
-              (logging (save-match-data (org-entry-get nil "LOGGING" t t)))
-              (org-log-done org-log-done)
-              (org-log-repeat org-log-repeat)
-              (org-todo-log-states org-todo-log-states)
-              (this (match-string 1))
-              (hl-pos (match-beginning 0))
-              (head (org-get-todo-sequence-head this))
-              (ass (assoc head org-todo-kwd-alist))
-              (interpret (nth 1 ass))
-              (done-word (nth 3 ass))
-              (final-done-word (nth 4 ass))
-              (last-state (or this ""))
-              (completion-ignore-case t)
-              (member (member this org-todo-keywords-1))
-              (tail (cdr member))
-              (state (cond
-                      ((and org-todo-key-trigger
-                            (or (and (equal arg '(4))
-                                     (eq org-use-fast-todo-selection 'prefix))
-                                (and (not arg) org-use-fast-todo-selection
-                                     (not (eq org-use-fast-todo-selection
-                                              'prefix)))))
-                       ;; Use fast selection
-                       (org-fast-todo-selection))
-                      ((and (equal arg '(4))
-                            (or (not org-use-fast-todo-selection)
-                                (not org-todo-key-trigger)))
-                       ;; Read a state with completion
-                       (org-icompleting-read
-                        "State: " (mapcar (lambda(x) (list x))
-                                          org-todo-keywords-1)
-                        nil t))
-                      ((eq arg 'right)
-                       (if this
-                           (if tail (car tail) nil)
-                         (car org-todo-keywords-1)))
-                      ((eq arg 'left)
-                       (if (equal member org-todo-keywords-1)
-                           nil
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
+                   'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        `(org-todo ,arg)
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (if (equal arg '(16)) (setq arg 'nextset))
+    (let ((org-blocker-hook org-blocker-hook)
+         (case-fold-search nil))
+      (when (equal arg '(64))
+       (setq arg nil org-blocker-hook nil))
+      (when (and org-blocker-hook
+                (or org-inhibit-blocking
+                    (org-entry-get nil "NOBLOCKING")))
+       (setq org-blocker-hook nil))
+      (save-excursion
+       (catch 'exit
+         (org-back-to-heading t)
+         (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0))))
+         (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)"))
+             (looking-at "\\(?: *\\|[ \t]*$\\)"))
+         (let* ((match-data (match-data))
+                (startpos (point-at-bol))
+                (logging (save-match-data (org-entry-get nil "LOGGING" t t)))
+                (org-log-done org-log-done)
+                (org-log-repeat org-log-repeat)
+                (org-todo-log-states org-todo-log-states)
+                (org-inhibit-logging
+                 (if (equal arg 0)
+                     (progn (setq arg nil) 'note) org-inhibit-logging))
+                (this (match-string 1))
+                (hl-pos (match-beginning 0))
+                (head (org-get-todo-sequence-head this))
+                (ass (assoc head org-todo-kwd-alist))
+                (interpret (nth 1 ass))
+                (done-word (nth 3 ass))
+                (final-done-word (nth 4 ass))
+                (last-state (or this ""))
+                (completion-ignore-case t)
+                (member (member this org-todo-keywords-1))
+                (tail (cdr member))
+                (state (cond
+                        ((and org-todo-key-trigger
+                              (or (and (equal arg '(4))
+                                       (eq org-use-fast-todo-selection 'prefix))
+                                  (and (not arg) org-use-fast-todo-selection
+                                       (not (eq org-use-fast-todo-selection
+                                                'prefix)))))
+                         ;; Use fast selection
+                         (org-fast-todo-selection))
+                        ((and (equal arg '(4))
+                              (or (not org-use-fast-todo-selection)
+                                  (not org-todo-key-trigger)))
+                         ;; Read a state with completion
+                         (org-icompleting-read
+                          "State: " (mapcar (lambda(x) (list x))
+                                            org-todo-keywords-1)
+                          nil t))
+                        ((eq arg 'right)
                          (if this
-                             (nth (- (length org-todo-keywords-1)
-                                     (length tail) 2)
-                                  org-todo-keywords-1)
-                           (org-last org-todo-keywords-1))))
-                      ((and (eq org-use-fast-todo-selection t) (equal arg '(4))
-                            (setq arg nil))) ; hack to fall back to cycling
-                      (arg
-                       ;; user or caller requests a specific state
-                       (cond
-                        ((equal arg "") nil)
-                        ((eq arg 'none) nil)
-                        ((eq arg 'done) (or done-word (car org-done-keywords)))
-                        ((eq arg 'nextset)
-                         (or (car (cdr (member head org-todo-heads)))
-                             (car org-todo-heads)))
-                        ((eq arg 'previousset)
-                         (let ((org-todo-heads (reverse org-todo-heads)))
+                             (if tail (car tail) nil)
+                           (car org-todo-keywords-1)))
+                        ((eq arg 'left)
+                         (if (equal member org-todo-keywords-1)
+                             nil
+                           (if this
+                               (nth (- (length org-todo-keywords-1)
+                                       (length tail) 2)
+                                    org-todo-keywords-1)
+                             (org-last org-todo-keywords-1))))
+                        ((and (eq org-use-fast-todo-selection t) (equal arg '(4))
+                              (setq arg nil))) ; hack to fall back to cycling
+                        (arg
+                         ;; user or caller requests a specific state
+                         (cond
+                          ((equal arg "") nil)
+                          ((eq arg 'none) nil)
+                          ((eq arg 'done) (or done-word (car org-done-keywords)))
+                          ((eq arg 'nextset)
                            (or (car (cdr (member head org-todo-heads)))
-                               (car org-todo-heads))))
-                        ((car (member arg org-todo-keywords-1)))
-                        ((stringp arg)
-                         (error "State `%s' not valid in this file" arg))
-                        ((nth (1- (prefix-numeric-value arg))
-                              org-todo-keywords-1))))
-                      ((null member) (or head (car org-todo-keywords-1)))
-                      ((equal this final-done-word) nil) ;; -> make empty
-                      ((null tail) nil) ;; -> first entry
-                      ((memq interpret '(type priority))
-                       (if (eq this-command last-command)
-                           (car tail)
-                         (if (> (length tail) 0)
-                             (or done-word (car org-done-keywords))
-                           nil)))
-                      (t
-                       (car tail))))
-              (state (or
-                      (run-hook-with-args-until-success
-                       'org-todo-get-default-hook state last-state)
-                      state))
-              (next (if state (concat " " state " ") " "))
-              (change-plist (list :type 'todo-state-change :from this :to state
-                                  :position startpos))
-              dolog now-done-p)
-         (when org-blocker-hook
+                               (car org-todo-heads)))
+                          ((eq arg 'previousset)
+                           (let ((org-todo-heads (reverse org-todo-heads)))
+                             (or (car (cdr (member head org-todo-heads)))
+                                 (car org-todo-heads))))
+                          ((car (member arg org-todo-keywords-1)))
+                          ((stringp arg)
+                           (error "State `%s' not valid in this file" arg))
+                          ((nth (1- (prefix-numeric-value arg))
+                                org-todo-keywords-1))))
+                        ((null member) (or head (car org-todo-keywords-1)))
+                        ((equal this final-done-word) nil) ;; -> make empty
+                        ((null tail) nil) ;; -> first entry
+                        ((memq interpret '(type priority))
+                         (if (eq this-command last-command)
+                             (car tail)
+                           (if (> (length tail) 0)
+                               (or done-word (car org-done-keywords))
+                             nil)))
+                        (t
+                         (car tail))))
+                (state (or
+                        (run-hook-with-args-until-success
+                         'org-todo-get-default-hook state last-state)
+                        state))
+                (next (if state (concat " " state " ") " "))
+                (change-plist (list :type 'todo-state-change :from this :to state
+                                    :position startpos))
+                dolog now-done-p)
+           (when org-blocker-hook
+             (setq org-last-todo-state-is-todo
+                   (not (member this org-done-keywords)))
+             (unless (save-excursion
+                       (save-match-data
+                         (org-with-wide-buffer
+                          (run-hook-with-args-until-failure
+                           'org-blocker-hook change-plist))))
+               (if (org-called-interactively-p 'interactive)
+                   (error "TODO state change from %s to %s blocked" this state)
+                 ;; fail silently
+                 (message "TODO state change from %s to %s blocked" this state)
+                 (throw 'exit nil))))
+           (store-match-data match-data)
+           (replace-match next t t)
+           (unless (pos-visible-in-window-p hl-pos)
+             (message "TODO state changed to %s" (org-trim next)))
+           (unless head
+             (setq head (org-get-todo-sequence-head state)
+                   ass (assoc head org-todo-kwd-alist)
+                   interpret (nth 1 ass)
+                   done-word (nth 3 ass)
+                   final-done-word (nth 4 ass)))
+           (when (memq arg '(nextset previousset))
+             (message "Keyword-Set %d/%d: %s"
+                      (- (length org-todo-sets) -1
+                         (length (memq (assoc state org-todo-sets) org-todo-sets)))
+                      (length org-todo-sets)
+                      (mapconcat 'identity (assoc state org-todo-sets) " ")))
            (setq org-last-todo-state-is-todo
-                 (not (member this org-done-keywords)))
-           (unless (save-excursion
-                     (save-match-data
-                       (org-with-wide-buffer
-                        (run-hook-with-args-until-failure
-                         'org-blocker-hook change-plist))))
-             (if (org-called-interactively-p 'interactive)
-                 (error "TODO state change from %s to %s blocked" this state)
-               ;; fail silently
-               (message "TODO state change from %s to %s blocked" this state)
-               (throw 'exit nil))))
-         (store-match-data match-data)
-         (replace-match next t t)
-         (unless (pos-visible-in-window-p hl-pos)
-           (message "TODO state changed to %s" (org-trim next)))
-         (unless head
-           (setq head (org-get-todo-sequence-head state)
-                 ass (assoc head org-todo-kwd-alist)
-                 interpret (nth 1 ass)
-                 done-word (nth 3 ass)
-                 final-done-word (nth 4 ass)))
-         (when (memq arg '(nextset previousset))
-           (message "Keyword-Set %d/%d: %s"
-                    (- (length org-todo-sets) -1
-                       (length (memq (assoc state org-todo-sets) org-todo-sets)))
-                    (length org-todo-sets)
-                    (mapconcat 'identity (assoc state org-todo-sets) " ")))
-         (setq org-last-todo-state-is-todo
-               (not (member state org-done-keywords)))
-         (setq now-done-p (and (member state org-done-keywords)
-                               (not (member this org-done-keywords))))
-         (and logging (org-local-logging logging))
-         (when (and (or org-todo-log-states org-log-done)
-                    (not (eq org-inhibit-logging t))
-                    (not (memq arg '(nextset previousset))))
-           ;; we need to look at recording a time and note
-           (setq dolog (or (nth 1 (assoc state org-todo-log-states))
-                           (nth 2 (assoc this org-todo-log-states))))
-           (if (and (eq dolog 'note) (eq org-inhibit-logging 'note))
-               (setq dolog 'time))
-           (when (and state
-                      (member state org-not-done-keywords)
-                      (not (member this org-not-done-keywords)))
-             ;; This is now a todo state and was not one before
-             ;; If there was a CLOSED time stamp, get rid of it.
-             (org-add-planning-info nil nil 'closed))
-           (when (and now-done-p org-log-done)
-             ;; It is now done, and it was not done before
-             (org-add-planning-info 'closed (org-current-effective-time))
-             (if (and (not dolog) (eq 'note org-log-done))
-                 (org-add-log-setup 'done state this 'findpos 'note)))
-           (when (and state dolog)
-             ;; This is a non-nil state, and we need to log it
-             (org-add-log-setup 'state state this 'findpos dolog)))
-         ;; Fixup tag positioning
-         (org-todo-trigger-tag-changes state)
-         (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)))
-         (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head)
-         ;; Do we need to trigger a repeat?
-         (when now-done-p
-           (when (boundp 'org-agenda-headline-snapshot-before-repeat)
-             ;; This is for the agenda, take a snapshot of the headline.
-             (save-match-data
-               (setq org-agenda-headline-snapshot-before-repeat
-                     (org-get-heading))))
-           (org-auto-repeat-maybe state))
-         ;; Fixup cursor location if close to the keyword
-         (if (and (outline-on-heading-p)
-                  (not (bolp))
-                  (save-excursion (beginning-of-line 1)
-                                  (looking-at org-todo-line-regexp))
-                  (< (point) (+ 2 (or (match-end 2) (match-end 1)))))
-             (progn
-               (goto-char (or (match-end 2) (match-end 1)))
-               (and (looking-at " ") (just-one-space))))
-         (when org-trigger-hook
-           (save-excursion
-             (run-hook-with-args 'org-trigger-hook change-plist))))))))
+                 (not (member state org-done-keywords)))
+           (setq now-done-p (and (member state org-done-keywords)
+                                 (not (member this org-done-keywords))))
+           (and logging (org-local-logging logging))
+           (when (and (or org-todo-log-states org-log-done)
+                      (not (eq org-inhibit-logging t))
+                      (not (memq arg '(nextset previousset))))
+             ;; we need to look at recording a time and note
+             (setq dolog (or (nth 1 (assoc state org-todo-log-states))
+                             (nth 2 (assoc this org-todo-log-states))))
+             (if (and (eq dolog 'note) (eq org-inhibit-logging 'note))
+                 (setq dolog 'time))
+             (when (and state
+                        (member state org-not-done-keywords)
+                        (not (member this org-not-done-keywords)))
+               ;; This is now a todo state and was not one before
+               ;; If there was a CLOSED time stamp, get rid of it.
+               (org-add-planning-info nil nil 'closed))
+             (when (and now-done-p org-log-done)
+               ;; It is now done, and it was not done before
+               (org-add-planning-info 'closed (org-current-effective-time))
+               (if (and (not dolog) (eq 'note org-log-done))
+                   (org-add-log-setup 'done state this 'findpos 'note)))
+             (when (and state dolog)
+               ;; This is a non-nil state, and we need to log it
+               (org-add-log-setup 'state state this 'findpos dolog)))
+           ;; Fixup tag positioning
+           (org-todo-trigger-tag-changes state)
+           (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)))
+           (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head)
+           ;; Do we need to trigger a repeat?
+           (when now-done-p
+             (when (boundp 'org-agenda-headline-snapshot-before-repeat)
+               ;; This is for the agenda, take a snapshot of the headline.
+               (save-match-data
+                 (setq org-agenda-headline-snapshot-before-repeat
+                       (org-get-heading))))
+             (org-auto-repeat-maybe state))
+           ;; Fixup cursor location if close to the keyword
+           (if (and (outline-on-heading-p)
+                    (not (bolp))
+                    (save-excursion (beginning-of-line 1)
+                                    (looking-at org-todo-line-regexp))
+                    (< (point) (+ 2 (or (match-end 2) (match-end 1)))))
+               (progn
+                 (goto-char (or (match-end 2) (match-end 1)))
+                 (and (looking-at " ") (just-one-space))))
+           (when org-trigger-hook
+             (save-excursion
+               (run-hook-with-args 'org-trigger-hook change-plist)))))))))
 
 (defun org-block-todo-from-children-or-siblings-or-parent (change-plist)
   "Block turning an entry into a TODO, using the hierarchy.
@@ -11217,7 +11441,7 @@ changes.  Such blocking occurs when:
                     (forward-line 1)
                     (re-search-forward org-not-done-heading-regexp pos t))
            (throw 'dont-block nil))  ; block, there is an older sibling not done.
-         ;; Search further up the hierarchy, to see if an ancestor is blocked
+         ;; Search further up the hierarchy, to see if an anchestor is blocked
          (while t
            (goto-char parent-pos)
            (if (not (looking-at org-not-done-heading-regexp))
@@ -11291,8 +11515,11 @@ changes because there are unchecked boxes in this entry."
          (outline-next-heading)
          (setq end (point))
          (goto-char beg)
-         (if (re-search-forward "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\[[- ]\\]"
-                                end t)
+         (if (org-list-search-forward
+              (concat (org-item-beginning-re)
+                      "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
+                      "\\[[- ]\\]")
+              end t)
              (progn
                (if (boundp 'org-blocked-by-checkboxes)
                    (setq org-blocked-by-checkboxes t))
@@ -11319,17 +11546,17 @@ This should be called with the cursor in a line with a statistics cookie."
       (progn
        (org-update-checkbox-count 'all)
        (org-map-entries 'org-update-parent-todo-statistics))
-    (if (not (org-on-heading-p))
+    (if (not (org-at-heading-p))
        (org-update-checkbox-count)
       (let ((pos (move-marker (make-marker) (point)))
            end l1 l2)
        (ignore-errors (org-back-to-heading t))
-       (if (not (org-on-heading-p))
+       (if (not (org-at-heading-p))
            (org-update-checkbox-count)
          (setq l1 (org-outline-level))
          (setq end (save-excursion
                      (outline-next-heading)
-                     (if (org-on-heading-p) (setq l2 (org-outline-level)))
+                     (if (org-at-heading-p) (setq l2 (org-outline-level)))
                      (point)))
          (if (and (save-excursion
                     (re-search-forward
@@ -11724,39 +11951,47 @@ With argument REMOVE, remove any deadline from the item.
 With argument TIME, set the deadline at the corresponding date.  TIME
 can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
   (interactive "P")
-  (let* ((old-date (org-entry-get nil "DEADLINE"))
-        (repeater (and old-date
-                       (string-match
-                        "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
-                         old-date)
-                       (match-string 1 old-date))))
-    (if remove
-       (progn
-         (when (and old-date org-log-redeadline)
-           (org-add-log-setup 'deldeadline nil old-date 'findpos
-                              org-log-redeadline))
-         (org-remove-timestamp-with-keyword org-deadline-string)
-         (message "Item no longer has a deadline."))
-      (org-add-planning-info 'deadline time 'closed)
-      (when (and old-date org-log-redeadline
-                (not (equal old-date
-                            (substring org-last-inserted-timestamp 1 -1))))
-       (org-add-log-setup 'redeadline nil old-date 'findpos
-                          org-log-redeadline))
-      (when repeater
-       (save-excursion
-         (org-back-to-heading t)
-         (when (re-search-forward (concat org-deadline-string " "
-                                          org-last-inserted-timestamp)
-                                  (save-excursion
-                                    (outline-next-heading) (point)) t)
-           (goto-char (1- (match-end 0)))
-           (insert " " repeater)
-           (setq org-last-inserted-timestamp
-                 (concat (substring org-last-inserted-timestamp 0 -1)
-                         " " repeater
-                         (substring org-last-inserted-timestamp -1))))))
-      (message "Deadline on %s" org-last-inserted-timestamp))))
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
+                   'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        `(org-deadline ',remove ,time)
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (let* ((old-date (org-entry-get nil "DEADLINE"))
+          (repeater (and old-date
+                         (string-match
+                          "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+                          old-date)
+                         (match-string 1 old-date))))
+      (if remove
+         (progn
+           (when (and old-date org-log-redeadline)
+             (org-add-log-setup 'deldeadline nil old-date 'findpos
+                                org-log-redeadline))
+           (org-remove-timestamp-with-keyword org-deadline-string)
+           (message "Item no longer has a deadline."))
+       (org-add-planning-info 'deadline time 'closed)
+       (when (and old-date org-log-redeadline
+                  (not (equal old-date
+                              (substring org-last-inserted-timestamp 1 -1))))
+         (org-add-log-setup 'redeadline nil old-date 'findpos
+                            org-log-redeadline))
+       (when repeater
+         (save-excursion
+           (org-back-to-heading t)
+           (when (re-search-forward (concat org-deadline-string " "
+                                            org-last-inserted-timestamp)
+                                    (save-excursion
+                                      (outline-next-heading) (point)) t)
+             (goto-char (1- (match-end 0)))
+             (insert " " repeater)
+             (setq org-last-inserted-timestamp
+                   (concat (substring org-last-inserted-timestamp 0 -1)
+                           " " repeater
+                           (substring org-last-inserted-timestamp -1))))))
+       (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.
@@ -11764,39 +11999,47 @@ With argument REMOVE, remove any scheduling date from the item.
 With argument TIME, scheduled at the corresponding date.  TIME can
 either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
   (interactive "P")
-  (let* ((old-date (org-entry-get nil "SCHEDULED"))
-        (repeater (and old-date
-                       (string-match
-                        "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
-                        old-date)
-                       (match-string 1 old-date))))
-    (if remove
-       (progn
-         (when (and old-date org-log-reschedule)
-           (org-add-log-setup 'delschedule nil old-date 'findpos
-                              org-log-reschedule))
-         (org-remove-timestamp-with-keyword org-scheduled-string)
-         (message "Item is no longer scheduled."))
-      (org-add-planning-info 'scheduled time 'closed)
-      (when (and old-date org-log-reschedule
-                (not (equal old-date
-                            (substring org-last-inserted-timestamp 1 -1))))
-       (org-add-log-setup 'reschedule nil old-date 'findpos
-                          org-log-reschedule))
-      (when repeater
-       (save-excursion
-         (org-back-to-heading t)
-         (when (re-search-forward (concat org-scheduled-string " "
-                                          org-last-inserted-timestamp)
-                                  (save-excursion
-                                    (outline-next-heading) (point)) t)
-           (goto-char (1- (match-end 0)))
-           (insert " " repeater)
-           (setq org-last-inserted-timestamp
-                 (concat (substring org-last-inserted-timestamp 0 -1)
-                         " " repeater
-                         (substring org-last-inserted-timestamp -1))))))
-      (message "Scheduled to %s" org-last-inserted-timestamp))))
+  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
+      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
+                   'region-start-level 'region))
+           org-loop-over-headlines-in-active-region)
+       (org-map-entries
+        `(org-schedule ',remove ,time)
+        org-loop-over-headlines-in-active-region
+        cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
+    (let* ((old-date (org-entry-get nil "SCHEDULED"))
+          (repeater (and old-date
+                         (string-match
+                          "\\([.+-]+[0-9]+[dwmy]\\(?:[/ ][-+]?[0-9]+[dwmy]\\)?\\) ?"
+                          old-date)
+                         (match-string 1 old-date))))
+      (if remove
+         (progn
+           (when (and old-date org-log-reschedule)
+             (org-add-log-setup 'delschedule nil old-date 'findpos
+                                org-log-reschedule))
+           (org-remove-timestamp-with-keyword org-scheduled-string)
+           (message "Item is no longer scheduled."))
+       (org-add-planning-info 'scheduled time 'closed)
+       (when (and old-date org-log-reschedule
+                  (not (equal old-date
+                              (substring org-last-inserted-timestamp 1 -1))))
+         (org-add-log-setup 'reschedule nil old-date 'findpos
+                            org-log-reschedule))
+       (when repeater
+         (save-excursion
+           (org-back-to-heading t)
+           (when (re-search-forward (concat org-scheduled-string " "
+                                            org-last-inserted-timestamp)
+                                    (save-excursion
+                                      (outline-next-heading) (point)) t)
+             (goto-char (1- (match-end 0)))
+             (insert " " repeater)
+             (setq org-last-inserted-timestamp
+                   (concat (substring org-last-inserted-timestamp 0 -1)
+                           " " repeater
+                           (substring org-last-inserted-timestamp -1))))))
+       (message "Scheduled to %s" org-last-inserted-timestamp)))))
 
 (defun org-get-scheduled-time (pom &optional inherit)
   "Get the scheduled time as a time tuple, of a format suitable
@@ -11861,9 +12104,8 @@ be removed."
                  default-input (and ts (org-get-compact-tod ts))))))
       (when what
        (setq time
-             (if (and (stringp time)
-                      (string-match "^[-+]+[0-9]" time))
-                 ;; This is a relative time, set the proper date
+             (if (stringp time)
+                 ;; This is a string (relative or absolute), set proper date
                  (apply 'encode-time
                         (org-read-date-analyze
                          time default-time (decode-time default-time)))
@@ -11914,7 +12156,7 @@ be removed."
                             (re-search-forward org-closed-time-regexp nil t)))
                (replace-match "")
                (if (looking-at "--+<[^>]+>") (replace-match ""))))
-           (and (looking-at "^[ \t]+") (replace-match ""))
+           (and (looking-at "[ \t]+") (replace-match ""))
            (and org-adapt-indentation (bolp) (org-indent-to-column col))
            (when what
              (insert
@@ -12041,7 +12283,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
   (setq org-log-note-window-configuration (current-window-configuration))
   (delete-other-windows)
   (move-marker org-log-note-return-to (point))
-  (switch-to-buffer (marker-buffer org-log-note-marker))
+  (org-pop-to-buffer-same-window (marker-buffer org-log-note-marker))
   (goto-char org-log-note-marker)
   (org-switch-to-buffer-other-window "*Org Note*")
   (erase-buffer)
@@ -12071,7 +12313,8 @@ EXTRA is additional text that will be inserted into the notes buffer."
                      "this entry")
                     (t (error "This should not happen")))))
     (if org-log-note-extra (insert org-log-note-extra))
-    (org-set-local 'org-finish-function 'org-store-log-note)))
+    (org-set-local 'org-finish-function 'org-store-log-note)
+    (run-hooks 'org-log-buffer-setup-hook)))
 
 (defvar org-note-abort nil) ; dynamically scoped
 (defun org-store-log-note ()
@@ -12097,6 +12340,12 @@ EXTRA is additional text that will be inserted into the notes buffer."
                   (cons "%T" (format-time-string
                               (org-time-stamp-format 'long nil)
                               org-log-note-effective-time))
+                  (cons "%d" (format-time-string
+                              (org-time-stamp-format nil 'inactive)
+                              org-log-note-effective-time))
+                  (cons "%D" (format-time-string
+                              (org-time-stamp-format nil nil)
+                              org-log-note-effective-time))
                   (cons "%s" (if org-log-note-state
                                  (concat "\"" org-log-note-state "\"")
                                ""))
@@ -12175,7 +12424,7 @@ b      Show deadlines and scheduled items before a date.
 a      Show deadlines and scheduled items after a date."
   (interactive "P")
   (let (ans kwd value)
-    (message "Sparse tree: [r]egexp [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty\n             [d]eadlines [b]efore-date [a]fter-date")
+    (message "Sparse tree: [r]egexp [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty\n             [d]eadlines [b]efore-date [a]fter-date [D]ates range")
     (setq ans (read-char-exclusive))
     (cond
      ((equal ans ?d)
@@ -12184,6 +12433,8 @@ a      Show deadlines and scheduled items after a date."
       (call-interactively 'org-check-before-date))
      ((equal ans ?a)
       (call-interactively 'org-check-after-date))
+     ((equal ans ?D)
+      (call-interactively 'org-check-dates-range))
      ((equal ans ?t)
       (org-show-todo-tree nil))
      ((equal ans ?T)
@@ -12286,9 +12537,9 @@ starting point when no match is found."
 (defun org-show-context (&optional key)
   "Make sure point and context are visible.
 How much context is shown depends upon the variables
-`org-show-hierarchy-above', `org-show-following-heading'. and
-`org-show-siblings'."
-  (let ((heading-p   (org-on-heading-p t))
+`org-show-hierarchy-above', `org-show-following-heading',
+`org-show-entry-below' and `org-show-siblings'."
+  (let ((heading-p   (org-at-heading-p t))
        (hierarchy-p (org-get-alist-option org-show-hierarchy-above key))
        (following-p (org-get-alist-option org-show-following-heading key))
        (entry-p     (org-get-alist-option org-show-entry-below key))
@@ -12476,7 +12727,7 @@ ACTION can be `set', `up', `down', or a character."
 (defvar org-agenda-archives-mode)
 (defvar org-map-continue-from nil
   "Position from where mapping should continue.
-Can be set by the action argument to `org-scan-tag's and `org-map-entries'.")
+Can be set by the action argument to `org-scan-tags' and `org-map-entries'.")
 
 (defvar org-scanner-tags nil
   "The current tag list while the tags scanner is running.")
@@ -12491,7 +12742,7 @@ obtain a list of properties.  Building the tags list for each entry in such
 a file becomes an N^2 operation - but with this variable set, it scales
 as N.")
 
-(defun org-scan-tags (action matcher &optional todo-only)
+(defun org-scan-tags (action matcher &optional todo-only start-level)
   "Scan headline tags with inheritance and produce output ACTION.
 
 ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
@@ -12501,9 +12752,17 @@ 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."
+only lines with a TODO keyword are included in the output.
+
+START-LEVEL can be a string with asterisks, reducing the scope to
+headlines matching this string."
   (require 'org-agenda)
-  (let* ((re (concat "^" org-outline-regexp " *\\(\\<\\("
+  (let* ((re (concat "^"
+                    (if start-level
+                        ;; Get the correct level to match
+                        (concat "\\*\\{" (number-to-string start-level) "\\} ")
+                      org-outline-regexp)
+                    " *\\(\\<\\("
                     (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
                     (org-re
                      "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*$")))
@@ -12513,6 +12772,7 @@ only lines with a TODO keyword are included in the output."
                      '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
                      'help-echo
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name
@@ -12532,6 +12792,7 @@ only lines with a TODO keyword are included in the output."
        (org-overview)
        (org-remove-occur-highlights))
       (while (re-search-forward re nil t)
+       (setq org-map-continue-from nil)
        (catch :skip
          (setq todo (if (match-end 1) (org-match-string-no-properties 2))
                tags (if (match-end 4) (org-match-string-no-properties 4)))
@@ -12603,7 +12864,7 @@ only lines with a TODO keyword are included in the output."
                    (match-beginning 0) (match-beginning 1)))
              (org-show-context 'tags-tree))
             ((eq action 'agenda)
-             (setq txt (org-format-agenda-item
+             (setq txt (org-agenda-format-item
                         ""
                         (concat
                          (if (eq org-tags-match-list-sublevels 'indented)
@@ -12996,7 +13257,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
          (goto-char (match-beginning 1))
          (insert " ")
          (delete-region (point) (1+ (match-beginning 2)))
-         (setq ncol (max (1+ (current-column))
+         (setq ncol (max (current-column)
                          (1+ col)
                          (if (> to-col 0)
                              to-col
@@ -13011,7 +13272,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
 (defun org-set-tags-command (&optional arg just-align)
   "Call the set-tags command for the current entry."
   (interactive "P")
-  (if (org-on-heading-p)
+  (if (org-at-heading-p)
       (org-set-tags arg just-align)
     (save-excursion
       (org-back-to-heading t)
@@ -13055,7 +13316,7 @@ If DATA is nil or the empty string, any tags will be removed."
   (save-excursion
     (or (ignore-errors (org-back-to-heading t))
        (outline-next-heading))
-    (if (org-on-heading-p)
+    (if (org-at-heading-p)
        (org-set-tags t)
       (message "No headings"))))
 
@@ -13159,7 +13420,7 @@ This works in the agenda, and also in an org-mode buffer."
   (interactive
    (list (region-beginning) (region-end)
         (let ((org-last-tags-completion-table
-               (if (org-mode-p)
+               (if (eq major-mode 'org-mode)
                    (org-get-buffer-tags)
                  (org-global-tags-completion-table))))
           (org-icompleting-read
@@ -13178,7 +13439,7 @@ This works in the agenda, and also in an org-mode buffer."
     (loop for l from l1 to l2 do
          (org-goto-line l)
          (setq m (get-text-property (point) 'org-hd-marker))
-         (when (or (and (org-mode-p) (org-on-heading-p))
+         (when (or (and (eq major-mode 'org-mode) (org-at-heading-p))
                    (and agendap m))
            (setq buf (if agendap (marker-buffer m) (current-buffer))
                  pos (if agendap m (point)))
@@ -13439,7 +13700,7 @@ Returns the new tags string, or nil to not change the current settings."
 
 (defun org-get-tags-string ()
   "Get the TAGS string in the current headline."
-  (unless (org-on-heading-p t)
+  (unless (org-at-heading-p t)
     (error "Not on a heading"))
   (save-excursion
     (beginning-of-line 1)
@@ -13496,6 +13757,9 @@ 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
 region  The entries within the active region, if any
+region-start-level
+        The entries within the active region, but only those at
+        the same level than the first one.
 file    The current buffer, without restriction
 file-with-archives
         The current buffer, and any archives associated with it
@@ -13524,61 +13788,76 @@ with `org-get-tags-at'.  If your function gets properties with
 to t around the call to `org-entry-properties' to get the same speedup.
 Note that if your function moves around to retrieve tags and properties at
 a *different* entry, you cannot use these techniques."
-  (let* ((org-agenda-archives-mode nil) ; just to make sure
-        (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 file res
-        org-todo-keywords-for-agenda
-        org-done-keywords-for-agenda
-        org-todo-keyword-alist-for-agenda
-        org-drawers-for-agenda
-        org-tag-alist-for-agenda)
+  (unless (and (or (eq scope 'region) (eq scope 'region-start-level))
+              (not (org-region-active-p)))
+    (let* ((org-agenda-archives-mode nil) ; just to make sure
+          (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)
+          (start-level (eq scope 'region-start-level))
+          matcher file res
+          org-todo-keywords-for-agenda
+          org-done-keywords-for-agenda
+          org-todo-keyword-alist-for-agenda
+          org-drawers-for-agenda
+          org-tag-alist-for-agenda)
 
-    (cond
-     ((eq match t)   (setq matcher t))
-     ((eq match nil) (setq matcher t))
-     (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t))))
+      (cond
+       ((eq match t)   (setq matcher t))
+       ((eq match nil) (setq matcher t))
+       (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t))))
 
-    (save-excursion
-      (save-restriction
-       (cond ((eq scope 'tree)
-              (org-back-to-heading t)
-              (org-narrow-to-subtree)
-              (setq scope nil))
-             ((and (eq scope 'region) (org-region-active-p))
-              (narrow-to-region (region-beginning) (region-end))
-              (setq scope nil)))
-
-       (if (not scope)
-           (progn
-             (org-prepare-agenda-buffers
-              (list (buffer-file-name (current-buffer))))
-             (setq res (org-scan-tags func matcher)))
-         ;; Get the right scope
-         (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))
-                 (setq res (append res (org-scan-tags func matcher))))))))))
-    res))
+      (save-excursion
+       (save-restriction
+         (cond ((eq scope 'tree)
+                (org-back-to-heading t)
+                (org-narrow-to-subtree)
+                (setq scope nil))
+               ((and (or (eq scope 'region) (eq scope 'region-start-level))
+                     (org-region-active-p))
+                ;; If needed, set start-level to a string like "2"
+                (when start-level
+                  (save-excursion
+                    (goto-char (region-beginning))
+                    (unless (org-at-heading-p) (outline-next-heading))
+                    (setq start-level (org-current-level))))
+                (narrow-to-region (region-beginning)
+                                  (save-excursion
+                                    (goto-char (region-end))
+                                    (unless (and (bolp) (org-at-heading-p))
+                                      (outline-next-heading))
+                                    (point)))
+                (setq scope nil)))
+
+         (if (not scope)
+             (progn
+               (org-prepare-agenda-buffers
+                (list (buffer-file-name (current-buffer))))
+               (setq res (org-scan-tags func matcher nil start-level)))
+           ;; Get the right scope
+           (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))
+                   (setq res (append res (org-scan-tags func matcher))))))))))
+      res)))
 
 ;;;; Properties
 
@@ -13748,7 +14027,7 @@ things up because then unnecessary parsing is avoided."
          beg end range props sum-props key key1 value string clocksum)
       (save-excursion
        (when (condition-case nil
-                 (and (org-mode-p) (org-back-to-heading t))
+                 (and (eq major-mode 'org-mode) (org-back-to-heading t))
                (error nil))
          (setq beg (point))
          (setq sum-props (get-text-property (point) 'org-summaries))
@@ -13859,17 +14138,23 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
          (cdr (assoc property (org-entry-properties nil 'special property)))
        (let ((range (unless (org-before-first-heading-p)
                       (org-get-property-block))))
-         (if (and range
-                  (goto-char (car range))
-                  (re-search-forward
-                   (org-re-property property)
-                   (cdr range) t))
-             ;; Found the property, return it.
-             (if (match-end 1)
-                 (if literal-nil
-                     (org-match-string-no-properties 1)
-                   (org-not-nil (org-match-string-no-properties 1)))
-               "")))))))
+         (when (and range (goto-char (car range)))
+           ((lambda (val) (when val (if literal-nil val (org-not-nil val))))
+            (cond
+             ((re-search-forward
+               (org-re-property property) (cdr range) t)
+              (if (match-end 1) (org-match-string-no-properties 1) ""))
+             ((re-search-forward
+               (org-re-property (concat property "+")) (cdr range) t)
+              (cdr (assoc
+                    property
+                    (org-update-property-plist
+                     (concat property "+")
+                     (if (match-end 1) (org-match-string-no-properties 1) "")
+                     (list (or (assoc property org-file-properties)
+                               (assoc property org-global-properties)
+                               (assoc property org-global-properties-fixed)
+                               ))))))))))))))
 
 (defun org-property-or-variable-value (var &optional inherit)
   "Check if there is a property fixing the value of VAR.
@@ -14221,8 +14506,11 @@ xxx_ALL property) or on existing values in other instances of this property
 in the current file."
   (interactive (list nil nil))
   (let* ((property (or property (org-read-property-name)))
-        (value (or value (org-read-property-value property))))
+        (value (or value (org-read-property-value property)))
+        (fn (assoc property org-properties-postprocess-alist)))
     (setq org-last-set-property property)
+    ;; Possibly postprocess the inserted value:
+    (when fn (setq value (funcall (cadr fn) value)))
     (unless (equal (org-entry-get nil property) value)
       (org-entry-put nil property value))))
 
@@ -14387,7 +14675,7 @@ only headings."
            (goto-char found)
            (setq lmin (1+ flevel) lmax (+ lmin (if org-odd-levels-only 1 0)))
            (setq end (save-excursion (org-end-of-subtree t t))))
-         (when (org-on-heading-p)
+         (when (org-at-heading-p)
            (move-marker (make-marker) (point))))))))
 
 (defun org-find-exact-headline-in-buffer (heading &optional buffer pos-only)
@@ -14567,7 +14855,7 @@ The prompt will suggest to enter an ISO date, but you can also enter anything
 which will at least partially be understood by `parse-time-string'.
 Unrecognized parts of the date will default to the current day, month, year,
 hour and minute.  If this command is called to replace a timestamp at point,
-of to enter the second timestamp of a range, the default time is taken
+or to enter the second timestamp of a range, the default time is taken
 from the existing stamp.  Furthermore, the command prefers the future,
 so if you are giving a date where the year is not given, and the day-month
 combination is already past in the current year, it will assume you
@@ -14835,7 +15123,7 @@ user."
       (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day)
                               t nil ans)))
 
-    ;; Help matching dotted european dates
+    ;; Help matching dottet european dates
     (when (string-match
           "^ *\\(3[01]\\|0?[1-9]\\|[12][0-9]\\)\\. ?\\(0?[1-9]\\|1[012]\\)\\. ?\\([1-9][0-9][0-9][0-9]\\)?" ans)
       (setq year (if (match-end 3)
@@ -14996,6 +15284,7 @@ WHAT       is \"d\", \"w\", \"m\", or \"y\" for day, week, month, year.
 N          is the number of WHATs to shift.
 DEF-FLAG   is t when a double ++ or -- indicates shift relative to
            the DEFAULT date rather than TODAY."
+  (require 'parse-time)
   (when (and
         (string-match
          (concat
@@ -15259,6 +15548,27 @@ days.  If the prefix is a raw \\[universal-argument] prefix, all deadlines are s
     (message "%d entries after %s"
             (org-occur regexp nil callback) date)))
 
+(defun org-check-dates-range (start-date end-date)
+  "Check for deadlines/scheduled entries between START-DATE and END-DATE."
+  (interactive (list (org-read-date nil nil nil "Range starts")
+                    (org-read-date nil nil nil "Range end")))
+  (let ((case-fold-search nil)
+       (regexp (concat "\\<\\(" org-deadline-string
+                       "\\|" org-scheduled-string
+                       "\\) *<\\([^>]+\\)>"))
+       (callback
+        (lambda ()
+          (let ((match (match-string 2)))
+            (and
+             (not (time-less-p
+                   (org-time-string-to-time match)
+                   (org-time-string-to-time start-date)))
+             (time-less-p
+              (org-time-string-to-time match)
+              (org-time-string-to-time end-date)))))))
+    (message "%d entries between %s and %s"
+            (org-occur regexp nil callback) start-date end-date)))
+
 (defun org-evaluate-time-range (&optional to-buffer)
   "Evaluate a time range by computing the difference between start and end.
 Normally the result is just printed in the echo area, but with prefix arg
@@ -15336,12 +15646,19 @@ days in order to avoid rounding problems."
                      l (push m l)))
     (apply 'format fmt (nreverse l))))
 
-(defun org-time-string-to-time (s)
-  (apply 'encode-time (org-parse-time-string s)))
+(defun org-time-string-to-time (s &optional buffer pos)
+  (condition-case errdata
+      (apply 'encode-time (org-parse-time-string s))
+    (error (error "Bad timestamp `%s'%s\nError was: %s"
+                 s (if (not (and buffer pos))
+                       ""
+                     (format " at %d in buffer `%s'" pos buffer))
+                 (cdr errdata)))))
+
 (defun org-time-string-to-seconds (s)
   (org-float-time (org-time-string-to-time s)))
 
-(defun org-time-string-to-absolute (s &optional daynr prefer show-all)
+(defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos)
   "Convert a time stamp to an absolute day number.
 If there is a specifier for a cyclic time stamp, get the closest date to
 DAYNR.
@@ -15356,7 +15673,14 @@ The variable date is bound by the calendar when this is called."
     (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
                          (time-to-days (current-time))) (match-string 0 s)
                          prefer show-all))
-   (t (time-to-days (apply 'encode-time (org-parse-time-string s))))))
+   (t (time-to-days
+       (condition-case errdata
+          (apply 'encode-time (org-parse-time-string s))
+        (error (error "Bad timestamp `%s'%s\nError was: %s"
+                      s (if (not (and buffer pos))
+                            ""
+                          (format " at %d in buffer `%s'" pos buffer))
+                      (cdr errdata))))))))
 
 (defun org-days-to-iso-week (days)
   "Return the iso week number."
@@ -15552,7 +15876,7 @@ With prefix ARG, change by that many units."
 With prefix ARG, change that many days."
   (interactive "p")
   (if (and (not (org-at-timestamp-p t))
-          (org-on-heading-p))
+          (org-at-heading-p))
       (org-todo 'up)
     (org-timestamp-change (prefix-numeric-value arg) 'day 'updown)))
 
@@ -15561,7 +15885,7 @@ With prefix ARG, change that many days."
 With prefix ARG, change that many days."
   (interactive "p")
   (if (and (not (org-at-timestamp-p t))
-          (org-on-heading-p))
+          (org-at-heading-p))
       (org-todo 'down)
     (org-timestamp-change (- (prefix-numeric-value arg)) 'day) 'updown))
 
@@ -15581,7 +15905,10 @@ With prefix ARG, change that many days."
         (setq org-ts-what
              (cond
               ((= pos (match-beginning 0))         'bracket)
-              ((= pos (1- (match-end 0)))          'bracket)
+              ;; Point is considered to be "on the bracket" whether
+              ;; it's really on it or right after it.
+              ((or (= pos (1- (match-end 0)))
+                    (= pos (match-end 0)))          'bracket)
               ((org-pos-in-match-range pos 2)      'year)
               ((org-pos-in-match-range pos 3)      'month)
               ((org-pos-in-match-range pos 7)      'hour)
@@ -15857,7 +16184,7 @@ Entries containing a colon are interpreted as H:MM by
   "Save all Org-mode buffers without user confirmation."
   (interactive)
   (message "Saving all Org-mode buffers...")
-  (save-some-buffers t 'org-mode-p)
+  (save-some-buffers t (lambda () (eq major-mode 'org-mode)))
   (when (featurep 'org-id) (org-id-locations-save))
   (message "Saving all Org-mode buffers... done"))
 
@@ -15881,9 +16208,9 @@ changes from another.  I believe the procedure must be like this:
     (save-window-excursion
       (mapc
        (lambda (b)
-        (when (and (with-current-buffer b (org-mode-p))
+        (when (and (with-current-buffer b (eq major-mode 'org-mode))
                    (with-current-buffer b buffer-file-name))
-          (switch-to-buffer b)
+          (org-pop-to-buffer-same-window b)
           (revert-buffer t 'no-confirm)))
        (buffer-list))
       (when (and (featurep 'org-id) org-id-track-globally)
@@ -15894,7 +16221,7 @@ changes from another.  I believe the procedure must be like this:
 ;;;###autoload
 (defun org-switchb (&optional arg)
   "Switch between Org buffers.
-With a prefix argument, restrict available to files.
+With one prefix argument, restrict available buffers to files.
 With two prefix arguments, restrict available buffers to agenda files.
 
 Defaults to `iswitchb' for buffer name completion.
@@ -15907,7 +16234,7 @@ Set `org-completion-use-ido' to make it use ido instead."
        (org-completion-use-ido org-completion-use-ido))
     (unless (or org-completion-use-ido org-completion-use-iswitchb)
       (setq org-completion-use-iswitchb t))
-    (switch-to-buffer
+    (org-pop-to-buffer-same-window
      (org-icompleting-read "Org buffer: "
                           (mapcar 'list (mapcar 'buffer-name blist))
                           nil t))))
@@ -15933,17 +16260,17 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
         (filter
          (cond
           ((eq predicate 'files)
-           (lambda (b) (with-current-buffer b (org-mode-p))))
+           (lambda (b) (with-current-buffer b (eq major-mode 'org-mode))))
           ((eq predicate 'export)
            (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
           ((eq predicate 'agenda)
            (lambda (b)
              (with-current-buffer b
-               (and (org-mode-p)
+               (and (eq major-mode 'org-mode)
                     (setq bfn (buffer-file-name b))
                     (member (file-truename bfn) agenda-files)))))
           (t (lambda (b) (with-current-buffer b
-                           (or (org-mode-p)
+                           (or (eq major-mode 'org-mode)
                                (string-match "\*Org .*Export"
                                              (buffer-name b)))))))))
     (delq nil
@@ -16074,7 +16401,7 @@ If the current buffer does not, find the first agenda file."
              (find-file (car files))
              (throw 'exit t))))
       (find-file (car fs)))
-    (if (buffer-base-buffer) (switch-to-buffer (buffer-base-buffer)))))
+    (if (buffer-base-buffer) (org-pop-to-buffer-same-window (buffer-base-buffer)))))
 
 (defun org-agenda-file-to-front (&optional to-end)
   "Move/add the current file to the top of the agenda file list.
@@ -16196,10 +16523,11 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
              (when org-agenda-skip-archived-trees
                (goto-char (point-min))
                (while (re-search-forward rea nil t)
-                 (if (org-on-heading-p t)
+                 (if (org-at-heading-p t)
                      (add-text-properties (point-at-bol) (org-end-of-subtree t) pa))))
              (goto-char (point-min))
-             (setq re (concat org-outline-regexp-bol "+" org-comment-string "\\>"))
+             (setq re (format org-heading-keyword-regexp-format
+                              org-comment-string))
              (while (re-search-forward re nil t)
                (add-text-properties
                 (match-beginning 0) (org-end-of-subtree t) pc)))
@@ -16230,7 +16558,10 @@ This mode supports entering LaTeX environment and math in LaTeX fragments
 in Org-mode.
 \\{org-cdlatex-mode-map}"
   nil " OCDL" nil
-  (when org-cdlatex-mode (require 'cdlatex))
+  (when org-cdlatex-mode
+    (require 'cdlatex)
+    (run-hooks 'cdlatex-mode-hook)
+    (cdlatex-compute-tables))
   (unless org-cdlatex-texmathp-advice-is-done
     (setq org-cdlatex-texmathp-advice-is-done t)
     (defadvice texmathp (around org-math-always-on activate)
@@ -16242,7 +16573,7 @@ an embedded LaTeX fragment, let texmathp do its job.
       (interactive)
       (let (p)
        (cond
-        ((not (org-mode-p)) ad-do-it)
+        ((not (eq major-mode 'org-mode)) ad-do-it)
         ((eq this-command 'cdlatex-math-symbol)
          (setq ad-return-value t
                texmathp-why '("cdlatex-math-symbol in org-mode" . 0)))
@@ -16315,14 +16646,16 @@ It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
     insert a LaTeX environment."
   (when org-cdlatex-mode
     (cond
+     ;; Before any word on the line: No expansion possible.
+     ((save-excursion (skip-chars-backward " \t") (bolp)) nil)
+     ;; Just after first word on the line: Expand it.  Make sure it
+     ;; cannot happen on headlines, though.
      ((save-excursion
        (skip-chars-backward "a-zA-Z0-9*")
        (skip-chars-backward " \t")
-       (bolp))
-      (cdlatex-tab) t)
-     ((org-inside-LaTeX-fragment-p)
+       (and (bolp) (not (org-at-heading-p))))
       (cdlatex-tab) t)
-     (t nil))))
+     ((org-inside-LaTeX-fragment-p) (cdlatex-tab) t))))
 
 (defun org-cdlatex-underscore-caret (&optional arg)
   "Execute `cdlatex-sub-superscript' in LaTeX fragments.
@@ -16397,8 +16730,8 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
   '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
     ;; ("$" "\\([      (]\\|^\\)\\(\\(\\([$]\\)\\([^   \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^       \r\n,.$]\\)\\4\\)\\)\\([        .,?;:'\")]\\|$\\)" 2 nil)
     ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
-    ("$1" "\\([^$]\\)\\(\\$[^  \r\n,;.$]\\$\\)\\([-    .,?;:'\")\000]\\|$\\)" 2 nil)
-    ("$" "\\([^$]\\)\\(\\(\\$\\([^     \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^        \r\n,.$]\\)\\$\\)\\)\\([-       .,?;:'\")\000]\\|$\\)" 2 nil)
+    ("$1" "\\([^$]\\|^\\)\\(\\$[^      \r\n,;.$]\\$\\)\\([-    .,?;:'\")\000]\\|$\\)" 2 nil)
+    ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^         \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^        \r\n,.$]\\)\\$\\)\\)\\([-       .,?;:'\")\000]\\|$\\)" 2 nil)
     ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
     ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
     ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
@@ -16421,11 +16754,11 @@ Some of the options can be changed using the variable
          (plist-get (org-infile-export-plist) :latex-header-extra))
         (cnt 0) txt hash link beg end re e checkdir
         executables-checked string
-        m n block linkfile movefile ov)
+        m n block-type block linkfile movefile ov)
     ;; Check the different regular expressions
     (while (setq e (pop re-list))
-      (setq m (car e) re (nth 1 e) n (nth 2 e)
-           block (if (nth 3 e) "\n\n" ""))
+      (setq m (car e) re (nth 1 e) n (nth 2 e) block-type (nth 3 e)
+           block (if block-type "\n\n" ""))
       (when (member m matchers)
        (goto-char (point-min))
        (while (re-search-forward re nil t)
@@ -16454,7 +16787,7 @@ Some of the options can be changed using the variable
                                '(org-protected t))))
                (add-text-properties (match-beginning n) (match-end n)
                                     '(org-protected t))))
-            ((or (eq processing-type 'dvipng) t)
+            ((eq processing-type 'dvipng)
              ;; Process to an image
              (setq txt (match-string n)
                    beg (match-beginning n) end (match-end n)
@@ -16510,7 +16843,115 @@ Some of the options can be changed using the variable
                (insert (org-add-props link
                            (list 'org-latex-src
                                  (replace-regexp-in-string
-                                  "\"" "" txt)))))))))))))
+                                  "\"" "" txt)
+                                 'org-latex-src-embed-type
+                                 (if block-type 'paragraph 'character))))))
+            ((eq processing-type 'mathml)
+             ;; Process to MathML
+             (unless executables-checked
+               (unless (save-match-data (org-format-latex-mathml-available-p))
+                 (error "LaTeX to MathML converter not configured"))
+               (setq executables-checked t))
+             (setq txt (match-string n)
+                   beg (match-beginning n) end (match-end n)
+                   cnt (1+ cnt))
+             (if msg (message msg cnt))
+             (goto-char beg)
+             (delete-region beg end)
+             (insert (org-format-latex-as-mathml
+                      txt block-type prefix dir)))
+            (t
+             (error "Unknown conversion type %s for latex fragments"
+                    processing-type)))))))))
+
+(defun org-create-math-formula (latex-frag &optional mathml-file)
+  "Convert LATEX-FRAG to MathML and store it in MATHML-FILE.
+Use `org-latex-to-mathml-convert-command'.  If the conversion is
+sucessful, return the portion between \"<math...> </math>\"
+elements otherwise return nil.  When MATHML-FILE is specified,
+write the results in to that file.  When invoked as an
+interactive command, prompt for LATEX-FRAG, with initial value
+set to the current active region and echo the results for user
+inspection."
+  (interactive (list (let ((frag (when (region-active-p)
+                                  (buffer-substring-no-properties
+                                   (region-beginning) (region-end)))))
+                      (read-string "LaTeX Fragment: " frag nil frag))))
+  (unless latex-frag (error "Invalid latex-frag"))
+  (let* ((tmp-in-file (file-relative-name
+                      (make-temp-name (expand-file-name "ltxmathml-in"))))
+        (ignore (write-region latex-frag nil tmp-in-file))
+        (tmp-out-file (file-relative-name
+                       (make-temp-name (expand-file-name  "ltxmathml-out"))))
+        (cmd (format-spec
+              org-latex-to-mathml-convert-command
+              `((?j . ,(shell-quote-argument
+                        (expand-file-name org-latex-to-mathml-jar-file)))
+                (?I . ,(shell-quote-argument tmp-in-file))
+                (?o . ,(shell-quote-argument tmp-out-file)))))
+        mathml shell-command-output)
+    (when (org-called-interactively-p 'any)
+      (unless (org-format-latex-mathml-available-p)
+       (error "LaTeX to MathML converter not configured")))
+    (message "Running %s" cmd)
+    (setq shell-command-output (shell-command-to-string cmd))
+    (setq mathml
+         (when (file-readable-p tmp-out-file)
+           (with-current-buffer (find-file-noselect tmp-out-file t)
+             (goto-char (point-min))
+             (when (re-search-forward
+                    (concat
+                     (regexp-quote
+                      "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">")
+                     "\\(.\\|\n\\)*"
+                     (regexp-quote "</math>")) nil t)
+               (prog1 (match-string 0) (kill-buffer))))))
+    (cond
+     (mathml
+      (setq mathml
+           (concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" mathml))
+      (when mathml-file
+       (write-region mathml nil mathml-file))
+      (when (org-called-interactively-p 'any)
+       (message mathml)))
+     ((message "LaTeX to MathML conversion failed")
+      (message shell-command-output)))
+    (delete-file tmp-in-file)
+    (when (file-exists-p tmp-out-file)
+      (delete-file tmp-out-file))
+    mathml))
+
+(defun org-format-latex-as-mathml (latex-frag latex-frag-type
+                                             prefix &optional dir)
+  "Use `org-create-math-formula' but check local cache first."
+  (let* ((absprefix (expand-file-name prefix dir))
+        (print-length nil) (print-level nil)
+        (formula-id (concat
+                     "formula-"
+                     (sha1
+                      (prin1-to-string
+                       (list latex-frag
+                             org-latex-to-mathml-convert-command)))))
+        (formula-cache (format "%s-%s.mathml" absprefix formula-id))
+        (formula-cache-dir (file-name-directory formula-cache)))
+
+    (unless (file-directory-p formula-cache-dir)
+      (make-directory formula-cache-dir t))
+
+    (unless (file-exists-p formula-cache)
+      (org-create-math-formula latex-frag formula-cache))
+
+    (if (file-exists-p formula-cache)
+       ;; Successful conversion.  Return the link to MathML file.
+       (org-add-props
+           (format  "[[file:%s]]" (file-relative-name formula-cache dir))
+           (list 'org-latex-src (replace-regexp-in-string "\"" "" latex-frag)
+                 'org-latex-src-embed-type (if latex-frag-type
+                                               'paragraph 'character)))
+      ;; Failed conversion.  Return the LaTeX fragment verbatim
+      (add-text-properties
+       0 (1- (length latex-frag)) '(org-protected t) latex-frag)
+      latex-frag)))
 
 ;; This function borrows from Ganesh Swami's latex2png.el
 (defun org-create-formula-image (string tofile options buffer)
@@ -16718,6 +17159,44 @@ BEG and END default to the buffer boundaries."
 
 ;;;; Key bindings
 
+;; Outline functions from `outline-mode-prefix-map'
+;; that can be remapped in Org:
+(define-key org-mode-map [remap outline-mark-subtree] 'org-mark-subtree)
+(define-key org-mode-map [remap show-subtree] 'org-show-subtree)
+(define-key org-mode-map [remap outline-forward-same-level]
+  'org-forward-same-level)
+(define-key org-mode-map [remap outline-backward-same-level]
+  'org-backward-same-level)
+(define-key org-mode-map [remap show-branches]
+  'org-kill-note-or-show-branches)
+(define-key org-mode-map [remap outline-promote] 'org-promote-subtree)
+(define-key org-mode-map [remap outline-demote] 'org-demote-subtree)
+(define-key org-mode-map [remap outline-insert-heading] 'org-ctrl-c-ret)
+
+;; Outline functions from `outline-mode-prefix-map'
+;; that can not be remapped in Org:
+;; - the column "key binding" shows whether the Outline function is still
+;;   available in Org mode on the same key that it has been bound to in
+;;   Outline mode:
+;;   - "overridden": key used for a different functionality in Org mode
+;;   - else: key still bound to the same Outline function in Org mode
+;; | Outline function                   | key binding | Org replacement       |
+;; |------------------------------------+-------------+-----------------------|
+;; | `outline-next-visible-heading'     | `C-c C-n'   | still same function   |
+;; | `outline-previous-visible-heading' | `C-c C-p'   | still same function   |
+;; | `show-children'                    | `C-c C-i'   | visibility cycling    |
+;; | `hide-subtree'                     | overridden  | visibility cycling    |
+;; | `outline-up-heading'               | `C-c C-u'   | still same function   |
+;; | `hide-body'                        | overridden  | no replacement        |
+;; | `show-all'                         | overridden  | no replacement        |
+;; | `hide-entry'                       | overridden  | visibility cycling    |
+;; | `show-entry'                       | overridden  | no replacement        |
+;; | `hide-leaves'                      | overridden  | no replacement        |
+;; | `hide-sublevels'                   | overridden  | no replacement        |
+;; | `hide-other'                       | overridden  | no replacement        |
+;; | `outline-move-subtree-up'          | `C-c C-^'   | better: org-shiftup   |
+;; | `outline-move-subtree-down'        | overridden  | better: org-shiftdown |
+
 ;; Make `C-c C-x' a prefix key
 (org-defkey org-mode-map "\C-c\C-x" (make-sparse-keymap))
 
@@ -17011,7 +17490,7 @@ If not, return to the original position and throw an error."
   (interactive)
   (let ((pos (point)))
     (call-interactively cmd)
-    (unless (and (bolp) (org-on-heading-p))
+    (unless (and (bolp) (org-at-heading-p))
       (goto-char pos)
       (error "Boundary reached while executing %s" cmd))))
 
@@ -17022,8 +17501,8 @@ If not, return to the original position and throw an error."
 
 (defun org-speed-command-default-hook (keys)
   "Hook for activating single-letter speed commands.
-`org-speed-commands-default' specifies a minimal command set. Use
-`org-speed-commands-user' for further customization."
+`org-speed-commands-default' specifies a minimal command set.
+Use `org-speed-commands-user' for further customization."
   (when (or (and (bolp) (looking-at org-outline-regexp))
            (and (functionp org-use-speed-commands)
                 (funcall org-use-speed-commands)))
@@ -17045,11 +17524,11 @@ Each hook takes a single argument, a user-pressed command key
 which is also a `self-insert-command' from the global map.
 
 Within the hook, examine the cursor position and the command key
-and return nil or a valid handler as appropriate. Handler could
+and return nil or a valid handler as appropriate.  Handler could
 be one of an interactive command, a function, or a form.
 
 Set `org-use-speed-commands' to non-nil value to enable this
-hook. The default setting is `org-speed-command-default-hook'."
+hook.  The default setting is `org-speed-command-default-hook'."
   :group 'org-structure
   :type 'hook)
 
@@ -17058,6 +17537,7 @@ hook. The default setting is `org-speed-command-default-hook'."
 If the cursor is in a table looking at whitespace, the whitespace is
 overwritten, and the table is not marked as requiring realignment."
   (interactive "p")
+  (org-check-before-invisible-edit 'insert)
   (cond
    ((and org-use-speed-commands
         (setq org-speed-command
@@ -17109,9 +17589,56 @@ overwritten, and the table is not marked as requiring realignment."
            (setq org-self-insert-command-undo-counter
                  (1+ org-self-insert-command-undo-counter))))))))
 
+(defun org-check-before-invisible-edit (kind)
+  "Check is editing if kind KIND would be dangerous with invisible text around.
+The detailed reaction depends on the user option `org-catch-invisible-edits'."
+  ;; First, try to get out of here as quickly as possible, to reduce overhead
+  (if (and org-catch-invisible-edits
+          (or (not (boundp 'visible-mode)) (not visible-mode))
+          (or (get-char-property (point) 'invisible)
+              (get-char-property (max (point-min) (1- (point))) 'invisible)))
+      ;; OK, we need to take a closer look
+      (let* ((invisible-at-point (get-char-property (point) 'invisible))
+            (invisible-before-point (if (bobp) nil  (get-char-property
+                                                     (1- (point)) 'invisible)))
+            (border-and-ok-direction
+             (or
+              ;; Check if we are acting predictably before invisible text
+              (and invisible-at-point (not invisible-before-point)
+                   (memq kind '(insert delete-backward)))
+              ;; Check if we are acting predictably after invisible text
+              ;; This works not well, and I have turned it off.  It seems
+              ;; better to always show and stop after invisible text.
+              ;; (and (not invisible-at-point) invisible-before-point
+              ;;  (memq kind '(insert delete)))
+              )))
+
+       (when (or (memq invisible-at-point '(outline org-hide-block))
+                 (memq invisible-before-point '(outline org-hide-block)))
+         (if (eq org-catch-invisible-edits 'error)
+             (error "Editing in invisible areas is prohibited - make visible first"))
+         ;; Make the area visible
+         (save-excursion
+           (if invisible-before-point
+               (goto-char (previous-single-char-property-change
+                           (point) 'invisible)))
+           (org-cycle))
+         (cond
+          ((eq org-catch-invisible-edits 'show)
+           ;; That's it, we do the edit after showing
+           (message
+            "Unfolding invisible region around point before editing")
+           (sit-for 1))
+          ((and (eq org-catch-invisible-edits 'smart)
+                border-and-ok-direction)
+           (message "Unfolding invisible region around point before editing"))
+          (t
+           ;; Don't do the edit, make the user repeat it in full visibility
+           (error "Edit in invisible region aborted, repeat to confirm with text visible")))))))
+
 (defun org-fix-tags-on-the-fly ()
   (when (and (equal (char-after (point-at-bol)) ?*)
-            (org-on-heading-p))
+            (org-at-heading-p))
     (org-align-tags-here org-tags-column)))
 
 (defun org-delete-backward-char (N)
@@ -17121,6 +17648,7 @@ front of the next \"|\" separator, to keep the table aligned.  The table will
 still be marked for re-alignment if the field did fill the entire column,
 because, in this case the deletion might narrow the column."
   (interactive "p")
+  (org-check-before-invisible-edit 'delete-backward)
   (if (and (org-table-p)
           (eq N 1)
           (string-match "|" (buffer-substring (point-at-bol) (point)))
@@ -17147,6 +17675,7 @@ front of the next \"|\" separator, to keep the table aligned.  The table will
 still be marked for re-alignment if the field did fill the entire column,
 because, in this case the deletion might narrow the column."
   (interactive "p")
+  (org-check-before-invisible-edit 'delete)
   (if (and (org-table-p)
           (not (bolp))
           (not (= (char-after) ?|))
@@ -17357,7 +17886,7 @@ See the individual commands for more information."
   (cond
    ((run-hook-with-args-until-success 'org-shiftmetaleft-hook))
    ((org-at-table-p) (call-interactively 'org-table-delete-column))
-   ((org-on-heading-p) (call-interactively 'org-promote-subtree))
+   ((org-at-heading-p) (call-interactively 'org-promote-subtree))
    ((org-at-item-p) (call-interactively 'org-outdent-item-tree))
    (t (org-modifier-cursor-error))))
 
@@ -17370,7 +17899,7 @@ See the individual commands for more information."
   (cond
    ((run-hook-with-args-until-success 'org-shiftmetaright-hook))
    ((org-at-table-p) (call-interactively 'org-table-insert-column))
-   ((org-on-heading-p) (call-interactively 'org-demote-subtree))
+   ((org-at-heading-p) (call-interactively 'org-demote-subtree))
    ((org-at-item-p) (call-interactively 'org-indent-item-tree))
    (t (org-modifier-cursor-error))))
 
@@ -17383,7 +17912,7 @@ for more information."
   (cond
    ((run-hook-with-args-until-success 'org-shiftmetaup-hook))
    ((org-at-table-p) (call-interactively 'org-table-kill-row))
-   ((org-on-heading-p) (call-interactively 'org-move-subtree-up))
+   ((org-at-heading-p) (call-interactively 'org-move-subtree-up))
    ((org-at-item-p) (call-interactively 'org-move-item-up))
    (t (org-modifier-cursor-error))))
 
@@ -17396,7 +17925,7 @@ commands for more information."
   (cond
    ((run-hook-with-args-until-success 'org-shiftmetadown-hook))
    ((org-at-table-p) (call-interactively 'org-table-insert-row))
-   ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
+   ((org-at-heading-p) (call-interactively 'org-move-subtree-down))
    ((org-at-item-p) (call-interactively 'org-move-item-down))
    (t (org-modifier-cursor-error))))
 
@@ -17414,15 +17943,15 @@ See the individual commands for more information."
    ((run-hook-with-args-until-success 'org-metaleft-hook))
    ((org-at-table-p) (org-call-with-arg 'org-table-move-column 'left))
    ((org-with-limited-levels
-     (or (org-on-heading-p)
+     (or (org-at-heading-p)
         (and (org-region-active-p)
              (save-excursion
                (goto-char (region-beginning))
-               (org-on-heading-p)))))
+               (org-at-heading-p)))))
     (when (org-check-for-hidden 'headlines) (org-hidden-tree-error))
     (call-interactively 'org-do-promote))
    ;; At an inline task.
-   ((org-on-heading-p)
+   ((org-at-heading-p)
     (call-interactively 'org-inlinetask-promote))
    ((or (org-at-item-p)
        (and (org-region-active-p)
@@ -17443,15 +17972,15 @@ See the individual commands for more information."
    ((run-hook-with-args-until-success 'org-metaright-hook))
    ((org-at-table-p) (call-interactively 'org-table-move-column))
    ((org-with-limited-levels
-     (or (org-on-heading-p)
+     (or (org-at-heading-p)
         (and (org-region-active-p)
              (save-excursion
                (goto-char (region-beginning))
-               (org-on-heading-p)))))
+               (org-at-heading-p)))))
     (when (org-check-for-hidden 'headlines) (org-hidden-tree-error))
     (call-interactively 'org-do-demote))
    ;; At an inline task.
-   ((org-on-heading-p)
+   ((org-at-heading-p)
     (call-interactively 'org-inlinetask-demote))
    ((or (org-at-item-p)
        (and (org-region-active-p)
@@ -17498,7 +18027,7 @@ for more information."
   (cond
    ((run-hook-with-args-until-success 'org-metaup-hook))
    ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up))
-   ((org-on-heading-p) (call-interactively 'org-move-subtree-up))
+   ((org-at-heading-p) (call-interactively 'org-move-subtree-up))
    ((org-at-item-p) (call-interactively 'org-move-item-up))
    (t (transpose-lines 1) (beginning-of-line -1))))
 
@@ -17511,7 +18040,7 @@ commands for more information."
   (cond
    ((run-hook-with-args-until-success 'org-metadown-hook))
    ((org-at-table-p) (call-interactively 'org-table-move-row))
-   ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
+   ((org-at-heading-p) (call-interactively 'org-move-subtree-down))
    ((org-at-item-p) (call-interactively 'org-move-item-down))
    (t (beginning-of-line 2) (transpose-lines 1) (beginning-of-line 0))))
 
@@ -17529,7 +18058,7 @@ depending on context.  See the individual commands for more information."
                            'org-timestamp-down 'org-timestamp-up)))
    ((and (not (eq org-support-shift-select 'always))
         org-enable-priority-commands
-        (org-on-heading-p))
+        (org-at-heading-p))
     (call-interactively 'org-priority-up))
    ((and (not org-support-shift-select) (org-at-item-p))
     (call-interactively 'org-previous-item))
@@ -17553,7 +18082,7 @@ depending on context.  See the individual commands for more information."
                            'org-timestamp-up 'org-timestamp-down)))
    ((and (not (eq org-support-shift-select 'always))
         org-enable-priority-commands
-        (org-on-heading-p))
+        (org-at-heading-p))
     (call-interactively 'org-priority-down))
    ((and (not org-support-shift-select) (org-at-item-p))
     (call-interactively 'org-next-item))
@@ -17579,7 +18108,7 @@ Depending on context, this does one of the following:
     (org-call-for-shift-select 'forward-char))
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
    ((and (not (eq org-support-shift-select 'always))
-        (org-on-heading-p))
+        (org-at-heading-p))
     (let ((org-inhibit-logging
           (not org-treat-S-cursor-todo-selection-as-state-change))
          (org-inhibit-blocking
@@ -17615,7 +18144,7 @@ Depending on context, this does one of the following:
     (org-call-for-shift-select 'backward-char))
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
    ((and (not (eq org-support-shift-select 'always))
-        (org-on-heading-p))
+        (org-at-heading-p))
     (let ((org-inhibit-logging
           (not org-treat-S-cursor-todo-selection-as-state-change))
          (org-inhibit-blocking
@@ -17642,7 +18171,7 @@ Depending on context, this does one of the following:
    ((and org-support-shift-select (org-region-active-p))
     (org-call-for-shift-select 'forward-word))
    ((and (not (eq org-support-shift-select 'always))
-        (org-on-heading-p))
+        (org-at-heading-p))
     (org-call-with-arg 'org-todo 'nextset))
    (org-support-shift-select
     (org-call-for-shift-select 'forward-word))
@@ -17655,7 +18184,7 @@ Depending on context, this does one of the following:
    ((and org-support-shift-select (org-region-active-p))
     (org-call-for-shift-select 'backward-word))
    ((and (not (eq org-support-shift-select 'always))
-        (org-on-heading-p))
+        (org-at-heading-p))
     (org-call-with-arg 'org-todo 'previousset))
    (org-support-shift-select
     (org-call-for-shift-select 'backward-word))
@@ -17686,6 +18215,17 @@ Depending on context, this does one of the following:
    ((org-at-table-p) (call-interactively 'org-table-hline-and-move))
    (t (call-interactively 'org-insert-heading))))
 
+(defun org-find-visible ()
+  (let ((s (point)))
+    (while (and (not (= (point-max) (setq s (next-overlay-change s))))
+               (get-char-property s 'invisible)))
+    s))
+(defun org-find-invisible ()
+  (let ((s (point)))
+    (while (and (not (= (point-max) (setq s (next-overlay-change s))))
+               (not (get-char-property s 'invisible))))
+    s))
+
 (defun org-copy-visible (beg end)
   "Copy the visible parts of the region."
  (interactive "r")
@@ -17757,6 +18297,7 @@ When in an #+include line, visit the include file.  Otherwise call
     (call-interactively 'org-table-edit-formulas))
    (t (call-interactively 'ffap))))
 
+(defvar org-table-coordinate-overlays) ; defined in org-table.el
 (defun org-ctrl-c-ctrl-c (&optional arg)
   "Set tags in headline, or update according to changed information at point.
 
@@ -17815,14 +18356,16 @@ This command does many different things, depending on context:
           (fboundp org-finish-function))
       (funcall org-finish-function))
      ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
+     ((org-in-regexp org-ts-regexp-both)
+      (org-timestamp-change 0 'day))
      ((or (looking-at org-property-start-re)
          (org-at-property-p))
       (call-interactively 'org-property-action))
-     ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
+     ((org-at-target-p) (call-interactively 'org-update-radio-target-regexp))
      ((and (org-in-regexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\]")
-          (or (org-on-heading-p) (org-at-item-p)))
+          (or (org-at-heading-p) (org-at-item-p)))
       (call-interactively 'org-update-statistics-cookies))
-     ((org-on-heading-p) (call-interactively 'org-set-tags))
+     ((org-at-heading-p) (call-interactively 'org-set-tags))
      ((org-at-table.el-p)
       (message "Use C-c ' to edit table.el tables"))
      ((org-at-table-p)
@@ -17842,44 +18385,61 @@ This command does many different things, depending on context:
             (struct (org-list-struct))
             (old-struct (copy-tree struct))
             (parents (org-list-parents-alist struct))
-            (prevs (org-list-prevs-alist struct))
             (orderedp (org-entry-get nil "ORDERED"))
             (firstp (= (org-list-get-top-point struct) (point-at-bol)))
             block-item)
        ;; Use a light version of `org-toggle-checkbox' to avoid
        ;; computing list structure twice.
-       (org-list-set-checkbox (point-at-bol) struct
-                              (cond
-                               ((equal arg '(16)) "[-]")
-                               ((equal arg '(4)) nil)
-                               ((equal "[X]" cbox) "[ ]")
-                               (t "[X]")))
-       (org-list-struct-fix-ind struct parents)
-       (org-list-struct-fix-bul struct prevs)
-       (setq block-item
-             (org-list-struct-fix-box struct parents prevs orderedp))
+       (let ((new-box (cond
+                       ((equal arg '(16)) "[-]")
+                       ((equal arg '(4)) nil)
+                       ((equal "[X]" cbox) "[ ]")
+                       (t "[X]"))))
+         (if (and firstp arg)
+             ;; If at first item of sub-list, remove check-box from
+             ;; every item at the same level.
+             (mapc
+              (lambda (pos) (org-list-set-checkbox pos struct new-box))
+              (org-list-get-all-items
+               (point-at-bol) struct (org-list-prevs-alist struct)))
+           (org-list-set-checkbox (point-at-bol) struct new-box)))
+       ;; Replicate `org-list-write-struct', while grabbing a return
+       ;; value from `org-list-struct-fix-box'.
+       (org-list-struct-fix-ind struct parents 2)
+       (org-list-struct-fix-item-end struct)
+       (let ((prevs (org-list-prevs-alist struct)))
+         (org-list-struct-fix-bul struct prevs)
+         (org-list-struct-fix-ind struct parents)
+         (setq block-item
+               (org-list-struct-fix-box struct parents prevs orderedp)))
+       (org-list-struct-apply-struct struct old-struct)
+       (org-update-checkbox-count-maybe)
        (when block-item
          (message
           "Checkboxes were removed due to unchecked box at line %d"
           (org-current-line block-item)))
-       (org-list-struct-apply-struct struct old-struct)
-       (org-update-checkbox-count-maybe)
        (when firstp (org-list-send-list 'maybe))))
      ((org-at-item-p)
-      ;; Cursor at an item: repair list. Do checkbox related actions
-      ;; only if function was called with an argument. Send list only
+      ;; Cursor at an item: repair list.  Do checkbox related actions
+      ;; only if function was called with an argument.  Send list only
       ;; if at top item.
       (let* ((struct (org-list-struct))
-            (old-struct (copy-tree struct))
-            (parents (org-list-parents-alist struct))
-            (prevs (org-list-prevs-alist struct))
+            (new-struct struct)
             (firstp (= (org-list-get-top-point struct) (point-at-bol))))
-       (org-list-struct-fix-ind struct parents)
-       (org-list-struct-fix-bul struct prevs)
        (when arg
-         (org-list-set-checkbox (point-at-bol) struct "[ ]")
-         (org-list-struct-fix-box struct parents prevs))
-       (org-list-struct-apply-struct struct old-struct)
+         (setq new-struct (copy-tree struct))
+         (if firstp
+             ;; If at first item of sub-list, add check-box to every
+             ;; item at the same level.
+             (mapc
+              (lambda (pos)
+                (unless (org-list-get-checkbox pos new-struct)
+                  (org-list-set-checkbox pos new-struct "[ ]")))
+              (org-list-get-all-items
+               (point-at-bol) new-struct (org-list-prevs-alist new-struct)))
+           (org-list-set-checkbox (point-at-bol) new-struct "[ ]")))
+       (org-list-write-struct
+        new-struct (org-list-parents-alist new-struct) struct)
        (when arg (org-update-checkbox-count-maybe))
        (when firstp (org-list-send-list 'maybe))))
      ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re))
@@ -17900,6 +18460,9 @@ This command does many different things, depending on context:
        (t
        (let ((org-inhibit-startup-visibility-stuff t)
              (org-startup-align-all-tables nil))
+         (when (boundp 'org-table-coordinate-overlays)
+           (mapc 'delete-overlay org-table-coordinate-overlays)
+           (setq org-table-coordinate-overlays nil))
          (org-save-outline-visibility 'use-markers (org-mode-restart)))
        (message "Local setup has been refreshed"))))
      ((org-clock-update-time-maybe))
@@ -17939,7 +18502,7 @@ See the individual commands for more information."
    ((and (org-in-item-p) indent)
     (if (and (org-at-item-p) (>= (point) (match-end 0)))
        (progn
-         (newline)
+         (save-match-data (newline))
          (org-indent-line-to (length (match-string 0))))
       (let ((ind (org-get-indentation)))
        (newline)
@@ -17947,7 +18510,9 @@ See the individual commands for more information."
            (org-indent-line-function)
          (org-indent-line-to ind)))))
    ((and org-return-follows-link
-        (eq (get-text-property (point) 'face) 'org-link))
+         (let ((tprop (get-text-property (point) 'face)))
+          (or (eq tprop 'org-link)
+              (and (listp tprop) (memq 'org-link tprop)))))
     (call-interactively 'org-open-at-point))
    ((and (org-at-heading-p)
         (looking-at
@@ -18001,7 +18566,7 @@ all headlines to items, shifting text accordingly.
 
 If it is an item, convert all items to normal lines.
 
-If it is normal text, change region into an item. With a prefix
+If it is normal text, change region into an item.  With a prefix
 argument ARG, change each line in region into an item."
   (interactive "P")
   (let ((shift-text
@@ -18055,7 +18620,7 @@ argument ARG, change each line in region into an item."
      (save-excursion
        (goto-char beg)
        (cond
-       ;; Case 1. Start at an item: de-itemize. Note that it only
+       ;; Case 1. Start at an item: de-itemize.  Note that it only
        ;;         happens when a region is active: `org-ctrl-c-minus'
        ;;         would call `org-cycle-list-bullet' otherwise.
        ((org-at-item-p)
@@ -18065,7 +18630,7 @@ argument ARG, change each line in region into an item."
             (delete-region (point) (match-end 0)))
           (forward-line)))
        ;; Case 2. Start at an heading: convert to items.
-       ((org-on-heading-p)
+       ((org-at-heading-p)
         (let* ((bul (org-list-bullet-string "-"))
                (bul-len (length bul))
                ;; Indentation of the first heading.  It should be
@@ -18099,7 +18664,7 @@ argument ARG, change each line in region into an item."
        ;;         an item.
        (arg
         (while (< (point) end)
-          (unless (or (org-on-heading-p) (org-at-item-p))
+          (unless (or (org-at-heading-p) (org-at-item-p))
             (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
                 (replace-match
                  (concat "\\1" (org-list-bullet-string "-") "\\2"))))
@@ -18164,9 +18729,9 @@ stars to add."
        (goto-char beg)
        (cond
        ;; Case 1. Started at an heading: de-star headings.
-       ((org-on-heading-p)
+       ((org-at-heading-p)
         (while (< (point) end)
-          (when (org-on-heading-p t)
+          (when (org-at-heading-p t)
             (looking-at org-outline-regexp) (replace-match ""))
           (forward-line)))
        ;; Case 2. Started at an item: change items into headlines.
@@ -18211,7 +18776,7 @@ stars to add."
                         (t "*")))                  ; inside heading, oddeven
                  (rpl (concat stars add-stars " ")))
             (while (< (point) end)
-              (when (and (not (org-on-heading-p)) (not (org-at-item-p))
+              (when (and (not (org-at-heading-p)) (not (org-at-item-p))
                          (looking-at "\\([ \t]*\\)\\(\\S-\\)"))
                 (replace-match (concat rpl (match-string 2))))
               (forward-line)))))))))
@@ -18355,23 +18920,23 @@ See the individual commands for more information."
      ["Previous link" org-previous-link t]
      "--"
      ["Descriptive Links"
-      (progn (add-to-invisibility-spec '(org-link)) (org-restart-font-lock))
+      org-toggle-link-display
       :style radio
-      :selected (member '(org-link) buffer-invisibility-spec)]
+      :selected org-descriptive-links
+      ]
      ["Literal Links"
-      (progn
-       (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock))
+      org-toggle-link-display
       :style radio
-      :selected (not (member '(org-link) buffer-invisibility-spec))])
+      :selected (not org-descriptive-links)])
     "--"
     ("TODO Lists"
      ["TODO/DONE/-" org-todo t]
      ("Select keyword"
-      ["Next keyword" org-shiftright (org-on-heading-p)]
-      ["Previous keyword" org-shiftleft (org-on-heading-p)]
+      ["Next keyword" org-shiftright (org-at-heading-p)]
+      ["Previous keyword" org-shiftleft (org-at-heading-p)]
       ["Complete Keyword" pcomplete (assq :todo-keyword (org-context))]
-      ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))]
-      ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))])
+      ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-at-heading-p))]
+      ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-at-heading-p))])
      ["Show TODO Tree" org-show-todo-tree :active t :keys "C-c / t"]
      ["Global TODO list" org-todo-list :active t :keys "C-c a t"]
      "--"
@@ -18511,7 +19076,7 @@ information about your Org-mode version and configuration."
      (org-version)
      (let (list)
        (save-window-excursion
-        (switch-to-buffer (get-buffer-create "*Warn about privacy*"))
+        (org-pop-to-buffer-same-window (get-buffer-create "*Warn about privacy*"))
         (delete-other-windows)
         (erase-buffer)
         (insert "You are about to submit a bug report to the Org-mode mailing list.
@@ -18557,8 +19122,8 @@ Your bug report will be posted to the Org-mode mailing list.
     (save-excursion
       (while bl
        (set-buffer (pop bl))
-       (if (org-mode-p) (setq bl nil)))
-      (when (org-mode-p)
+       (if (eq major-mode 'org-mode) (setq bl nil)))
+      (when (eq major-mode 'org-mode)
        (easy-menu-change
         '("Org") "File List for Agenda"
         (append
@@ -18708,7 +19273,7 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
   (if (and marker (marker-buffer marker)
           (buffer-live-p (marker-buffer marker)))
       (progn
-       (switch-to-buffer (marker-buffer marker))
+       (org-pop-to-buffer-same-window (marker-buffer marker))
        (if (or (> marker (point-max)) (< marker (point-min)))
            (widen))
        (goto-char marker)
@@ -18971,7 +19536,7 @@ and :keyword."
         (p (point)) clist o)
     ;; First the large context
     (cond
-     ((org-on-heading-p t)
+     ((org-at-heading-p t)
       (push (list :headline (point-at-bol) (point-at-eol)) clist)
       (when (progn
              (beginning-of-line 1)
@@ -19014,7 +19579,7 @@ and :keyword."
       (push (list :keyword
                  (previous-single-property-change p 'face)
                  (next-single-property-change p 'face)) clist))
-     ((org-on-target-p)
+     ((org-at-target-p)
       (push (org-point-in-group p 0 :target) clist)
       (goto-char (1- (match-beginning 0)))
       (if (looking-at org-radio-target-regexp)
@@ -19066,37 +19631,58 @@ really on, so that the block visually is on the match."
              (throw 'exit t)))
        nil))))
 
-(defun org-in-regexps-block-p (start-re end-re &optional bound)
-  "Return t if the current point is between matches of START-RE and END-RE.
-This will also return t if point is on one of the two matches or
-in an unfinished block. END-RE can be a string or a form
-returning a string.
+(defun org-between-regexps-p (start-re end-re &optional lim-up lim-down)
+  "Non-nil when point is between matches of START-RE and END-RE.
 
-An optional third argument bounds the search for START-RE. It
-defaults to previous heading or `point-min'."
-  (let ((pos (point))
-       (limit (or bound (save-excursion (outline-previous-heading)))))
-    (save-excursion
-      ;; we're on a block when point is on start-re...
-      (or (org-at-regexp-p start-re)
-         ;; ... or start-re can be found above...
-         (and (re-search-backward start-re limit t)
-              ;; ... but no end-re between start-re and point.
-              (not (re-search-forward (eval end-re) pos t)))))))
+Also return a non-nil value when point is on one of the matches.
+
+Optional arguments LIM-UP and LIM-DOWN bound the search; they are
+buffer positions.  Default values are the positions of headlines
+surrounding the point.
+
+The functions returns a cons cell whose car (resp. cdr) is the
+position before START-RE (resp. after END-RE)."
+  (save-match-data
+    (let ((pos (point))
+         (limit-up (or lim-up (save-excursion (outline-previous-heading))))
+         (limit-down (or lim-down (save-excursion (outline-next-heading))))
+         beg end)
+      (save-excursion
+       ;; Point is on a block when on START-RE or if START-RE can be
+       ;; found before it...
+       (and (or (org-at-regexp-p start-re)
+                (re-search-backward start-re limit-up t))
+            (setq beg (match-beginning 0))
+            ;; ... and END-RE after it...
+            (goto-char (match-end 0))
+            (re-search-forward end-re limit-down t)
+            (> (setq end (match-end 0)) pos)
+            ;; ... without another START-RE in-between.
+            (goto-char (match-beginning 0))
+            (not (re-search-backward start-re (1+ beg) t))
+            ;; Return value.
+            (cons beg end))))))
 
 (defun org-in-block-p (names)
-  "Is point inside any block whose name belongs to NAMES?
+  "Non-nil when point belongs to a block whose name belongs to NAMES.
+
+NAMES is a list of strings containing names of blocks.
 
-NAMES is a list of strings containing names of blocks."
+Return first block name matched, or nil.  Beware that in case of
+nested blocks, the returned name may not belong to the closest
+block from point."
   (save-match-data
     (catch 'exit
-      (let ((case-fold-search t))
+      (let ((case-fold-search t)
+           (lim-up (save-excursion (outline-previous-heading)))
+           (lim-down (save-excursion (outline-next-heading))))
        (mapc (lambda (name)
                (let ((n (regexp-quote name)))
-                 (when (org-in-regexps-block-p
+                 (when (org-between-regexps-p
                         (concat "^[ \t]*#\\+begin_" n)
-                        (concat "^[ \t]*#\\+end_" n))
-                   (throw 'exit t))))
+                        (concat "^[ \t]*#\\+end_" n)
+                        lim-up lim-down)
+                   (throw 'exit n))))
              names))
       nil)))
 
@@ -19127,18 +19713,18 @@ NAMES is a list of strings containing names of blocks."
     ;; Emacs 23
     (add-hook 'occur-mode-find-occurrence-hook
              (lambda ()
-               (when (org-mode-p)
+               (when (eq major-mode 'org-mode)
                  (org-reveal))))
   ;; Emacs 22
   (defadvice occur-mode-goto-occurrence
     (after org-occur-reveal activate)
-    (and (org-mode-p) (org-reveal)))
+    (and (eq major-mode 'org-mode) (org-reveal)))
   (defadvice occur-mode-goto-occurrence-other-window
     (after org-occur-reveal activate)
-    (and (org-mode-p) (org-reveal)))
+    (and (eq major-mode 'org-mode) (org-reveal)))
   (defadvice occur-mode-display-occurrence
     (after org-occur-reveal activate)
-    (when (org-mode-p)
+    (when (eq major-mode 'org-mode)
       (let ((pos (occur-mode-find-occurrence)))
        (with-current-buffer (marker-buffer pos)
          (save-excursion
@@ -19194,13 +19780,26 @@ Taken from `count' in cl-seq.el with all keyword arguments removed."
       (if (funcall predicate e) (push e res)))
     (nreverse res)))
 
+(defun org-reduce (cl-func cl-seq &rest cl-keys)
+  "Reduce two-argument FUNCTION across SEQ.
+Taken from `reduce' in cl-seq.el with all keyword arguments but
+\":initial-value\" removed."
+  (let ((cl-accum (cond ((memq :initial-value cl-keys)
+                         (cadr (memq :initial-value cl-keys)))
+                        (cl-seq (pop cl-seq))
+                        (t (funcall cl-func)))))
+    (while cl-seq
+      (setq cl-accum (funcall cl-func cl-accum (pop cl-seq))))
+    cl-accum))
+
 (defun org-back-over-empty-lines ()
   "Move backwards over whitespace, to the beginning of the first empty line.
 Returns the number of empty lines passed."
   (let ((pos (point)))
     (if (cdr (assoc 'heading org-blank-before-new-entry))
        (skip-chars-backward " \t\n\r")
-      (forward-line -1))
+      (unless (eobp)
+       (forward-line -1)))
     (beginning-of-line 2)
     (goto-char (min (point) pos))
     (count-lines (point) pos)))
@@ -19416,7 +20015,7 @@ If point is in an inline task, mark that task instead."
      ;; Footnote definition
      ((looking-at org-footnote-definition-re) (setq column 0))
      ;; Literal examples
-     ((looking-at "[ \t]*:[ \t]")
+     ((looking-at "[ \t]*:\\( \\|$\\)")
       (setq column (org-get-indentation))) ; do nothing
      ;; Lists
      ((ignore-errors (goto-char (org-in-item-p)))
@@ -19437,14 +20036,18 @@ If point is in an inline task, mark that task instead."
              (concat "^[ \t]*#\\+begin_" (downcase (match-string 1))) nil t)))
       (setq column (org-get-indentation (match-string 0))))
      ((and (not (looking-at "[ \t]*#\\+begin_"))
-          (org-in-regexps-block-p "^[ \t]*#\\+begin_" "[ \t]*#\\+end_"))
+          (org-between-regexps-p "^[ \t]*#\\+begin_" "[ \t]*#\\+end_"))
       (save-excursion
        (re-search-backward "^[ \t]*#\\+begin_\\([a-z]+\\)" nil t))
       (setq column
-           (if (equal (downcase (match-string 1)) "src")
-               ;; src blocks: let `org-edit-src-exit' handle them
-               (org-get-indentation)
-             (org-get-indentation (match-string 0)))))
+            (cond ((equal (downcase (match-string 1)) "src")
+                   ;; src blocks: let `org-edit-src-exit' handle them
+                   (org-get-indentation))
+                  ((equal (downcase (match-string 1)) "example")
+                   (max (org-get-indentation)
+                       (org-get-indentation (match-string 0))))
+                  (t
+                   (org-get-indentation (match-string 0))))))
      ;; This line has nothing special, look at the previous relevant
      ;; line to compute indentation
      (t
@@ -19543,10 +20146,11 @@ the functionality can be provided as a fall-back.")
   ;; through to `fill-paragraph' when appropriate.
   (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
   ;; Prevent auto-fill from inserting unwanted new items.
-  (org-set-local 'fill-nobreak-predicate
-                (if (memq 'org-fill-item-nobreak-p fill-nobreak-predicate)
-                    fill-nobreak-predicate
-                  (cons 'org-fill-item-nobreak-p fill-nobreak-predicate)))
+  (if (boundp 'fill-nobreak-predicate)
+      (org-set-local 'fill-nobreak-predicate
+                    (if (memq 'org-fill-item-nobreak-p fill-nobreak-predicate)
+                        fill-nobreak-predicate
+                      (cons 'org-fill-item-nobreak-p fill-nobreak-predicate))))
   ;; Adaptive filling: To get full control, first make sure that
   ;; `adaptive-fill-regexp' never matches.  Then install our own matcher.
   (unless (local-variable-p 'adaptive-fill-regexp (current-buffer))
@@ -19695,7 +20299,7 @@ this line is also exported in fixed-width font."
         (end (if regionp (region-end)))
         (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
         (case-fold-search nil)
-        (re "[ \t]*\\(: \\)")
+        (re "[ \t]*\\(:\\(?: \\|$\\)\\)")
         off)
     (if regionp
        (save-excursion
@@ -19717,13 +20321,16 @@ this line is also exported in fixed-width font."
            (forward-line 1)))
       (save-excursion
        (org-back-to-heading)
-       (if (looking-at (concat org-outline-regexp
-                               "\\( *\\<" org-quote-string "\\>[ \t]*\\)"))
-           (replace-match "" t t nil 1)
-         (if (looking-at org-outline-regexp)
-             (progn
-               (goto-char (match-end 0))
-               (insert org-quote-string " "))))))))
+       (cond
+        ((looking-at (format org-heading-keyword-regexp-format
+                             org-quote-string))
+         (goto-char (match-end 1))
+         (looking-at (concat " +" org-quote-string))
+         (replace-match "" t t)
+         (when (eolp) (insert " ")))
+        ((looking-at org-outline-regexp)
+         (goto-char (match-end 0))
+         (insert org-quote-string " ")))))))
 
 (defun org-reftex-citation ()
   "Use reftex-citation to insert a citation into the buffer.
@@ -19817,13 +20424,14 @@ beyond the end of the headline."
   (let ((special (if (consp org-special-ctrl-a/e)
                     (cdr org-special-ctrl-a/e)
                   org-special-ctrl-a/e)))
-    (if (or (not special)
-           (not (org-on-heading-p))
-           arg)
-       (call-interactively
-        (cond ((org-bound-and-true-p line-move-visual) 'end-of-visual-line)
-              ((fboundp 'move-end-of-line) 'move-end-of-line)
-              (t 'end-of-line)))
+    (cond
+     ((or (not special) arg
+         (not (or (org-at-heading-p) (org-at-item-p) (org-at-drawer-p))))
+      (call-interactively
+       (cond ((org-bound-and-true-p line-move-visual) 'end-of-visual-line)
+            ((fboundp 'move-end-of-line) 'move-end-of-line)
+            (t 'end-of-line))))
+     ((org-at-heading-p)
       (let ((pos (point)))
        (beginning-of-line 1)
        (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$"))
@@ -19838,6 +20446,11 @@ beyond the end of the headline."
          (call-interactively (if (fboundp 'move-end-of-line)
                                  'move-end-of-line
                                'end-of-line)))))
+     ((org-at-drawer-p)
+      (move-end-of-line 1)
+      (when (overlays-at (1- (point))) (backward-char 1)))
+     ;; At an item: Move before any hidden text.
+     (t (call-interactively 'end-of-line)))
     (org-no-warnings
      (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
 
@@ -19871,7 +20484,7 @@ depending on context."
   (cond
    ((or (not org-special-ctrl-k)
        (bolp)
-       (not (org-on-heading-p)))
+       (not (org-at-heading-p)))
     (if (and (get-char-property (min (point-max) (point-at-eol)) 'invisible)
             org-ctrl-k-protect-subtree)
        (if (or (eq org-ctrl-k-protect-subtree 'error)
@@ -19917,7 +20530,7 @@ plainly yank the text as it is.
   "Perform some yank-like command.
 
 This function implements the behavior described in the `org-yank'
-documentation. However, it has been generalized to work for any
+documentation.  However, it has been generalized to work for any
 interactive command with similar behavior."
 
   ;; pretend to be command COMMAND
@@ -20026,10 +20639,16 @@ This version does not only check the character property, but also
     (end-of-line)
     (null (re-search-backward org-outline-regexp-bol nil t))))
 
-(defun org-on-heading-p (&optional ignored)
-  (outline-on-heading-p t))
 (defun org-at-heading-p (&optional ignored)
   (outline-on-heading-p t))
+;; Compatibility alias with Org versions < 7.8.03
+(defalias 'org-on-heading-p 'org-at-heading-p)
+
+(defun org-at-drawer-p nil
+  "Whether point is at a drawer."
+  (save-excursion
+    (move-beginning-of-line 1)
+    (looking-at org-drawer-regexp)))
 
 (defun org-point-at-end-of-empty-headline ()
   "If point is at the end of an empty headline, return t, else nil.
@@ -20039,14 +20658,17 @@ empty."
        (save-excursion
          (beginning-of-line 1)
         (let ((case-fold-search nil))
-          (looking-at (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp
-                              "\\)?[ \t]*$"))))))
+          (looking-at org-todo-line-regexp)))
+       (string= (match-string 3) "")))
+
 (defun org-at-heading-or-item-p ()
-  (or (org-on-heading-p) (org-at-item-p)))
+  (or (org-at-heading-p) (org-at-item-p)))
 
-(defun org-on-target-p ()
+(defun org-at-target-p ()
   (or (org-in-regexp org-radio-target-regexp)
       (org-in-regexp org-target-regexp)))
+;; Compatibility alias with Org versions < 7.8.03
+(defalias 'org-on-target-p 'org-at-target-p)
 
 (defun org-up-heading-all (arg)
   "Move to the heading line of which the present line is a subheading.
@@ -20117,7 +20739,7 @@ move point."
 
 (defun org-goto-first-child ()
   "Goto the first child, even if it is invisible.
-Return t when a child was found. Otherwise don't move point and
+Return t when a child was found.  Otherwise don't move point and
 return nil."
   (let (level (pos (point)) (re org-outline-regexp-bol))
     (when (condition-case nil (org-back-to-heading t) (error nil))
@@ -20185,7 +20807,7 @@ If there is no such heading, return nil."
   (org-back-to-heading invisible-OK)
   (let ((first t)
        (level (funcall outline-level)))
-    (if (and (org-mode-p) (< level 1000))
+    (if (and (eq major-mode 'org-mode) (< level 1000))
        ;; A true heading (not a plain list item), in Org-mode
        ;; This means we can easily find the end by looking
        ;; only for the right number of stars.  Using a regexp to do
@@ -20210,7 +20832,7 @@ If there is no such heading, return nil."
 
 (defadvice outline-end-of-subtree (around prefer-org-version activate compile)
   "Use Org version in org-mode, for dramatic speed-up."
-  (if (org-mode-p)
+  (if (eq major-mode 'org-mode)
       (progn
        (org-end-of-subtree nil t)
        (unless (eobp) (backward-char 1)))
@@ -20242,7 +20864,7 @@ Normally this only looks at visible headings, but when INVISIBLE-OK is non-nil
 it wil also look at invisible ones."
   (interactive "p")
   (org-back-to-heading invisible-ok)
-  (org-on-heading-p)
+  (org-at-heading-p)
   (let* ((level (- (match-end 0) (match-beginning 0) 1))
         (re (format "^\\*\\{1,%d\\} " level))
         l)
@@ -20262,7 +20884,7 @@ it wil also look at invisible ones."
 Stop at the first and last subheadings of a superior heading."
   (interactive "p")
   (org-back-to-heading)
-  (org-on-heading-p)
+  (org-at-heading-p)
   (let* ((level (- (match-end 0) (match-beginning 0) 1))
         (re (format "^\\*\\{1,%d\\} " level))
         l)
@@ -20382,7 +21004,7 @@ Show the heading too, if it is currently invisible."
   '(progn
      (add-hook 'imenu-after-jump-hook
               (lambda ()
-                (if (org-mode-p)
+                (if (eq major-mode 'org-mode)
                     (org-show-context 'org-goto))))))
 
 (defun org-link-display-format (link)
@@ -20397,6 +21019,17 @@ if no description is present"
                           nil t link)
       link)))
 
+(defun org-toggle-link-display ()
+  "Toggle the literal or descriptive display of links."
+  (interactive)
+  (if org-descriptive-links
+      (progn (org-remove-from-invisibility-spec '(org-link))
+            (org-restart-font-lock)
+            (setq org-descriptive-links nil))
+    (progn (add-to-invisibility-spec '(org-link))
+          (org-restart-font-lock)
+          (setq org-descriptive-links t))))
+
 ;; Speedbar support
 
 (defvar org-speedbar-restriction-lock-overlay (make-overlay 1 1)
@@ -20432,7 +21065,7 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
       (with-current-buffer (find-file-noselect
                            (let ((default-directory dir))
                              (expand-file-name txt)))
-       (unless (org-mode-p)
+       (unless (eq major-mode 'org-mode)
          (error "Cannot restrict to non-Org-mode file"))
        (org-agenda-set-restriction-lock 'file)))
      (t (error "Don't know how to restrict Org-mode's agenda")))
@@ -20449,7 +21082,7 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
      (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
      (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
      (add-hook 'speedbar-visiting-tag-hook
-              (lambda () (and (org-mode-p) (org-show-context 'org-goto))))))
+              (lambda () (and (eq major-mode 'org-mode) (org-show-context 'org-goto))))))
 
 ;;; Fixes and Hacks for problems with other packages
 
@@ -20492,12 +21125,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
 (eval-after-load "ecb"
   '(defadvice ecb-method-clicked (after esf/org-show-context activate)
      "Make hierarchy visible when jumping into location from ECB tree buffer."
-     (if (org-mode-p)
+     (if (eq major-mode 'org-mode)
         (org-show-context))))
 
 (defun org-bookmark-jump-unhide ()
   "Unhide the current position, to show the bookmark location."
-  (and (org-mode-p)
+  (and (eq major-mode 'org-mode)
        (or (outline-invisible-p)
           (save-excursion (goto-char (max (point-min) (1- (point))))
                           (outline-invisible-p)))
@@ -20536,6 +21169,4 @@ Still experimental, may disappear in the future."
 
 (run-hooks 'org-load-hook)
 
-
-
 ;;; org.el ends here