changeset 111880:a7740098b594

Update to Org mode 7.4
author Carsten Dominik <carsten.dominik@gmail.com>
date Sat, 11 Dec 2010 17:42:53 +0100
parents 4a0faa1cecc2
children 66cacb91ed45
files doc/misc/ChangeLog doc/misc/org.texi etc/ChangeLog 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-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-gnuplot.el lisp/org/ob-haskell.el lisp/org/ob-js.el lisp/org/ob-keys.el lisp/org/ob-latex.el lisp/org/ob-ledger.el lisp/org/ob-lisp.el lisp/org/ob-lob.el lisp/org/ob-matlab.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-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-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-complete.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-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-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-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-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
diffstat 101 files changed, 4257 insertions(+), 2728 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/ChangeLog	Sat Dec 11 17:41:04 2010 +0200
+++ b/doc/misc/ChangeLog	Sat Dec 11 17:42:53 2010 +0100
@@ -1,3 +1,25 @@
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Using capture): Document using prefix arguments for
+	finalizing capture.
+	(Agenda commands): Document prefix argument for the bulk scatter
+	command.
+	(Beamer class export): Document that also overlay arguments can be
+	passed to the column environment.
+	(Template elements): Document the new entry type.
+
+2010-12-11  Puneeth Chaganti  <punchagan@gmail.com>
+
+	* org.texi (Include files): Document :minlevel.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org.texi (Categories): Document category icons.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* org.texi (noweb): Fix typo.
+
 2010-12-06  Tassilo Horn  <tassilo@member.fsf.org>
 
 	* gnus.texi (Server Commands): Point to the rest of the server
--- a/doc/misc/org.texi	Sat Dec 11 17:41:04 2010 +0200
+++ b/doc/misc/org.texi	Sat Dec 11 17:42:53 2010 +0100
@@ -4,8 +4,8 @@
 @setfilename ../../info/org
 @settitle The Org Manual
 
-@set VERSION 7.3
-@set DATE November 2010
+@set VERSION 7.4
+@set DATE December 2010
 
 @c Use proper quote and backtick for code sections in PDF output
 @c Cf. Texinfo manual 14.2
@@ -21,40 +21,236 @@
 @c %**end of header
 @finalout
 
-@c Macro definitions
-@macro orgcmd{key,command}
-@iftex
-@kindex \key\
-@findex \command\
-@item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
-@end iftex
-@ifnottex
-@kindex \key\
-@findex \command\
-@item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
-@end ifnottex
-@end macro
-
+
+@c -----------------------------------------------------------------------------
+
+@c Macro definitions for commands and keys
+@c =======================================
+
+@c The behavior of the key/command macros will depend on the flag cmdnames
+@c When set, commands names are shown.  When clear, they are not shown.
+
+@set cmdnames
+
+@c Below we define the following macros for Org key tables:
+
+@c orgkey{key}                        A key item                     
+@c orgcmd{key,cmd}                    Key with command name
+@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"
+@c orgcmdkxkc{key1,key2,cmd}          Two keys with one command name, but
+@c                                    different functions, so format as @itemx
+@c orgcmdkskc{key1,key2,cmd}          Same as orgcmdkkc, but use "or short"
+@c xorgcmdkskc{key1,key2,cmd}         Same as previous, but use @itemx
+@c orgcmdkkcc{key1,key2,cmd1,cmd2}    Two keys and two commands
+
+@c a key but no command
+@c    Inserts:    @item key
 @macro orgkey{key}
 @kindex \key\
 @item @kbd{\key\}
 @end macro
 
+@macro xorgkey{key}
+@kindex \key\
+@itemx @kbd{\key\}
+@end macro
+
+@c one key with a command
+@c   Inserts:    @item KEY               COMMAND
+@macro orgcmd{key,command}
+@ifset cmdnames
+@kindex \key\
+@findex \command\
+@iftex
+@item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key\
+@item @kbd{\key\}
+@end ifclear
+@end macro
+
+@c One key with one command, formatted using @itemx
+@c   Inserts:    @itemx KEY               COMMAND
+@macro xorgcmd{key,command}
+@ifset cmdnames
+@kindex \key\
+@findex \command\
+@iftex
+@itemx @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@itemx @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key\
+@itemx @kbd{\key\}
+@end ifclear
+@end macro
+
+@c one key with a command, bit do not index the key
+@c   Inserts:    @item KEY               COMMAND
+@macro orgcmdnki{key,command}
+@ifset cmdnames
+@findex \command\
+@iftex
+@item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@item @kbd{\key\}
+@end ifclear
+@end macro
+
+@c one key with a command, and special text to replace key in item
+@c   Inserts:    @item TEXT                    COMMAND
+@macro orgcmdtkc{text,key,command}
+@ifset cmdnames
+@kindex \key\
+@findex \command\
+@iftex
+@item @kbd{\text\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@item @kbd{\text\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key\
+@item @kbd{\text\}
+@end ifclear
+@end macro
+
+@c two keys with one command
+@c   Inserts:    @item KEY1 or KEY2            COMMAND
+@macro orgcmdkkc{key1,key2,command}
+@ifset cmdnames
+@kindex \key1\
+@kindex \key2\
+@findex \command\
+@iftex
+@item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key1\
+@kindex \key2\
+@item @kbd{\key1\} @ @r{or} @ @kbd{\key2\}
+@end ifclear
+@end macro
+
+@c Two keys with one command name, but different functions, so format as
+@c @itemx
+@c   Inserts:    @item KEY1
+@c               @itemx KEY2                COMMAND
+@macro orgcmdkxkc{key1,key2,command}
+@ifset cmdnames
+@kindex \key1\
+@kindex \key2\
+@findex \command\
+@iftex
+@item @kbd{\key1\}
+@itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@item @kbd{\key1\}
+@itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key1\
+@kindex \key2\
+@item @kbd{\key1\}
+@itemx @kbd{\key2\}
+@end ifclear
+@end macro
+
+@c Same as previous, but use "or short"
+@c   Inserts:    @item KEY1 or short KEY2            COMMAND
+@macro orgcmdkskc{key1,key2,command}
+@ifset cmdnames
+@kindex \key1\
+@kindex \key2\
+@findex \command\
+@iftex
+@item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key1\
+@kindex \key2\
+@item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
+@end ifclear
+@end macro
+
+@c Same as previous, but use @itemx
+@c   Inserts:    @itemx KEY1 or short KEY2            COMMAND
+@macro xorgcmdkskc{key1,key2,command}
+@ifset cmdnames
+@kindex \key1\
+@kindex \key2\
+@findex \command\
+@iftex
+@itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
+@end iftex
+@ifnottex
+@itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key1\
+@kindex \key2\
+@itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
+@end ifclear
+@end macro
+
+@c two keys with two commands
+@c   Inserts:    @item KEY1                        COMMAND1
+@c               @itemx KEY2                       COMMAND2
+@macro orgcmdkkcc{key1,key2,command1,command2}
+@ifset cmdnames
+@kindex \key1\
+@kindex \key2\
+@findex \command1\
+@findex \command2\
+@iftex
+@item @kbd{\key1\} @hskip 0pt plus 1filll @code{\command1\}
+@itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command2\}
+@end iftex
+@ifnottex
+@item @kbd{\key1\} @tie{}@tie{}@tie{}@tie{}(@code{\command1\})
+@itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command2\})
+@end ifnottex
+@end ifset
+@ifclear cmdnames
+@kindex \key1\
+@kindex \key2\
+@item @kbd{\key1\}
+@itemx @kbd{\key2\}
+@end ifclear
+@end macro
+@c -----------------------------------------------------------------------------
+
 @iftex
 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
 @end iftex
-@macro Ie {}
-I.e.,
-@end macro
-@macro ie {}
-i.e.,
-@end macro
-@macro Eg {}
-E.g.,
-@end macro
-@macro eg {}
-e.g.,
-@end macro
 
 @c Subheadings inside a table.
 @macro tsubheading{text}
@@ -260,7 +456,6 @@
 * Creating timestamps::         Commands which insert timestamps
 * Deadlines and scheduling::    Planning your work
 * Clocking work time::          Tracking how long you spend on a task
-* Resolving idle time::         Resolving time if you've been idle
 * Effort estimates::            Planning work effort in advance
 * Relative timer::              Notes with a running timer
 * Countdown timer::             Starting a countdown timer for a task
@@ -275,6 +470,12 @@
 * Inserting deadline/schedule::  Planning items
 * Repeated tasks::              Items that show up again and again
 
+Clocking work time
+
+* Clocking commands::           Starting and stopping a clock
+* The clock table::             Detailed reports
+* Resolving idle time::         Resolving time when you've been idle
+
 Capture - Refile - Archive
 
 * Capture::                     Capturing new stuff
@@ -355,7 +556,7 @@
 * Horizontal rules::            Make a line
 * Comment lines::               What will *not* be exported
 
-Embedded La@TeX{}
+Embedded @LaTeX{}
 
 * Special symbols::             Greek letters and other symbols
 * Subscripts and superscripts::  Simple syntax for raising/lowering text
@@ -370,7 +571,7 @@
 * 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 La@TeX{}, and processing to PDF
+* LaTeX and PDF export::        Exporting to @LaTeX{}, and processing to PDF
 * DocBook export::              Exporting to DocBook
 * TaskJuggler export::          Exporting to TaskJuggler
 * Freemind export::             Exporting to Freemind mind maps
@@ -389,13 +590,13 @@
 * CSS support::                 Changing the appearance of the output
 * JavaScript support::          Info and Folding in a web browser
 
-La@TeX{} and PDF export
+@LaTeX{} and PDF export
 
 * LaTeX/PDF export commands::   Which key invokes which commands
 * Header and sectioning::       Setting up the export file structure
-* Quoting LaTeX code::          Incorporating literal La@TeX{} code
-* Tables in LaTeX export::      Options for exporting tables to La@TeX{}
-* Images in LaTeX export::      How to insert figures into La@TeX{} 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
@@ -506,7 +707,7 @@
 * Add-on packages::             Available extensions
 * Adding hyperlink types::      New custom link types
 * Context-sensitive commands::  How to add functionality to such commands
-* Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
+* Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
 * Dynamic blocks::              Automatically filled blocks
 * Special agenda views::        Customized views
 * Extracting agenda information::  Postprocessing of agenda information
@@ -567,14 +768,14 @@
 nodes.  Based on this data, specific entries can be extracted in queries and
 create dynamic @i{agenda views}.
 
-Org mode contains the Org Babel environment which allows to work with
-embedded source code block in a file, to facilitate code evaluation,
+Org mode contains the Org Babel environment which allows you to work with
+embedded source code blocks in a file, to facilitate code evaluation,
 documentation, and tangling.
 
 Org's automatic, context-sensitive table editor with spreadsheet
 capabilities can be integrated into any major mode by activating the
 minor Orgtbl mode.  Using a translation step, it can be used to maintain
-tables in arbitrary file types, for example in La@TeX{}.  The structure
+tables in arbitrary file types, for example in @LaTeX{}.  The structure
 editing and list creation capabilities can be used outside Org with
 the minor Orgstruct mode.
 
@@ -591,7 +792,7 @@
 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
 @pindex GTD, Getting Things Done
 @r{@bullet{} an environment in which to implement David Allen's GTD system}
-@r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
+@r{@bullet{} a simple hypertext system, with HTML and @LaTeX{} export}
 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
 @r{@bullet{} an environment for literate programming}
 @end example
@@ -742,7 +943,7 @@
 moderators have to do.}.
 
 For bug reports, please first try to reproduce the bug with the latest
-version of Org available - if you are running an outdated version, it is
+version of Org available---if you are running an outdated version, it is
 quite possible that the bug has been fixed already.  If the bug persists,
 prepare a report and provide as much information as possible, including the
 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
@@ -819,6 +1020,18 @@
 special meaning are written with all capitals.
 @end table
 
+The manual lists both the keys and the corresponding commands for accessing
+functionality.  Org mode often uses the same key for different functions,
+depending on context.  The command that is bound to such keys has a generic
+name, like @code{org-metaright}.  In the manual we will, wherever possible,
+give the function that is internally called by the generic command.  For
+example, in the chapter on document structure, @kbd{M-@key{right}} will be
+listed to call @code{org-do-demote}, while in the chapter on tables, it will
+be listed to call org-table-move-column-right.
+
+If you prefer, you can compile the manual without the command names by
+unsetting the flag @code{cmdnames} in @file{org.texi}.
+
 @node Document Structure, Tables, Introduction, Top
 @chapter Document structure
 @cindex document structure
@@ -1199,8 +1412,7 @@
 @table @asis
 @orgcmd{C-c /,org-sparse-tree}
 This prompts for an extra key to select a sparse-tree creating command.
-@kindex C-c / r
-@item C-c / r
+@orgcmd{C-c / r,org-occur}
 @vindex org-remove-highlights-with-change
 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
 the match is in a headline, the headline is made visible.  If the match is in
@@ -1270,7 +1482,7 @@
 @emph{Ordered} list items start with a numeral followed by either a period or
 a right parenthesis@footnote{You can filter out any of them by configuring
 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or
-@samp{1)}.  If you want a list to start a different value (e.g. 20), start
+@samp{1)}.  If you want a list to start with a different value (e.g. 20), start
 the text of the item with @code{[@@20]}@footnote{If there's a checkbox in the
 item, the cookie must be put @emph{before} the checkbox.}.  Those constructs
 can be used in any item of the list in order to enforce a particular
@@ -1325,7 +1537,7 @@
 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
 properly (@pxref{Exporting}).  Since indentation is what governs the
 structure of these lists, many structural constructs like @code{#+BEGIN_...}
-blocks can be indented to signal that they should be considered of a list
+blocks can be indented to signal that they should be considered as a list
 item.
 
 @vindex org-list-demote-modify-bullet
@@ -1336,7 +1548,7 @@
 @vindex org-list-automatic-rules
 The following commands act on items when the cursor is in the first line of
 an item (the line with the bullet or number).  Some of them imply the
-application of automatic rules to keep list structure in tact.  If some of
+application of automatic rules to keep list structure intact.  If some of
 these actions get in your way, configure @code{org-list-automatic-rules}
 to disable them individually.
 
@@ -1345,8 +1557,9 @@
 @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}. to @code{integrate}, plain list items
-will be treated like low-level.  The level of an item is then given by the
+@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.
 @orgcmd{M-@key{RET},org-insert-heading}
@@ -1357,7 +1570,7 @@
 of a line, the line is @emph{split} and the rest of the line becomes the new
 item@footnote{If you do not want the line 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 item.  If the
+an item's body}, the new item is created @emph{before} the current item.  If the
 command is executed in the white space before the text that is part of an
 item but does not contain the bullet, a bullet is added to the current line.
 
@@ -1369,7 +1582,7 @@
 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.  Subsequents @key{TAB} move 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}
@@ -1475,8 +1688,7 @@
 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
-want to store a quick note in the LOGBOOK drawer, in a similar way as this is
-done by state changes, use
+want to store a quick note in the LOGBOOK drawer, in a similar way to state changes, use
 
 @table @kbd
 @kindex C-c C-z
@@ -1513,7 +1725,7 @@
 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
 brackets in column 0, no indentation allowed.  If you need a paragraph break
-inside a footnote, use the La@TeX{} idiom @samp{\par}.  The footnote reference
+inside a footnote, use the @LaTeX{} idiom @samp{\par}.  The footnote reference
 is simply the marker in square brackets, inside text.  For example:
 
 @example
@@ -1525,7 +1737,7 @@
 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 La@TeX{} snippets (@pxref{Embedded
+encouraged because of possible conflicts with @LaTeX{} snippets (@pxref{Embedded
 LaTeX}).  Here are the valid references:
 
 @table @code
@@ -1537,7 +1749,7 @@
 A named footnote reference, where @code{name} is a unique label word, or, for
 simplicity of automatic creation, a number.
 @item [fn:: This is the inline definition of this footnote]
-A La@TeX{}-like anonymous footnote where the definition is given directly at the
+A @LaTeX{}-like anonymous footnote where the definition is given directly at the
 reference point.
 @item [fn:name: a definition]
 An inline definition of a footnote, which also specifies a name for the note.
@@ -1548,7 +1760,7 @@
 @vindex org-footnote-auto-label
 Footnote labels can be created automatically, or you can create names yourself.
 This is handled by the variable @code{org-footnote-auto-label} and its
-corresponding @code{#+STARTUP} keywords, see the docstring of that variable
+corresponding @code{#+STARTUP} keywords.  See the docstring of that variable
 for details.
 
 @noindent The following command handles footnotes:
@@ -1631,7 +1843,7 @@
 headline or the first line of a list item, most structure editing commands
 will work, even if the same keys normally have different functionality in the
 major mode you are using.  If the cursor is not in one of those special
-lines, Orgstruct mode lurks silently in the shadow.  When you use
+lines, Orgstruct mode lurks silently in the shadows.  When you use
 @code{orgstruct++-mode}, Org will also export indentation and autofill
 settings into that mode, and detect item context after the first line of an
 item.
@@ -1642,8 +1854,7 @@
 @cindex editing tables
 
 Org comes with a fast and intuitive table editor.  Spreadsheet-like
-calculations are supported in connection with the Emacs @file{calc}
-package
+calculations are supported using the Emacs @file{calc} package
 @ifinfo
 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
 @end ifinfo
@@ -1722,70 +1933,55 @@
 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
 
 @tsubheading{Re-aligning and field motion}
-@orgcmd{C-c C-c,org-ctrl-c-ctrl-c}
+@orgcmd{C-c C-c,org-table-align}
 Re-align the table without moving the cursor.
 @c
-@orgcmd{<TAB>,org-cycle}
+@orgcmd{<TAB>,org-table-next-field}
 Re-align the table, move to the next field.  Creates a new row if
 necessary.
 @c
-@orgcmd{S-@key{TAB},org-shifttab}
+@orgcmd{S-@key{TAB},org-table-previous-field}
 Re-align, move to previous field.
 @c
-@orgcmd{@key{RET},org-return}
+@orgcmd{@key{RET},org-table-next-row}
 Re-align the table and move down to next row.  Creates a new row if
 necessary.  At the beginning or end of a line, @key{RET} still does
 NEWLINE, so it can be used to split a table.
 @c
-@kindex M-a
-@item M-a
+@orgcmd{M-a,org-table-beginning-of-field}
 Move to beginning of the current table field, or on to the previous field.
-@kindex M-e
-@item M-e
+@orgcmd{M-e,org-table-end-of-field}
 Move to end of the current table field, or on to the next field.
 
 @tsubheading{Column and row editing}
-@kindex M-@key{left}
-@kindex M-@key{right}
-@item M-@key{left}
-@itemx M-@key{right}
+@orgcmdkkcc{M-@key{left},M-@key{right},org-table-move-column-left,org-table-move-column-right}
 Move the current column left/right.
 @c
-@kindex M-S-@key{left}
-@item M-S-@key{left}
+@orgcmd{M-S-@key{left},org-table-delete-column}
 Kill the current column.
 @c
-@kindex M-S-@key{right}
-@item M-S-@key{right}
+@orgcmd{M-S-@key{right},org-table-insert-column}
 Insert a new column to the left of the cursor position.
 @c
-@kindex M-@key{up}
-@kindex M-@key{down}
-@item M-@key{up}
-@itemx M-@key{down}
+@orgcmdkkcc{M-@key{up},M-@key{down},org-table-move-row-up,org-table-move-row-down}
 Move the current row up/down.
 @c
-@kindex M-S-@key{up}
-@item M-S-@key{up}
+@orgcmd{M-S-@key{up},org-table-kill-row}
 Kill the current row or horizontal line.
 @c
-@kindex M-S-@key{down}
-@item M-S-@key{down}
+@orgcmd{M-S-@key{down},org-table-insert-row}
 Insert a new row above the current row.  With a prefix argument, the line is
 created below the current one.
 @c
-@kindex C-c -
-@item C-c -
+@orgcmd{C-c -,org-table-insert-hline}
 Insert a horizontal line below current row.  With a prefix argument, the line
 is created above the current line.
 @c
-@kindex C-c @key{RET}
-@item C-c @key{RET}
+@orgcmd{C-c @key{RET},org-table-hline-and-move}
 Insert a horizontal line below current row, and move the cursor into the row
 below that line.
 @c
-@kindex C-c ^
-@item C-c ^
+@orgcmd{C-c ^,org-table-sort-lines}
 Sort the table lines in the region.  The position of point indicates the
 column to be used for sorting, and the range of lines is the range
 between the nearest horizontal separator lines, or the entire table.  If
@@ -1797,35 +1993,30 @@
 argument, alphabetic sorting will be case-sensitive.
 
 @tsubheading{Regions}
-@kindex C-c C-x M-w
-@item C-c C-x M-w
+@orgcmd{C-c C-x M-w,org-table-copy-region}
 Copy a rectangular region from a table to a special clipboard.  Point and
 mark determine edge fields of the rectangle.  If there is no active region,
 copy just the current field.  The process ignores horizontal separator lines.
 @c
-@kindex C-c C-x C-w
-@item C-c C-x C-w
+@orgcmd{C-c C-x C-w,org-table-cut-region}
 Copy a rectangular region from a table to a special clipboard, and
 blank all fields in the rectangle.  So this is the ``cut'' operation.
 @c
-@kindex C-c C-x C-y
-@item C-c C-x C-y
+@orgcmd{C-c C-x C-y,org-table-paste-rectangle}
 Paste a rectangular region into a table.
 The upper left corner ends up in the current field.  All involved fields
 will be overwritten.  If the rectangle does not fit into the present table,
 the table is enlarged as needed.  The process ignores horizontal separator
 lines.
 @c
-@kindex M-@key{RET}
-@itemx M-@kbd{RET}
-Wrap several fields in a column like a paragraph.  If there is an active
-region, and both point and mark are in the same column, the text in the
-column is wrapped to minimum width for the given number of lines.  A numeric
-prefix argument may be used to change the number of desired lines.  If there
-is no region, the current field is split at the cursor position and the text
-fragment to the right of the cursor is prepended to the field one line
-down. If there is no region, but you specify a prefix argument, the current
-field is made blank, and the content is appended to the field above.
+@orgcmd{M-@key{RET},org-table-wrap-region}
+Split the current field at the cursor position and move the rest to the line
+below.  If there is an active region, and both point and mark are in the same
+column, the text in the column is wrapped to minimum width for the given
+number of lines.  A numeric prefix argument may be used to change the number
+of desired lines.  If there is no region, but you specify a prefix argument,
+the current field is made blank, and the content is appended to the field
+above.
 
 @tsubheading{Calculations}
 @cindex formula, in tables
@@ -1833,14 +2024,12 @@
 @cindex region, active
 @cindex active region
 @cindex transient mark mode
-@kindex C-c +
-@item C-c +
+@orgcmd{C-c +,org-table-sum}
 Sum the numbers in the current column, or in the rectangle defined by
 the active region.  The result is shown in the echo area and can
 be inserted with @kbd{C-y}.
 @c
-@kindex S-@key{RET}
-@item S-@key{RET}
+@orgcmd{S-@key{RET},org-table-copy-down}
 @vindex org-table-copy-increment
 When current field is empty, copy from first non-empty field above.  When not
 empty, copy current field down to next row and move cursor along with it.
@@ -1851,8 +2040,7 @@
 (@pxref{Conflicts}).
 
 @tsubheading{Miscellaneous}
-@kindex C-c `
-@item C-c `
+@orgcmd{C-c `,org-table-edit-field}
 Edit the current field in a separate window.  This is useful for fields that
 are not fully visible (@pxref{Column width and alignment}).  When called with
 a @kbd{C-u} prefix, just make the full field visible, so that it can be
@@ -1866,12 +2054,13 @@
 the buffer and then converting the region to a table.  Any prefix
 argument is passed on to the converter, which uses it to determine the
 separator.
-@item C-c |
+@orgcmd{C-c |,org-table-create-or-convert-from-region}
 Tables can also be imported by pasting tabular text into the Org
 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
 @kbd{C-c |} command (see above under @i{Creation and conversion}).
 @c
 @item M-x org-table-export
+@findex org-table-export
 @vindex org-table-export-default-format
 Export the table, by default as a TAB-separated file.  Use for data
 exchange with, for example, spreadsheet or database programs.  The format
@@ -1926,7 +2115,7 @@
 
 @noindent
 Fields that are wider become clipped and end in the string @samp{=>}.
-Note that the full text is still in the buffer, it is only invisible.
+Note that the full text is still in the buffer but is hidden.
 To see the full text, hold the mouse over the field---a tool-tip window
 will show the full content.  To edit such a field, use the command
 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
@@ -1947,7 +2136,7 @@
 @end example
 
 If you would like to overrule the automatic alignment of number-rich columns
-to the right and of string-rich column to the left, you and use @samp{<r>},
+to the right and of string-rich column to the left, you can use @samp{<r>},
 @samp{c}@footnote{Centering does not work inside Emacs, but it does have an
 effect when exporting to HTML.} or @samp{<l>} in a similar fashion.  You may
 also combine alignment and field width like this: @samp{<l10>}.
@@ -2007,7 +2196,7 @@
 
 Furthermore, with some special setup, it is possible to maintain tables
 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
-construct La@TeX{} tables with the underlying ease and power of
+construct @LaTeX{} tables with the underlying ease and power of
 Orgtbl mode, including spreadsheet capabilities.  For details, see
 @ref{Tables in arbitrary syntax}.
 
@@ -2280,7 +2469,7 @@
 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
 vmean($2..$7)        @r{Compute column range mean, using vector function}
 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
-taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
+taylor($3,x=7,2)     @r{Taylor series of $3, at x=7, second degree}
 @end example
 
 Calc also contains a complete set of logical operations.  For example
@@ -2293,24 +2482,23 @@
 @subsection Emacs Lisp forms as formulas
 @cindex Lisp forms, as table formulas
 
-It is also possible to write a formula in Emacs Lisp; this can be useful
-for string manipulation and control structures, if Calc's
-functionality is not enough.  If a formula starts with a single-quote
-followed by an opening parenthesis, then it is evaluated as a Lisp form.
-The evaluation should return either a string or a number.  Just as with
-@file{calc} formulas, you can specify modes and a printf format after a
-semicolon.  With Emacs Lisp forms, you need to be conscious about the way
-field references are interpolated into the form.  By default, a
-reference will be interpolated as a Lisp string (in double-quotes)
-containing the field.  If you provide the @samp{N} mode switch, all
-referenced elements will be numbers (non-number fields will be zero) and
-interpolated as Lisp numbers, without quotes.  If you provide the
-@samp{L} flag, all fields will be interpolated literally, without quotes.
-I.e., if you want a reference to be interpreted as a string by the Lisp
-form, enclose the reference operator itself in double-quotes, like
-@code{"$3"}.  Ranges are inserted as space-separated fields, so you can
-embed them in list or vector syntax.  A few examples, note how the
-@samp{N} mode is used when we do computations in Lisp.
+It is also possible to write a formula in Emacs Lisp; this can be useful for
+string manipulation and control structures, if Calc's functionality is not
+enough.  If a formula starts with a single-quote followed by an opening
+parenthesis, then it is evaluated as a Lisp form.  The evaluation should
+return either a string or a number.  Just as with @file{calc} formulas, you
+can specify modes and a printf format after a semicolon.  With Emacs Lisp
+forms, you need to be conscious about the way field references are
+interpolated into the form.  By default, a reference will be interpolated as
+a Lisp string (in double-quotes) containing the field.  If you provide the
+@samp{N} mode switch, all referenced elements will be numbers (non-number
+fields will be zero) and interpolated as Lisp numbers, without quotes.  If
+you provide the @samp{L} flag, all fields will be interpolated literally,
+without quotes.  I.e., if you want a reference to be interpreted as a string
+by the Lisp form, enclose the reference operator itself in double-quotes,
+like @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
++embed them in list or vector syntax.  Here are a few examples---note how the
+@samp{N} mode is used when we do computations in Lisp:
 
 @example
 @r{Swap the first two characters of the content of column 1}
@@ -2334,7 +2522,7 @@
 
 @cindex #+TBLFM
 Formulas are stored in a special line starting with @samp{#+TBLFM:}
-directly below the table.  If you typed the equation in the 4th field of
+directly below the table.  If you type the equation in the 4th field of
 the 3rd data line in the table, the formula will look like
 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
 with the appropriate commands, @i{absolute references} (but not relative
@@ -2348,8 +2536,7 @@
 following command
 
 @table @kbd
-@kindex C-u C-c =
-@item C-u C-c =
+@orgcmd{C-u C-c =,org-table-eval-formula}
 Install a new formula for the current field.  The command prompts for a
 formula with default taken from the @samp{#+TBLFM:} line, applies
 it to the current field, and stores it.
@@ -2382,8 +2569,7 @@
 following command:
 
 @table @kbd
-@kindex C-c =
-@item C-c =
+@orgcmd{C-c =,org-table-eval-formula}
 Install a new formula for the current column and replace current field with
 the result of the formula.  The command prompts for a formula, with default
 taken from the @samp{#+TBLFM} line, applies it to the current field and
@@ -2406,32 +2592,29 @@
 @code{org-table-use-standard-references}.
 
 @table @kbd
-@kindex C-c =
-@kindex C-u C-c =
-@item C-c =
-@itemx C-u C-c =
+@orgcmdkkc{C-c =,C-u C-c =,org-table-eval-formula}
 Edit the formula associated with the current column/field in the
 minibuffer.  See @ref{Column formulas}, and @ref{Field formulas}.
-@kindex C-u C-u C-c =
-@item C-u C-u C-c =
+@orgcmd{C-u C-u C-c =,org-table-eval-formula}
 Re-insert the active formula (either a
 field formula, or a column formula) into the current field, so that you
 can edit it directly in the field.  The advantage over editing in the
 minibuffer is that you can use the command @kbd{C-c ?}.
-@kindex C-c ?
-@item C-c ?
+@orgcmd{C-c ?,org-table-field-info}
 While editing a formula in a table field, highlight the field(s)
 referenced by the reference at the cursor position in the formula.
 @kindex C-c @}
+@findex org-table-toggle-coordinate-overlays
 @item C-c @}
-Toggle the display of row and column numbers for a table, using
-overlays.  These are updated each time the table is aligned; you can
-force it with @kbd{C-c C-c}.
+Toggle the display of row and column numbers for a table, using overlays
+(@command{org-table-toggle-coordinate-overlays}).  These are updated each
+time the table is aligned; you can force it with @kbd{C-c C-c}.
 @kindex C-c @{
+@findex org-table-toggle-formula-debugger
 @item C-c @{
-Toggle the formula debugger on and off.  See below.
-@kindex C-c '
-@item C-c '
+Toggle the formula debugger on and off
+(@command{org-table-toggle-formula-debugger}).  See below.
+@orgcmd{C-c ',org-table-edit-formulas}
 Edit all formulas for the current table in a special buffer, where the
 formulas will be displayed one per line.  If the current field has an
 active formula, the cursor in the formula editor will mark it.
@@ -2439,46 +2622,40 @@
 any field or range reference at the cursor position.  You may edit,
 remove and add formulas, and use the following commands:
 @table @kbd
-@kindex C-c C-c
-@kindex C-x C-s
-@item C-c C-c
-@itemx C-x C-s
+@orgcmdkkc{C-c C-c,C-x C-s,org-table-fedit-finish}
 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
 prefix, also apply the new formulas to the entire table.
-@kindex C-c C-q
-@item C-c C-q
+@orgcmd{C-c C-q,org-table-fedit-abort}
 Exit the formula editor without installing changes.
-@kindex C-c C-r
-@item C-c C-r
+@orgcmd{C-c C-r,org-table-fedit-toggle-ref-type}
 Toggle all references in the formula editor between standard (like
 @code{B3}) and internal (like @code{@@3$2}).
-@kindex @key{TAB}
-@item @key{TAB}
+@orgcmd{@key{TAB},org-table-fedit-lisp-indent}
 Pretty-print or indent Lisp formula at point.  When in a line containing
 a Lisp formula, format the formula according to Emacs Lisp rules.
 Another @key{TAB} collapses the formula back again.  In the open
 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
-@kindex M-@key{TAB}
-@item M-@key{TAB}
+@orgcmd{M-@key{TAB},lisp-complete-symbol}
 Complete Lisp symbols, just like in Emacs Lisp mode.
 @kindex S-@key{up}
 @kindex S-@key{down}
 @kindex S-@key{left}
 @kindex S-@key{right}
+@findex org-table-fedit-ref-up
+@findex org-table-fedit-ref-down
+@findex org-table-fedit-ref-left
+@findex org-table-fedit-ref-right
 @item S-@key{up}/@key{down}/@key{left}/@key{right}
 Shift the reference at point.  For example, if the reference is
 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
 This also works for relative references and for hline references.
-@kindex M-S-@key{up}
-@kindex M-S-@key{down}
-@item M-S-@key{up}/@key{down}
+@orgcmdkkcc{M-S-@key{up},M-S-@key{down},org-table-fedit-line-up,org-table-fedit-line-down}
 Move the test line for column formulas in the Org buffer up and
 down.
-@kindex M-@key{up}
-@kindex M-@key{down}
-@item M-@key{up}/@key{down}
+@orgcmdkkcc{M-@key{up},M-@key{down},org-table-fedit-scroll-down,org-table-fedit-scroll-up}
 Scroll the window displaying the table.
 @kindex C-c @}
+@findex org-table-toggle-coordinate-overlays
 @item C-c @}
 Turn the coordinate grid in the table on and off.
 @end table
@@ -2518,8 +2695,7 @@
 following commands:
 
 @table @kbd
-@kindex C-c *
-@item C-c *
+@orgcmd{C-c *,org-table-recalculate}
 Recalculate the current row by first applying the stored column formulas
 from left to right, and all field formulas in the current row.
 @c
@@ -2530,16 +2706,15 @@
 Recompute the entire table, line by line.  Any lines before the first
 hline are left alone, assuming that these are part of the table header.
 @c
-@kindex C-u C-u C-c *
-@kindex C-u C-u C-c C-c
-@item C-u C-u C-c *
-@itemx C-u C-u C-c C-c
+@orgcmdkkc{C-u C-u C-c *,C-u C-u C-c C-c,org-table-iterate}
 Iterate the table by recomputing it until no further changes occur.
 This may be necessary if some computed fields use the value of other
 fields that are computed @i{later} in the calculation sequence.
 @item M-x org-table-recalculate-buffer-tables
+@findex org-table-recalculate-buffer-tables
 Recompute all tables in the current buffer.
 @item M-x org-table-iterate-buffer-tables
+@findex org-table-iterate-buffer-tables
 Iterate all tables in the current buffer, in order to converge table-to-table
 dependencies.
 @end table
@@ -2551,8 +2726,7 @@
 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.
 @table @kbd
-@kindex C-#
-@item C-#
+@orgcmd{C-#,org-table-rotate-recalc-marks}
 Rotate the calculation mark in first column through the states @samp{ },
 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
 change all marks in the region.
@@ -2708,8 +2882,8 @@
 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
 
 @item labels
-List of labels to be used for the deps (defaults to the column headers if
-they exist).
+List of labels to be used for the @code{deps} (defaults to the column headers
+if they exist).
 
 @item line
 Specify an entire line to be inserted in the Gnuplot script.
@@ -2821,7 +2995,7 @@
 star followed by a few optional letters into the buffer and press
 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
 completions.}.  In non-Org files, the search will look for the words in the
-link text, in the above example the search would be for @samp{my target}.
+link text.  In the above example the search would be for @samp{my target}.
 
 Following a link pushes a mark onto Org's own mark ring.  You can
 return to the previous position with @kbd{C-c &}.  Using this command
@@ -2939,9 +3113,8 @@
 insert it into an Org file, and to follow the link.
 
 @table @kbd
-@kindex C-c l
+@orgcmd{C-c l,org-store-link}
 @cindex storing links
-@item C-c l
 Store a link to the current location.  This is a @emph{global} command (you
 must create the key binding yourself) which can be used in any buffer to
 create a link.  The link will be stored for later insertion into an Org
@@ -2997,11 +3170,10 @@
 entry referenced by the current line.
 
 @c
-@kindex C-c C-l
+@orgcmd{C-c C-l,org-insert-link}
 @cindex link completion
 @cindex completion, of links
 @cindex inserting links
-@item C-c C-l
 @vindex org-keep-stored-link-after-insertion
 Insert a link@footnote{ Note that you don't have to use this command to
 insert a link.  Links in Org are plain text, and you can type or paste them
@@ -3031,10 +3203,9 @@
 example, if you type @kbd{file @key{RET}}, file name completion (alternative
 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
 @key{RET}} you can complete contact names.
-@kindex C-u C-c C-l
+@orgkey C-u C-c C-l
 @cindex file name completion
 @cindex completion, of file names
-@item C-u C-c C-l
 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
 a file will be inserted and you may use file name completion to select
 the name of the file.  The path to the file is inserted relative to the
@@ -3049,9 +3220,7 @@
 link and description parts of the link.
 @c
 @cindex following links
-@kindex C-c C-o
-@kindex @key{RET}
-@item C-c C-o @ @r{(or, if @code{org-return-follows-link} is set, also} @key{RET}
+@orgcmd{C-c C-o,org-open-at-point}
 @vindex org-file-apps
 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
@@ -3067,13 +3236,17 @@
 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.
+@orgkey @key{RET}
+@vindex org-return-follows-link
+When @code{org-return-follows-link} is set, @kbd{@key{RET}} will also follow
+the link at point.
 @c
 @kindex mouse-2
 @kindex mouse-1
 @item mouse-2
 @itemx mouse-1
 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
-would.  Under Emacs 22, @kbd{mouse-1} will also follow a link.
+would.  Under Emacs 22 and later, @kbd{mouse-1} will also follow a link.
 @c
 @kindex mouse-3
 @item mouse-3
@@ -3082,13 +3255,12 @@
 internal links to be displayed in another window@footnote{See the
 variable @code{org-display-internal-link-with-indirect-buffer}}.
 @c
+@orgcmd{C-c C-x C-v,org-toggle-inline-images}
 @cindex inlining images
 @cindex images, inlining
-@kindex C-c C-x C-v
 @vindex org-startup-with-inline-images
 @cindex @code{inlineimages}, STARTUP keyword
 @cindex @code{noinlineimages}, STARTUP keyword
-@item C-c C-x C-v
 Toggle the inline display of linked images.  Normally this will only inline
 images that have no description part in the link, i.e. images that will also
 be inlined during export.  When called with a prefix argument, also display
@@ -3096,28 +3268,23 @@
 displayed at startup by configuring the variable
 @code{org-startup-with-inline-images}@footnote{with corresponding
 @code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
+@orgcmd{C-c %,org-mark-ring-push}
 @cindex mark ring
-@kindex C-c %
-@item C-c %
 Push the current position onto the mark ring, to be able to return
 easily. Commands following an internal link do this automatically.
 @c
+@orgcmd{C-c &,org-mark-ring-goto}
 @cindex links, returning to
-@kindex C-c &
-@item C-c &
 Jump back to a recorded position.  A position is recorded by the
 commands following internal links, and by @kbd{C-c %}.  Using this
 command several times in direct succession moves through a ring of
 previously recorded positions.
 @c
-@kindex C-c C-x C-n
-@kindex C-c C-x C-p
+@orgcmdkkcc{C-c C-x C-n,C-c C-x C-p,org-next-link,org-previous-link}
 @cindex links, finding next/previous
-@item C-c C-x C-n
-@itemx C-c C-x C-p
 Move forward/backward to the next link in the buffer.  At the limit of
 the buffer, the search fails once, and then wraps around.  The key
-bindings for this are really too long, you might want to bind this also
+bindings for this are really too long; you might want to bind this also
 to @kbd{C-n} and @kbd{C-p}
 @lisp
 (add-hook 'org-load-hook
@@ -3316,9 +3483,8 @@
 The most important commands to work with TODO entries are:
 
 @table @kbd
-@kindex C-c C-t
+@orgcmd{C-c C-t,org-todo}
 @cindex cycling, of TODO states
-@item C-c C-t
 Rotate the TODO state of the current item among
 
 @example
@@ -3329,8 +3495,7 @@
 The same rotation can also be done ``remotely'' from the timeline and
 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
 
-@kindex C-u C-c C-t
-@item C-u C-c C-t
+@orgkey{C-u C-c C-t}
 Select a specific keyword using completion or (if it has been set up)
 the fast selection interface.  For the latter, you need to assign keys
 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
@@ -3338,17 +3503,15 @@
 
 @kindex S-@key{right}
 @kindex S-@key{left}
+@item S-@key{right} @ @r{/} @ S-@key{left}
 @vindex org-treat-S-cursor-todo-selection-as-state-change
-@item S-@key{right}
-@itemx S-@key{left}
 Select the following/preceding TODO state, similar to cycling.  Useful
 mostly if more than two TODO states are possible (@pxref{TODO
 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
 with @code{shift-selection-mode}.  See also the variable
 @code{org-treat-S-cursor-todo-selection-as-state-change}.
-@kindex C-c / t
+@orgcmd{C-c / t,org-show-todo-key}
 @cindex sparse tree, for TODO
-@itemx C-c / t
 @vindex org-todo-keywords
 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
 entire buffer, but shows all TODO items (with not-DONE state) and the
@@ -3359,15 +3522,13 @@
 N, show the tree for the Nth keyword in the variable
 @code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
 both un-done and done.
-@kindex C-c a t
-@item C-c a t
+@orgcmd{C-c a t,org-todo-list}
 Show the global TODO list.  Collects the TODO items (with not-DONE states)
 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
 buffer will be in @code{agenda-mode}, which provides commands to examine and
 manipulate the TODO entries from the new buffer (@pxref{Agenda commands}).
 @xref{Global TODO list}, for more information.
-@kindex S-M-@key{RET}
-@item S-M-@key{RET}
+@orgcmd{S-M-@key{RET},org-insert-todo-heading}
 Insert a new TODO entry below the current one.
 @end table
 
@@ -3644,8 +3805,7 @@
 @end example
 
 @table @kbd
-@kindex C-c C-x o
-@item C-c C-x o
+@orgcmd{C-c C-x o,org-toggle-ordered-property}
 @vindex org-track-ordered-property-with-tag
 @cindex property, ORDERED
 Toggle the @code{ORDERED} property of the current entry.  A property is used
@@ -3653,8 +3813,7 @@
 inherited like a tag.  However, if you would like to @i{track} the value of
 this property with a tag for better visibility, customize the variable
 @code{org-track-ordered-property-with-tag}.
-@kindex C-u C-u C-u C-c C-t
-@item C-u C-u C-u C-c C-t
+@orgkey{C-u C-u C-u C-c C-t}
 Change TODO state, circumventing any state blocking.
 @end table
 
@@ -3698,7 +3857,7 @@
 
 The most basic logging is to keep track of @emph{when} a certain TODO
 item was finished.  This is achieved with@footnote{The corresponding
-in-buffer setting is: @code{#+STARTUP: logdone}}.
+in-buffer setting is: @code{#+STARTUP: logdone}}
 
 @lisp
 (setq org-log-done 'time)
@@ -3928,18 +4087,16 @@
 items.
 
 @table @kbd
+@item @kbd{C-c ,}
 @kindex @kbd{C-c ,}
-@item @kbd{C-c ,}
-Set the priority of the current headline.  The command prompts for a
-priority character @samp{A}, @samp{B} or @samp{C}.  When you press
-@key{SPC} instead, the priority cookie is removed from the headline.
-The priorities can also be changed ``remotely'' from the timeline and
-agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
-@c
-@kindex S-@key{up}
-@kindex S-@key{down}
-@item S-@key{up}
-@itemx S-@key{down}
+@findex org-priority
+Set the priority of the current headline (@command{org-priority}).  The
+command prompts for a priority character @samp{A}, @samp{B} or @samp{C}.
+When you press @key{SPC} instead, the priority cookie is removed from the
+headline.  The priorities can also be changed ``remotely'' from the timeline
+and agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
+@c
+@orgcmdkkcc{S-@key{up},S-@key{down},org-priority-up,org-priority-down}
 @vindex org-priority-start-cycle-with-default
 Increase/decrease priority of current headline@footnote{See also the option
 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
@@ -4089,13 +4246,11 @@
 @noindent The following commands work with checkboxes:
 
 @table @kbd
-@kindex C-c C-c
-@item C-c C-c
+@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.
-@kindex C-c C-x C-b
-@item C-c C-x C-b
+@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
 intermediate state.
@@ -4110,13 +4265,11 @@
 @item
 If there is no active region, just toggle the checkbox at point.
 @end itemize
-@kindex M-S-@key{RET}
-@item M-S-@key{RET}
+@orgcmd{M-S-@key{RET},org-insert-todo-heading}
 Insert a new item with a checkbox.
 This works only if the cursor is already in a plain list item
 (@pxref{Plain lists}).
-@kindex C-c C-x o
-@item C-c C-x o
+@orgcmd{C-c C-x o,org-toggle-ordered-property}
 @vindex org-track-ordered-property-with-tag
 @cindex property, ORDERED
 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
@@ -4125,8 +4278,7 @@
 However, if you would like to @i{track} the value of this property with a tag
 for better visibility, customize the variable
 @code{org-track-ordered-property-with-tag}.
-@kindex C-c #
-@item C-c #
+@orgcmd{C-c #,org-update-statistics-cookies}
 Update the statistics cookie in the current outline entry.  When called with
 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
@@ -4220,8 +4372,7 @@
 also a special command for inserting tags:
 
 @table @kbd
-@kindex C-c C-q
-@item C-c C-q
+@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
@@ -4231,8 +4382,7 @@
 tags in the current buffer will be aligned to that column, just to make
 things look nice.  TAGS are automatically realigned after promotion,
 demotion, and TODO state changes (@pxref{TODO basics}).
-@kindex C-c C-c
-@item C-c C-c
+@orgcmd{C-c C-c,org-set-tags-command}
 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
 @end table
 
@@ -4399,18 +4549,13 @@
 information into special lists.
 
 @table @kbd
-@kindex C-c \
-@kindex C-c / m
-@item C-c \
-@itemx C-c / m
+@orgcmdkkc{C-c / m,C-c \,org-match-sparse-tree}
 Create a sparse tree with all headlines matching a tags search.  With a
 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
-@kindex C-c a m
-@item C-c a m
+@orgcmd{C-c a m,org-tags-view}
 Create a global list of tag matches from all agenda files.
 @xref{Matching tags and properties}.
-@kindex C-c a M
-@item C-c a M
+@orgcmd{C-c a M,org-tags-view}
 @vindex org-tags-match-list-sublevels
 Create a global list of tag matches from all agenda files, but check
 only TODO items and force checking subitems (see variable
@@ -4511,33 +4656,29 @@
 The following commands help to work with properties:
 
 @table @kbd
-@kindex M-@key{TAB}
-@item M-@key{TAB}
+@orgcmd{M-@key{TAB},org-complete}
 After an initial colon in a line, complete property keys.  All keys used
 in the current file will be offered as possible completions.
-@kindex C-c C-x p
-@item C-c C-x p
+@orgcmd{C-c C-x p,org-set-property}
 Set a property.  This prompts for a property name and a value.  If
 necessary, the property drawer is created as well.
 @item M-x org-insert-property-drawer
+@findex org-insert-property-drawer
 Insert a property drawer into the current entry.  The drawer will be
 inserted early in the entry, but after the lines with planning
 information like deadlines.
-@kindex C-c C-c
-@item C-c C-c
+@orgcmd{C-c C-c,org-property-action}
 With the cursor in a property drawer, this executes property commands.
-@item C-c C-c s
+@orgcmd{C-c C-c s,org-set-property}
 Set a property in the current entry.  Both the property and the value
 can be inserted using completion.
-@kindex S-@key{right}
-@kindex S-@key{left}
-@item S-@key{left}/@key{right}
+@orgcmdkkcc{S-@key{right},S-@key{left},org-property-next-allowed-value,org-property-previous-allowed-value}
 Switch property at point to the next/previous allowed value.
-@item C-c C-c d
+@orgcmd{C-c C-c d,org-delete-property}
 Remove a property from the current entry.
-@item C-c C-c D
+@orgcmd{C-c C-c D,org-delete-property-globally}
 Globally remove a property, from all entries in the current file.
-@item C-c C-c c
+@orgcmd{C-c C-c c,org-compute-property-at-point}
 Compute the property at point, using the operator and scope from the
 nearest column format definition.
 @end table
@@ -4592,18 +4733,13 @@
 To create sparse trees and special lists with selection based on properties,
 the same commands are used as for tag searches (@pxref{Tag searches}).
 @table @kbd
-@kindex C-c \
-@kindex C-c / m
-@item C-c \
-@itemx C-c / m
+@orgcmdkkc{C-c / m,C-c \,org-match-sparse-tree}
 Create a sparse tree with all matching entries.  With a
 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
-@kindex C-c a m
-@item C-c a m
+@orgcmd{C-c a m,org-tags-view}
 Create a global list of tag/property  matches from all agenda files.
 @xref{Matching tags and properties}.
-@kindex C-c a M
-@item C-c a M
+@orgcmd{C-c a M,org-tags-view}
 @vindex org-tags-match-list-sublevels
 Create a global list of tag matches from all agenda files, but check
 only TODO items and force checking of subitems (see variable
@@ -4617,12 +4753,11 @@
 single property:
 
 @table @kbd
-@kindex C-c / p
-@item C-c / p
+@orgkey{C-c / p}
 Create a sparse tree based on the value of a property.  This first
 prompts for the name of a property, and then for a value.  A sparse tree
 is created with all entries that define this property with the given
-value.  If you enclose the value into curly braces, it is interpreted as
+value.  If you enclose the value in curly braces, it is interpreted as
 a regular expression and matched against the property values.
 @end table
 
@@ -4632,7 +4767,7 @@
 @cindex inheritance, of properties
 
 @vindex org-use-property-inheritance
-The outline structure of Org-mode documents lends itself for 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
 turn this on by default, because it can slow down property searches
@@ -4642,7 +4777,7 @@
 all properties inherited from the parent, to a list of properties
 that should be inherited, or to a regular expression that matches
 inherited properties.  If a property has the value @samp{nil}, this is
-interpreted as an explicit undefine of he property, so that inheritance
+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
@@ -4784,7 +4919,7 @@
 The @code{est+} summary type requires further explanation.  It is used for
 combining estimates, expressed as low-high ranges.  For example, instead
 of estimating a particular task will take 5 days, you might estimate it as
-5-6 days if you're fairly confident you know how much woark is required, or
+5-6 days if you're fairly confident you know how much work is required, or
 1-10 days if you don't really know what needs to be done.  Both ranges
 average at 5.5 days, but the first represents a more predictable delivery.
 
@@ -4829,8 +4964,7 @@
 
 @table @kbd
 @tsubheading{Turning column view on and off}
-@kindex C-c C-x C-c
-@item C-c C-x C-c
+@orgcmd{C-c C-x C-c,org-columns}
 @vindex org-columns-default-format
 Turn on column view.  If the cursor is before the first headline in the file,
 column view is turned on for the entire file, using the @code{#+COLUMNS}
@@ -4841,14 +4975,11 @@
 property.  If no such property is found, the format is taken from the
 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
 and column view is established for the current entry and its subtree.
-@kindex r
-@item r
+@orgcmd{r,org-columns-redo}
 Recreate the column view, to include recent changes made in the buffer.
-@kindex g
-@item g
+@orgcmd{g,org-columns-redo}
 Same as @kbd{r}.
-@kindex q
-@item q
+@orgcmd{q,org-columns-quit}
 Exit column view.
 @tsubheading{Editing values}
 @item @key{left} @key{right} @key{up} @key{down}
@@ -4859,40 +4990,30 @@
 Switch to the next/previous allowed value of the field.  For this, you
 have to have specified allowed values for a property.
 @item 1..9,0
-Directly select the nth allowed value, @kbd{0} selects the 10th value.
-@kindex n
-@kindex p
-@itemx  n / p
+Directly select the Nth allowed value, @kbd{0} selects the 10th value.
+@orgcmdkkcc{n,p,org-columns-next-allowed-value,org-columns-previous-allowed-value}
 Same as @kbd{S-@key{left}/@key{right}}
-@kindex e
-@item e
+@orgcmd{e,org-columns-edit-value}
 Edit the property at point.  For the special properties, this will
 invoke the same interface that you normally use to change that
 property.  For example, when editing a TAGS property, the tag completion
 or fast selection interface will pop up.
-@kindex C-c C-c
-@item C-c C-c
+@orgcmd{C-c C-c,org-columns-set-tags-or-toggle}
 When there is a checkbox at point, toggle it.
-@kindex v
-@item v
+@orgcmd{v,org-columns-show-value}
 View the full value of this property.  This is useful if the width of
 the column is smaller than that of the value.
-@kindex a
-@item a
+@orgcmd{a,org-columns-edit-allowed}
 Edit the list of allowed values for this property.  If the list is found
 in the hierarchy, the modified values is stored there.  If no list is
 found, the new value is stored in the first entry that is part of the
 current column view.
 @tsubheading{Modifying the table structure}
-@kindex <
-@kindex >
-@item < / >
+@orgcmdkkcc{<,>,org-columns-narrow,org-columns-widen}
 Make the column narrower/wider by one character.
-@kindex S-M-@key{right}
-@item S-M-@key{right}
+@orgcmd{S-M-@key{right},org-columns-new}
 Insert a new column, to the left of the current column.
-@kindex S-M-@key{left}
-@item S-M-@key{left}
+@orgcmd{S-M-@key{left},org-columns-delete}
 Delete the current column.
 @end table
 
@@ -4948,20 +5069,16 @@
 The following commands insert or update the dynamic block:
 
 @table @kbd
-@kindex C-c C-x i
-@item C-c C-x i
+@orgcmd{C-c C-x i,org-insert-columns-dblock}
 Insert a dynamic block capturing a column view.  You will be prompted
 for the scope or ID of the view.
-@kindex C-c C-c
-@item C-c C-c
-@kindex C-c C-x C-u
-@itemx C-c C-x C-u
+@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.
-@kindex C-u C-c C-x C-u
-@item C-u C-c C-x C-u
+@orgcmd{C-u C-c C-x C-u,org-update-all-dblocks}
 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
-you have several clock table blocks in a buffer.
+you have several clock table blocks, column-capturing blocks or other dynamic
+blocks in a buffer.
 @end table
 
 You can add formulas to the column view table and you may add plotting
@@ -5006,7 +5123,6 @@
 * Creating timestamps::         Commands which insert timestamps
 * Deadlines and scheduling::    Planning your work
 * Clocking work time::          Tracking how long you spend on a task
-* Resolving idle time::         Resolving time if you've been idle
 * Effort estimates::            Planning work effort in advance
 * Relative timer::              Notes with a running timer
 * Countdown timer::             Starting a countdown timer for a task
@@ -5130,17 +5246,11 @@
 Access the agenda for the date given by the timestamp or -range at
 point (@pxref{Weekly/daily agenda}).
 @c
-@kindex S-@key{left}
-@kindex S-@key{right}
-@item S-@key{left}
-@itemx S-@key{right}
+@orgcmdkkcc{S-@key{left},S-@key{right},org-timestamp-down-day,org-timestamp-up-day}
 Change date at cursor by one day.  These key bindings conflict with
 shift-selection and related modes (@pxref{Conflicts}).
 @c
-@kindex S-@key{up}
-@kindex S-@key{down}
-@item S-@key{up}
-@itemx S-@key{down}
+@orgcmdkkcc{S-@key{up},S-@key{down},org-timestamp-up,org-timestamp-down-down}
 Change the item under the cursor in a timestamp.  The cursor can be on a
 year, month, day, hour or minute.  When the timestamp contains a time range
 like @samp{15:30-16:30}, modifying the first time will also shift the second,
@@ -5150,9 +5260,8 @@
 (@pxref{Priorities}). The key bindings also conflict with shift-selection and
 related modes (@pxref{Conflicts}).
 @c
-@kindex C-c C-y
+@orgcmd{C-c C-y,org-evaluate-time-range}
 @cindex evaluate time range
-@item C-c C-y
 Evaluate a time range by computing the difference between start and end.
 With a prefix argument, insert result after the time range (in a table: into
 the following column).
@@ -5215,7 +5324,7 @@
 single plus or minus, the date is always relative to today.  With a
 double plus or minus, it is relative to the default date.  If instead of
 a single letter, you use the abbreviation of day name, the date will be
-the nth such day.  E.g.
+the Nth such day.  E.g.
 
 @example
 +0            --> today
@@ -5234,7 +5343,7 @@
 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
 
 You can specify a time range by giving start and end times or by giving a
-start time and a duration (in HH:MM format). Use '-' or '--' as the separator
+start time and a duration (in HH:MM format). Use `-' or `-@{@}-' as the separator
 in the former case and use '+' as the separator in the latter case. E.g.
 
 @example
@@ -5298,8 +5407,7 @@
 @code{org-time-stamp-custom-formats}.
 
 @table @kbd
-@kindex C-c C-x C-t
-@item C-c C-x C-t
+@orgcmd{C-c C-x C-t,org-toggle-time-stamp-overlays}
 Toggle the display of custom formats for dates and times.
 @end table
 
@@ -5320,7 +5428,7 @@
 time will be changed by one minute.
 @item
 If the timestamp contains a range of clock times or a repeater, these
-will not be overlayed, but remain in the buffer as they were.
+will not be overlaid, but remain in the buffer as they were.
 @item
 When you delete a timestamp character-by-character, it will only
 disappear from the buffer after @emph{all} (invisible) characters
@@ -5372,8 +5480,8 @@
 be listed on that date after it has been marked DONE.  If you don't like
 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
 addition, a reminder that the scheduled date has passed will be present
-in the compilation for @emph{today}, until the entry is marked DONE.
-I.e. the task will automatically be forwarded until completed.
+in the compilation for @emph{today}, until the entry is marked DONE, i.e.
+the task will automatically be forwarded until completed.
 
 @example
 *** TODO Call Trillian for a date on New Years Eve.
@@ -5415,8 +5523,7 @@
 
 @table @kbd
 @c
-@kindex C-c C-d
-@item C-c C-d
+@orgcmd{C-c C-d,org-deadline}
 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
 in the line directly following the headline.  When called with a prefix arg,
 an existing deadline will be removed from the entry.  Depending on the
@@ -5426,8 +5533,7 @@
 deadline.
 @c FIXME Any CLOSED timestamp will be removed.????????
 @c
-@kindex C-c C-s
-@item C-c C-s
+@orgcmd{C-c C-s,org-schedule}
 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
 happen in the line directly following the headline.  Any CLOSED timestamp
 will be removed.  When called with a prefix argument, remove the scheduling
@@ -5437,18 +5543,16 @@
 @code{nologredeadline}}, a note will be taken when changing an existing
 scheduling time.
 @c
-@kindex C-c C-x C-k
+@orgcmd{C-c C-x C-k,org-mark-entry-for-agenda-action}
 @kindex k a
 @kindex k s
-@item C-c C-x C-k
 Mark the current entry for agenda action.  After you have marked the entry
 like this, you can open the agenda or the calendar to find an appropriate
 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
 schedule the marked item.
 @c
-@kindex C-c / d
+@orgcmd{C-c / d,org-check-deadlines}
 @cindex sparse tree, for deadlines
-@item C-c / d
 @vindex org-deadline-warning-days
 Create a sparse tree with all deadlines that are either past-due, or
 which will become due within @code{org-deadline-warning-days}.
@@ -5456,12 +5560,10 @@
 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
 all deadlines due tomorrow.
 @c
-@kindex C-c / b
-@item C-c / b
+@orgcmd{C-c / b,org-check-before-date}
 Sparse tree for deadlines and scheduled items before a given date.
 @c
-@kindex C-c / a
-@item C-c / a
+@orgcmd{C-c / a,org-check-after-date}
 Sparse tree for deadlines and scheduled items after a given date.
 @end table
 
@@ -5520,11 +5622,11 @@
 month.  So if you have not paid the rent for three months, marking this
 entry DONE will still keep it as an overdue deadline.  Depending on the
 task, this may not be the best way to handle it.  For example, if you
-forgot to call you father for 3 weeks, it does not make sense to call
+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
-special repeaters markers with @samp{++} and @samp{.+}.  For example:
+special repeaters  @samp{++} and @samp{.+}.  For example:
 
 @example
 ** TODO Call Father
@@ -5547,8 +5649,10 @@
 created for this purpose, it is described in @ref{Structure editing}.
 
 
-@node Clocking work time, Resolving idle time, Deadlines and scheduling, Dates and Times
+@node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
 @section Clocking work time
+@cindex clocking time
+@cindex time clocking
 
 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.
@@ -5569,9 +5673,17 @@
 will be found (@pxref{Resolving idle time}) and you will be prompted about
 what to do with it.
 
-@table @kbd
-@kindex C-c C-x C-i
-@item C-c C-x C-i
+@menu
+* Clocking commands::           Starting and stopping a clock
+* The clock table::             Detailed reports
+* Resolving idle time::         Resolving time when you've been idle
+@end menu
+
+@node Clocking commands, The clock table, Clocking work time, Clocking work time
+@subsection Clocking commands
+
+@table @kbd
+@orgcmd{C-c C-x C-i,org-clock-in}
 @vindex org-clock-into-drawer
 Start the clock on the current item (clock-in).  This inserts the CLOCK
 keyword together with a timestamp.  If this is not the first clocking of
@@ -5601,8 +5713,8 @@
 @code{auto} which is the default@footnote{See also the variable
 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
 mode line entry will pop up a menu with clocking options.
-@kindex C-c C-x C-o
-@item C-c C-x C-o
+@c
+@orgcmd{C-c C-x C-o,org-clock-out}
 @vindex org-log-note-clock-out
 Stop the clock (clock-out).  This inserts another timestamp at the same
 location where the clock was last started.  It also directly computes
@@ -5611,29 +5723,24 @@
 possibility to record an additional note together with the clock-out
 timestamp@footnote{The corresponding in-buffer setting is:
 @code{#+STARTUP: lognoteclock-out}}.
-@kindex C-c C-x C-e
-@item C-c C-x C-e
+@orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
 Update the effort estimate for the current clock task.
 @kindex C-c C-y
 @kindex C-c C-c
-@item C-c C-y @ @ @r{or}@ @ C-c C-c
+@orgcmdkkc{C-c C-c,C-c C-y,org-evaluate-time-range}
 Recompute the time interval after changing one of the timestamps.  This
 is only necessary if you edit the timestamps directly.  If you change
 them with @kbd{S-@key{cursor}} keys, the update is automatic.
-@kindex C-c C-t
-@item C-c C-t
+@orgcmd{C-c C-t,org-todo}
 Changing the TODO state of an item to DONE automatically stops the clock
 if it is running in this same item.
-@kindex C-c C-x C-x
-@item C-c C-x C-x
+@orgcmd{C-c C-x C-x,org-clock-cancel}
 Cancel the current clock.  This is useful if a clock was started by
 mistake, or if you ended up working on something else.
-@kindex C-c C-x C-j
-@item C-c C-x C-j
+@orgcmd{C-c C-x C-j,org-clock-goto}
 Jump to the headline of the currently clocked in task.  With a @kbd{C-u}
 prefix arg, select the target task from a list of recently clocked tasks.
-@kindex C-c C-x C-d
-@item C-c C-x C-d
+@orgcmd{C-c C-x C-d,org-clock-display}
 @vindex org-remove-highlights-with-change
 Display time summaries for each subtree in the current buffer.  This
 puts overlays at the end of each headline, showing the total time
@@ -5641,24 +5748,60 @@
 can use visibility cycling to study the tree, but the overlays disappear
 when you change the buffer (see variable
 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
-@kindex C-c C-x C-r
-@item C-c C-x C-r
+@end table
+
+The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
+the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
+worked on or closed during a day.
+
+@node The clock table, Resolving idle time, Clocking commands, Clocking work time
+@subsection The clock table
+@cindex clocktable, dynamic block
+@cindex report, of clocked time
+
+Org mode can produce quite complex reports based on the time clocking
+information.  Such a report is called a @emph{clock table}, because it is
+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
 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.
+@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.
+@orgkey{C-u C-c C-x C-u}
+Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
+you have several clock table blocks in a buffer.
+@orgcmdkxkc{S-@key{left},S-@key{right},org-clocktable-try-shift}
+Shift the current @code{:block} interval and update the table.  The cursor
+needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
+@code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
+@end table
+
+
+Here is an example of the frame for a clock table as it is inserted into the
+buffer with the @kbd{C-c C-x C-r} command:
+
 @cindex #+BEGIN, clocktable
 @example
 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
 #+END: clocktable
 @end example
 @noindent
-If such a block already exists at point, its content is replaced by the
-new table.  The @samp{BEGIN} line can specify options:
+@vindex org-clocktable-defaults
+The @samp{BEGIN} line and specify a number of options to define the scope,
+structure, and formatting of the report.  Defaults for all these options can
+be configured in the variable @code{org-clocktable-defaults}.
+
+@noindent First there are options that determine which clock entries are to
+be selected:
 @example
 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
-:emphasize   @r{When @code{t}, emphasize level one and level two items.}
+             @r{Clocks at deeper levels will be summed into the upper level.}
 :scope       @r{The scope to consider.  This can be any of the following:}
              nil        @r{the current buffer or narrowed region}
              file       @r{the full current buffer}
@@ -5675,6 +5818,7 @@
              2007-12-31    @r{New year eve 2007}
              2007-12       @r{December 2007}
              2007-W50      @r{ISO-week 50 in 2007}
+             2007-Q2       @r{2nd quarter in 2007}
              2007          @r{the year 2007}
              today, yesterday, today-@var{N}          @r{a relative day}
              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
@@ -5685,15 +5829,33 @@
 :tend        @r{A time string specifying when to stop considering times.}
 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
-:stepskip0   @r{Don't show steps that have zero time}
-:tags        @r{A tags match to select entries that should contribute}
+:stepskip0   @r{Do not show steps that have zero time.}
+:fileskip0   @r{Do not show table sections from files which did not contribute.}
+:tags        @r{A tags match to select entries that should contribute}.
+@end example
+
+Then there are options which determine the formatting of the table.  There
+options are interpreted by the function @code{org-clocktable-write-default},
+but you can specify your own function using the @code{:formatter} parameter.
+@example
+:emphasize   @r{When @code{t}, emphasize level one and level two items.}
 :link        @r{Link the item headlines in the table to their origins.}
+:narrow      @r{An integer to limit the width of the headline column in}
+             @r{the org table.  If you write it like @samp{50!}, then the}
+             @r{headline will also be shortened in export.}
+:indent      @r{Indent each headline field according to its level.}
+:tcolumns    @r{Number of columns to be used for times.  If this is smaller}
+             @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
+:level       @r{Should a level number column be included?}
+:compact     @r{Abbreviation for @code{:level nil :indent t :narrow 40! :tcolumns 1}}
+             @r{All are overwritten except if there is an explicit @code{:narrow}}
+:timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
+             @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
              @r{As a special case, @samp{:formula %} adds a column with % time.}
-             @r{If you do not specify a formula here, any existing formula.}
+             @r{If you do not specify a formula here, any existing formula}
              @r{below the clock table will survive updates and be evaluated.}
-:timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
-             @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
+:formatter   @r{A function to format clock data and insert it into the buffer.}
 @end example
 To get a clock summary of the current level 1 tree, for the current
 day, you could write
@@ -5715,31 +5877,15 @@
 #+BEGIN: clocktable :scope subtree :link t :formula %
 #+END: clocktable
 @end example
-@kindex C-c C-c
-@item C-c C-c
-@kindex C-c C-x C-u
-@itemx C-c C-x C-u
-Update dynamic block at point.  The cursor needs to be in the
-@code{#+BEGIN} line of the dynamic block.
-@kindex C-u C-c C-x C-u
-@item C-u C-c C-x C-u
-Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
-you have several clock table blocks in a buffer.
-@kindex S-@key{left}
-@kindex S-@key{right}
-@item S-@key{left}
-@itemx S-@key{right}
-Shift the current @code{:block} interval and update the table.  The cursor
-needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
-@code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
-@end table
-
-The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
-the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
-worked on or closed during a day.
-
-@node Resolving idle time, Effort estimates, Clocking work time, Dates and Times
-@section Resolving idle time
+A horizontally compact representation of everything clocked during last week
+would be
+@example
+#+BEGIN: clocktable :scope agenda :block lastweek :compact t
+#+END: clocktable
+@end example
+
+@node Resolving idle time,  , The clock table, Clocking work time
+@subsection Resolving idle time
 @cindex resolve idle time
 
 @cindex idle, resolve, dangling
@@ -5800,13 +5946,13 @@
 dangling clock which was never clocked out from your last session.  Using
 that clock's starting time as the beginning of the unaccounted-for period,
 Org will ask how you want to resolve that time.  The logic and behavior is
-identical to dealing with away time due to idleness, it's just happening due
+identical to dealing with away time due to idleness; it's just happening due
 to a recovery event rather than a set amount of idle time.
 
 You can also check all the files visited by your Org agenda for dangling
 clocks at any time using @kbd{M-x org-resolve-clocks}.
 
-@node Effort estimates, Relative timer, Resolving idle time, Dates and Times
+@node Effort estimates, Relative timer, Clocking work time, Dates and Times
 @section Effort estimates
 @cindex effort estimates
 
@@ -5822,13 +5968,11 @@
 for an entry with the following commands:
 
 @table @kbd
-@kindex C-c C-x e
-@item C-c C-x e
+@orgcmd{C-c C-x e,org-set-effort}
 Set the effort estimate for the current entry.  With a numeric prefix
-argument, set it to the NTH allowed value (see below).  This command is also
+argument, set it to the Nth allowed value (see below).  This command is also
 accessible from the agenda with the @kbd{e} key.
-@kindex C-c C-x C-e
-@item C-c C-x C-e
+@orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
 Modify the effort estimate of the item currently being clocked.
 @end table
 
@@ -5880,29 +6024,27 @@
 such a relative timer and make it easy to create timed notes.
 
 @table @kbd
-@kindex C-c C-x .
-@item C-c C-x .
+@orgcmd{C-c C-x .,org-timer}
 Insert a relative time into the buffer.  The first time you use this, the
 timer will be started.  When called with a prefix argument, the timer is
 restarted.
-@kindex C-c C-x -
-@item C-c C-x -
+@orgcmd{C-c C-x -,org-timer-item}
 Insert a description list item with the current relative time.  With a prefix
 argument, first reset the timer to 0.
-@kindex M-@key{RET}
-@item M-@key{RET}
+@orgcmd{M-@key{RET},org-insert-heading}
 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
 new timer items.
+@c for key sequences with a comma, command name macros fail :(
 @kindex C-c C-x ,
 @item C-c C-x ,
-Pause the timer, or continue it if it is already paused.
+Pause the timer, or continue it if it is already paused
+(@command{org-timer-pause-or-continue}).
 @c removed the sentence because it is redundant to the following item
 @kindex C-u C-c C-x ,
 @item C-u C-c C-x ,
 Stop the timer.  After this, you can only start a new timer, not continue the
 old one.  This command also removes the timer from the mode line.
-@kindex C-c C-x 0
-@item C-c C-x 0
+@orgcmd{C-c C-x 0,org-timer-start}
 Reset the timer without inserting anything into the buffer.  By default, the
 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
 specific starting offset.  The user is prompted for the offset, with a
@@ -5994,31 +6136,31 @@
 @subsection Using capture
 
 @table @kbd
-@kindex C-c c
-@item C-c c
-Call the command @code{org-capture}.  If you have templates defined
-@pxref{Capture templates}, it will offer these templates for selection or use
-a new Org outline node as the default template.  It will insert the template
-into the target file and switch to an indirect buffer narrowed to this new
-node.  You may then insert the information you want.
-
-@kindex C-c C-c
-@item C-c C-c
-Once you have finished entering information into the capture buffer, 
-@kbd{C-c C-c} will return you to the window configuration before the capture
-process, so that you can resume your work without further distraction.
-
-@kindex C-c C-w
-@item C-c C-w
+@orgcmd{C-c c,org-capture}
+Call the command @code{org-capture}.  Note that this keybinding is global and
+not active by default - you need to install it.  If you have templates
+defined @pxref{Capture templates}, it will offer these templates for
+selection or use a new Org outline node as the default template.  It will
+insert the template into the target file and switch to an indirect buffer
+narrowed to this new node.  You may then insert the information you want.
+
+@orgcmd{C-c C-c,org-capture-finalize}
+Once you have finished entering information into the capture buffer, @kbd{C-c
+C-c} will return you to the window configuration before the capture process,
+so that you can resume your work without further distraction.  When called
+with a prefix arg, finalize and then jump to the captured item.
+
+@orgcmd{C-c C-w,org-capture-refile}
 Finalize the capture process by refiling (@pxref{Refiling notes}) the note to
 a different place.  Please realize that this is a normal refiling command
-that will be executed - so the cursor position at the moment you run this
+that will be executed---so the cursor position at the moment you run this
 command is important.  If you have inserted a tree with a parent and
-children, first move the cursor back to the parent.
-
-@kindex C-c C-k
-@item C-c C-k
+children, first move the cursor back to the parent.  Any prefix argument
+given to this command will be passed on to the @code{org-refile} command.
+
+@orgcmd{C-c C-k,org-capture-kill}
 Abort the capture process and return to the previous state.
+
 @end table
 
 You can also call @code{org-capture} in a special way from the agenda, using
@@ -6026,6 +6168,17 @@
 the selected capture template will default to the cursor date in the agenda,
 rather than to the current date.
 
+To find the locations of the last stored capture, use @code{org-capture} with
+prefix commands:
+
+@table @kbd
+@orgkey{C-u C-c c}
+Visit the target location of a cpature template.  You get to select the
+template in the usual way.
+@orgkey{C-u C-u C-c c}
+Visit the last stored capture item in its buffer.
+@end table
+
 @node Capture templates,  , Using capture, Capture
 @subsection Capture templates
 @cindex templates, for Capture
@@ -6035,8 +6188,7 @@
 through the customize interface.
 
 @table @kbd
-@kindex C-c c C
-@item C-c c C
+@orgkey{C-c c C}
 Customize the variable @code{org-capture-templates}.
 @end table
 
@@ -6124,7 +6276,7 @@
 @vindex org-default-notes-file
 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.  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
 the empty string, it defaults to @code{org-default-notes-file}.
 
@@ -6146,7 +6298,10 @@
 Use a regular expression to position the cursor.
 
 @item (file+datetree "path/to/file")
-Will create a heading in a date tree.
+Will create a heading in a date tree for today's date.
+
+@item (file+datetree+prompt "path/to/file")
+Will create a heading in a date tree, but will prompt for the date.
 
 @item (file+function "path/to/file" function-finding-location)
 A function to find the right location in the file.
@@ -6302,15 +6457,13 @@
 
 @table @kbd
 
-@kindex C-c C-a
-@item C-c C-a
+@orgcmd{C-c C-a,org-attach}
 The dispatcher for commands related to the attachment system.  After these
 keys, a list of commands is displayed and you must press an additional key
 to select a command:
 
 @table @kbd
-@kindex C-c C-a a
-@item a
+@orgcmdtkc{a,C-c C-a a,org-attach-attach}
 @vindex org-attach-method
 Select a file and move it into the task's attachment directory.  The file
 will be copied, moved, or linked, depending on @code{org-attach-method}.
@@ -6323,52 +6476,42 @@
 Attach a file using the copy/move/link method.
 Note that hard links are not supported on all systems.
 
-@kindex C-c C-a n
-@item n
+@orgcmdtkc{n,C-c C-a n,org-attach-new}
 Create a new attachment as an Emacs buffer.
 
-@kindex C-c C-a z
-@item z
+@orgcmdtkc{z,C-c C-a z,org-attach-sync}
 Synchronize the current task with its attachment directory, in case you added
 attachments yourself.
 
-@kindex C-c C-a o
-@item o
+@orgcmdtkc{p,C-c C-a o,org-attach-open}
 @vindex org-file-apps
 Open current task's attachment.  If there is more than one, prompt for a
 file name first.  Opening will follow the rules set by @code{org-file-apps}.
 For more details, see the information on following hyperlinks
 (@pxref{Handling links}).
 
-@kindex C-c C-a O
-@item O
+@orgcmdtkc{O,C-c C-a O,org-attach-open-in-emacs}
 Also open the attachment, but force opening the file in Emacs.
 
-@kindex C-c C-a f
-@item f
+@orgcmdtkc{f,C-c C-a f,org-attach-reveal}
 Open the current task's attachment directory.
 
-@kindex C-c C-a F
-@item F
+@orgcmdtkc{F,C-c C-a F,org-attach-reveal-in-emacs}
 Also open the directory, but force using @command{dired} in Emacs.
 
-@kindex C-c C-a d
-@item d
+@orgcmdtkc{d,C-c C-a d,org-attach-delete-one}
 Select and delete a single attachment.
 
-@kindex C-c C-a D
-@item D
+@orgcmdtkc{D,C-c C-a D,org-attach-delete-all}
 Delete all of a task's attachments.  A safer way is to open the directory in
 @command{dired} and delete from there.
 
-@kindex C-c C-a s
-@item C-c C-a s
+@orgcmdtkc{s,C-c C-a s,org-attach-set-directory}
 @cindex property, ATTACH_DIR
 Set a specific directory as the entry's attachment directory.  This works by
 putting the directory path into the @code{ATTACH_DIR} property.
 
-@kindex C-c C-a i
-@item C-c C-a i
+@orgcmdtkc{i,C-c C-a i,org-attach-set-inherit}
 @cindex property, ATTACH_DIR_INHERIT
 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
 same directory for attachments as the parent does.
@@ -6401,12 +6544,11 @@
 the following command is used:
 
 @table @kbd
-@kindex C-c C-x g
+@orgcmd{C-c C-x g,org-feed-update-all}
 @item C-c C-x g
 Collect items from the feeds configured in @code{org-feed-alist} and act upon
 them.
-@kindex C-c C-x G
-@item C-c C-x G
+@orgcmd{C-c C-x G,org-feed-goto-inbox}
 Prompt for a feed name and go to the inbox configured for this feed.
 @end table
 
@@ -6446,8 +6588,7 @@
 process, you can use the following special command:
 
 @table @kbd
-@kindex C-c C-w
-@item C-c C-w
+@orgcmd{C-c C-w,org-refile}
 @vindex org-reverse-note-order
 @vindex org-refile-targets
 @vindex org-refile-use-outline-path
@@ -6472,17 +6613,18 @@
 @code{#+STARTUP} keywords @code{logrefile}, @code{lognoterefile},
 and @code{nologrefile}} is set, a time stamp or a note will be
 recorded when an entry has been refiled.
-@kindex C-u C-c C-w
-@item C-u C-c C-w
+@orgkey{C-u C-c C-w}
 Use the refile interface to jump to a heading.
-@kindex C-u C-u C-c C-w
-@item C-u C-u C-c C-w
+@orgcmd{C-u C-u C-c C-w,org-refile-goto-last-stored}
 Jump to the location where @code{org-refile} last moved a tree to.
 @item C-2 C-c C-w
 Refile as the child of the item currently being clocked.
 @item C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w
+
+@orgcmdtkc{C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w,C-0 C-c C-w,org-refile-cache-clear}
+
 Clear the target cache.  Caching of refile targets can be turned on by
-setting @code{org-refile-use-cache}.  To make the command seen new possible
+setting @code{org-refile-use-cache}.  To make the command see new possible
 targets, you have to clear the cache with this command.
 @end table
 
@@ -6496,8 +6638,7 @@
 searches like the construction of agenda views fast.
 
 @table @kbd
-@kindex C-c C-x C-a
-@item C-c C-x C-a
+@orgcmd{C-c C-x C-a,org-archive-subtree-default}
 @vindex org-archive-default-command
 Archive the current entry using the command specified in the variable
 @code{org-archive-default-command}.
@@ -6516,14 +6657,11 @@
 the archive file.
 
 @table @kbd
-@kindex C-c $
-@kindex C-c C-x C-s
-@item C-c C-x C-s@ @r{or short} @ C-c $
+@orgcmdkskc{C-c C-x C-s,C-c $,org-archive-subtree}
 @vindex org-archive-location
 Archive the subtree starting at the cursor position to the location
 given by @code{org-archive-location}.
-@kindex C-u C-c C-x C-s
-@item C-u C-c C-x C-s
+@orgkey{C-u C-c C-x C-s}
 Check if any direct children of the current headline could be moved to
 the archive.  To do this, each subtree is checked for open TODO entries.
 If none are found, the command offers to move it to the archive
@@ -6606,23 +6744,19 @@
 The following commands help manage the ARCHIVE tag:
 
 @table @kbd
-@kindex C-c C-x a
-@item C-c C-x a
+@orgcmd{C-c C-x a,org-toggle-archive-tag}
 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
 the headline changes to a shadowed face, and the subtree below it is
 hidden.
-@kindex C-u C-c C-x a
-@item C-u C-c C-x a
+@orgkey{C-u C-c C-x a}
 Check if any direct children of the current headline should be archived.
 To do this, each subtree is checked for open TODO entries.  If none are
 found, the command offers to set the ARCHIVE tag for the child.  If the
 cursor is @emph{not} on a headline when this command is invoked, the
 level 1 trees will be checked.
-@kindex C-@kbd{TAB}
-@item C-@kbd{TAB}
+@orgcmd{C-@kbd{TAB},org-force-cycle-archived}
 Cycle a tree even if it is tagged with ARCHIVE.
-@kindex C-c C-x A
-@item C-c C-x A
+@orgcmd{C-c C-x A,org-archive-to-archive-sibling}
 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
 entry becomes a child of that sibling and in this way retains a lot of its
@@ -6715,18 +6849,15 @@
 
 @cindex files, adding to agenda list
 @table @kbd
-@kindex C-c [
-@item C-c [
+@orgcmd{C-c [,org-agenda-to-front}
 Add current file to the list of agenda files.  The file is added to
 the front of the list.  If it was already in the list, it is moved to
 the front.  With a prefix argument, file is added/moved to the end.
-@kindex C-c ]
-@item C-c ]
+@orgcmd{C-c ],org-remove-file}
 Remove current file from the list of agenda files.
 @kindex C-,
-@kindex C-'
-@item C-,
-@itemx C-'
+@orgcmd{C-',org-cycle-agenda-files}
+@itemx C-,
 Cycle through agenda file list, visiting one file after the other.
 @kindex M-x org-iswitchb
 @item M-x org-iswitchb
@@ -6746,16 +6877,14 @@
 extended period, use the following commands:
 
 @table @kbd
-@kindex C-c C-x <
-@item C-c C-x <
+@orgcmd{C-c C-x <,org-agenda-set-restriction-lock}
 Permanently restrict the agenda to the current subtree.  When with a
 prefix argument, or with the cursor before the first headline in a file,
 the agenda scope is set to the entire file.  This restriction remains in
 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
 agenda view, the new restriction takes effect immediately.
-@kindex C-c C-x >
-@item C-c C-x >
+@orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
 Remove the permanent restriction created by @kbd{C-c C-x <}.
 @end table
 
@@ -6763,14 +6892,12 @@
 When working with @file{speedbar.el}, you can use the following commands in
 the Speedbar frame:
 @table @kbd
-@kindex <
-@item < @r{in the speedbar frame}
+@orgcmdtkc{< @r{in the speedbar frame},<,org-speedbar-set-agenda-restriction}
 Permanently restrict the agenda to the item---either an Org file or a subtree
 in such a file---at the cursor in the Speedbar frame.
 If there is a window displaying an agenda view, the new restriction takes
 effect immediately.
-@kindex >
-@item > @r{in the speedbar frame}
+@orgcmdtkc{> @r{in the speedbar frame},>,org-agenda-remove-restriction-lock}
 Lift the restriction.
 @end table
 
@@ -6850,17 +6977,22 @@
 
 @table @kbd
 @cindex org-agenda, command
-@kindex C-c a a
-@item C-c a a
-@vindex org-agenda-ndays
+@orgcmd{C-c a a,org-agenda-list}
 Compile an agenda for the current week from a list of Org files.  The agenda
 shows the entries for each day.  With a numeric prefix@footnote{For backward
 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
 listed before the agenda.  This feature is deprecated, use the dedicated TODO
 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
-C-c a a}) you may set the number of days to be displayed (see also the
-variable @code{org-agenda-ndays})
-@end table
+C-c a a}) you may set the number of days to be displayed.
+@end table
+
+@vindex org-agenda-span
+@vindex org-agenda-ndays
+The default number of days displayed in the agenda is set by the variable
+@code{org-agenda-span} (or the obsolete @code{org-agenda-ndays}).  This
+variable can be set to any number of days you want to see by default in the
+agenda, or to a span name, such a @code{day}, @code{week}, @code{month} or
+@code{year}.
 
 Remote editing from the agenda buffer means, for example, that you can
 change the dates of deadlines and appointments from the agenda buffer.
@@ -6972,22 +7104,20 @@
 collected into a single place.
 
 @table @kbd
-@kindex C-c a t
-@item C-c a t
+@orgcmd{C-c a t,org-todo-list}
 Show the global TODO list.  This collects the TODO items from all agenda
 files (@pxref{Agenda Views}) into a single buffer.  By default, this lists
 items with a state the is not a DONE state.  The buffer is in
 @code{agenda-mode}, so there are commands to examine and manipulate the TODO
 entries directly from that buffer (@pxref{Agenda commands}).
-@kindex C-c a T
-@item C-c a T
+@orgcmd{C-c a T,org-todo-list}
 @cindex TODO keyword matching
 @vindex org-todo-keywords
 Like the above, but allows selection of a specific TODO keyword.  You can
 also do this by specifying a prefix argument to @kbd{C-c a t}.  You are
 prompted for a keyword, and you may also specify several keywords by
 separating them with @samp{|} as the boolean OR operator.  With a numeric
-prefix, the nth keyword in @code{org-todo-keywords} is selected.
+prefix, the Nth keyword in @code{org-todo-keywords} is selected.
 @kindex r
 The @kbd{r} key in the agenda buffer regenerates it, and you can give
 a prefix argument to this command to change the selected TODO keyword,
@@ -7009,13 +7139,15 @@
 @item
 @vindex org-agenda-todo-ignore-scheduled
 @vindex org-agenda-todo-ignore-deadlines
+@vindex org-agenda-todo-ignore-timestamp
 @vindex org-agenda-todo-ignore-with-date
 Some people view a TODO item that has been @emph{scheduled} for execution or
 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
 Configure the variables @code{org-agenda-todo-ignore-scheduled},
-@code{org-agenda-todo-ignore-deadlines}, and/or
-@code{org-agenda-todo-ignore-with-date} to exclude such items from the
-global TODO list.
+@code{org-agenda-todo-ignore-deadlines},
+@code{org-agenda-todo-ignore-timestamp} and/or
+@code{org-agenda-todo-ignore-with-date} to exclude such items from the global
+TODO list.
 @item
 @vindex org-agenda-todo-list-sublevels
 TODO items may have sublevels to break up the task into subtasks.  In
@@ -7038,15 +7170,13 @@
 m}.
 
 @table @kbd
-@kindex C-c a m
-@item C-c a m
+@orgcmd{C-c a m,org-tags-view}
 Produce a list of all headlines that match a given set of tags.  The
 command prompts for a selection criterion, which is a boolean logic
 expression with tags, like @samp{+work+urgent-withboss} or
 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
 define a custom command for it (@pxref{Agenda dispatcher}).
-@kindex C-c a M
-@item C-c a M
+@orgcmd{C-c a M,org-tags-view}
 @vindex org-tags-match-list-sublevels
 @vindex org-agenda-tags-todo-honor-ignore-options
 Like @kbd{C-c a m}, but only select headlines that are also TODO items in a
@@ -7197,8 +7327,7 @@
 to give an overview over events in a project.
 
 @table @kbd
-@kindex C-c a L
-@item C-c a L
+@orgcmd{C-c a L,org-timeline}
 Show a time-sorted view of the Org file, with all time-stamped items.
 When called with a @kbd{C-u} prefix, all unfinished TODO entries
 (scheduled or not) are also listed under the current date.
@@ -7218,8 +7347,7 @@
 It is particularly useful to find notes.
 
 @table @kbd
-@kindex C-c a s
-@item C-c a s
+@orgcmd{C-c a s,org-search-view}
 This is a special search that lets you select entries by matching a substring
 or specific words using a boolean logic.
 @end table
@@ -7250,8 +7378,7 @@
 projects and define next actions for them.
 
 @table @kbd
-@kindex C-c a #
-@item C-c a #
+@orgcmd{C-c a #,org-agenda-list-stuck-projects}
 List projects that are stuck.
 @kindex C-c a !
 @item C-c a !
@@ -7336,6 +7463,10 @@
 The display in the agenda buffer looks best if the category is not
 longer than 10 characters.
 
+@noindent
+You can set up icons for category by customizing the
+@code{org-agenda-category-icon-alist} variable.
+
 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
 @subsection Time-of-day specifications
 @cindex time-of-day specification
@@ -7438,40 +7569,26 @@
 @table @kbd
 @tsubheading{Motion}
 @cindex motion commands in agenda
-@kindex n
-@item n
+@orgcmd{n,org-agenda-next-line}
 Next line (same as @key{up} and @kbd{C-p}).
-@kindex p
-@item p
+@orgcmd{p,org-agenda-previous-line}
 Previous line (same as @key{down} and @kbd{C-n}).
 @tsubheading{View/Go to Org file}
-@kindex mouse-3
-@kindex @key{SPC}
-@item mouse-3
-@itemx @key{SPC}
+@orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
 Display the original location of the item in another window.
 With prefix arg, make sure that the entire entry is made visible in the
 outline, not only the heading.
 @c
-@kindex L
-@item L
+@orgcmd{L,org-agenda-recenter}
 Display original location and recenter that window.
 @c
-@kindex mouse-2
-@kindex mouse-1
-@kindex @key{TAB}
-@item mouse-2
-@itemx mouse-1
-@itemx @key{TAB}
-Go to the original location of the item in another window.  Under Emacs
-22, @kbd{mouse-1} will also works for this.
-@c
-@kindex @key{RET}
-@itemx @key{RET}
+@orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
+Go to the original location of the item in another window.
+@c
+@orgcmd{@key{RET},org-agenda-switch-to}
 Go to the original location of the item and delete other windows.
 @c
-@kindex F
-@item F
+@orgcmd{F,org-agenda-follow-mode}
 @vindex org-agenda-start-with-follow-mode
 Toggle Follow mode.  In Follow mode, as you move the cursor through
 the agenda buffer, the other window always shows the corresponding
@@ -7479,15 +7596,13 @@
 agenda buffers can be set with the variable
 @code{org-agenda-start-with-follow-mode}.
 @c
-@kindex C-c C-x b
-@item C-c C-x b
+@orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
 Display the entire subtree of the current item in an indirect buffer.  With a
 numeric prefix argument N, go up to level N and then take that tree.  If N is
 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
 previously used indirect buffer.
 
-@kindex C-c C-o
-@item C-c C-o
+@orgcmd{C-c C-o,org-agenda-open-link}
 Follow a link in the entry.  This will offer a selection of any links in the
 text belonging to the referenced Org node.  If there is only one link, it
 will be followed without a selection prompt.
@@ -7498,16 +7613,20 @@
 @item o
 Delete other windows.
 @c
-@kindex v d
-@kindex d
-@kindex v w
-@kindex w
-@kindex v m
-@kindex v y
-@item v d @ @r{or short} @ d
-@itemx v w @ @r{or short} @ w
-@itemx v m
-@itemx v y
+@c @kindex v d
+@c @kindex d
+@c @kindex v w
+@c @kindex w
+@c @kindex v m
+@c @kindex v y
+@c @item v d @ @r{or short} @ d
+@c @itemx v w @ @r{or short} @ w
+@c @itemx v m
+@c @itemx v y
+@orgcmdkskc{v d,d,org-aganda-day-view}
+@xorgcmdkskc{v w,w,org-aganda-day-view}
+@xorgcmd{v m,org-agenda-month-view}
+@xorgcmd{v y,org-agenda-month-year}
 Switch to day/week/month/year view.  When switching to day or week view,
 this setting becomes the default for subsequent agenda commands.  Since
 month and year views are slow to create, they do not become the default.
@@ -7519,37 +7638,28 @@
 2007.  If such a year specification has only one or two digits, it will
 be mapped to the interval 1938-2037.
 @c
-@kindex f
-@item f
-@vindex org-agenda-ndays
-Go forward in time to display the following @code{org-agenda-ndays} days.
+@orgcmd{f,org-agenda-later}
+Go forward in time to display the following @code{org-agenda-current-span} days.
 For example, if the display covers a week, switch to the following week.
-With prefix arg, go forward that many times @code{org-agenda-ndays} days.
-@c
-@kindex b
-@item b
+With prefix arg, go forward that many times @code{org-agenda-current-span} days.
+@c
+@orgcmd{b,org-agenda-earlier}
 Go backward in time to display earlier dates.
 @c
-@kindex .
-@item .
+@orgcmd{.,org-agenda-goto-today}
 Go to today.
 @c
-@kindex j
-@item j
+@orgcmd{j,org-agenda-goto-date}
 Prompt for a date and go there.
 @c
-@kindex J
-@item J
-Go to the currently clocked in task in the agenda buffer.
-@c
-@kindex D
-@item D
+@orgcmd{J,org-agenda-clock-goto}
+Go to the currently clocked-in task @i{in the agenda buffer}.
+@c
+@orgcmd{D,org-agenda-toggle-diary}
 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
 @c
-@kindex v l
+@orgcmdkskc{v l,l,org-agenda-log-mode}
 @kindex v L
-@kindex l
-@item v l @ @r{or short} @ l
 @vindex org-log-done
 @vindex org-agenda-log-mode-items
 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
@@ -7561,34 +7671,29 @@
 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
 @kbd{v L} is equivalent to @kbd{C-u v l}.
 @c
-@kindex v [
-@kindex [
-@item v [ @ @r{or short} @ [
+@orgcmdkskc{v [,[,org-agenda-manipulate-query-add}
 Include inactive timestamps into the current view.  Only for weekly/daily
 agenda and timeline views.
 @c
-@kindex v a
-@kindex v A
-@item v a
-@itemx v A
+@orgcmd{v a,org-agenda-archives-mode}
+@xorgcmd{v A,org-agenda-archives-mode 'files}
 Toggle Archives mode.  In Archives mode, trees that are marked
 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
 capital @kbd{A}, even all archive files are included.  To exit archives mode,
 press @kbd{v a} again.
 @c
-@kindex v R
-@kindex R
-@item v R @ @r{or short} @ R
+@orgcmdkskc{v R,R,org-agenda-clockreport-mode}
 @vindex org-agenda-start-with-clockreport-mode
 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
 agenda buffers can be set with the variable
-@code{org-agenda-start-with-clockreport-mode}.
-@c
-@kindex v E
-@kindex E
-@item v E @ @r{or short} @ E
+@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.}.
+@c
+@orgcmdkskc{v E,E,org-agenda-entry-text-mode}
 @vindex org-agenda-start-with-entry-text-mode
 @vindex org-agenda-entry-text-maxlines
 Toggle entry text mode.  In entry text mode, a number of lines from the Org
@@ -7597,33 +7702,26 @@
 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
 prefix argument will temporarily modify that number to the prefix value.
 @c
-@kindex G
-@item G
+@orgcmd{G,org-agenda-toggle-time-grid}
 @vindex org-agenda-use-time-grid
 @vindex org-agenda-time-grid
 Toggle the time grid on and off.  See also the variables
 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
 @c
-@kindex r
-@item r
+@orgcmd{r,org-agenda-rodo}
 Recreate the agenda buffer, for example to reflect the changes after
 modification of the timestamps of items with @kbd{S-@key{left}} and
 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
 argument is interpreted to create a selective list for a specific TODO
 keyword.
-@kindex g
-@item g
+@orgcmd{g,org-agenda-rodo}
 Same as @kbd{r}.
 @c
-@kindex s
-@kindex C-x C-s
-@item s
-@itemx C-x C-s
+@orgcmdkskc{C-x C-s,s,org-save-all-org-buffers}
 Save all Org buffers in the current Emacs session, and also the locations of
 IDs.
 @c
-@kindex C-c C-x C-c
-@item C-c C-x C-c
+@orgcmd{C-c C-x C-c,org-agenda-columns}
 @vindex org-columns-default-format
 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
 view format is taken from the entry at point, or (if there is no entry at
@@ -7632,8 +7730,7 @@
 @code{#+COLUMNS} line, or from the default variable
 @code{org-columns-default-format}), will be used in the agenda.
 
-@kindex C-c C-x >
-@item C-c C-x >
+@orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
 Remove the restriction lock on the agenda, if it is currently restricted to a
 file or subtree (@pxref{Agenda files}).
 
@@ -7643,20 +7740,19 @@
 @cindex effort filtering, in agenda
 @cindex query editing, in agenda
 
-@kindex /
-@item /
+@orgcmd{/,org-agenda-filter-by-tag}
 @vindex org-agenda-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
+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
 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
+the entire agenda view---in a block agenda, you should only set this in the
 global options section, not in the section of an individual block.}
 
-You will be prompted for a tag selection letter, SPC will mean any tag at
+You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
 tag (including any tags that do not have a selection character).  The command
 then hides all entries that do not contain or inherit this tag.  When called
@@ -7668,7 +7764,7 @@
 immediately use the @kbd{\} command.
 
 @vindex org-sort-agenda-noeffort-is-high
-In order to filter for effort estimates, you should set-up allowed
+In order to filter for effort estimates, you should set up allowed
 efforts globally, for example
 @lisp
 (setq org-global-properties
@@ -7711,13 +7807,13 @@
 @end group
 @end lisp
 
-@kindex \
-@item \
+@orgcmd{\,org-agenda-filter-by-tag-refine}
 Narrow the current agenda filter by an additional condition.  When called with
 prefix arg, remove the entries that @emph{do} have the tag, or that do match
 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
 @kbd{-} as the first key after the @kbd{/} command.
 
+@c
 @kindex [
 @kindex ]
 @kindex @{
@@ -7733,7 +7829,6 @@
 selected.
 @end table
 
-@page
 @tsubheading{Remote editing}
 @cindex remote editing, from agenda
 
@@ -7742,115 +7837,89 @@
 @c
 @cindex undoing remote-editing events
 @cindex remote editing, undo
-@kindex C-_
-@item C-_
+@orgcmd{C-_,org-agenda-undo}
 Undo a change due to a remote editing command.  The change is undone
 both in the agenda buffer and in the remote buffer.
 @c
-@kindex t
-@item t
+@orgcmd{t,org-agenda-todo}
 Change the TODO state of the item, both in the agenda and in the
 original org file.
 @c
-@kindex C-S-@key{right}
-@kindex C-S-@key{left}
-@item C-S-@key{right}@r{/}@key{left}
+@orgcmd{C-S-@key{right},org-agenda-todo-nextset}
+@orgcmd{C-S-@key{left},org-agenda-todo-previousset}
 Switch to the next/previous set of TODO keywords.
 @c
-@kindex C-k
-@item C-k
+@orgcmd{C-k,org-agenda-kill}
 @vindex org-agenda-confirm-kill
 Delete the current agenda item along with the entire subtree belonging
 to it in the original Org file.  If the text to be deleted remotely
 is longer than one line, the kill needs to be confirmed by the user.  See
 variable @code{org-agenda-confirm-kill}.
 @c
-@kindex C-c C-w
-@item C-c C-w
+@orgcmd{C-c C-w,org-agenda-refile}
 Refile the entry at point.
 @c
-@kindex C-c C-x C-a
-@kindex a
-@item C-c C-x C-a @ @r{or short} @ a
+@orgcmdkskc{C-c C-x C-a,a,org-agenda-archive-default-with-confirmation}
 @vindex org-archive-default-command
 Archive the subtree corresponding to the entry at point using the default
 archiving command set in @code{org-archive-default-command}.  When using the
 @code{a} key, confirmation will be required.
 @c
-@kindex C-c C-x a
-@item C-c C-x a
+@orgcmd{C-c C-x a,org-agenda-toggle-archive-tag}
 Toggle the ARCHIVE tag for the current headline.
 @c
-@kindex C-c C-x A
-@item C-c C-x A
+@orgcmd{C-c C-x A,org-agenda-archive-to-archive-sibling}
 Move the subtree corresponding to the current entry to its @emph{archive
 sibling}.
 @c
-@kindex $
-@kindex C-c C-x C-s
-@item C-c C-x C-s @ @r{or short} @ $
+@orgcmdkskc{C-c C-x C-s,$,org-agenda-archive}
 Archive the subtree corresponding to the current headline.  This means the
 entry will be moved to the configured archive location, most likely a
 different file.
 @c
-@kindex T
-@item T
+@orgcmd{T,org-agenda-show-tags}
 @vindex org-agenda-show-inherited-tags
 Show all tags associated with the current item.  This is useful if you have
 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
 tags of a headline occasionally.
 @c
-@kindex :
-@item :
+@orgcmd{:,org-agenda-set-tags}
 Set tags for the current headline.  If there is an active region in the
 agenda, change a tag for all headings in the region.
 @c
 @kindex ,
 @item ,
-Set the priority for the current item.  Org-mode prompts for the
-priority character. If you reply with @key{SPC}, the priority cookie
-is removed from the entry.
-@c
-@kindex P
-@item P
+Set the priority for the current item (@command{org-agenda-priority}).
+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}
 Display weighted priority of current item.
 @c
-@kindex +
-@kindex S-@key{up}
-@item +
-@itemx S-@key{up}
+@orgcmdkkc{+,S-@key{up},org-agenda-priority-up}
 Increase the priority of the current item.  The priority is changed in
 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
 key for this.
 @c
-@kindex -
-@kindex S-@key{down}
-@item -
-@itemx S-@key{down}
+@orgcmdkkc{-,S-@key{down},org-agenda-priority-down}
 Decrease the priority of the current item.
 @c
-@kindex C-c C-z
-@kindex z
-@item z @ @r{or also} @ C-c C-z
+@orgcmdkkc{z,C-c C-z,org-agenda-add-note}
 @vindex org-log-into-drawer
-Add a note to the entry.  This note will be recorded, and then files to the
+Add a note to the entry.  This note will be recorded, and then filed to the
 same location where state change notes are put.  Depending on
-@code{org-log-into-drawer}, this maybe inside a drawer.
-@c
-@kindex C-c C-a
-@item C-c C-a
+@code{org-log-into-drawer}, this may be inside a drawer.
+@c
+@orgcmd{C-c C-a,org-attach}
 Dispatcher for all command related to attachments.
 @c
-@kindex C-c C-s
-@item C-c C-s
-Schedule this item, with prefix arg remove the scheduling timestamp
-@c
-@kindex C-c C-d
-@item C-c C-d
-Set a deadline for this item, with prefix arg remove the deadline.
-@c
-@kindex k
-@item k
+@orgcmd{C-c C-s,org-agenda-schedule}
+Schedule this item.  With prefix arg remove the scheduling timestamp
+@c
+@orgcmd{C-c C-d,org-agenda-deadline}
+Set a deadline for this item.  With prefix arg remove the deadline.
+@c
+@orgcmd{k,org-agenda-action}
 Agenda actions, to set dates for selected items to the cursor date.
 This command also works in the calendar!  The command prompts for an
 additional key:
@@ -7865,8 +7934,7 @@
 Press @kbd{r} afterward to refresh the agenda and see the effect of the
 command.
 @c
-@kindex S-@key{right}
-@item S-@key{right}
+@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
@@ -7876,57 +7944,48 @@
 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
-@kindex S-@key{left}
-@item S-@key{left}
+@orgcmd{S-@key{left},org-agenda-do-date-earlier}
 Change the timestamp associated with the current line by one day
 into the past.
 @c
-@kindex >
-@item >
+@orgcmd{>,org-agenda-date-prompt}
 Change the timestamp associated with the current line.  The key @kbd{>} has
 been chosen, because it is the same as @kbd{S-.}  on my keyboard.
 @c
-@kindex I
-@item I
+@orgcmd{I,org-agenda-clock-in}
 Start the clock on the current item.  If a clock is running already, it
 is stopped first.
 @c
-@kindex O
-@item O
+@orgcmd{O,org-agenda-clock-out}
 Stop the previously started clock.
 @c
-@kindex X
-@item X
+@orgcmd{X,org-agenda-clock-cancel}
 Cancel the currently running clock.
-
-@kindex J
-@item J
+@c
+@orgcmd{J,org-agenda-clock-goto}
 Jump to the running clock in another window.
 
 @tsubheading{Bulk remote editing selected entries}
 @cindex remote editing, bulk, from agenda
 
-@kindex m
-@item m
-Mark the entry at point for bulk action.
-
-@kindex u
-@item u
+@orgcmd{m,org-agenda-bulk-mark}
+Mark the entry at point for bulk action.  With prefix arg, mark that many
+successive entries.
+@c
+@orgcmd{u,org-agenda-bulk-unmark}
 Unmark entry for bulk action.
-
-@kindex U
-@item U
+@c
+@orgcmd{U,org-agenda-bulk-remove-all-marks}
 Unmark all marked entries for bulk action.
-
-@kindex B
-@item B
+@c
+@orgcmd{B,org-agenda-bulk-action}
 Bulk action: act on all marked entries in the agenda.  This will prompt for
 another key to select the action to be applied.  The prefix arg to @kbd{B}
 will be passed through to the @kbd{s} and @kbd{d} commands, to bulk-remove
 these special timestamps.
 @example
 r  @r{Prompt for a single refile target and move all entries.  The entries}
-   @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
+   @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
 $  @r{Archive all selected entries.}
 A  @r{Archive entries by moving them to their respective archive siblings.}
 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
@@ -7937,23 +7996,24 @@
 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
    @r{by a fixed number of days, use something starting with double plus}
    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
+S  @r{Reschedule randomly by N days.  N will be prompted for.  With prefix}
+   @r{arg (@kbd{C-u B S}), scatter only accross weekdays.}
 d  @r{Set deadline to a specific date.}
 @end example
 
 
 @tsubheading{Calendar commands}
 @cindex calendar commands, from agenda
-@kindex c
-@item c
+
+@orgcmd{c,org-agenda-goto-calendar}
 Open the Emacs calendar and move to the date at the agenda cursor.
 @c
-@item c
+@orgcmd{c,org-calendar-goto-agenda}
 When in the calendar, compute and show the Org-mode agenda for the
 date at the cursor.
 @c
 @cindex diary entries, creating from agenda
-@kindex i
-@item i
+@orgcmd{i,org-agenda-diary-entry}
 @vindex org-agenda-diary-file
 Insert a new entry into the diary, using the date at the cursor and (for
 block entries) the date at the mark.  This will add to the Emacs diary
@@ -7967,28 +8027,24 @@
 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
-top-level entries.  Emacs will prompt you for the entry text - if you specify
+top-level entries.  Emacs will prompt you for the entry text---if you specify
 it, the entry will be created in @code{org-agenda-diary-file} without further
 interaction.  If you directly press @key{RET} at the prompt without typing
 text, the target file will be shown in another window for you to finish the
 entry there.  See also the @kbd{k r} command.
 @c
-@kindex M
-@item M
+@orgcmd{M,org-agenda-phases-of-moon}
 Show the phases of the moon for the three months around current date.
 @c
-@kindex S
-@item S
+@orgcmd{S,org-agenda-sunrise-sunset}
 Show sunrise and sunset times.  The geographical location must be set
 with calendar variables, see the documentation for the Emacs calendar.
 @c
-@kindex C
-@item C
+@orgcmd{C,org-agenda-convert-date}
 Convert the date at cursor into many other cultural and historic
 calendars.
 @c
-@kindex H
-@item H
+@orgcmd{H,org-agenda-holidays}
 Show holidays for three months around the cursor date.
 
 @item M-x org-export-icalendar-combine-agenda-files
@@ -7996,8 +8052,7 @@
 This is a globally available command, and also available in the agenda menu.
 
 @tsubheading{Exporting to a file}
-@kindex C-x C-w
-@item C-x C-w
+@orgcmd{C-x C-w,org-write-agenda}
 @cindex exporting agenda views
 @cindex agenda views, exporting
 @vindex org-agenda-exporter-settings
@@ -8010,13 +8065,11 @@
 for @file{htmlize} to be used during export.
 
 @tsubheading{Quit and Exit}
-@kindex q
-@item q
+@orgcmd{q,org-agenda-quit}
 Quit agenda, remove the agenda buffer.
 @c
-@kindex x
 @cindex agenda files, removing buffers
-@item x
+@orgcmd{x,org-agenda-exit}
 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
 for the compilation of the agenda.  Buffers created by the user to
 visit Org files will not be removed.
@@ -8182,7 +8235,7 @@
 @code{org-agenda-custom-commands} has two separate spots for setting
 options.  You can add options that should be valid for just a single
 command in the set, and options that should be valid for all commands in
-the set.  The former are just added to the command entry, the latter
+the set.  The former are just added to the command entry; the latter
 must come after the list of command entries.  Going back to the block
 agenda example (@pxref{Block agenda}), let's change the sorting strategy
 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
@@ -8226,8 +8279,7 @@
 you want to do this only occasionally, use the command
 
 @table @kbd
-@kindex C-x C-w
-@item C-x C-w
+@orgcmd{C-x C-w,org-write-agenda}
 @cindex exporting agenda views
 @cindex agenda views, exporting
 @vindex org-agenda-exporter-settings
@@ -8297,8 +8349,7 @@
 files in one step:
 
 @table @kbd
-@kindex C-c a e
-@item C-c a e
+@orgcmd{C-c a e,org-store-agenda-views}
 Export all agenda views that have export file names associated with
 them.
 @end table
@@ -8338,7 +8389,7 @@
 system you use, please check the FAQ for examples.}
 @example
 emacs -eval '(org-batch-store-agenda-views                      \
-              org-agenda-ndays 30                               \
+              org-agenda-span month                             \
               org-agenda-start-day "2007-11-01"                 \
               org-agenda-include-diary nil                      \
               org-agenda-files (quote ("~/org/project.org")))'  \
@@ -8365,8 +8416,7 @@
 collected by certain criteria.
 
 @table @kbd
-@kindex C-c C-x C-c
-@item C-c C-x C-c
+@orgcmd{C-c C-x C-c,org-agenda-columns}
 Turn on column view in the agenda.
 @end table
 
@@ -8393,7 +8443,7 @@
 make sure that the computations of this property are up to date.  This is
 also true for the special @code{CLOCKSUM} property.  Org will then sum the
 values displayed in the agenda.  In the daily/weekly agenda, the sums will
-cover a single day, in all other views they cover the entire block.  It is
+cover a single day; in all other views they cover the entire block.  It is
 vital to realize that the agenda may show the same entry @emph{twice} (for
 example as scheduled and as a deadline), and it may show two entries from the
 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
@@ -8416,7 +8466,7 @@
 
 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, La@TeX{}, or DocBook allow much richer formatting,
+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.
 
@@ -8512,7 +8562,7 @@
 
 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, La@TeX{}, or DocBook code, use the special
+you need to include literal HTML, @LaTeX{}, or DocBook code, use the special
 constructs described below in the sections for the individual exporters.
 
 @vindex org-export-skip-text-before-1st-heading
@@ -8605,7 +8655,7 @@
 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
 in the code and verbatim string is not processed for Org-mode specific
-syntax, it is exported verbatim.
+syntax; it is exported verbatim.
 
 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
 @subheading  Horizontal rules
@@ -8653,7 +8703,7 @@
 @end example
 
 @cindex inlined images, markup rules
-Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include
+Some backends (HTML, @LaTeX{}, and DocBook) allow you to directly include
 images into the exported document.  Org does this, if a link to an image
 files does not have a description part, for example @code{[[./img/a.jpg]]}.
 If you wish to define a caption for the image and maybe a label for internal
@@ -8704,7 +8754,7 @@
 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
@@ -8773,7 +8823,7 @@
 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
 or @samp{#} will get a comma prepended, to keep them from being interpreted
 by Org as outline nodes or special comments.  These commas will be stripped
-for editing with @kbd{C-c '}, and also for export.}, the edited version will
+for editing with @kbd{C-c '}, and also for export.}.  The edited version will
 then replace the old version in the Org buffer.  Fixed-width regions
 (where each line starts with a colon followed by a space) will be edited
 using @code{artist-mode}@footnote{You may select a different-mode with the
@@ -8783,7 +8833,7 @@
 @kindex C-c l
 @item C-c l
 Calling @code{org-store-link} while editing a source code example in a
-temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
+temporary buffer created with @kbd{C-c '} will prompt for a label.  Make sure
 that it is unique in the current buffer, and insert it with the proper
 formatting like @samp{(ref:label)} at the end of the current line.  Then the
 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
@@ -8804,12 +8854,14 @@
 @noindent
 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
+language for formatting the contents.  The markup is optional; if it is not
 given, the text will be assumed to be in Org-mode format and will be
 processed normally.  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, as well as any options accepted by
-the selected markup.  For example, to include a file as an item, use
+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
+accepted by the selected markup.  For example, to include a file as an item,
+use
 
 @example
 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
@@ -8865,20 +8917,19 @@
 
 
 @node Embedded LaTeX,  , Macro replacement, Markup
-@section Embedded La@TeX{}
+@section Embedded @LaTeX{}
 @cindex @TeX{} interpretation
-@cindex La@TeX{} interpretation
-
-Plain ASCII is normally sufficient for almost all note taking.  One
-exception, however, are scientific notes which need to be able to contain
-mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
-is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
-features described here as ``La@TeX{}'' are really from @TeX{}, but for
-simplicity I am blurring this distinction.}  is widely used to typeset
-scientific documents. Org-mode supports embedding La@TeX{} code into its
-files, because many academics are used to writing and reading La@TeX{} source
-code, and because it can be readily processed to produce pretty output for a
-number of export backends.
+@cindex @LaTeX{} interpretation
+
+Plain ASCII is normally sufficient for almost all note taking.  Exceptions
+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
+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.
 
 @menu
 * Special symbols::             Greek letters and other symbols
@@ -8893,14 +8944,14 @@
 @cindex math symbols
 @cindex special symbols
 @cindex @TeX{} macros
-@cindex La@TeX{} fragments, markup rules
+@cindex @LaTeX{} fragments, markup rules
 @cindex HTML entities
-@cindex La@TeX{} entities
-
-You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
+@cindex @LaTeX{} entities
+
+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 La@TeX{}
+and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
 code, Org-mode allows these macros to be present without surrounding math
 delimiters, for example:
 
@@ -8911,13 +8962,13 @@
 @vindex org-entities
 During export, these symbols will be transformed into the native format of
 the exporter backend.  Strings like @code{\alpha} will be exported as
-@code{&alpha;} in the HTML output, and as @code{$\alpha$} in the La@TeX{}
+@code{&alpha;} in the HTML output, and as @code{$\alpha$} in the @LaTeX{}
 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
-@code{~} in La@TeX{}.  If you need such a symbol inside a word, terminate it
+@code{~} in @LaTeX{}.  If you need such a symbol inside a word, terminate it
 like this: @samp{\Aacute@{@}stor}.
 
 A large number of entities is provided, with names taken from both HTML and
-La@TeX{}, see the variable @code{org-entities} for the complete list.
+@LaTeX{}; see the variable @code{org-entities} for the complete list.
 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
 @samp{...} are all converted into special commands creating hyphens of
 different lengths or a compact set of dots.
@@ -8930,8 +8981,8 @@
 @table @kbd
 @kindex C-c C-x \
 @item C-c C-x \
-Toggle display of entities as UTF8 characters.  This does not change the
-buffer content which remains plain ASCII, but it overlays the UTF8 character
+Toggle display of entities as UTF-8 characters.  This does not change the
+buffer content which remains plain ASCII, but it overlays the UTF-8 character
 for display purposes only.
 @end table
 
@@ -8940,14 +8991,14 @@
 @cindex subscript
 @cindex superscript
 
-Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
+Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super-
 and subscripts.  Again, these can be used without embedding them in
 math-mode delimiters.  To increase the readability of ASCII text, it is
 not necessary (but OK) to surround multi-character sub- and superscripts
 with curly braces.  For example
 
 @example
-The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
+The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
 the sun is R_@{sun@} = 6.96 x 10^8 m.
 @end example
 
@@ -8969,42 +9020,43 @@
 @table @kbd
 @kindex C-c C-x \
 @item C-c C-x \
-In addition to showing entities as UTF8 characters, this command will also
+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
-@subsection La@TeX{} fragments
-@cindex La@TeX{} fragments
+@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 La@TeX{} math fragments, and it supports ways
-to process these for several export backends.  When exporting to La@TeX{},
+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
 HTML export}) to process and display the math@footnote{If you plan to use
 this regularly or on pages with significant page views, you should install
-@file{MathJax} on your own server in order to limit the load of our server.}.
-Finally, it can also process the mathematical expressions into
-images@footnote{For this to work you need to be on a system with a working
-La@TeX{} installation. You also need the @file{dvipng} program, available at
-@url{http://sourceforge.net/projects/dvipng/}.  The La@TeX{} header that will
+@file{MathJax} on your own
+server in order to limit the load of our server.}.  Finally, it can also
+process the mathematical expressions into images@footnote{For this to work
+you need to be on a system with a working @LaTeX{} installation. You also
+need the @file{dvipng} program, available at
+@url{http://sourceforge.net/projects/dvipng/}.  The @LaTeX{} header that will
 be used when processing a fragment can be configured with the variable
 @code{org-format-latex-header}.}  that can be displayed in a browser or in
 DocBook documents.
 
-La@TeX{} fragments don't need any special marking at all.  The following
-snippets will be identified as La@TeX{} source code:
+@LaTeX{} fragments don't need any special marking at all.  The following
+snippets will be identified as @LaTeX{} source code:
 @itemize @bullet
 @item
 Environments of any kind@footnote{When @file{MathJax} is used, only the
-environment recognized by @file{MathJax} will be processed.  When dvipng is
-used to create images, any La@TeX{} environments will be handled.}.  The only
-requirement is that the @code{\begin} statement appears on a new line,
-preceded by only whitespace.
-@item
-Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
+environment recognized by @file{MathJax} will be processed.  When
+@file{dvipng} is used to create images, any @LaTeX{} environments will be
+handled.}.  The only requirement is that the @code{\begin} statement appears
+on a new line, preceded by only whitespace.
+@item
+Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
 math delimiters if the enclosed text contains at most two line breaks, is
 directly attached to the @samp{$} characters with no whitespace in between,
@@ -9028,7 +9080,7 @@
 @vindex org-format-latex-options
 If you need any of the delimiter ASCII sequences for other purposes, you
 can configure the option @code{org-format-latex-options} to deselect the
-ones you do not wish to have interpreted by the La@TeX{} converter.
+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
@@ -9040,7 +9092,7 @@
 @example
 #+OPTIONS: LaTeX:t          @r{Do the right thing automatically (MathJax)}
 #+OPTIONS: LaTeX:dvipng     @r{Force using dvipng images}
-#+OPTIONS: LaTeX:nil        @r{Do not process La@TeX{} fragments at all}
+#+OPTIONS: LaTeX:nil        @r{Do not process @LaTeX{} fragments at all}
 #+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
 @end example
 
@@ -9048,13 +9100,13 @@
 @subsection Previewing LaTeX fragments
 @cindex LaTeX fragments, preview
 
-If you have @file{dvipng} installed, La@TeX{} fragments can be processed to
+If you have @file{dvipng} installed, @LaTeX{} fragments can be processed to
 produce preview images of the typeset expressions:
 
 @table @kbd
 @kindex C-c C-x C-l
 @item C-c C-x C-l
-Produce a preview image of the La@TeX{} fragment at point and overlay it
+Produce a preview image of the @LaTeX{} fragment at point and overlay it
 over the source code.  If there is no fragment at point, process all
 fragments in the current entry (between two headlines).  When called
 with a prefix argument, process the entire subtree.  When called with
@@ -9076,7 +9128,7 @@
 @cindex CDLa@TeX{}
 
 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
-major La@TeX{} mode like AUC@TeX{} in order to speed-up insertion of
+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
 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
@@ -9099,7 +9151,7 @@
 @item
 @kindex @key{TAB}
 The @key{TAB} key will do template expansion if the cursor is inside a
-La@TeX{} 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
@@ -9113,7 +9165,7 @@
 @kindex _
 @kindex ^
 @vindex cdlatex-simplify-sub-super-scripts
-Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
+Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment will insert these
 characters together with a pair of braces.  If you use @key{TAB} to move
 out of the braces, and if the braces surround only a single character or
 macro, they are removed again (depending on the variable
@@ -9121,14 +9173,14 @@
 @item
 @kindex `
 Pressing the backquote @kbd{`} followed by a character inserts math
-macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
+macros, also outside @LaTeX{} fragments.  If you wait more than 1.5 seconds
 after the backquote, a help window will pop up.
 @item
 @kindex '
 Pressing the single-quote @kbd{'} followed by another character modifies
 the symbol before point with an accent or a font.  If you wait more than
-1.5 seconds after the backquote, a help window will pop up.  Character
-modification will work only inside La@TeX{} fragments, outside the quote
+1.5 seconds after the single-quote, a help window will pop up.  Character
+modification will work only inside @LaTeX{} fragments; outside the quote
 is normal.
 @end itemize
 
@@ -9140,8 +9192,8 @@
 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. La@TeX{} export lets you use Org-mode and
-its structured editing functions to easily create La@TeX{} files.  DocBook
+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.  For project management you can create gantt and resource
 charts by using TaskJuggler export.  To incorporate entries with associated
@@ -9158,7 +9210,7 @@
 * 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 La@TeX{}, and processing to PDF
+* LaTeX and PDF export::        Exporting to @LaTeX{}, and processing to PDF
 * DocBook export::              Exporting to DocBook
 * TaskJuggler export::          Exporting to TaskJuggler
 * Freemind export::             Exporting to Freemind mind maps
@@ -9205,8 +9257,7 @@
 a separate file which can be included using @code{#+SETUPFILE}.
 
 @table @kbd
-@kindex C-c C-e t
-@item C-c C-e t
+@orgcmd{C-c C-e t,org-insert-export-options-template}
 Insert template with export options, see example below.
 @end table
 
@@ -9232,7 +9283,7 @@
 @example
 #+TITLE:       the title to be shown (default is the buffer name)
 #+AUTHOR:      the author (default taken from @code{user-full-name})
-#+DATE:        a date, fixed, of a format string for @code{format-time-string}
+#+DATE:        a date, fixed, 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
@@ -9252,8 +9303,8 @@
 
 @noindent
 The OPTIONS line is a compact@footnote{If you want to configure many options
-this way, you can use several OPTIONS lines.} form to specify export settings.  Here
-you can:
+this way, you can use several OPTIONS lines.} form to specify export
+settings.  Here you can:
 @cindex headline levels
 @cindex section-numbers
 @cindex table of contents
@@ -9266,7 +9317,7 @@
 @cindex special strings
 @cindex emphasized text
 @cindex @TeX{} macros
-@cindex La@TeX{} fragments
+@cindex @LaTeX{} fragments
 @cindex author info, in export
 @cindex time info, in export
 @example
@@ -9288,7 +9339,7 @@
 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
-LaTeX:     @r{configure export of La@TeX{} fragments.  Default @code{auto}}
+LaTeX:     @r{configure export of @LaTeX{} fragments.  Default @code{auto}}
 skip:      @r{turn on/off skipping the text before the first heading}
 author:    @r{turn on/off inclusion of author name/email into exported file}
 email:     @r{turn on/off inclusion of author email into exported file}
@@ -9297,9 +9348,12 @@
 d:         @r{turn on/off inclusion of drawers}
 @end example
 @noindent
-These options take effect in both the HTML and La@TeX{} export, except
-for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
-@code{nil} for the La@TeX{} export.
+These options take effect in both the HTML and @LaTeX{} export, except for
+@code{TeX} and @code{LaTeX}, which are respectively @code{t} and @code{nil}
+for the @LaTeX{} export.  The default values for these and many other options
+are given by a set of variables.  For a list of such variables, the
+corresponding OPTIONS keys and also the publishing keys (@pxref{Project
+alist}), see the constant @code{org-export-plist-vars}.
 
 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
 calling an export command, the subtree can overrule some of the file's export
@@ -9318,8 +9372,7 @@
 the subtrees are exported.
 
 @table @kbd
-@kindex C-c C-e
-@item C-c C-e
+@orgcmd{C-c C-e,org-export}
 @vindex org-export-run-in-background
 Dispatcher for export and publishing commands.  Displays a help-window
 listing the additional key(s) needed to launch an export or publishing
@@ -9327,14 +9380,12 @@
 @kbd{C-u C-u} causes most commands to be executed in the background, in a
 separate Emacs process@footnote{To make this behavior the default, customize
 the variable @code{org-export-run-in-background}.}.
-@kindex C-c C-e v
-@item C-c C-e v
+@orgcmd{C-c C-e v,org-export-visible}
 Like @kbd{C-c C-e}, but only export the text that is currently visible
 (i.e. not hidden by outline visibility).
-@kindex C-u C-u C-c C-e
-@item C-u C-u C-c C-e
+@orgcmd{C-u C-u C-c C-e,org-export}
 @vindex org-export-run-in-background
-Call an the exporter, but reverse the setting of
+Call the exporter, but reverse the setting of
 @code{org-export-run-in-background}, i.e. request background processing if
 not set, or force processing in the current Emacs process if set.
 @end table
@@ -9353,8 +9404,7 @@
 @cindex active region
 @cindex transient-mark-mode
 @table @kbd
-@kindex C-c C-e a
-@item C-c C-e a
+@orgcmd{C-c C-e a,org-export-as-ascii}
 @cindex property, EXPORT_FILE_NAME
 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
 will be @file{myfile.txt}.  The file will be overwritten without
@@ -9365,21 +9415,15 @@
 become the document title.  If the tree head entry has or inherits an
 @code{EXPORT_FILE_NAME} property, that name will be used for the
 export.
-@kindex C-c C-e A
-@item C-c C-e A
-Export to a temporary buffer, do not create a file.
-@kindex C-c C-e n
-@kindex C-c C-e N
-@item C-c C-e n @ @ @r{and} @ @ C-c C-e N
+@orgcmd{C-c C-e A,org-export-as-ascii-to-buffer}
+Export to a temporary buffer.  Do not create a file.
+@orgcmd{C-c C-e n,org-export-as-latin1}
+@xorgcmd{C-c C-e N,org-export-as-latin1-to-buffer}
 Like the above commands, but use Latin-1 encoding.
-@kindex C-c C-e u
-@kindex C-c C-e U
-@item C-c C-e u @ @ @r{and} @ @ C-c C-e U
+@orgcmd{C-c C-e u,org-export-as-utf8}
+@xorgcmd{C-c C-e U,org-export-as-utf8-to-buffer}
 Like the above commands, but use UTF-8 encoding.
-@kindex C-c C-e v a
-@kindex C-c C-e v n
-@kindex C-c C-e v u
-@item C-c C-e v a @ @ @r{and} @ @ C-c C-e v n @ @ @r{and} @ @ C-c C-e v u
+@item C-c C-e v a/n/u
 Export only the visible part of the document.
 @end table
 
@@ -9434,8 +9478,7 @@
 @cindex active region
 @cindex transient-mark-mode
 @table @kbd
-@kindex C-c C-e h
-@item C-c C-e h
+@orgcmd{C-c C-e h,org-export-as-html}
 @cindex property, EXPORT_FILE_NAME
 Export as HTML file @file{myfile.html}.  For an Org file @file{myfile.org},
 the ASCII file will be @file{myfile.html}.  The file will be overwritten
@@ -9445,25 +9488,15 @@
 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
 property, that name will be used for the export.
-@kindex C-c C-e b
-@item C-c C-e b
+@orgcmd{C-c C-e b,org-export-as-html-and-open}
 Export as HTML file and immediately open it with a browser.
-@kindex C-c C-e H
-@item C-c C-e H
-Export to a temporary buffer, do not create a file.
-@kindex C-c C-e R
-@item C-c C-e R
+@orgcmd{C-c C-e H,org-export-as-html-to-buffer}
+Export to a temporary buffer.  Do not create a file.
+@orgcmd{C-c C-e R,org-export-region-as-html}
 Export the active region to a temporary buffer.  With a prefix argument, do
 not produce the file header and footer, but just the plain HTML section for
 the region.  This is good for cut-and-paste operations.
-@kindex C-c C-e v h
-@kindex C-c C-e v b
-@kindex C-c C-e v H
-@kindex C-c C-e v R
-@item C-c C-e v h
-@item C-c C-e v b
-@item C-c C-e v H
-@item C-c C-e v R
+@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
@@ -9599,16 +9632,18 @@
 @cindex MathJax
 @cindex dvipng
 
-La@TeX{} 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
 purposes.  @b{If you plan to use this regularly or on pages with significant
-page views, you should install MathJax on your own server in order to limit
-the load of our server.}  To configure @file{MathJax}, use the variable
-@code{org-export-html-mathjax-options} or insert something like the following
-into the buffer:
+page views, you should install@footnote{Installation instructions can be
+found on the MathJax website, see
+@uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on
+your own server in order to limit the load of our server.}  To configure
+@file{MathJax}, use the variable @code{org-export-html-mathjax-options} or
+insert something like the following into the buffer:
 
 @example
 #+MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
@@ -9618,11 +9653,11 @@
 @code{org-export-html-mathjax-options} for the meaning of the parameters in
 this line.
 
-If you prefer, you can also request that La@TeX{} are processed into small
-images that will be inserted into the browser page.  Before the availability
-of MathJax, this was the default method for Org files.  This method requires
-that the @file{dvipng} program is available on your system.  You can still
-get this processing with
+If you prefer, you can also request that @LaTeX{} fragments are processed
+into small images that will be inserted into the browser page.  Before the
+availability of MathJax, this was the default method for Org files.  This
+method requires that the @file{dvipng} program is available on your system.
+You can still get this processing with
 
 @example
 #+OPTIONS: LaTeX:dvipng
@@ -9705,7 +9740,7 @@
 @code{org-export-html-style-include-default}}.  You may overwrite these
 settings, or add to them by using the variables @code{org-export-html-style}
 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
-granular settings, like file-local settings).  To set the latter variable
+fine-grained settings, like file-local settings).  To set the latter variable
 individually for each file, you can use
 
 @cindex #+STYLE
@@ -9773,11 +9808,11 @@
          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
          @r{If this is smaller than in @code{org-export-headline-levels}, each}
          @r{info/folding section can still contain child headlines.}
-toc:     @r{Should the table of content @emph{initially} be visible?}
+toc:     @r{Should the table of contents @emph{initially} be visible?}
          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
-ftoc:    @r{Does the css of the page specify a fixed position for the "toc"?}
+ftoc:    @r{Does the CSS of the page specify a fixed position for the "toc"?}
          @r{If yes, the toc will never be displayed as a section.}
 ltoc:    @r{Should there be short contents (children) in each section?}
          @r{Make this @code{above} if the section should be above initial text.}
@@ -9794,41 +9829,40 @@
 pages, configure the variable @code{org-export-html-use-infojs}.
 
 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
-@section La@TeX{} and PDF export
-@cindex La@TeX{} export
+@section @LaTeX{} and PDF export
+@cindex @LaTeX{} export
 @cindex PDF export
 @cindex Guerry, Bastien
 
-Org-mode contains a La@TeX{} exporter written by Bastien Guerry.  With
+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
 @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 La@TeX{} output uses @file{hyperref} to
+produce PDF output.  Since the @LaTeX{} output uses @file{hyperref} to
 implement links and cross references, the PDF output file will be fully
 linked.
 
 @menu
 * LaTeX/PDF export commands::   Which key invokes which commands
 * Header and sectioning::       Setting up the export file structure
-* Quoting LaTeX code::          Incorporating literal La@TeX{} code
-* Tables in LaTeX export::      Options for exporting tables to La@TeX{}
-* Images in LaTeX export::      How to insert figures into La@TeX{} 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
-@subsection La@TeX{} export commands
+@subsection @LaTeX{} export commands
 
 @cindex region, active
 @cindex active region
 @cindex transient-mark-mode
 @table @kbd
-@kindex C-c C-e l
-@item C-c C-e l
+@orgcmd{C-c C-e l,org-export-as-latex}
 @cindex property EXPORT_FILE_NAME
-Export as La@TeX{} file @file{myfile.tex}.  For an Org file
+Export as @LaTeX{} file @file{myfile.tex}.  For an Org file
 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
 be overwritten without warning.  If there is an active region@footnote{This
 requires @code{transient-mark-mode} be turned on.}, only the region will be
@@ -9836,27 +9870,21 @@
 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
 property, that name will be used for the export.
-@kindex C-c C-e L
-@item C-c C-e L
-Export to a temporary buffer, do not create a file.
-@kindex C-c C-e v l
-@kindex C-c C-e v L
-@item C-c C-e v l
-@item C-c C-e v L
+@orgcmd{C-c C-e L,org-export-as-latex-to-buffer}
+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 La@TeX{} 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 La@TeX{}
+Replace the active region (assumed to be in Org-mode syntax) by @LaTeX{}
 code.
-@kindex C-c C-e p
-@item C-c C-e p
-Export as La@TeX{} and then process to PDF.
-@kindex C-c C-e d
-@item C-c C-e d
-Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
+@orgcmd{C-c C-e p,org-export-as-pdf}
+Export as @LaTeX{} and then process to PDF.
+@orgcmd{C-c C-e d,org-export-as-pdf-and-open}
+Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
 @end table
 
 @cindex headline levels, for exporting
@@ -9879,13 +9907,13 @@
 
 @node Header and sectioning, Quoting LaTeX code, LaTeX/PDF export commands, LaTeX and PDF export
 @subsection Header and sectioning structure
-@cindex La@TeX{} class
-@cindex La@TeX{} sectioning structure
-@cindex La@TeX{} header
+@cindex @LaTeX{} class
+@cindex @LaTeX{} sectioning structure
+@cindex @LaTeX{} header
 @cindex header, for LaTeX files
 @cindex sectioning structure, for LaTeX export
 
-By default, the La@TeX{} output uses the class @code{article}.
+By default, the @LaTeX{} output uses the class @code{article}.
 
 @vindex org-export-latex-default-class
 @vindex org-export-latex-classes
@@ -9912,12 +9940,12 @@
 information.
 
 @node Quoting LaTeX code, Tables in LaTeX export, Header and sectioning, LaTeX and PDF export
-@subsection Quoting La@TeX{} code
-
-Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
-inserted into the La@TeX{} file.  This includes simple macros like
+@subsection Quoting @LaTeX{} code
+
+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 La@TeX{} export with
+you can add special code that should only be present in @LaTeX{} export with
 the following constructs:
 
 @cindex #+LaTeX
@@ -9937,10 +9965,10 @@
 
 
 @node Tables in LaTeX export, Images in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
-@subsection Tables in La@TeX{} export
-@cindex tables, in La@TeX{} export
-
-For La@TeX{} export of a table, you can specify a label and a caption
+@subsection Tables in @LaTeX{} export
+@cindex tables, in @LaTeX{} export
+
+For @LaTeX{} export of a table, you can specify a label and a caption
 (@pxref{Images and tables}).  You can also use the @code{ATTR_LaTeX} line to
 request a @code{longtable} environment for the table, so that it may span
 several pages, or provide the @code{multicolumn} keyword that will make the
@@ -9960,13 +9988,13 @@
 
 
 @node Images in LaTeX export, Beamer class export, Tables in LaTeX export, LaTeX and PDF export
-@subsection Images in La@TeX{} export
-@cindex images, inline in La@TeX{}
-@cindex inlining images in La@TeX{}
+@subsection Images in @LaTeX{} export
+@cindex images, inline in @LaTeX{}
+@cindex inlining images in @LaTeX{}
 
 Images that are linked to without a description part in the link, like
 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
-output file resulting from La@TeX{} processing.  Org will use an
+output file resulting from @LaTeX{} processing.  Org will use an
 @code{\includegraphics} macro to insert the image.  If you have specified a
 caption and/or a label as described in @ref{Images and tables}, the figure
 will be wrapped into a @code{figure} environment and thus become a floating
@@ -9997,7 +10025,7 @@
 @end example
 
 If you need references to a label created in this way, write
-@samp{\ref@{fig:SED-HR4049@}} just like in La@TeX{}.
+@samp{\ref@{fig:SED-HR4049@}} just like in @LaTeX{}.
 
 @node Beamer class export,  , Images in LaTeX export, LaTeX and PDF export
 @subsection Beamer class export
@@ -10014,7 +10042,7 @@
 the first level below the selected subtree heading) will be turned into
 frames, and the outline structure below this level will become itemize lists.
 You can also configure the variable @code{org-beamer-frame-level} to a
-different level - then the hierarchy above frames will produce the sectioning
+different level---then the hierarchy above frames will produce the sectioning
 structure of the presentation.
 
 A template for useful in-buffer settings or properties can be inserted into
@@ -10037,7 +10065,8 @@
 @code{[t]} or @code{[<+->]} of @code{<2-3>}.  If the @code{BEAMER_col}
 property is also set, something like @code{C[t]} can be added here as well to
 set an options argument for the implied @code{columns} environment.
-@code{c[t]} will set an option for the implied @code{column} environment.
+@code{c[t]} or @code{c<2->} will set an options for the implied @code{column}
+environment.
 @item BEAMER_col
 The width of a column that should start with this entry.  If this property is
 set, the entry will also get a @code{:BMCOL:} property to make this visible.
@@ -10076,8 +10105,7 @@
 @end example
 
 @table @kbd
-@kindex C-c C-b
-@item C-c C-b
+@orgcmd{C-c C-b,org-beamer-select-environment}
 In @code{org-beamer-mode}, this key offers fast selection of a beamer
 environment or the @code{BEAMER_col} property.
 @end table
@@ -10155,8 +10183,7 @@
 @cindex active region
 @cindex transient-mark-mode
 @table @kbd
-@kindex C-c C-e D
-@item C-c C-e D
+@orgcmd{C-c C-e D,org-export-as-docbook}
 @cindex property EXPORT_FILE_NAME
 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
 file will be @file{myfile.xml}.  The file will be overwritten without
@@ -10166,8 +10193,7 @@
 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
 property, that name will be used for the export.
-@kindex C-c C-e V
-@item C-c C-e V
+@orgcmd{C-c C-e V,org-export-as-docbook-pdf-and-open}
 Export as DocBook file, process to PDF, then open the resulting PDF file.
 
 @vindex org-export-docbook-xslt-proc-command
@@ -10184,8 +10210,7 @@
 the user.  You can also overrule this global setting on a per-file basis by
 adding an in-buffer setting @code{#+XSLT:} to the Org file.
 
-@kindex C-c C-e v D
-@item C-c C-e v D
+@orgkey{C-c C-e v D}
 Export only the visible part of the document.
 @end table
 
@@ -10220,7 +10245,7 @@
 #+BEGIN_DOCBOOK
 <warning>
   <para>You should know what you are doing when quoting DocBook XML code
-  in your Org file.  Invalid DocBook XML file may be generated by
+  in your Org file.  Invalid DocBook XML may be generated by
   DocBook exporter if you are not careful!</para>
 </warning>
 #+END_DOCBOOK
@@ -10349,12 +10374,10 @@
 @subsection TaskJuggler export commands
 
 @table @kbd
-@kindex C-c C-e j
-@item C-c C-e j
+@orgcmd{C-c C-e j,org-export-as-taskjuggler}
 Export as TaskJuggler file.
 
-@kindex C-c C-e J
-@item C-c C-e J
+@orgcmd{C-c C-e J,org-export-as-taskjuggler-and-open}
 Export as TaskJuggler file and then open the file with TaskJugglerUI.
 @end table
 
@@ -10381,7 +10404,7 @@
 identifier (named @samp{resource_id}) to the resources (using the standard
 Org properties commands, @pxref{Property syntax}) or you can let the exporter
 generate identifiers automatically (the exporter picks the first word of the
-headline as the identifier as long as it is unique, see the documentation of
+headline as the identifier as long as it is unique---see the documentation of
 @code{org-taskjuggler-get-unique-id}). Using that identifier you can then
 allocate resources to tasks. This is again done with the @samp{allocate}
 property on the tasks. Do this in column view or when on the task type
@@ -10407,7 +10430,7 @@
 
 The exporter will handle dependencies that are defined in the tasks either
 with the @samp{ORDERED} attribute (@pxref{TODO dependencies}), with the
-@samp{BLOCKER} attribute (see org-depend.el) or alternatively with a
+@samp{BLOCKER} attribute (see @file{org-depend.el}) or alternatively with a
 @samp{depends} attribute. Both the @samp{BLOCKER} and the @samp{depends}
 attribute can be either @samp{previous-sibling} or a reference to an
 identifier (named @samp{task_id}) which is defined for another task in the
@@ -10464,8 +10487,7 @@
 The Freemind exporter was written by Lennart Borgman.
 
 @table @kbd
-@kindex C-c C-e m
-@item C-c C-e m
+@orgcmd{C-c C-e m,org-export-as-freemind}
 Export as Freemind mind map @file{myfile.mm}.
 @end table
 
@@ -10478,11 +10500,9 @@
 does not interpret any additional Org-mode features.
 
 @table @kbd
-@kindex C-c C-e x
-@item C-c C-e x
+@orgcmd{C-c C-e x,org-export-as-xoxo}
 Export as XOXO file @file{myfile.html}.
-@kindex C-c C-e v
-@item C-c C-e v x
+@orgkey{C-c C-e v x}
 Export only the visible part of the document.
 @end table
 
@@ -10525,18 +10545,15 @@
 figure out from which entry all the different instances originate.
 
 @table @kbd
-@kindex C-c C-e i
-@item C-c C-e i
+@orgcmd{C-c C-e i,org-export-icalendar-this-file}
 Create iCalendar entries for the current file and store them in the same
 directory, using a file extension @file{.ics}.
-@kindex C-c C-e I
-@item C-c C-e I
+@orgcmd{C-c C-e I, org-export-icalendar-all-agenda-files}
 @vindex org-agenda-files
 Like @kbd{C-c C-e i}, but do this for all files in
 @code{org-agenda-files}.  For each of these files, a separate iCalendar
 file will be written.
-@kindex C-c C-e c
-@item C-c C-e c
+@orgcmd{C-c C-e c,org-export-icalendar-combine-agenda-files}
 @vindex org-combined-agenda-icalendar-file
 Create a single large iCalendar file from all files in
 @code{org-agenda-files} and write it to the file given by
@@ -10674,6 +10691,9 @@
 @item @code{:include}
 @tab List of files to be included regardless of @code{:base-extension}
 and @code{:exclude}.
+
+@item @code{:recursive}
+@tab Non-nil means, check base-directory recursively for files to publish.
 @end multitable
 
 @node Publishing action, Publishing options, Selecting files, Configuration
@@ -10694,10 +10714,10 @@
 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
 source and publishing directories are equal.  Note that with this kind of
 setup, you need to add @code{:exclude "-source\\.org"} to the project
-definition in @code{org-publish-project-alist} to avoid that the published
-source files will be considered as new org files the next time the project is
-published.}.  Other files like images only need to be copied to the
-publishing destination, for this you may use @code{org-publish-attachment}.
+definition in @code{org-publish-project-alist} to prevent the published
+source files from being considered as new org files the next time the project
+is published.}.  Other files like images only need to be copied to the
+publishing destination; for this you may use @code{org-publish-attachment}.
 For non-Org files, you always need to specify the publishing function:
 
 @multitable @columnfractions 0.3 0.7
@@ -10717,11 +10737,11 @@
 and place the result into the destination folder.
 
 @node Publishing options, Publishing links, Publishing action, Configuration
-@subsection Options for the HTML/La@TeX{} exporters
+@subsection Options for the HTML/@LaTeX{} exporters
 @cindex options, for publishing
 
 The property list can be used to set many export options for the HTML
-and La@TeX{} exporters.  In most cases, these properties correspond to user
+and @LaTeX{} exporters.  In most cases, these properties correspond to user
 variables in Org.  The table below lists these properties along
 with the variable they belong to.  See the documentation string for the
 respective variable for details.
@@ -10826,9 +10846,9 @@
 @end multitable
 
 Most of the @code{org-export-with-*} variables have the same effect in
-both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
+both HTML and @LaTeX{} exporters, except for @code{:TeX-macros} and
 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
-La@TeX{} export.
+@LaTeX{} export.
 
 @vindex org-publish-project-alist
 When a property is given a value in @code{org-publish-project-alist},
@@ -11048,17 +11068,13 @@
 Once properly configured, Org can publish with the following commands:
 
 @table @kbd
-@kindex C-c C-e C
-@item C-c C-e C
+@orgcmd{C-c C-e X,org-publish}
 Prompt for a specific project and publish all files that belong to it.
-@kindex C-c C-e P
-@item C-c C-e P
+@orgcmd{C-c C-e P,org-publish-current-project}
 Publish the project containing the current file.
-@kindex C-c C-e F
-@item C-c C-e F
+@orgcmd{C-c C-e F,org-publish-current-file}
 Publish only the current file.
-@kindex C-c C-e E
-@item C-c C-e E
+@orgcmd{C-c C-e E,org-publish-all}
 Publish every project.
 @end table
 
@@ -11192,7 +11208,7 @@
 Controls the way Emacs windows are rearranged when the edit buffer is created.
 @item org-src-preserve-indentation
 This variable is especially useful for tangling languages such as
-python, in which whitespace indentation in the output is critical.
+Python, in which whitespace indentation in the output is critical.
 @item org-src-ask-before-returning-to-edit-buffer
 By default, Org will ask before returning to an open edit buffer. Set
 this variable to nil to switch without asking.
@@ -11234,7 +11250,7 @@
 @end table
 
 It is possible to inhibit the evaluation of code blocks during export.
-Setting the the @code{org-export-babel-evaluate} variable to @code{nil} will
+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
@@ -11361,17 +11377,17 @@
 @item @b{Language} @tab @b{Identifier} @tab @b{Language} @tab @b{Identifier}
 @item Asymptote @tab asymptote @tab C @tab C
 @item C++ @tab C++ @tab Clojure @tab clojure
-@item css @tab css @tab ditaa @tab ditaa
+@item CSS @tab css @tab ditaa @tab ditaa
 @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp
 @item gnuplot @tab gnuplot @tab Haskell @tab haskell
-@item LaTeX @tab latex @tab Matlab @tab matlab
+@item LaTeX @tab latex @tab MATLAB @tab matlab
 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
-@item Octave @tab octave @tab OZ @tab oz
+@item Octave @tab octave @tab Oz @tab oz
 @item Perl @tab perl @tab Python @tab python
 @item R @tab R @tab Ruby @tab ruby
 @item Sass @tab sass @tab GNU Screen @tab screen
 @item shell @tab sh @tab SQL @tab sql
-@item Sqlite @tab sqlite
+@item SQLite @tab sqlite
 @end multitable
 
 Language-specific documentation is available for some languages.  If
@@ -11771,8 +11787,8 @@
 @node results, file, var, Specific header arguments
 @subsubsection @code{:results}
 
-There are three classes of @code{:results} header argument.  Only one option of
-each type may be supplied per code block.
+There are three classes of @code{:results} header argument.  Only one option
+per class may be supplied per code block.
 
 @itemize @bullet
 @item
@@ -11795,7 +11811,7 @@
 @item @code{value}
 This is the default.  The result is the value of the last statement in the
 code block.  This header argument places the evaluation in functional
-mode.  Note that in some languages, e.g., python, use of this result type
+mode.  Note that in some languages, e.g., Python, use of this result type
 requires that a @code{return} statement be included in the body of the source
 code block. E.g., @code{:results value}.
 @item @code{output}
@@ -11815,6 +11831,9 @@
 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
+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
@@ -11837,7 +11856,7 @@
 E.g., @code{:results value code}.
 @item @code{pp}
 The result is converted to pretty-printed code and is enclosed in a code
-block.  This option currently supports Emacs Lisp, python, and ruby.  E.g.,
+block.  This option currently supports Emacs Lisp, Python, and Ruby.  E.g.,
 @code{:results value pp}.
 @end itemize
 
@@ -11875,7 +11894,7 @@
 graphical output is sent to the specified file without the file being
 referenced explicitly in the code block. See the documentation for the
 individual languages for details. In contrast, general purpose languages such
-as python and ruby require that the code explicitly create output
+as Python and Ruby require that the code explicitly create output
 corresponding to the path indicated by @code{:file}.
 
 
@@ -11894,8 +11913,8 @@
 (e.g. @code{:file myfile.jpg} or @code{:file results/myfile.jpg}) in which
 case that path will be interpreted relative to the default directory.
 
-In other words, if you want your plot to go into a folder called Work in your
-home directory, you could use
+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
@@ -11928,7 +11947,7 @@
 Most of this functionality follows immediately from the fact that @code{:dir}
 sets the value of the Emacs variable @code{default-directory}, thanks to
 tramp. Those using XEmacs, or GNU Emacs prior to version 23 may need to
-install tramp separately in order for the these features to work correctly.
+install tramp separately in order for these features to work correctly.
 
 @subsubheading Further points
 
@@ -11974,7 +11993,7 @@
 block should be included in tangled extraction of source code files.
 
 @itemize @bullet
-@item @code{yes}
+@item @code{tangle}
 The code block is exported to a source code file named after the
 basename (name w/o extension) of the Org-mode file.  E.g., @code{:tangle
 yes}.
@@ -12047,7 +12066,7 @@
 The default.  No ``noweb'' syntax specific action is taken on evaluating
 code blocks, However, noweb references will still be expanded during
 tangling.
-@item @code{yes}
+@item @code{tangle}
 All ``noweb'' syntax references in the body of the code block will be
 expanded before the block is tangled, however ``noweb'' references will not
 be expanded when the block is evaluated or exported.
@@ -12091,7 +12110,7 @@
 The default.  No caching takes place, and the code block will be evaluated
 every time it is called.
 @item @code{yes}
-Every time the code block is run a sha1 hash of the code and arguments
+Every time the code block is run a SHA1 hash of the code and arguments
 passed to the block will be generated.  This hash is packed into the
 @code{#+results:} line and will be checked on subsequent
 executions of the code block.  If the code block has not
@@ -12269,9 +12288,9 @@
 This is the default. Internally, the value is obtained by wrapping the code
 in a function definition in the external language, and evaluating that
 function. Therefore, code should be written as if it were the body of such a
-function. In particular, note that python does not automatically return a
+function. In particular, note that Python does not automatically return a
 value from a function unless a @code{return} statement is present, and so a
-@samp{return} statement will usually be required in python.
+@samp{return} statement will usually be required in Python.
 
 This is the only one of the four evaluation contexts in which the code is
 automatically wrapped in a function definition.
@@ -12282,12 +12301,12 @@
 languages this also contains the error output stream; this is an area for
 future work.)
 
-@subsection @code{:session}
+@subsection Session
 @subsubsection @code{:results value}
 The code is passed to the interpreter running as an interactive Emacs
 inferior process. The result returned is the result of the last evaluation
 performed by the interpreter. (This is obtained in a language-specific
-manner: the value of the variable @code{_} in python and ruby, and the value
+manner: the value of the variable @code{_} in Python and Ruby, and the value
 of @code{.Last.value} in R).
 
 @subsubsection @code{:results output}
@@ -12310,7 +12329,7 @@
 : bye
 @end example
 
-In non-session mode, the '2' is not printed and does not appear.
+In non-session mode, the `2' is not printed and does not appear.
 @example
 #+begin_src python :results output :session
  print "hello"
@@ -12324,8 +12343,8 @@
 : bye
 @end example
 
-But in @code{:session} mode, the interactive interpreter receives input '2'
-and prints out its value, '2'. (Indeed, the other print statements are
+But in @code{:session} mode, the interactive interpreter receives input `2'
+and prints out its value, `2'. (Indeed, the other print statements are
 unnecessary here).
 
 @node Noweb reference syntax, Key bindings and useful functions, Results of evaluation, Working With Source Code
@@ -12573,7 +12592,7 @@
 into a complete EXAMPLE template.
 
 You can install additional templates by customizing the variable
-@code{org-structure-template-alist}. Refer docstring of the variable for
+@code{org-structure-template-alist}. See the docstring of the variable for
 additional details.
 
 @node Speed keys, Code evaluation security, Easy Templates, Miscellaneous
@@ -12588,7 +12607,7 @@
 pre-defined list of commands, and you can add more such commands using the
 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
 navigation and other commands, but they also provide an alternative way to
-execute commands bound to keys that are not or not easily available on a tty,
+execute commands bound to keys that are not or not easily available on a TTY,
 or on a small mobile device with a limited keyboard.
 
 To see which commands are available, activate the feature and press @kbd{?}
@@ -12617,7 +12636,7 @@
 C-c} in the block.  The most important thing to realize here is that Org mode
 files which contain code snippets are, in a certain sense, like executable
 files.  So you should accept them and load them into Emacs only from trusted
-sources - just like you would do with a program you install on your computer.
+sources---just like you would do with a program you install on your computer.
 
 Make sure you know what you are doing before customizing the variables
 which take off the default security brakes.
@@ -12692,7 +12711,7 @@
 @vindex org-table-formula-constants
 @vindex org-table-formula
 Set file-local values for constants to be used in table formulas.  This
-line set the local variable @code{org-table-formula-constants-local}.
+line sets the local variable @code{org-table-formula-constants-local}.
 The global version of this variable is
 @code{org-table-formula-constants}.
 @item #+FILETAGS: :tag1:tag2:tag3:
@@ -12713,7 +12732,7 @@
 @vindex org-default-priority
 This line sets the limits and the default for the priorities.  All three
 must be either letters A-Z or numbers 0-9.  The highest priority must
-have a lower ASCII number that the lowest priority.
+have a lower ASCII number than the lowest priority.
 @item #+PROPERTY: Property_Name Value
 This line sets a default inheritance value for entries in the current
 buffer, most useful for specifying the allowed values of a property.
@@ -12894,12 +12913,12 @@
 nohideblocks @r{Do not hide blocks on startup}
 @end example
 @cindex org-pretty-entities
-The the display of entities as UTF8 characters is governed by the variable
+The display of entities as UTF-8 characters is governed by the variable
 @code{org-pretty-entities} and the keywords
 @cindex @code{entitiespretty}, STARTUP keyword
 @cindex @code{entitiesplain}, STARTUP keyword
 @example
-entitiespretty  @r{Show entities as UTF8 characters where possible}
+entitiespretty  @r{Show entities as UTF-8 characters where possible}
 entitiesplain   @r{Leave entities plain}
 @end example
 @item #+TAGS:  TAG1(c1) TAG2(c2)
@@ -13023,7 +13042,7 @@
 #+STARTUP: indent
 @end example
 
-If you want a similar effect in earlier version of Emacs and/or Org, or if
+If you want a similar effect in an earlier version of Emacs and/or Org, or if
 you want the indentation to be hard space characters so that the plain text
 file looks as similar as possible to the Emacs display, Org supports you in
 the following way:
@@ -13181,7 +13200,7 @@
 @cindex @file{cdlatex.el}
 @cindex Dominik, Carsten
 Org-mode can make use of the CDLa@TeX{} package to efficiently enter
-La@TeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
+@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
@@ -13221,12 +13240,10 @@
 @kbd{C-c '} to edit them, similar to source code snippets.
 
 @table @kbd
-@kindex C-c '
-@item C-c '
+@orgcmd{C-c ',org-edit-special}
 Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
 @c
-@kindex C-c ~
-@item C-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
 format.  See the documentation string of the command
@@ -13288,7 +13305,7 @@
 @item @file{yasnippet.el}
 @cindex @file{yasnippet.el}
 The way Org-mode binds the TAB key (binding to @code{[tab]} instead of
-@code{"\t"}) overrules yasnippets' access to this key.  The following code
+@code{"\t"}) overrules YASnippet's access to this key.  The following code
 fixed this problem:
 
 @lisp
@@ -13341,7 +13358,7 @@
 * Add-on packages::             Available extensions
 * Adding hyperlink types::      New custom link types
 * Context-sensitive commands::  How to add functionality to such commands
-* Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
+* Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
 * Dynamic blocks::              Automatically filled blocks
 * Special agenda views::        Customized views
 * Extracting agenda information::  Postprocessing of agenda information
@@ -13470,7 +13487,7 @@
 the link description when the link is later inserted into an Org
 buffer with @kbd{C-c C-l}.
 
-When is makes sense for your new link type, you may also define a function
+When it makes sense for your new link type, you may also define a function
 @code{org-PREFIX-complete-link} that implements special (e.g. completion)
 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
 not accept any arguments, and return the full link with prefix.
@@ -13521,7 +13538,7 @@
 
 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
 frequent feature request has been to make it work with native tables in
-specific languages, for example La@TeX{}.  However, this is extremely
+specific languages, for example @LaTeX{}.  However, this is extremely
 hard to do in a general way, would lead to a customization nightmare,
 and would take away much of the simplicity of the Orgtbl-mode table
 editor.
@@ -13536,7 +13553,7 @@
 Bastien added the ability to do the same with lists, in Orgstruct mode.  You
 can use Org's facilities to edit and structure lists by turning
 @code{orgstruct-mode} on, then locally exporting such lists in another format
-(HTML, La@TeX{} or Texinfo.)
+(HTML, @LaTeX{} or Texinfo.)
 
 
 @menu
@@ -13594,7 +13611,7 @@
 @noindent
 The one problem remaining is how to keep the source table in the buffer
 without disturbing the normal workings of the file, for example during
-compilation of a C file or processing of a La@TeX{} file.  There are a
+compilation of a C file or processing of a @LaTeX{} file.  There are a
 number of different solutions:
 
 @itemize @bullet
@@ -13605,7 +13622,7 @@
 @item
 Sometimes it is possible to put the table after some kind of @i{END}
 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
-in La@TeX{}.
+in @LaTeX{}.
 @item
 You can just comment the table line-by-line whenever you want to process
 the file, and uncomment it whenever you need to edit the table.  This
@@ -13615,14 +13632,14 @@
 @end itemize
 
 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
-@subsection A La@TeX{} example of radio tables
-@cindex La@TeX{}, and Orgtbl mode
-
-The best way to wrap the source table in La@TeX{} is to use the
+@subsection A @LaTeX{} example of radio tables
+@cindex @LaTeX{}, and Orgtbl mode
+
+The best way to wrap the source table in @LaTeX{} is to use the
 @code{comment} environment provided by @file{comment.sty}.  It has to be
 activated by placing @code{\usepackage@{comment@}} into the document
 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
-default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
+default this works only for @LaTeX{}, HTML, and Texinfo.  Configure the
 variable @code{orgtbl-radio-tables} to install templates for other
 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
 be prompted for a table name, let's say we use @samp{salesfigures}.  You
@@ -13639,13 +13656,13 @@
 @end example
 
 @noindent
-@vindex La@TeX{}-verbatim-environments
+@vindex @LaTeX{}-verbatim-environments
 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
-@code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
+@code{orgtbl-to-latex} to convert the table into @LaTeX{} and to put it
 into the receiver location with name @code{salesfigures}.  You may now
-fill in the table, feel free to use the spreadsheet features@footnote{If
+fill in the table---feel free to use the spreadsheet features@footnote{If
 the @samp{#+TBLFM} line contains an odd number of dollar characters,
-this may cause problems with font-lock in La@TeX{} mode.  As shown in the
+this may cause problems with font-lock in @LaTeX{} mode.  As shown in the
 example you can fix this by adding an extra line inside the
 @code{comment} environment that is used to balance the dollar
 expressions.  If you are using AUC@TeX{} with the font-latex library, a
@@ -13695,7 +13712,7 @@
 \end@{comment@}
 @end example
 
-The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
+The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
 and marks horizontal lines with @code{\hline}.  Furthermore, it
 interprets the following parameters (see also @pxref{Translator functions}):
@@ -13759,7 +13776,7 @@
 @var{PARAMS}) are combined with the ones newly defined in the function
 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
-would like to use the La@TeX{} translator, but wanted the line endings to
+would like to use the @LaTeX{} translator, but wanted the line endings to
 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
 overrule the default with
 
@@ -13768,7 +13785,7 @@
 @end example
 
 For a new language, you can either write your own converter function in
-analogy with the La@TeX{} translator, or you can use the generic function
+analogy with the @LaTeX{} translator, or you can use the generic function
 directly.  For example, if you have a language where a table is started
 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
@@ -13802,9 +13819,9 @@
 @cindex radio lists
 @cindex org-list-insert-radio-list
 
-Sending and receiving radio lists works exactly the same way than sending and
+Sending and receiving radio lists works exactly the same way as sending and
 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
-insert radio lists templates in HTML, La@TeX{} and Texinfo modes by calling
+insert radio list templates in HTML, @LaTeX{} and Texinfo modes by calling
 @code{org-list-insert-radio-list}.
 
 Here are the differences with radio tables:
@@ -13821,8 +13838,8 @@
 @kbd{C-c C-c} will work when pressed on the first item of the list.
 @end itemize
 
-Here is a La@TeX{} example.  Let's say that you have this in your
-La@TeX{} file:
+Here is a @LaTeX{} example.  Let's say that you have this in your
+@LaTeX{} file:
 
 @cindex #+ORGLST
 @example
@@ -13839,7 +13856,7 @@
 @end example
 
 Pressing `C-c C-c' on @code{a new house} and will insert the converted
-La@TeX{} list between the two marker lines.
+@LaTeX{} list between the two marker lines.
 
 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
 @section Dynamic blocks
@@ -13850,11 +13867,11 @@
 A good example for such a block is the clock table inserted by the
 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
 
-Dynamic block are enclosed by a BEGIN-END structure that assigns a name
+Dynamic blocks are enclosed by a BEGIN-END structure that assigns a name
 to the block and can also specify parameters for the function producing
 the content of the block.
 
-#+BEGIN:dynamic block
+@cindex #+BEGIN:dynamic block
 @example
 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
 
@@ -13864,11 +13881,9 @@
 Dynamic blocks are updated with the following commands
 
 @table @kbd
-@kindex C-c C-x C-u
-@item C-c C-x C-u
+@orgcmd{C-c C-x C-u,org-dblock-update}
 Update dynamic block at point.
-@kindex C-u C-c C-x C-u
-@item C-u C-c C-x C-u
+@orgkey{C-u C-c C-x C-u}
 Update all dynamic blocks in the current file.
 @end table
 
@@ -14037,7 +14052,7 @@
 @example
 emacs -batch -l ~/.emacs                                      \
    -eval '(org-batch-agenda "a"                               \
-            org-agenda-ndays 30                               \
+            org-agenda-span month                             \
             org-agenda-include-diary nil                      \
             org-agenda-files (quote ("~/org/project.org")))'  \
    | lpr
@@ -14115,7 +14130,7 @@
 Get all properties of the entry at point-or-marker POM.@*
 This includes the TODO keyword, the tags, time strings for deadline,
 scheduled, and clocking, and any additional properties defined in the
-entry.  The return value is an alist, keys may occur multiple times
+entry.  The return value is an alist.  Keys may occur multiple times
 if the property key was used several times.@*
 POM may also be nil, in which case the current entry is used.
 If WHICH is nil or `all', get all properties.  If WHICH is
@@ -14173,7 +14188,7 @@
 @end defun
 
 @defopt org-property-allowed-value-functions
-Hook for functions supplying allowed values for specific.
+Hook for functions supplying allowed values for a specific property.
 The functions must take a single argument, the name of the property, and
 return a flat list of allowed values.  If @samp{:ETC} is one of
 the values, use the values as completion help, but allow also other values
@@ -14252,12 +14267,12 @@
 Here are a couple of functions that might be handy:
 
 @defun org-todo &optional arg
-Change the TODO state of the entry, see the docstring of the functions for
+Change the TODO state of the entry.  See the docstring of the functions for
 the many possible values for the argument ARG.
 @end defun
 
 @defun org-priority &optional action
-Change the priority of the entry, see the docstring of this function for the
+Change the priority of the entry.  See the docstring of this function for the
 possible values for ACTION.
 @end defun
 
@@ -14325,7 +14340,7 @@
 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
 @section Setting up the staging area
 
-MobileOrg needs to interact with Emacs through directory on a server.  If you
+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
 @i{MobileOrg 1.5} (iPhone version), and you need an @file{openssl}
@@ -14340,8 +14355,7 @@
 The easiest way to create that directory is to use a free
 @uref{http://dropbox.com,Dropbox.com} account@footnote{If you cannot use
 Dropbox, or if your version of MobileOrg does not support it, you can use a
-webdav server.  For more information, check out the the documentation of
-MobileOrg and also this
+webdav server.  For more information, check out the documentation of MobileOrg and also this
 @uref{http://orgmode.org/worg/org-faq.php#mobileorg_webdav, FAQ entry}.}.
 When MobileOrg first connects to your Dropbox, it will create a directory
 @i{MobileOrg} inside the Dropbox.  After the directory has been created, tell
@@ -14361,7 +14375,7 @@
 to the directory @code{org-mobile-directory}.  By default this list contains
 all agenda files (as listed in @code{org-agenda-files}), but additional files
 can be included by customizing @code{org-mobiles-files}.  File names will be
-staged with path relative to @code{org-directory}, so all files should 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
@@ -14415,7 +14429,7 @@
 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
 Pressing @kbd{?} twice in succession will offer to remove the
 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
-in a property).  In this way you indicate, that the intended processing for
+in a property).  In this way you indicate that the intended processing for
 this flagged entry is finished.
 @end table
 @end enumerate
@@ -14475,12 +14489,12 @@
 Org into a multi-language environment for evaluating code and doing literate
 programming and reproducible research.
 @item John Wiegley
-John has also contributed a number of great ideas and patches
-directly to Org, including the attachment system (@file{org-attach.el}),
-integration with Apple Mail (@file{org-mac-message.el}), hierarchical
-dependencies of TODO items, habit tracking (@file{org-habits.el}), and
-encryption (@file{org-crypt.el}).  Also, the capture system is really an
-extended copy of his great @file{remember.el}.
+John has contributed a number of great ideas and patches directly to Org,
+including the attachment system (@file{org-attach.el}), integration with
+Apple Mail (@file{org-mac-message.el}), hierarchical dependencies of TODO
+items, habit tracking (@file{org-habits.el}), and encryption
+(@file{org-crypt.el}).  Also, the capture system is really an extended copy
+of his great @file{remember.el}.
 @item Sebastian Rose
 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
@@ -14537,8 +14551,9 @@
 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
 the Org-Babel documentation into the manual.
 @item
-@i{Christian Egli} converted the documentation into Texinfo format,
-patched CSS formatting into the HTML exporter, and inspired the agenda.
+@i{Christian Egli} converted the documentation into Texinfo format, inspired
+the agenda, patched CSS formatting into the HTML exporter, and wrote
+@file{org-taskjuggler.el}.
 @item
 @i{David Emery} provided a patch for custom CSS support in exported
 HTML agendas.
@@ -14556,12 +14571,21 @@
 @item
 @i{Austin Frank} works as a mailing list moderator.
 @item
+@i{Eric Fraga} drove the development of BEAMER export with ideas and
+testing.
+@item
+@i{Barry Gidden} did proofreading the manual in preparation for the book
+publication through Network Theory Ltd.
+@item
 @i{Niels Giesen} had the idea to automatically archive DONE trees.
 @item
 @i{Nicolas Goaziou} rewrote much of the plain list code.
 @item
 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
 @item
+@i{Brian Gough} of Network Theory Ltd publishes the Org mode manual as a
+book.
+@item
 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
 task state change logging, and the clocktable.  His clear explanations have
 been critical when we started to adopt the Git version control system.
@@ -14578,7 +14602,7 @@
 @item
 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
 @item
-@i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
+@i{Shidai Liu} ("Leo") asked for embedded @LaTeX{} and tested it.  He also
 provided frequent feedback and some patches.
 @item
 @i{Matt Lundin} has proposed last-row references for table formulas and named
@@ -14610,7 +14634,7 @@
 @i{Tim O'Callaghan} suggested in-file links, search options for general
 file links, and TAGS.
 @item
-@i{Osamu Okano} wrote @file{orgcard2ref.pl}, a perl program to create a text
+@i{Osamu Okano} wrote @file{orgcard2ref.pl}, a Perl program to create a text
 version of the reference card.
 @item
 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
@@ -14680,6 +14704,9 @@
 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
 chapter about publishing.
 @item
+@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
 concept index for HTML export.
@@ -14739,6 +14766,8 @@
 @c Local variables:
 @c fill-column: 77
 @c indent-tabs-mode: nil
+@c paragraph-start:    "\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|\f\\|[ 	]*$"
+@c paragraph-separate: "\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|[ 	\f]*$"
 @c End:
 
 
--- a/etc/ChangeLog	Sat Dec 11 17:41:04 2010 +0200
+++ b/etc/ChangeLog	Sat Dec 11 17:42:53 2010 +0100
@@ -1,3 +1,7 @@
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* refcards/orgcard.tex: Cleanup.
+
 2010-11-27  Ulrich Mueller  <ulm@gentoo.org>
 
 	* HELLO: Add ancient Greek (Bug#7418).
--- a/etc/refcards/orgcard.tex	Sat Dec 11 17:41:04 2010 +0200
+++ b/etc/refcards/orgcard.tex	Sat Dec 11 17:42:53 2010 +0100
@@ -1,5 +1,5 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{7.3}
+\def\orgversionnumber{7.4}
 \def\versionyear{2010}          % latest update
 \def\year{2010}                 % latest copyright year
 
@@ -266,6 +266,10 @@
 \def\threecol#1#2#3{\hskip\keyindent\relax#1\hfil&\kbd{#2}\hfil\quad
   &\kbd{#3}\hfil\quad\cr}
 
+\def\noteone{{\small \hfill [1]}}
+\def\notetwo{{\small \hfill [2]}}
+
+
 %**end of header
 
 
@@ -274,14 +278,6 @@
 \centerline{(for version \orgversionnumber)}
 
 \section{Getting Started}
-%
-%\vskip -2mm
-%\beginexample%
-%(add-to-list 'auto-mode-alist '("\\\\.org\$" . org-mode))
-%(define-key global-map "\\C-cl" 'org-store-link)$^1$
-%(define-key global-map "\\C-ca" 'org-agenda)$^1$
-%\endexample
-%
 \metax{To read the on-line documentation try}{M-x org-info}
 
 \section{Visibility Cycling}
@@ -298,7 +294,7 @@
 \key{next/previous heading, same level}{C-c C-f/b}
 \key{backward to higher level heading}{C-c C-u}
 \key{jump to another place in document}{C-c C-j}
-\key{previous/next plain list item}{S-UP/DOWN$^3$}
+\key{previous/next plain list item}{S-UP/DOWN\notetwo}
 
 \section{Structure Editing}
 
@@ -310,17 +306,16 @@
 \key{turn item/line into headline}{C-c *}
 \key{promote/demote heading}{M-LEFT/RIGHT}
 \metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
-
 \metax{move subtree/list item up/down}{M-S-UP/DOWN}
 \metax{sort subtree/region/plain-list}{C-c \^{}}
 \metax{clone a subtree}{C-c C-x c}
-\metax{refile subtree}{C-c C-w}
 \metax{kill/copy subtree}{C-c C-x C-w/M-w}
 \metax{yank subtree}{C-c C-x C-y or C-y}
 \metax{narrow buffer to subtree / widen}{C-x n s/w}
 
-\section{Archiving}
-
+\section{Capture - Refile - Archiving}
+\key{capture a new item (C-u C-u = goto last)}{C-c c \noteone}
+\key{refile subtree (C-u C-u = goto last)}{C-c C-w}
 \key{archive subtree using the default command}{C-c C-x C-a}
 \key{move subtree to archive file}{C-c C-x C-s}
 \key{toggle ARCHIVE tag / to ARCHIVE sibling}{C-c C-x a/A}
@@ -330,7 +325,7 @@
 
 \key{construct a sparse tree by various criteria}{C-c /}
 \key{view TODO's in sparse tree}{C-c / t/T}
-\key{global TODO list in agenda mode}{C-c a t$^1$}
+\key{global TODO list in agenda mode}{C-c a t \noteone}
 \key{time sorted view of current org file}{C-c a L}
 
 \section{Tables}
@@ -428,7 +423,7 @@
 
 \section{Links}
 
-\key{globally store link to the current location}{C-c l$^1$}
+\key{globally store link to the current location}{C-c l \noteone}
 \key{insert a link (TAB completes stored links)}{C-c C-l}
 \key{insert file link with file name completion}{C-u C-c C-l}
 \key{edit (also hidden part of) link at point}{C-c C-l}
@@ -444,35 +439,6 @@
 \key{edit code snippet of file at point}{C-c '}
 \key{toggle inline display of linked images}{C-c C-x C-v}
 
-% {\bf Internal Links}
-
-% \key{\kbd{<<My Target>>}}{\rm target}
-% \key{\kbd{<<<My Target>>>}}{\rm radio target$^2$}
-% \key{\kbd{[[*this text]]}}{\rm find headline}
-% \metax{\kbd{[[this text]]}}{\rm find target or text in buffer}
-% \metax{\kbd{[[this text][description]]}}{\rm optional link text}
-
-% {\bf External Links}
-
-% \key{\kbd{file:/home/dominik/img/mars.jpg}}{\rm file, absolute}
-% \key{\kbd{file:papers/last.pdf}}{\rm file, relative}
-% \key{\kbd{file:projects.org::*that text}}{\rm find headline}
-% \key{\kbd{file:projects.org::find me}}{\rm find trgt/string}
-% %\key{\kbd{file:projects.org::/regexp/}}{\rm regexp search}
-% \key{\kbd{http://www.astro.uva.nl/~dominik}}{\rm on the web}
-% \key{\kbd{mailto:adent@galaxy.net}}{\rm Email address}
-% \key{\kbd{news:comp.emacs}}{\rm Usenet group}
-% \key{\kbd{bbdb:Richard Stallman}}{\rm BBDB person}
-% \key{\kbd{gnus:group}}{\rm GNUS group}
-% \key{\kbd{gnus:group\#id}}{\rm GNUS message}
-% \key{\kbd{vm|wl|mhe|rmail:folder}}{\rm Mail folder}
-% \key{\kbd{vm|wl|mhe|rmail:folder\#id}}{\rm Mail message}
-% \key{\kbd{info:emacs:Regexps}}{\rm Info file:node}
-% \key{\kbd{shell:ls *.org}}{\rm shell command}
-% \key{\kbd{elisp:(calendar)}}{\rm elisp form}
-% \metax{\kbd{[[external link][description]]}}{\rm optional link text}
-% %\key{\kbd{vm://myself@some.where.org/folder\#id}}{\rm VM remote}
-
 \section{Working with Code (Babel)}
 
 \key{execute code block at point}{C-c C-c}
@@ -494,25 +460,6 @@
 \key{load expanded body of 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{Remember-mode Integration}
-
-% See the manual for how to make remember.el use Org-mode links and
-% files.  The note-finishing command \kbd{C-c C-c} will first prompt for
-% an org file. In the file, find a location with:
-
-% \key{rotate subtree visibility}{TAB}
-% \key{next heading}{DOWN}
-% \key{previous heading}{UP}
-
-% Insert the note with one of the following: 
-
-% \key{as sublevel of heading at cursor}{RET}
-% \key{right here (cursor not on heading)}{RET}
-% \key{before current heading}{LEFT}
-% \key{after current heading}{RIGHT}
-% \key{shortcut to end of buffer (cursor at buf-start)}{RET}
-% \key{Abort}{q}
-
 \section{Completion}
 
 In-buffer completion completes TODO keywords at headline start, TeX
@@ -538,11 +485,7 @@
 
 \key{set the priority of the current item}{C-c , [ABC]}
 \key{remove priority cookie from current item}{C-c , SPC}
-\key{raise/lower priority of current item}{S-UP/DOWN$^3$}
-%\key{lower priority of current item}{S-DOWN$^3$}
-
-%\key{\kbd{\#+SEQ_TODO: TODO TRY BLUFF DONE}}{\rm todo workflow}
-%\key{\kbd{\#+TYP_TODO: Phil home work DONE}}{\rm todo types}
+\key{raise/lower priority of current item}{S-UP/DOWN\notetwo}
 
 \key{insert new checkbox item in plain list}{M-S-RET}
 \key{toggle checkbox(es) in region/entry/at point}{C-c C-x C-b}
@@ -585,8 +528,8 @@
 \key{insert SCHEDULED timestamp}{C-c C-s}
 \key{create sparse tree with all deadlines due}{C-c / d}
 \key{the time between 2 dates in a time range}{C-c C-y}
-\key{change timestamp at cursor by $\pm 1$ day}{S-RIGHT/LEFT$^3$}
-\key{change year/month/day at cursor by $\pm 1$}{S-UP/DOWN$^3$}
+\metax{change timestamp at cursor $\pm 1$ day}{S-RIGHT/LEFT\notetwo}
+\key{change year/month/day at cursor by $\pm 1$}{S-UP/DOWN\notetwo}
 \key{access the calendar for the current date}{C-c >}
 \key{insert timestamp matching date in calendar}{C-c <}
 \key{access agenda for current date}{C-c C-o}
@@ -615,15 +558,15 @@
 \key{cycle through agenda file list}{C-'}
 \key{set/remove restriction lock}{C-c C-x </>}
 
-\key{compile agenda for the current week}{C-c a a$^1$}
-\key{compile global TODO list}{C-c a t$^1$}
-\key{compile TODO list for specific keyword}{C-c a T$^1$}
-\key{match tags, TODO kwds, properties}{C-c a m$^1$}
-\key{match only in TODO entries}{C-c a M$^1$}
-\key{find stuck projects}{C-c a \#$^1$}
-\key{show timeline of current org file}{C-c a L$^1$}
-\key{configure custom commands}{C-c a C$^1$}
-%\key{configure stuck projects}{C-c a !$^1$}
+\key{compile agenda for the current week}{C-c a a \noteone}
+\key{compile global TODO list}{C-c a t \noteone}
+\key{compile TODO list for specific keyword}{C-c a T \noteone}
+\key{match tags, TODO kwds, properties}{C-c a m \noteone}
+\key{match only in TODO entries}{C-c a M \noteone}
+\key{find stuck projects}{C-c a \# \noteone}
+\key{show timeline of current org file}{C-c a L \noteone}
+\key{configure custom commands}{C-c a C \noteone}
+%\key{configure stuck projects}{C-c a ! \noteone}
 \key{agenda for date at cursor}{C-c C-o}
 
 {\bf Commands available in an agenda buffer}
@@ -664,10 +607,10 @@
 \key{set/show tags of current headline}{: / T}
 \key{set effort property (prefix=nth)}{e}
 \key{set / compute priority of current item}{, / P}
-\key{raise/lower priority of current item}{S-UP/DOWN$^3$}
+\key{raise/lower priority of current item}{S-UP/DOWN\notetwo}
 \key{run an attachment command}{C-c C-a}
 \key{schedule/set deadline for this item}{C-c C-s/d}
-\key{change timestamp to one day earlier/later}{S-LEFT/RIGHT$^3$}
+\metax{change timestamp one day earlier/later}{S-LEFT/RIGHT\notetwo}
 \key{change timestamp to today}{>}
 \key{insert new entry into diary}{i}
 \newcolumn
@@ -713,43 +656,6 @@
 \key{toggle fixed width for entry or region}{C-c :}
 \key{toggle pretty display of scripts, entities}{C-c C-x {\tt\char`\\}}
 
-%{\bf HTML formatting}
-
-%\key{make words {\bf bold}}{*bold*}
-%\key{make words {\it italic}}{/italic/}
-%\key{make words \underbar{underlined}}{_underlined_}
-%\key{sub- and superscripts}{x\^{}3, J_dust}
-%\key{\TeX{}-like macros}{\\alpha, \\to}
-%\key{typeset lines in fixed width font}{start with :}
-%\key{tables are exported as HTML tables}{start with |}
-%\key{links become HTML links}{http:... etc}
-%\key{include html tags}{@<b>...@</b>}
-
-%{\bf Export options}
-%
-%Include additional information for export by putting these anywhere in the
-%org file.  Use {\tt M-TAB} completion to make sure to get the right
-%keywords. {\tt M-TAB} again just after keyword is complete inserts examples.
-%
-%\key{the title to be shown}{\#+TITLE:}
-%\key{the author}{\#+AUTHOR:}
-%\key{authors email address}{\#+EMAIL:}
-%\key{language code for html}{\#+LANGUAGE:}
-%\key{free text description of file}{\#+TEXT:}
-%\key{... which can carry over multiple lines}{\#+TEXT:}
-%\key{settings for the export process}{\#+OPTIONS:}
-
-%\key{set number of headline levels for export}{H:2}
-%\key{turn on/off section numbers}{num:t}
-%\key{turn on/off table of contents}{toc:t}
-%\key{turn on/off linebreak preservation}{\\n:nil}
-%\key{turn on/off quoted html tags}{@:t}
-%\key{turn on/off fixed width sections}{::t}
-%\key{turn on/off tables}{|:t}
-%\key{turn on/off \TeX\ syntax for sub/super-scripts}{\^{}:t}
-%\key{turn on/off emphasised text}{*:nil}
-%\key{turn on/off \TeX\ macros}{TeX:t}
-
 {\bf Comments: Text not being exported}
 
 Lines starting with \kbd{\#} and subtrees starting with COMMENT are
@@ -763,13 +669,10 @@
 \metax{update all dynamic blocks}{C-u C-c C-x C-u}
 
 \section{Notes}
-$^1$ This is only a suggestion for a binding of this command.  Choose
+[1] This is only a suggestion for a binding of this command.  Choose
 your own key as shown under INSTALLATION.
 
-$^2$ After changing a \kbd{\#+KEYWORD} or \kbd{<<<target>>>} line,
-press \kbd{C-c C-c} with the cursor still in the line to update.
-
-$^3$ Keybinding affected by {\tt org-support-shift-select} and
+[2] Keybinding affected by {\tt org-support-shift-select} and also
  {\tt org-replace-disputed-keys}.
 
 \copyrightnotice
--- a/lisp/org/ChangeLog	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ChangeLog	Sat Dec 11 17:42:53 2010 +0100
@@ -1,3 +1,684 @@
+2010-12-11  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* org-footnote.el (org-footnote-create-definition): Place
+	Footnotes section before message-signature-separator also in modes
+	derived from message-mode.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org.el (org-make-tags-matcher): Remove useless cat-p value.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org.el (org-entry-properties): Enhance docstring.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-list.el (org-list-top-point-with-indent)
+	(org-list-bottom-point-with-indent): Pay also attention to
+	'original-indentation property of text, as blocks are put to
+	column 0 upon exporting.
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* ob.el (org-babel-remove-temporary-directory): Handle exception
+	with message informing of failure to remove directory.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-clojure.el (org-babel-header-arg-names:clojure): Add
+	`package' to the list of Clojure header arguments which will be read
+	from heading properties.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-inlinetask.el (org-inlinetask-export-templates): Add
+	Sébastien Vauban's suggestion for LaTeX export in docstring. This is
+	not default as it requires an additional LaTeX package: "todonotes".
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-inlinetask.el (org-inlinetask-export-templates): New variable.
+
+	* org-inlinetask.el (org-inlinetask-export-handler): Make use of
+	templates to export inline tasks.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org.el (org-current-level): Ignore inline tasks when getting current
+	level of entry.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org.el (org-indent-line-function): Ignore drawers inside inline
+	tasks  if the line to indent isn't inside an inline task itself.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-inlinetask.el (org-inlinetask-get-task-level): New function.
+
+	* org-indent.el (org-indent-add-properties): Find true level of
+	indentation wrt inline tasks.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-inlinetask.el (org-inlinetask-outline-regexp): New function.
+
+	* org-inlinetask.el (org-inlinetask-goto-beginning): New function.
+
+	* org-inlinetask.el (org-inlinetask-goto-end): New function.
+
+	* org.el (org-mark-subtree): New command.
+
+	* org.el (org-speed-commands-default, org-mode-map): Make use of
+	new command.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-inlinetask.el (org-inlinetask-export-handler): Remove protection
+	from @<span class...> so it can be removed during LaTeX export.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-insert-result): More informative code block
+	evaluation messages.
+
+2010-12-11  Matt Lundin  <mdl@imapmail.org>
+
+	* org.el (org-make-heading-search-string): Optionally limit number
+	of lines stored in file link search strings.
+	(org-context-in-file-links) Add option to set to integer specifying
+	number of lines.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-capture.el (org-capture-finalize): New prefix argument
+	STAY-WITH-CAPTURE.
+	(org-capture-refile): Improve docstring.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-sql.el (org-babel-execute:sql): Add msosql as optional sql
+	interaction engine.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-agenda.el (org-agenda-list):
+	(org-agenda-goto-today): Use `org-today'.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-make-header): Swap \begin{document}
+	and the title/author definitions.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-macs.el: Better backup definition for
+	`with-silent-modifications'.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-python.el (org-babel-execute:python): Rename "prefix" to
+	"preamble".
+	(org-babel-python-evaluate): Rename "prefix" to "preamble".
+	(org-babel-python-evaluate-external-process): Rename "prefix" to
+	"preamble".
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-examplize-region): Check if `end' is a marker
+	or a point and handle appropriately.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-sql.el (org-babel-execute:sql): Explicitly set field
+	separator to \t when importing tabular data.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-agenda.el (org-agenda-custom-commands-local-options):
+	Allow org-agenda-span to be a symbol.
+	(org-agenda-ndays): Make obsolete.
+	(org-agenda-span): New variable superseding org-agenda-ndays.
+	(org-agenda-menu): Use org-agenda-current-span.
+	(org-agenda-current-span): New local variable storing current
+	span.
+	(org-agenda-list): Take a span instead of ndays as argument.
+	This function is now responsible for computing the ndays based
+	on span.
+	(org-agenda-ndays-to-span): Return span only if number of days
+	really matches.
+	(org-agenda-span-to-ndays): New function.
+	(org-agenda-manipulate-query): Use org-agenda-compute-starting-span.
+	(org-agenda-goto-today): Use org-agenda-compute-starting-span.
+	(org-agenda-later): Do not give compute a new span, use the
+	current one.
+	(org-agenda-day-view, org-agenda-week-view)
+	(org-agenda-month-view, org-agenda-year-view): Stop touching
+	org-agenda-ndays.
+	(org-agenda-change-time-span): Only compute starting-span.
+	(org-agenda-compute-starting-span): New function derived from
+	the old org-agenda-compute-time-span.
+	(org-agenda-set-mode-name): Compute mode based on
+	org-agenda-current-span.
+	(org-agenda-span-name): New function.
+
+2010-12-11  Robert Pluim  <rpluim@gmail.com>  (tiny change)
+
+	* org-agenda.el (org-agenda-toggle-deadlines): Fix docstring.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-clock.el (org-quarter-to-date): Define variables.
+	(org-clock-special-range): Defin variables.  Use org-floor*.
+	(org-clocktable-write-default): Define tcol.
+
+	* org-compat.el (org-floor*): New function.
+
+	* org-complete.el: New file.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-clock.el (org-clocktable-write-default): Fix the % formula.
+
+2010-12-11  Matt Lundin  <mdl@imapmail.org>
+
+	* org-agenda.el: (org-format-agenda-item) The value of
+	org-category is not converted to a string unless it is defined.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-python.el (org-babel-execute:python): Pass the new "prefix"
+	header argument through to external evaluation.
+	(org-babel-python-evaluate): Pass the new "prefix" header argument
+	through to external evaluation.
+	(org-babel-python-evaluate-external-process): When specified prepend
+	"prefix" to the file used in external evaluation.
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* ob-python.el (org-babel-python-evaluate-session): Change python
+	module name from 'pp' to 'pprint'.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-R.el (org-babel-R-evaluate-session): Removing empty lines
+	from R session output, these are often the result of variable
+	assignments.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-sql.el (orgtbl-to-csv): Declaring an external function to
+	fix a compiler warning.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-eval.el (require): No longer require ob.el to allow
+	requiring by ob.el.
+
+	* ob.el (ob-eval): Require ob-eval.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-confirm-evaluate): Show code block's name when
+	it is available during evaluation query.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-sql.el (org-babel-expand-body:sql): Expand the body of a sql
+	code block.
+	(org-babel-execute:sql): Use sql specific body expansion function.
+	(org-babel-sql-expand-vars): Insert variables into a sql code block.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-insert-result): Using markers instead of
+	points for more robust buffer anchors.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-capture.el: Use org-today.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-habit.el: Use org-today.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org.el (org-auto-repeat-maybe): Use org-today.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* test-org.el (test-org/org-link-escape-url-with-escaped-char): Add
+	test for escaping and unescaping url with already escaped char.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-clock.el (org-day-of-week): New function.
+	(org-quarter-to-date): New function.
+	(org-clock-special-range): Implement quarters.
+
+2010-12-11  Sébastien Vauban  <wxhgmqzgwmuf@spammotel.com>
+
+	* org.el (org-complete-tags-always-offer-all-agenda-tags): Fix
+	docstring.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-agenda.el (org-format-agenda-item): Convert category to a string
+	if it is a symbol. This fixes the following call to
+	org-agenda-get-category-icon which fails if category is not a string.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-clojure.el: Updated requirements documentation to mention
+	the minimum version of Clojure.
+	(org-babel-expand-body:clojure): Fully qualified function name.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-latex.el (org-export-latex-lists): do not add an
+	unnecessary newline character after a list.
+
+	* org-list.el (org-list-bottom-point-with-indent): ensure bottom
+	point is just after a non blank line.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-examplize-region): Remove old assertion which
+	no longer applies to the result insertion code.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-python.el (org-babel-execute:python): Use a :return header
+	argument for external evaluation in which the code block body need
+	be wrapped in a function
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-clojure.el (org-babel-expand-body:clojure): Trapped free
+	variable.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-edit-special): Edit formulas when in TBLMF line
+
+2010-12-11  Allen S. Rout  <asr@ufl.edu>  (tiny change)
+
+	* org-capture.el (org-capture-after-finalize-hook): New hook.
+	(org-capture-finalize): Run the new hook.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-clojure.el (org-babel-expand-body:clojure): Support for
+	pretty printing of Clojure code and data.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-insert-result): No longer escape results which
+	will be wrapped in a block.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-eval.el (org-babel-eval-wipe-error-buffer): Fixed compiler
+	warning and added documentation string.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-clojure.el (org-babel-execute:clojure): Remade using slime
+	for all code evaluation.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-beamer.el (org-beamer-sectioning): Allow overlay arguments for
+	the column as well.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-confirm-evaluate): More descriptive message
+	when evaluation is aborted or disabled.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-insert-result): Responds to new "wrap" header
+	argument.
+	(org-babel-merge-params): Includes new "wrap" header argument in
+	one of the results header argument exclusive groups.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org-macs.el (with-silent-modifications): Fix condition for
+	with-silent-modification.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-parse-header-arguments): Stripping trailing
+	spaces off of header arguments (even the first one).
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-sh.el (org-babel-sh-var-to-sh): Wrap end token of heredoc in
+	single quotes which is the best practice.
+	(org-babel-sh-table-or-results): Use `org-babel-script-escape' for
+	more robust parsing of shell output.
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* org.el (org-additional-option-like-keywords): Add more keywords,
+	and colons to some old ones.
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* ob-eval.el (org-babel-error-buffer-name): Define new variable.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-python.el (org-babel-python-table-or-string): Using
+	`org-babel-script-escape' for reading string input from scripting
+	languages.
+
+2010-12-11  Achim Gratz  <Stromeko@nexgo.de>  (tiny change)
+
+	* org-macs.el (org-called-interactively-p): Wrap function call in
+	with-no-warnings.
+	(with-silent-modifications) Declare macro for Emacs < 23.2.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org-test.el (org-test-current-file): New function.  Run all tests
+	for current file.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-parse-header-arguments): Removed addition of
+	":" to singleton first header arguments as it was leading to errors.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* test-org.el (test-org/org-link-escape-ascii-character)
+	(test-org/org-link-escape-ascii-ctrl-character)
+	(test-org/org-link-escape-multibyte-character)
+	(test-org/org-link-escape-custom-table)
+	(test-org/org-link-escape-custom-table-merge)
+	(test-org/org-link-unescape-ascii-character)
+	(test-org/org-link-unescape-ascii-ctrl-character)
+	(test-org/org-link-unescape-multibyte-character)
+	(test-org/org-link-unescape-ascii-extended-char): New tests for
+	unicode aware percent escaping.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-make-header): Run the title through
+	`org-export-latex-fontify-headline'.
+	(org-export-latex-fontify-headline): Do the protection of math
+	snippets also here.
+
+2010-12-11  Richard Lawrence  <richard.lawrence@berkeley.edu>
+
+	* org-latex.el (org-export-as-latex): Sent the section title
+	through the preprocessor.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-html.el (org-html-level-start): Mark listified headings
+	with a custom id.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-open-at-point): Don't do footnote action if cursor is
+	on a bracket link.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-edit-special): Check also for TBLFM line.
+
+2010-12-11  Achim Gratz  <Stromeko@Stromeko.DE>  (tiny change)
+
+	* org-clock.el (org-get-clocktable): previous patch incorrectly
+	required whitespace in front of #+BEGIN: and #+END:
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* org-src.el (org-edit-src-code): Allow region to be inherited by
+	edit buffer when mark is one character beyond end of src block.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-list.el (org-cycle-list-bullet): ensure point is at bol before
+	checking item indentation.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-map-src-blocks): Moved to earlier in the file
+	and now autoloading.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-ref.el (org-babel-ref-at-ref-p): Use higher level function
+	for testing list membership.
+
+	* ob.el (org-babel-read-result): Use higher level function for
+	testing list membership.
+	(org-babel-result-end): Use higher level function for testing list
+	membership.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-sqlite.el (ob-eval): Require ob-eval for external command
+	execution.
+	(org-babel-execute:sqlite): No longer uses the init option for
+	passing commands to sqlite.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org.el (org-indent-line-function): Drawers and blocks have no
+	influence on indentation of text below. Also fix indentation
+	problem with a block at column 0 and add a special case for
+	literal examples.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob.el (org-babel-map-src-blocks): Ensure that the file argument
+	is only evaluated once.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-ref.el (org-babel-ref-resolve): Recognize `list' as a unique
+	type of data
+	(org-babel-ref-at-ref-p): Recognize `list' as a unique type of data
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-tangle.el (org-babel-load-file): Can be called interactively.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>  (tiny change)
+
+	* org-table.el (orgtbl-after-send-table-hook): New hook.
+	(orgtbl-ctrl-c-ctrl-c): Run `orgtbl-after-send-table-hook' when a
+	table was sent.
+	(orgtbl-send-table): Return the number of sent tables, or nil if no
+	sending has happened.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-get-priority-function): New option.
+	(org-get-priority): Call `org-get-priority-function' if that
+	has been set.
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* ob-table.el (org-babel-table-truncate-at-newline): Only add
+	"..." if there is something after the newline.
+
+2010-12-11  Achim Gratz  <Stromeko@nexgo.de>  (tiny change)
+
+	* org-clock.el (org-get-clocktable):
+	(org-in-clocktable-p):
+	(org-clocktable-shift):
+	(org-clocktable-steps): Fix regexp to allow for indented clock tables
+
+2010-12-11  Puneeth Chaganti  <punchagan@gmail.com>
+
+	* org-exp.el (org-export-handle-include-files): Support :minlevel
+	property.
+	(org-get-file-contents): New argument minlevel to demote included
+	content.
+
+2010-12-11  Noorul Islam  <noorul@noorul.com>
+
+	* org-latex.el (org-export-latex-hyperref-format): New option.
+	(org-export-latex-href-format): Renamed the existing variable
+	`org-export-latex-hyperref-format' as `org-export-latex-href-format'
+	(org-export-latex-links): Use `org-export-latex-hyperref-format' and
+	`org-export-latex-href-format'
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-calc.el (org-babel-execute:calc): Ensure the *Calculator*
+	buffer exists before it is used.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org-exp.el (org-export-preprocess-string): delaying code block
+	processing a bit to allow correct list parsing in the export string
+
+2010-12-11  Christopher Allan Webber  <cwebber@dustycloud.org>
+
+	* org-agenda.el (org-agenda-timegrid-use-ampm): New option.
+	(org-agenda-time-of-day-to-ampm): New function.
+	(org-agenda-time-of-day-to-ampm-maybe): New function.
+	(org-format-agenda-item): Call org-agenda-time-of-day-to-ampm-maybe.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-faces.el (org-cycle-level-faces): New option.
+
+	* org.el (org-get-level-face): Honor org-cycle-level-faces.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-agenda.el (org-agenda-today): New function.
+	(org-agenda-get-day-face): New function.
+	(org-timeline): Use org-agenda-today and org-agenda-get-day-face.
+	(org-agenda-list): Use org-agenda-today and org-agenda-get-day-face.
+	(org-todo-list): Use org-agenda-today.
+	(org-get-all-dates): Use org-agenda-today.
+	(org-agenda-day-face-function): New variable.
+	(org-agenda-get-day-face): Use org-agenda-day-face-function.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-ctrl-c-ctrl-c): Consider sending a radio table also
+	in Org.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-html.el (org-export-as-html): Do not treat partially
+	protected lines as if they were fully protected.
+
+2010-12-11  Dan Davison  <dandavison7@gmail.com>
+
+	* org-exp.el: (org-export-format-source-code-or-example):
+	Remove hard-wired configuration of minted export
+	(org-export-latex-minted-with-line-numbers): Remove variable
+
+2010-12-11  Bastien Guerry  <bzg@altern.org>
+
+	* org-clock.el (org-dblock-write:clocktable): Fix double
+	reference to `link' in let construct.
+	(org-clock-clocktable-formatter): Fix typo in docstring.
+	(org-clocktable-write-default): Fix typo in docstring.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org-protocol.el (org-protocol-unhex-string): Normalize percent
+	escape sequence to upper case letters.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-lob.el (org-babel-lob-get-info): including pass-through
+	header arguments in results variable header argument string
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org-exp.el (org-export-visible): Limit search for in-buffer options
+	beginning of first headline.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org.el (org-open-at-point): Remove stale link handler for news:
+	links.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-clock.el (org-clocktable-write-default): Better handling of
+	narrowing.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* list/org-agenda.el (org-agenda-category-icon-alist): Fix defcustom
+	type.
+
+2010-12-11  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+	* org.el (org-indent-line-function): simplify code and remove bug that
+	would insert a tab at the beginning of the line when trying to
+	indent the item.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org.el (org-diary-sexp-entry): Split sexp result strings at semicolon.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-agenda.el (org-agenda-prefix-format): Insert place holder
+	for icon.
+	(org-agenda-category-icon-alist): New option.
+	(org-agenda-get-category-icon): New function.
+	(org-format-agenda-item): Support for icons.
+	(org-compile-prefix-format): Support for icons.
+
+2010-12-11  Julien Danjou  <julien@danjou.info>
+
+	* org-compat.el: Create defalias for `string-match-p' and
+	looking-at-p.
+
+2010-12-11  Eric Schulte  <schulte.eric@gmail.com>
+
+	* ob-calc.el (org-babel-execute:calc): support for variables --
+	converts :var variables in calc variables
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-sparse-tree): Mention [r] in dispatch menu
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-list.el (org-list-parse-list): Use `org-looking-at-p'.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-id.el (org-id-store-link): Test for org-mode before checking
+	for IDs.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org-test.el (org-test-current-defun): `which-function' does not
+	return a list, but the name of the function.
+
+2010-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-shorten-string): New function.
+
+	* org-exp.el (org-export-convert-protected-spaces): New function.
+	(org-export-preprocess-string): Call
+	`org-export-convert-protected-spaces' to handle new hard spaces.
+
+2010-12-11  David Maus  <dmaus@ictsoc.de>
+
+	* org.el (org-narrow-to-subtree): Check for heading that ends at end
+	of buffer.
+
 2010-11-12  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-capture.el (org-capture-templates): Remove autoload from
--- a/lisp/org/ob-C.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-C.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-R.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-R.el	Sat Dec 11 17:42:53 2010 +0100
@@ -2,11 +2,10 @@
 
 ;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
-;;	Dan Davison
+;; Author: Eric Schulte, Dan Davison
 ;; Keywords: literate programming, reproducible research, R, statistics
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -277,16 +276,18 @@
       (butlast
        (delq nil
 	     (mapcar
-	      (lambda (line) ;; cleanup extra prompts left in output
-		(if (string-match
-		     "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
-		    (substring line (match-end 1))
-		  line))
-	      (org-babel-comint-with-output (session org-babel-R-eoe-output)
-		(insert (mapconcat #'org-babel-chomp
-				   (list body org-babel-R-eoe-indicator)
-				   "\n"))
-		(inferior-ess-send-input)))) 2) "\n"))))
+	      (lambda (line) (when (> (length line) 0) line))
+	      (mapcar
+	       (lambda (line) ;; cleanup extra prompts left in output
+		 (if (string-match
+		      "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
+		     (substring line (match-end 1))
+		   line))
+	       (org-babel-comint-with-output (session org-babel-R-eoe-output)
+		 (insert (mapconcat #'org-babel-chomp
+				    (list body org-babel-R-eoe-indicator)
+				    "\n"))
+		 (inferior-ess-send-input)))))) "\n"))))
 
 (defun org-babel-R-process-value-result (result column-names-p)
   "R-specific processing of return value.
--- a/lisp/org/ob-asymptote.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-asymptote.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-calc.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-calc.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,11 +1,11 @@
 ;;; ob-calc.el --- org-babel functions for calc code evaluation
 
-;; Copyright (C) 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2010  Free Software Foundation, Inc
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -40,25 +40,55 @@
 
 (defun org-babel-execute:calc (body params)
   "Execute a block of calc code with Babel."
-  (mapcar
-   (lambda (line)
-     (when (> (length line) 0)
-       (if (string= "'" (substring line 0 1))
-	   (funcall (lookup-key calc-mode-map (substring line 1)) nil)
-	 (calc-push-list
-	  (list ((lambda (res)
-		   (cond
-		    ((numberp res) res)
-		    ((listp res) (error "calc error \"%s\" on input \"%s\""
-					(cadr res) line))
-		    (t res))
-		   (if (numberp res) res (math-read-number res)))
-		 (calc-eval line)))))))
-   (mapcar #'org-babel-trim
-	   (split-string (org-babel-expand-body:calc body params) "[\n\r]")))
+  (unless (get-buffer "*Calculator*")
+    (save-window-excursion (calc) (calc-quit)))
+  (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+	 (var-syms (mapcar #'car vars))
+	 (var-names (mapcar #'symbol-name var-syms)))
+    (mapc
+     (lambda (pair)
+       (calc-push-list (list (cdr pair)))
+       (calc-store-into (car pair)))
+     vars)
+    (mapc
+     (lambda (line)
+       (when (> (length line) 0)
+	 (cond
+	  ;; simple variable name
+	  ((member line var-names) (calc-recall (intern line)))
+	  ;; stack operation
+	  ((string= "'" (substring line 0 1))
+	   (funcall (lookup-key calc-mode-map (substring line 1)) nil))
+	  ;; complex expression
+	  (t
+	   (calc-push-list
+	    (list ((lambda (res)
+		     (cond
+		      ((numberp res) res)
+		      ((math-read-number res) (math-read-number res))
+		      ((listp res) (error "calc error \"%s\" on input \"%s\""
+					  (cadr res) line))
+		      (t (calc-eval
+			  (math-evaluate-expr
+			   ;; resolve user variables, calc built in
+			   ;; variables are handled automatically
+			   ;; upstream by calc
+			   (mapcar (lambda (el)
+				     (if (and (consp el) (equal 'var (car el))
+					      (member (cadr el) var-syms))
+					 (progn
+					   (calc-recall (cadr el))
+					   (prog1 (calc-top 1)
+					     (calc-pop 1)))
+				       el))
+				   ;; parse line into calc objects
+				   (car (math-read-exprs line))))))))
+		   (calc-eval line))))))))
+     (mapcar #'org-babel-trim
+	     (split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
   (save-excursion
-    (set-buffer (get-buffer "*Calculator*"))
-    (calc-eval (calc-top 1))))
+    (with-current-buffer (get-buffer "*Calculator*")
+      (calc-eval (calc-top 1)))))
 
 (provide 'ob-calc)
 
--- a/lisp/org/ob-clojure.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-clojure.el	Sat Dec 11 17:42:53 2010 +0100
@@ -2,10 +2,10 @@
 
 ;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
 
-;; Author: Joel Boehland
+;; Author: Joel Boehland, Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -24,14 +24,14 @@
 
 ;;; Commentary:
 
-;;; ob support for evaluating clojure code
+;;; support for evaluating clojure code, relies on slime for all eval
 
 ;;; Requirements:
 
-;;; A working clojure install. This also implies a working java executable
-;;; clojure-mode
-;;; slime
-;;; swank-clojure
+;;; - clojure (at least 1.2.0)
+;;; - clojure-mode
+;;; - slime
+;;; - swank-clojure
 
 ;;; By far, the best way to install these components is by following
 ;;; the directions as set out by Phil Hagelberg (Technomancy) on the
@@ -39,277 +39,47 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
-(eval-when-compile (require 'cl))
 
-(declare-function slime-eval-async "ext:slime" (sexp &optional cont package))
 (declare-function slime-eval "ext:slime" (sexp &optional package))
-(declare-function swank-clojure-concat-paths "ext:slime" (paths))
-(declare-function slime "ext:slime" (&optional command coding-system))
-(declare-function slime-output-buffer "ext:slime" (&optional noprompt))
-(declare-function slime-filter-buffers "ext:slime" (predicate))
 
 (add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
 
 (defvar org-babel-default-header-args:clojure '())
-
-(defvar org-babel-clojure-wrapper-method
-  "
-(defn spit
-  [f content]
-  (with-open [#^java.io.PrintWriter w
-                 (java.io.PrintWriter.
-                   (java.io.BufferedWriter.
-                     (java.io.OutputStreamWriter.
-                       (java.io.FileOutputStream.
-                         (java.io.File. f)))))]
-      (.print w content)))
-
-(defn main
-  []
-  %s)
-
-(spit \"%s\" (str (main)))")
-;;";; <-- syntax highlighting is messed without this double quote
-
-;;taken mostly from clojure-test-mode.el
-(defun org-babel-clojure-clojure-slime-eval (string &optional handler)
-  "Evaluate a STRING of clojure code using `slime-eval-async'."
-  (slime-eval-async `(swank:eval-and-grab-output ,string)
-                    (or handler #'identity)))
-
-(defun org-babel-clojure-slime-eval-sync (string)
-  "Evaluate a STRING of clojure code using `slime-eval'."
-  (slime-eval `(swank:eval-and-grab-output ,string)))
-
-;;taken from swank-clojure.el
-(defvar swank-clojure-binary)
-(defvar swank-clojure-classpath)
-(defvar swank-clojure-java-path)
-(defvar swank-clojure-extra-vm-args)
-(defvar swank-clojure-library-paths)
-(defvar swank-clojure-extra-classpaths)
-(defun org-babel-clojure-babel-clojure-cmd ()
-  "Create the command to start clojure according to current settings."
-  (or (when swank-clojure-binary
-	(if (listp swank-clojure-binary)
-	    swank-clojure-binary
-	  (list swank-clojure-binary)))
-      (when swank-clojure-classpath
-	(delq
-	 nil
-	 (append
-	  (list swank-clojure-java-path)
-	  swank-clojure-extra-vm-args
-	  (list
-	   (when swank-clojure-library-paths
-	     (concat "-Djava.library.path="
-		     (swank-clojure-concat-paths swank-clojure-library-paths)))
-	   "-classpath"
-	   (swank-clojure-concat-paths
-	    (append
-	     swank-clojure-classpath
-	     swank-clojure-extra-classpaths))
-	   "clojure.main"))))
-      (error "%s" (concat "You must specifiy either a `swank-clojure-binary' "
-			  "or a `swank-clojure-classpath'"))))
-
-(defun org-babel-clojure-table-or-string (results)
-  "Convert RESULTS to an elisp value.
-If RESULTS looks like a table, then convert to an Emacs-lisp
-table, otherwise return the results as a string."
-  (org-babel-read
-   (if (string-match "^\\[.+\\]$" results)
-       (org-babel-read
-        (concat "'"
-                (replace-regexp-in-string
-                 "\\[" "(" (replace-regexp-in-string
-                            "\\]" ")" (replace-regexp-in-string
-                                       ", " " " (replace-regexp-in-string
-                                                 "'" "\"" results))))))
-     results)))
-
-(defun org-babel-clojure-var-to-clojure (var)
-  "Convert an elisp value into a clojure variable.
-The elisp value VAR is converted into a string of clojure source
-code specifying a variable of the same value."
-  (if (listp var)
-      (format "'%s" var)
-    (format "%S" var)))
-
-(defun org-babel-clojure-build-full-form (body vars)
-  "Construct a clojure let form with VARS as the let variables."
-  (let ((vars-forms
-	 (mapconcat ;; define any variables
-	  (lambda (pair)
-	    (format "%s %s"
-		    (car pair) (org-babel-clojure-var-to-clojure (cdr pair))))
-	  vars "\n      "))
-	(body (org-babel-trim body)))
-    (if (> (length vars-forms) 0)
-	(format "(let [%s]\n  %s)" vars-forms body)
-      body)))
-
-(defun org-babel-prep-session:clojure (session params)
-  "Prepare SESSION according to the header arguments specified in PARAMS."
-  (require 'slime) (require 'swank-clojure)
-  (let* ((session-buf (org-babel-clojure-initiate-session session))
-         (vars (mapcar #'cdr (org-babel-get-header params :var)))
-         (var-lines (mapcar ;; define any top level session variables
-                     (lambda (pair)
-                       (format "(def %s %s)\n" (car pair)
-                               (org-babel-clojure-var-to-clojure (cdr pair))))
-                     vars)))
-    session-buf))
-
-(defun org-babel-load-session:clojure (session body params)
-  "Load BODY into SESSION."
-  (require 'slime) (require 'swank-clojure)
-  (save-window-excursion
-    (let ((buffer (org-babel-prep-session:clojure session params)))
-      (with-current-buffer buffer
-        (goto-char (point-max))
-        (insert (org-babel-chomp body)))
-      buffer)))
-
-(defvar org-babel-clojure-buffers '())
-(defvar org-babel-clojure-pending-sessions '())
-
-(defun org-babel-clojure-session-buffer (session)
-  "Return the buffer associated with SESSION."
-  (cdr (assoc session org-babel-clojure-buffers)))
-
-(defun org-babel-clojure-initiate-session-by-key (&optional session)
-  "Initiate a clojure session in an inferior-process-buffer.
-If there is not a current inferior-process-buffer in SESSION
-then create one.  Return the initialized session."
-  (save-window-excursion
-    (let* ((session (if session
-                        (if (stringp session) (intern session)
-                          session)
-		      :default))
-           (clojure-buffer (org-babel-clojure-session-buffer session)))
-      (unless (and clojure-buffer (buffer-live-p clojure-buffer))
-        (setq org-babel-clojure-buffers
-	      (assq-delete-all session org-babel-clojure-buffers))
-        (push session org-babel-clojure-pending-sessions)
-        (slime)
-        ;; we are waiting to finish setting up which will be done in
-        ;; org-babel-clojure-session-connected-hook below.
-        (let ((timeout 9))
-          (while (and (not (org-babel-clojure-session-buffer session))
-                      (< 0 timeout))
-            (message "Waiting for clojure repl for session: %s ... %i"
-		     session timeout)
-            (sit-for 1)
-            (decf timeout)))
-        (setq org-babel-clojure-pending-sessions
-              (remove session org-babel-clojure-pending-sessions))
-        (unless (org-babel-clojure-session-buffer session)
-          (error "Couldn't create slime clojure process"))
-        (setq clojure-buffer (org-babel-clojure-session-buffer session)))
-      session)))
-
-(defun org-babel-clojure-initiate-session (&optional session params)
-  "Return the slime-clojure repl buffer bound to SESSION.
-Returns nil if \"none\" is specified."
-  (require 'slime) (require 'swank-clojure)
-  (unless (and (stringp session) (string= session "none"))
-    (org-babel-clojure-session-buffer
-     (org-babel-clojure-initiate-session-by-key session))))
-
-(defun org-babel-clojure-session-connected-hook ()
-  "Finish  binding an org-babel session to a slime-clojure repl."
-  (let ((pending-session (pop org-babel-clojure-pending-sessions)))
-    (when pending-session
-      (save-excursion
-        (switch-to-buffer (slime-output-buffer))
-        (rename-buffer
-	 (if (stringp pending-session)
-	     pending-session (symbol-name pending-session)))
-        (org-babel-clojure-bind-session-to-repl-buffer
-	 pending-session (slime-output-buffer))))))
-
-(add-hook 'slime-connected-hook 'org-babel-clojure-session-connected-hook)
-
-(defun org-babel-clojure-bind-session-to-repl-buffer (session repl-buffer)
-  "Associate SESSION with REPL-BUFFER."
-  (when (stringp session) (setq session (intern session)))
-  (setq org-babel-clojure-buffers
-        (cons (cons session repl-buffer)
-              (assq-delete-all session org-babel-clojure-buffers))))
-
-(defun org-babel-clojure-repl-buffer-pred ()
-  "Test whether the current buffer is an active slime-clojure
-repl buffer."
-  (and (buffer-live-p (current-buffer)) (eq major-mode 'slime-repl-mode)))
-
-(defun org-babel-clojure-bind-session-to-repl (session)
-  "Bind SESSION to a clojure repl."
-  (interactive "sEnter session name: ")
-  (let ((repl-bufs (slime-filter-buffers 'org-babel-clojure-repl-buffer-pred)))
-    (unless repl-bufs (error "No existing slime-clojure repl buffers exist"))
-    (let ((repl-buf (read-buffer "Choose slime-clojure repl: " repl-bufs t)))
-      (org-babel-clojure-bind-session-to-repl-buffer session repl-buf))))
-
-(defun org-babel-clojure-evaluate-external-process
-  (buffer body &optional result-type)
-  "Evaluate the body in an external process."
-  (let ((cmd (format "%s -" (mapconcat #'identity
-				       (org-babel-clojure-babel-clojure-cmd)
-				       " "))))
-    (case result-type
-      (output (org-babel-eval cmd body))
-      (value (let* ((tmp-file (org-babel-temp-file "clojure-")))
-	       (org-babel-eval
-		cmd
-		(format
-		 org-babel-clojure-wrapper-method
-		 body
-		 (org-babel-process-file-name tmp-file 'noquote)))
-	       (org-babel-clojure-table-or-string
-		(org-babel-eval-read-file tmp-file)))))))
-
-(defun org-babel-clojure-evaluate-session (buffer body &optional result-type)
-  "Evaluate the body in the context of a clojure session."
-  (require 'slime) (require 'swank-clojure)
-  (let ((raw nil)
-        (results nil))
-    (with-current-buffer buffer
-      (setq raw (org-babel-clojure-slime-eval-sync body))
-      (setq results (reverse (mapcar #'org-babel-trim raw)))
-      (cond
-       ((equal result-type 'output)
-	(mapconcat #'identity (reverse (cdr results)) "\n"))
-       ((equal result-type 'value)
-	(org-babel-clojure-table-or-string (car results)))))))
-
-(defun org-babel-clojure-evaluate (buffer body &optional result-type)
-  "Pass BODY to the Clojure process in BUFFER.
-If RESULT-TYPE equals 'output then return a list of the outputs
-of the statements in BODY, if RESULT-TYPE equals 'value then
-return the value of the last statement in BODY as elisp."
-  (if buffer
-      (org-babel-clojure-evaluate-session buffer body result-type)
-    (org-babel-clojure-evaluate-external-process buffer body result-type)))
+(defvar org-babel-header-arg-names:clojure '(package))
 
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (org-babel-clojure-build-full-form
-   body (mapcar #'cdr (org-babel-get-header params :var))))
+  (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+	 (result-params (cdr (assoc :result-params params)))
+	 (print-level nil) (print-length nil)
+	 (body (org-babel-trim
+		(if (> (length vars) 0)
+		    (concat "(let ["
+			    (mapconcat
+			     (lambda (var)
+			       (format "%S (quote %S)" (car var) (cdr var)))
+			     vars "\n      ")
+			    "]\n" body ")")
+		  body))))
+    (if (or (member "code" result-params)
+	    (member "pp" result-params))
+	(format (concat "(let [org-mode-print-catcher (java.io.StringWriter.)]"
+			"(clojure.pprint/with-pprint-dispatch %s-dispatch"
+			"(clojure.pprint/pprint %s org-mode-print-catcher)"
+			"(str org-mode-print-catcher)))")
+		(if (member "code" result-params) "code" "simple") body)
+      body)))
 
 (defun org-babel-execute:clojure (body params)
-  "Execute a block of Clojure code."
+  "Execute a block of Clojure code with Babel."
   (require 'slime) (require 'swank-clojure)
-  (let* ((body (org-babel-expand-body:clojure body params))
-         (session (org-babel-clojure-initiate-session
-		   (cdr (assoc :session params)))))
-    (org-babel-reassemble-table
-     (org-babel-clojure-evaluate session body (cdr (assoc :result-type params)))
-     (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))))))
+  (with-temp-buffer
+    (insert (org-babel-expand-body:clojure body params))
+    (read
+     (slime-eval
+      `(swank:interactive-eval-region
+        ,(buffer-substring-no-properties (point-min) (point-max)))
+      (cdr (assoc :package params))))))
 
 (provide 'ob-clojure)
 
--- a/lisp/org/ob-comint.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-comint.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-css.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-css.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-ditaa.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-ditaa.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-dot.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-dot.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-emacs-lisp.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-emacs-lisp.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,11 +1,11 @@
 ;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation
 
-;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010  Free Software Foundation, Inc
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-eval.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-eval.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -28,12 +28,13 @@
 ;; shell commands.
 
 ;;; Code:
-(require 'ob)
 (eval-when-compile (require 'cl))
 
+(defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
+
 (defun org-babel-eval-error-notify (exit-code stderr)
   "Open a buffer to display STDERR and a message with the value of EXIT-CODE."
-  (let ((buf (get-buffer-create "*Org-Babel Error Output*")))
+  (let ((buf (get-buffer-create org-babel-error-buffer-name)))
     (with-current-buffer buf
       (goto-char (point-max))
       (save-excursion (insert stderr)))
@@ -44,7 +45,7 @@
   "Run CMD on BODY.
 If CMD succeeds then return its results, otherwise display
 STDERR with `org-babel-eval-error-notify'."
-  (let ((err-buff (get-buffer-create "*Org-Babel Error*")) exit-code)
+  (let ((err-buff (get-buffer-create " *Org-Babel Error*")) exit-code)
     (with-current-buffer err-buff (erase-buffer))
     (with-temp-buffer
       (insert body)
@@ -138,9 +139,9 @@
 	 (if error-buffer
 	     (make-temp-file
 	      (expand-file-name "scor"
-				(or (unless (featurep 'xemacs)
-				      small-temporary-file-directory)
-				    temporary-file-directory)))
+                                (if (featurep 'xemacs)
+                                    (temp-directory)
+                                  temporary-file-directory)))
 	   nil))
 	exit-status)
     (if (or replace
@@ -247,6 +248,13 @@
       (delete-file error-file))
     exit-status))
 
+(defun org-babel-eval-wipe-error-buffer ()
+  "Delete the contents of the Org code block error buffer.
+This buffer is named by `org-babel-error-buffer-name'."
+  (when (get-buffer org-babel-error-buffer-name)
+    (with-current-buffer org-babel-error-buffer-name
+      (delete-region (point-min) (point-max)))))
+
 (provide 'ob-eval)
 
 ;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d
--- a/lisp/org/ob-exp.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-exp.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte, Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -39,8 +39,7 @@
 (defvar org-babel-lob-one-liner-regexp)
 (defvar org-babel-ref-split-regexp)
 (declare-function org-babel-lob-get-info "ob-lob" ())
-(declare-function org-babel-ref-literal "ob-ref" (ref))
-
+(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)
@@ -289,6 +288,7 @@
 			   (org-babel-process-params (nth 2 info))))
        ;; skip code blocks which we can't evaluate
        (when (fboundp (intern (concat "org-babel-execute:" lang)))
+	 (org-babel-eval-wipe-error-buffer)
 	 (if (equal type 'inline)
 	     (let ((raw (org-babel-execute-src-block
 			 nil info '((:results . "silent"))))
--- a/lisp/org/ob-gnuplot.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-gnuplot.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-haskell.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-haskell.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -136,16 +136,7 @@
   "Convert RESULTS to an Emacs-lisp table or string.
 If RESULTS look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-read
-   (if (and (stringp results) (string-match "^\\[.+\\]$" results))
-       (org-babel-read
-        (concat "'"
-                (replace-regexp-in-string
-                 "\\[" "(" (replace-regexp-in-string
-                            "\\]" ")" (replace-regexp-in-string
-                                       "," " " (replace-regexp-in-string
-                                                "'" "\"" results))))))
-     results)))
+  (org-babel-script-escape results))
 
 (defun org-babel-haskell-var-to-haskell (var)
   "Convert an elisp value VAR into a haskell variable.
--- a/lisp/org/ob-js.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-js.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,26 +1,28 @@
 ;;; ob-js.el --- org-babel functions for Javascript
 
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010 Free Software Foundation
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, js
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
-;; This file is part of GNU Emacs.
+;;; License:
 
-;; GNU Emacs is free software: you can redistribute it and/or modify
+;; 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 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; 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.  If not, see <http://www.gnu.org/licenses/>.
+;; 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:
 
@@ -33,7 +35,7 @@
 
 ;; - a non-browser javascript engine such as node.js http://nodejs.org/
 ;;   or mozrepl http://wiki.github.com/bard/mozrepl/
-;;
+;; 
 ;; - for session based evaluation mozrepl and moz.el are required see
 ;;   http://wiki.github.com/bard/mozrepl/emacs-integration for
 ;;   configuration instructions
--- a/lisp/org/ob-keys.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-keys.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-latex.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-latex.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-ledger.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-ledger.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric S Fraga
 ;; Keywords: literate programming, reproducible research, accounting
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-lisp.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-lisp.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,27 +1,28 @@
 ;;; ob-lisp.el --- org-babel functions for Common Lisp
 
-;; Copyright (C) 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2010 Free Software Foundation
 
-;; Author: David T. O'Toole <dto@gnu.org>
-;;	Eric Schulte
+;; Author: David T. O'Toole <dto@gnu.org>, Eric Schulte
 ;; Keywords: literate programming, reproducible research, lisp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
-;; This file is part of GNU Emacs.
+;;; License:
 
-;; GNU Emacs is free software: you can redistribute it and/or modify
+;; 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 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; 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.  If not, see <http://www.gnu.org/licenses/>.
+;; 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:
 
@@ -40,16 +41,18 @@
 (require 'ob-ref)
 (require 'ob-comint)
 (require 'ob-eval)
-(declare-function slime-eval "ext:slime" (form))
+
+(declare-function slime-eval "ext:slime" (sexp &optional package))
+(declare-function slime-process "ext:slime" (&optional connection))
 (declare-function slime-connected-p "ext:slime" ())
-(declare-function slime-process "ext:slime" ())
-(require 'slime nil 'noerror)
 
 (defvar org-babel-default-header-args:lisp '()
   "Default header arguments for lisp code blocks.")
 
 (defcustom org-babel-lisp-cmd "sbcl --script"
-  "Name of command used to evaluate lisp blocks.")
+  "Name of command used to evaluate lisp blocks."
+  :group 'org-babel
+  :type 'string)
 
 (defun org-babel-expand-body:lisp (body params)
   "Expand BODY according to PARAMS, return the expanded body."
@@ -65,6 +68,7 @@
 (defun org-babel-execute:lisp (body params)
   "Execute a block of Lisp code with org-babel.
 This function is called by `org-babel-execute-src-block'"
+  (require 'slime)
   (message "executing Lisp source code block")
   (let* ((session (org-babel-lisp-initiate-session
 		   (cdr (assoc :session params))))
@@ -96,6 +100,7 @@
 (defun org-babel-lisp-initiate-session (&optional session)
   "If there is not a current inferior-process-buffer in SESSION
 then create.  Return the initialized session."
+  (require 'slime)
   (unless (string= session "none")
     (save-window-excursion
       (or (slime-connected-p)
--- a/lisp/org/ob-lob.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-lob.el	Sat Dec 11 17:42:53 2010 +0100
@@ -2,11 +2,10 @@
 
 ;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
-;;	Dan Davison
+;; Author: Eric Schulte, Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -26,7 +25,7 @@
 ;;; Commentary:
 
 ;; See the online documentation for more information
-;;
+;; 
 ;;   http://orgmode.org/worg/org-contrib/babel/
 
 ;;; Code:
@@ -72,7 +71,8 @@
   (concat
    "^\\([ \t]*\\)#\\+\\(?:"
    (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
-   "\\):[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\([^\n]*\\)")
+   "\\):[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
+   "\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\([^\n]*\\)")
   "Regexp to match calls to predefined source block functions.")
 
 ;; functions for executing lob one-liners
@@ -93,13 +93,16 @@
       (beginning-of-line 1)
       (if (looking-at org-babel-lob-one-liner-regexp)
           (append
-	   (mapcar #'org-babel-clean-text-properties
+	   (mapcar #'org-babel-clean-text-properties 
 		   (list
-		    (format "%s(%s)%s"
-			    (match-string 2) (match-string 3) (match-string 4))
-		    (match-string 5)))
+		    (format "%s%s(%s)%s"
+			    (match-string 2)
+			    (if (match-string 4)
+				(concat "[" (match-string 4) "]") "")
+			    (or (match-string 6) "") (match-string 7))
+		    (match-string 8)))
 	   (list (length (match-string 1))))))))
-
+  
 (defun org-babel-lob-execute (info)
   "Execute the lob call specified by INFO."
   (let ((params (org-babel-process-params
--- a/lisp/org/ob-matlab.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-matlab.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-mscgen.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-mscgen.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Juan Pechiar
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-ocaml.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-ocaml.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-octave.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-octave.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-org.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-org.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-perl.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-perl.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,12 +1,11 @@
 ;;; ob-perl.el --- org-babel functions for perl evaluation
 
-;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010  Free Software Foundation
 
-;; Author: Dan Davison
-;;	Eric Schulte
+;; Author: Dan Davison, Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-plantuml.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-plantuml.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Zhang Weize
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-python.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-python.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,12 +1,11 @@
 ;;; ob-python.el --- org-babel functions for python evaluation
 
-;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010  Free Software Foundation
 
-;; Author: Eric Schulte
-;;	Dan Davison
+;; Author: Eric Schulte, Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -57,11 +56,15 @@
 		   (cdr (assoc :session params))))
          (result-params (cdr (assoc :result-params params)))
          (result-type (cdr (assoc :result-type params)))
+	 (return-val (when (and (eq result-type 'value) (not session))
+		       (cdr (assoc :return params))))
+	 (preamble (cdr (assoc :preamble params)))
          (full-body
 	  (org-babel-expand-body:generic
-	   body params (org-babel-variable-assignments:python params)))
+	   (concat body (if return-val (format "return %s" return-val) ""))
+	   params (org-babel-variable-assignments:python params)))
          (result (org-babel-python-evaluate
-		  session full-body result-type result-params)))
+		  session full-body result-type result-params preamble)))
     (or (cdr (assoc :file params))
         (org-babel-reassemble-table
          result
@@ -118,20 +121,7 @@
   "Convert RESULTS into an appropriate elisp value.
 If the results look like a list or tuple, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  ((lambda (res)
-     (if (listp res)
-	 (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res)
-       res))
-   (org-babel-read
-    (if (and (stringp results) (string-match "^[([].+[])]$" results))
-       (org-babel-read
-        (concat "'"
-                (replace-regexp-in-string
-                 "\\[" "(" (replace-regexp-in-string
-                            "\\]" ")" (replace-regexp-in-string
-                                       ", " " " (replace-regexp-in-string
-                                                 "'" "\"" results t))))))
-     results))))
+  (org-babel-script-escape results))
 
 (defvar org-babel-python-buffers '((:default . nil)))
 
@@ -192,35 +182,38 @@
 open('%s', 'w').write( pprint.pformat(main()) )")
 
 (defun org-babel-python-evaluate
-  (session body &optional result-type result-params)
+  (session body &optional result-type result-params preamble)
   "Evaluate BODY as python code."
   (if session
       (org-babel-python-evaluate-session
        session body result-type result-params)
     (org-babel-python-evaluate-external-process
-     body result-type result-params)))
+     body result-type result-params preamble)))
 
 (defun org-babel-python-evaluate-external-process
-  (body &optional result-type result-params)
+  (body &optional result-type result-params preamble)
   "Evaluate BODY in external python process.
 If RESULT-TYPE equals 'output then return standard output as a
 string. If RESULT-TYPE equals 'value then return the value of the
 last statement in BODY, as elisp."
   (case result-type
-    (output (org-babel-eval org-babel-python-command body))
+    (output (org-babel-eval org-babel-python-command
+			    (concat (if preamble (concat preamble "\n") "") body)))
     (value (let ((tmp-file (org-babel-temp-file "python-")))
 	     (org-babel-eval org-babel-python-command
-			     (format
-			      (if (member "pp" result-params)
-				  org-babel-python-pp-wrapper-method
-				org-babel-python-wrapper-method)
-			      (mapconcat
-			       (lambda (line) (format "\t%s" line))
-			       (split-string
-				(org-remove-indentation
-				 (org-babel-trim body))
-				"[\r\n]") "\n")
-			      (org-babel-process-file-name tmp-file 'noquote)))
+			     (concat
+			      (if preamble (concat preamble "\n") "")
+			      (format
+			       (if (member "pp" result-params)
+				   org-babel-python-pp-wrapper-method
+				 org-babel-python-wrapper-method)
+			       (mapconcat
+				(lambda (line) (format "\t%s" line))
+				(split-string
+				 (org-remove-indentation
+				  (org-babel-trim body))
+				 "[\r\n]") "\n")
+			       (org-babel-process-file-name tmp-file 'noquote))))
 	     ((lambda (raw)
 		(if (or (member "code" result-params)
 			(member "pp" result-params))
@@ -240,7 +233,7 @@
 	   (lambda (statement) (insert statement) (comint-send-input))
 	   (if pp
 	       (list
-		"import pp"
+		"import pprint"
 		(format "open('%s', 'w').write(pprint.pformat(_))"
 			(org-babel-process-file-name tmp-file 'noquote)))
 	     (list (format "open('%s', 'w').write(str(_))"
--- a/lisp/org/ob-ref.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-ref.el	Sat Dec 11 17:42:53 2010 +0100
@@ -2,11 +2,10 @@
 
 ;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
-;;	Dan Davison
+;; Author: Eric Schulte, Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -52,11 +51,13 @@
 ;;; Code:
 (require 'ob)
 (eval-when-compile
+  (require 'org-list)
   (require 'cl))
 
 (declare-function org-remove-if-not "org" (predicate seq))
 (declare-function org-at-table-p "org" (&optional table-type))
 (declare-function org-count "org" (CL-ITEM CL-SEQ))
+(declare-function org-in-item-p "org-list" ())
 
 (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]*")
@@ -74,46 +75,39 @@
     (let ((var (match-string 1 assignment))
 	  (ref (match-string 2 assignment)))
       (cons (intern var)
-	    ((lambda (val)
-	       (if (equal :ob-must-be-reference val)
-		   (org-babel-ref-resolve ref) val))
-	     (org-babel-ref-literal ref))))))
-
-(defun org-babel-ref-literal (ref)
-  "Return the value of REF if it is a literal value.
-Determine if the right side of a header argument variable
-assignment is a literal value or is a reference to some external
-resource.  REF should be a string of the right hand side of the
-assignment.  If REF is literal then return it's value, otherwise
-return nil."
-  (let ((out (org-babel-read ref)))
-    (if (equal out ref)
-        (if (string-match "^\".+\"$" ref)
-            (read ref)
-	  :ob-must-be-reference)
-      out)))
+	    (let ((out (org-babel-read ref)))
+	      (if (equal out ref)
+		  (if (string-match "^\".+\"$" ref)
+		      (read ref)
+		    (org-babel-ref-resolve ref))
+		out))))))
 
 (defvar org-babel-library-of-babel)
 (defun org-babel-ref-resolve (ref)
   "Resolve the reference REF and return its value."
   (save-excursion
     (let ((case-fold-search t)
-          type args new-refere new-referent result lob-info split-file split-ref
-          index index-row index-col)
+          type args new-refere new-header-args new-referent result
+	  lob-info split-file split-ref index index-row index-col)
       ;; if ref is indexed grab the indices -- beware nested indices
-      (when (and (string-match "\\[\\(.+\\)\\]" ref)
+      (when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref)
 		 (let ((str (substring ref 0 (match-beginning 0))))
 		   (= (org-count ?( str) (org-count ?) str))))
         (setq index (match-string 1 ref))
         (setq ref (substring ref 0 (match-beginning 0))))
       ;; assign any arguments to pass to source block
-      (when (string-match "^\\(.+?\\)\(\\(.*\\)\)$" ref)
-        (setq new-refere (match-string 1 ref))
-        (setq new-referent (match-string 2 ref))
+      (when (string-match
+	     "^\\(.+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)\(\\(.*\\)\)$" ref)
+        (setq new-refere      (match-string 1 ref))
+	(setq new-header-args (match-string 3 ref))
+        (setq new-referent    (match-string 5 ref))
         (when (> (length new-refere) 0)
-          (if (> (length new-referent) 0)
-              (setq args (mapcar (lambda (ref) (cons :var ref))
-                                 (org-babel-ref-split-args new-referent))))
+          (when (> (length new-referent) 0)
+	    (setq args (mapcar (lambda (ref) (cons :var ref))
+			       (org-babel-ref-split-args new-referent))))
+	  (when (> (length new-header-args) 0)
+	    (setq args (append (org-babel-parse-header-arguments new-header-args)
+			       args)))
           (setq ref new-refere)))
       (when (string-match "^\\(.+\\):\\(.+\\)$" ref)
         (setq split-file (match-string 1 ref))
@@ -155,6 +149,7 @@
 		(case type
 		  ('results-line (org-babel-read-result))
 		  ('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))
 		  ('lob (org-babel-execute-src-block nil lob-info params)))))
@@ -222,6 +217,7 @@
 Return nil if none of the supported reference types are found.
 Supported reference types are tables and source blocks."
   (cond ((org-at-table-p) 'table)
+	((org-in-item-p) 'list)
         ((looking-at "^[ \t]*#\\+BEGIN_SRC") 'source-block)
         ((looking-at org-bracket-link-regexp) 'file)
         ((looking-at org-babel-result-regexp) 'results-line)))
--- a/lisp/org/ob-ruby.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-ruby.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,11 +1,11 @@
 ;;; ob-ruby.el --- org-babel functions for ruby evaluation
 
-;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010  Free Software Foundation
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -29,10 +29,10 @@
 ;;; Requirements:
 
 ;; - ruby and irb executables :: http://www.ruby-lang.org/
-;;
+;; 
 ;; - ruby-mode :: Can be installed through ELPA, or from
 ;;   http://github.com/eschulte/rinari/raw/master/util/ruby-mode.el
-;;
+;;   
 ;; - inf-ruby mode :: Can be installed through ELPA, or from
 ;;   http://github.com/eschulte/rinari/raw/master/util/inf-ruby.el
 
@@ -116,16 +116,7 @@
   "Convert RESULTS into an appropriate elisp value.
 If RESULTS look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-read
-   (if (and (stringp results) (string-match "^\\[.+\\]$" results))
-       (org-babel-read
-        (concat "'"
-                (replace-regexp-in-string
-                 "\\[" "(" (replace-regexp-in-string
-                            "\\]" ")" (replace-regexp-in-string
-                                       ", " " " (replace-regexp-in-string
-						 "'" "\"" results))))))
-     results)))
+  (org-babel-script-escape results))
 
 (defun org-babel-ruby-initiate-session (&optional session params)
   "Initiate a ruby session.
--- a/lisp/org/ob-sass.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-sass.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-scheme.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-scheme.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,26 +1,28 @@
 ;;; ob-scheme.el --- org-babel functions for Scheme
 
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010 Free Software Foundation
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, scheme
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
-;; This file is part of GNU Emacs.
+;;; License:
 
-;; GNU Emacs is free software: you can redistribute it and/or modify
+;; 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 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; 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.  If not, see <http://www.gnu.org/licenses/>.
+;; 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:
 
@@ -33,7 +35,7 @@
 
 ;; - a working scheme implementation
 ;;   (e.g. guile http://www.gnu.org/software/guile/guile.html)
-;;
+;;   
 ;; - for session based evaluation cmuscheme.el is required which is
 ;;   included in Emacs
 
--- a/lisp/org/ob-screen.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-screen.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,11 +1,11 @@
 ;;; ob-screen.el --- org-babel support for interactive terminal
 
-;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010  Free Software Foundation
 
 ;; Author: Benjamin Andresen
 ;; Keywords: literate programming, interactive shell
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/ob-sh.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-sh.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -100,7 +100,7 @@
                           (if (listp el)
                               (mapcar #'deep-string el)
 			    (org-babel-sh-var-to-sh el sep))))
-	(format "$(cat <<BABEL_TABLE\n%s\nBABEL_TABLE\n)"
+	(format "$(cat <<'BABEL_TABLE'\n%s\nBABEL_TABLE\n)"
 		(orgtbl-to-generic
 		 (deep-string (if (listp (car var)) var (list var)))
 		 (list :sep (or sep "\t")))))
@@ -114,16 +114,7 @@
   "Convert RESULTS to an appropriate elisp value.
 If the results look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-read
-   (if (string-match "^\\[.+\\]$" results)
-       (org-babel-read
-        (concat "'"
-                (replace-regexp-in-string
-                 "\\[" "(" (replace-regexp-in-string
-                            "\\]" ")" (replace-regexp-in-string
-                                       ", " " " (replace-regexp-in-string
-                                                 "'" "\"" results))))))
-     results)))
+  (org-babel-script-escape results))
 
 (defun org-babel-sh-initiate-session (&optional session params)
   "Initiate a session named SESSION according to PARAMS."
--- a/lisp/org/ob-sql.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-sql.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -47,9 +47,15 @@
 (eval-when-compile (require 'cl))
 
 (declare-function org-table-import "org-table" (file arg))
+(declare-function orgtbl-to-csv "org-table" (TABLE PARAMS))
 
 (defvar org-babel-default-header-args:sql '())
 
+(defun org-babel-expand-body:sql (body params)
+  "Expand BODY according to the values of PARAMS."
+  (org-babel-sql-expand-vars
+   body (mapcar #'cdr (org-babel-get-header params :var))))
+
 (defun org-babel-execute:sql (body params)
   "Execute a block of Sql code with Babel.
 This function is called by `org-babel-execute-src-block'."
@@ -60,6 +66,10 @@
          (out-file (or (cdr (assoc :out-file params))
                        (org-babel-temp-file "sql-out-")))
          (command (case (intern engine)
+                    ('msosql (format "osql %s -s \"\t\" -i %s -o %s"
+                                     (or cmdline "")
+                                     (org-babel-process-file-name in-file)
+                                     (org-babel-process-file-name out-file)))
                     ('mysql (format "mysql %s -e \"source %s\" > %s"
                                     (or cmdline "")
 				    (org-babel-process-file-name in-file)
@@ -70,11 +80,11 @@
 				    (or cmdline "")))
                     (t (error "no support for the %s sql engine" engine)))))
     (with-temp-file in-file
-      (insert (org-babel-expand-body:generic body params)))
+      (insert (org-babel-expand-body:sql body params)))
     (message command)
     (shell-command command)
     (with-temp-buffer
-      (org-table-import out-file nil)
+      (org-table-import out-file '(16))
       (org-babel-reassemble-table
        (org-table-to-lisp)
        (org-babel-pick-name (cdr (assoc :colname-names params))
@@ -82,6 +92,28 @@
        (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."
+  (mapc
+   (lambda (pair)
+     (setq body
+	   (replace-regexp-in-string
+	    (format "\$%s" (car pair))
+	    ((lambda (val)
+	       (if (listp val)
+		   ((lambda (data-file)
+		      (with-temp-file data-file
+			(insert (orgtbl-to-csv
+				 val '(:fmt (lambda (el) (if (stringp el)
+							el
+						      (format "%S" el)))))))
+		      data-file)
+		    (org-babel-temp-file "sql-data-"))
+		 (if (stringp val) val (format "%S" val))))
+	     (cdr pair))
+	    body)))
+   vars)
+  body)
 
 (defun org-babel-prep-session:sql (session params)
   "Raise an error because Sql sessions aren't implemented."
--- a/lisp/org/ob-sqlite.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-sqlite.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,11 +1,11 @@
 ;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
 
-;; Copyright (C) 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2010  Free Software Foundation
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -28,6 +28,7 @@
 
 ;;; Code:
 (require 'ob)
+(require 'ob-eval)
 (require 'ob-ref)
 
 (declare-function org-fill-template "org" (template alist))
@@ -52,7 +53,6 @@
   "Execute a block of Sqlite code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
-	(vars (org-babel-get-header params :var))
 	(db (cdr (assoc :db params)))
 	(separator (cdr (assoc :separator params)))
 	(nullvalue (cdr (assoc :nullvalue params)))
@@ -65,15 +65,10 @@
     (unless db (error "ob-sqlite: can't evaluate without a database."))
     (with-temp-buffer
       (insert
-       (shell-command-to-string
+       (org-babel-eval
 	(org-fill-template
-	 "%cmd -init %body %header %separator %nullvalue %others %csv %db "
+	 "%cmd %header %separator %nullvalue %others %csv %db "
 	 (list
-	  (cons "body" ((lambda (sql-file)
-			  (with-temp-file sql-file
-			    (insert (org-babel-expand-body:sqlite body params)))
-			  sql-file)
-			(org-babel-temp-file "sqlite-sql-")))
 	  (cons "cmd" org-babel-sqlite3-command)
 	  (cons "header" (if headers-p "-header" "-noheader"))
 	  (cons "separator"
@@ -90,7 +85,9 @@
 			      (member :html others) separator)
 			  ""
 			"-csv"))
-	  (cons "db " db)))))
+	  (cons "db " db)))
+	;; body of the code block
+	(org-babel-expand-body:sqlite body params)))
       (if (or (member "scalar" result-params)
 	      (member "html" result-params)
 	      (member "code" result-params)
--- a/lisp/org/ob-table.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-table.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -57,9 +57,9 @@
   "Replace newline character with ellipses.
 If STRING ends in a newline character, then remove the newline
 character and replace it with ellipses."
-  (if (and (stringp string) (string-match "[\n\r]" string))
-      (concat (substring string 0 (match-beginning 0)) "...")
-    string))
+  (if (and (stringp string) (string-match "[\n\r]\\(.\\)?" string))
+      (concat (substring string 0 (match-beginning 0))
+	      (if (match-string 1 string) "...")) string))
 
 (defmacro sbe (source-block &rest variables)
   "Return the results of calling SOURCE-BLOCK with VARIABLES.
--- a/lisp/org/ob-tangle.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob-tangle.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -125,6 +125,7 @@
 This function exports the source code using
 `org-babel-tangle' and then loads the resulting file using
 `load-file'."
+  (interactive "fFile to load: ")
   (flet ((age (file)
               (float-time
                (time-subtract (current-time)
--- a/lisp/org/ob.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/ob.el	Sat Dec 11 17:42:53 2010 +0100
@@ -2,11 +2,10 @@
 
 ;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
-;;	Dan Davison
+;; Author: Eric Schulte, Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -31,7 +30,9 @@
 
 ;;; Code:
 (eval-when-compile
+  (require 'org-list)
   (require 'cl))
+(require 'ob-eval)
 (require 'org-macs)
 
 (defvar org-babel-call-process-region-original)
@@ -43,7 +44,7 @@
 (declare-function tramp-file-name-host "tramp" (vec))
 (declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
 (declare-function org-icompleting-read "org" (&rest args))
-(declare-function org-edit-src-code "org-src" 
+(declare-function org-edit-src-code "org-src"
                   (&optional context code edit-buffer-name quietp))
 (declare-function org-edit-src-exit "org-src"  (&optional context))
 (declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
@@ -73,6 +74,10 @@
 (declare-function org-babel-ref-resolve "ob-ref" (ref))
 (declare-function org-babel-lob-execute-maybe "ob-lob" ())
 (declare-function org-number-sequence "org-compat" (from &optional to inc))
+(declare-function org-in-item-p "org-list" ())
+(declare-function org-list-parse-list "org-list" (&optional delete))
+(declare-function org-list-to-generic "org-list" (LIST PARAMS))
+(declare-function org-list-bottom-point "org-list" ())
 
 (defgroup org-babel nil
   "Code block evaluation and management in `org-mode' documents."
@@ -213,9 +218,13 @@
     (if (or (equal eval "never") (equal eval "no")
 	    (and query
 		 (not (yes-or-no-p
-		       (format "Evaluate this%scode on your system? "
-			       (if info (format " %s " (nth 0 info)) " "))))))
-	(prog1 nil (message "evaluation aborted"))
+		       (format "Evaluate this%scode block%son your system? "
+			       (if info (format " %s " (nth 0 info)) " ")
+			       (if (nth 4 info)
+				   (format " (%s) " (nth 4 info)) " "))))))
+	(prog1 nil (message "Evaluation %s"
+			    (if (or (equal eval "never") (equal eval "no"))
+				"Disabled" "Aborted")))
       t)))
 
 ;;;###autoload
@@ -238,7 +247,8 @@
   (interactive)
   (let ((info (org-babel-get-src-block-info)))
     (if info
-	(progn (org-babel-execute-src-block current-prefix-arg info) t) nil)))
+	(progn (org-babel-eval-wipe-error-buffer)
+	       (org-babel-execute-src-block current-prefix-arg info) t) nil)))
 
 ;;;###autoload
 (defun org-babel-expand-src-block-maybe ()
@@ -363,10 +373,12 @@
 	     (new-hash (when cache? (org-babel-sha1-hash info)))
 	     (old-hash (when cache? (org-babel-result-hash info)))
 	     (body (setf (nth 1 info)
-			 (if (and (cdr (assoc :noweb params))
-				  (string= "yes" (cdr (assoc :noweb params))))
-			     (org-babel-expand-noweb-references info)
-			   (nth 1 info))))
+			 (let ((noweb (cdr (assoc :noweb params))))
+			   (if (and noweb
+				    (or (string= "yes" noweb)
+					(string= "tangle" noweb)))
+			       (org-babel-expand-noweb-references info)
+			     (nth 1 info)))))
 	     (cmd (intern (concat "org-babel-execute:" lang)))
 	     (dir (cdr (assoc :dir params)))
 	     (default-directory
@@ -379,7 +391,7 @@
 	     result)
 	(unwind-protect
 	    (flet ((call-process-region (&rest args)
-					(apply 'org-babel-tramp-handle-call-process-region args)))
+		    (apply 'org-babel-tramp-handle-call-process-region args)))
 	      (unless (fboundp cmd)
 		(error "No org-babel-execute function for %s!" lang))
 	      (if (and (not arg) new-hash (equal new-hash old-hash))
@@ -584,6 +596,60 @@
       t)))
 
 ;;;###autoload
+(defmacro org-babel-map-src-blocks (file &rest body)
+  "Evaluate BODY forms on each source-block in FILE.
+If FILE is nil evaluate BODY forms on source blocks in current
+buffer.  During evaluation of BODY the following local variables
+are set relative to the currently matched code block.
+
+full-block ------- string holding the entirety of the code block
+beg-block -------- point at the beginning of the code block
+end-block -------- point at the end of the matched code block
+lang ------------- string holding the language of the code block
+beg-lang --------- point at the beginning of the lang
+end-lang --------- point at the end of the lang
+switches --------- string holding the switches
+beg-switches ----- point at the beginning of the switches
+end-switches ----- point at the end of the switches
+header-args ------ string holding the header-args
+beg-header-args -- point at the beginning of the header-args
+end-header-args -- point at the end of the header-args
+body ------------- string holding the body of the code block
+beg-body --------- point at the beginning of the body
+end-body --------- point at the end of the body"
+  (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-src-block-regexp nil t)
+	   (goto-char (match-beginning 0))
+	   (let ((full-block (match-string 0))
+		 (beg-block (match-beginning 0))
+		 (end-block (match-end 0))
+		 (lang (match-string 2))
+		 (beg-lang (match-beginning 2))
+		 (end-lang (match-end 2))
+		 (switches (match-string 3))
+		 (beg-switches (match-beginning 3))
+		 (end-switches (match-end 3))
+		 (header-args (match-string 4))
+		 (beg-header-args (match-beginning 4))
+		 (end-header-args (match-end 4))
+		 (body (match-string 5))
+		 (beg-body (match-beginning 5))
+		 (end-body (match-end 5)))
+	     ,@body
+	     (goto-char end-block))))
+       (unless visited-p (kill-buffer to-be-removed))
+       (goto-char point))))
+
+;;;###autoload
 (defun org-babel-execute-buffer (&optional arg)
   "Execute source code blocks in a buffer.
 Call `org-babel-execute-src-block' on every source block in
@@ -757,57 +823,6 @@
 	  (lambda () (org-add-hook 'change-major-mode-hook
 				   'org-babel-show-result-all 'append 'local)))
 
-(defmacro org-babel-map-src-blocks (file &rest body)
-  "Evaluate BODY forms on each source-block in FILE.
-If FILE is nil evaluate BODY forms on source blocks in current
-buffer.  During evaluation of BODY the following local variables
-are set relative to the currently matched code block.
-
-full-block ------- string holding the entirety of the code block
-beg-block -------- point at the beginning of the code block
-end-block -------- point at the end of the matched code block
-lang ------------- string holding the language of the code block
-beg-lang --------- point at the beginning of the lang
-end-lang --------- point at the end of the lang
-switches --------- string holding the switches
-beg-switches ----- point at the beginning of the switches
-end-switches ----- point at the end of the switches
-header-args ------ string holding the header-args
-beg-header-args -- point at the beginning of the header-args
-end-header-args -- point at the end of the header-args
-body ------------- string holding the body of the code block
-beg-body --------- point at the beginning of the body
-end-body --------- point at the end of the body"
-  (declare (indent 1))
-  `(let ((visited-p (or (null ,file)
-			(get-file-buffer (expand-file-name ,file))))
-	 (point (point)) to-be-removed)
-     (save-window-excursion
-       (when ,file (find-file ,file))
-       (setq to-be-removed (current-buffer))
-       (goto-char (point-min))
-       (while (re-search-forward org-babel-src-block-regexp nil t)
-         (goto-char (match-beginning 0))
-	 (let ((full-block (match-string 0))
-	       (beg-block (match-beginning 0))
-	       (end-block (match-end 0))
-	       (lang (match-string 2))
-	       (beg-lang (match-beginning 2))
-	       (end-lang (match-end 2))
-	       (switches (match-string 3))
-	       (beg-switches (match-beginning 3))
-	       (end-switches (match-end 3))
-	       (header-args (match-string 4))
-	       (beg-header-args (match-beginning 4))
-	       (end-header-args (match-end 4))
-	       (body (match-string 5))
-	       (beg-body (match-beginning 5))
-	       (end-body (match-end 5)))
-	   ,@body
-	   (goto-char end-block))))
-     (unless visited-p (kill-buffer to-be-removed))
-     (goto-char point)))
-
 (defvar org-file-properties)
 (defun org-babel-params-from-properties (&optional lang)
   "Retrieve parameters specified as properties.
@@ -893,17 +908,31 @@
 
 (defun org-babel-parse-header-arguments (arg-string)
   "Parse a string of header arguments returning an alist."
-  (if (> (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 (concat ":" (match-string 1 arg)))
-                         (org-babel-read (org-babel-chomp (match-string 2 arg))))
-		 (cons (intern (concat ":" arg)) nil)))
-	     (split-string (concat " " arg-string) "[ \f\t\n\r\v]+:" t)))))
+  (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)))))))
 
 (defun org-babel-process-params (params)
   "Expand variables in PARAMS and add summary parameters."
@@ -1291,6 +1320,7 @@
   (let ((case-fold-search t) result-string)
     (cond
      ((org-at-table-p) (org-babel-read-table))
+     ((org-in-item-p) (org-babel-read-list))
      ((looking-at org-bracket-link-regexp) (org-babel-read-link))
      ((looking-at org-block-regexp) (org-babel-trim (match-string 4)))
      ((looking-at "^[ \t]*: ")
@@ -1316,6 +1346,10 @@
               (mapcar #'org-babel-read row)))
           (org-table-to-lisp)))
 
+(defun org-babel-read-list ()
+  "Read the list at `point' into emacs-lisp."
+  (mapcar #'org-babel-read (cdr (org-list-parse-list))))
+
 (defvar org-link-types-re)
 (defun org-babel-read-link ()
   "Read the link at `point' into emacs-lisp.
@@ -1349,7 +1383,9 @@
 file ---- the results are interpreted as a file path, and are
           inserted into the buffer using the Org-mode file syntax
 
-raw ----- results are added directly to the org-mode file.  This
+list ---- the results are interpreted as an Org-mode list.
+
+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.
 
@@ -1406,16 +1442,24 @@
 	   ((member "replace" result-params)
 	    (delete-region (point) (org-babel-result-end)))
 	   ((member "append" result-params)
-	    (goto-char (org-babel-result-end)) (setq beg (point)))
-	   ((member "prepend" result-params) ;; already there
-	    )))
+	    (goto-char (org-babel-result-end)) (setq beg (point-marker)))
+	   ((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
+				       (if (listp result) result (list result)))
+				 '(:splicep nil :istart "- " :iend "\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))
@@ -1425,24 +1469,34 @@
 	  (goto-char beg) (when (org-at-table-p) (org-table-align)))
 	 ((member "file" result-params)
 	  (insert result))
-	 ((member "html" result-params)
-	  (insert (format "#+BEGIN_HTML%s\n%s#+END_HTML\n"
-			  results-switches result)))
-	 ((member "latex" result-params)
-	  (insert (format "#+BEGIN_LaTeX%s\n%s#+END_LaTeX\n"
-			  results-switches result)))
-	 ((member "code" result-params)
-	  (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n"
-			  (or lang "none") results-switches result)))
-	 ((member "org" result-params)
-	  (insert (format "#+BEGIN_SRC org\n%s#+END_SRC\n" result)))
-	 ((member "raw" result-params)
-	  (save-excursion (insert result)) (if (org-at-table-p) (org-cycle)))
-	 (t
-	  (org-babel-examplize-region
-	   (point) (progn (insert result) (point)) results-switches)))
+	 (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 start)
+		     (goto-char end) (insert finish)
+		     (setq end (point-marker))))
+	  (cond
+	   ((member "html" result-params)
+	    (wrap "#+BEGIN_HTML\n" "#+END_HTML"))
+	   ((member "latex" result-params)
+	    (wrap "#+BEGIN_LaTeX\n" "#+END_LaTeX"))
+	   ((member "code" result-params)
+	    (wrap (format "#+BEGIN_SRC %s%s\n" (or lang "none") results-switches)
+		  "#+END_SRC"))
+	   ((member "org" result-params)
+	    (wrap "#+BEGIN_ORG\n" "#+END_ORG"))
+	   ((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\n" "#+END_RESULT"))
+	   ((and (stringp 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
-	(setq end (if (listp result) (org-table-end) (point)))
 	(when (and indent (> indent 0)
 		   ;; in this case `table-align' does the work for us
 		   (not (and (listp result)
@@ -1450,9 +1504,9 @@
 	  (indent-rigidly beg end indent))))
     (if (= (length result) 0)
 	(if (member "value" result-params)
-	    (message "No result returned by source block")
-	  (message "Source block produced no output"))
-      (message "finished"))))
+	    (message "Code block returned no value.")
+	  (message "Code block produced no output."))
+      (message "Code block evaluation complete."))))
 
 (defun org-babel-remove-result (&optional info)
   "Remove the result of the current source block."
@@ -1466,25 +1520,18 @@
 (defun org-babel-result-end ()
   "Return the point at the end of the current set of results"
   (save-excursion
-    (if (org-at-table-p)
-        (progn (goto-char (org-table-end)) (point))
-      (let ((case-fold-search t))
-        (cond
-         ((looking-at "[ \t]*#\\+begin_latex")
-          (re-search-forward "[ \t]*#\\+end_latex" nil t)
-          (forward-line 1))
-         ((looking-at "[ \t]*#\\+begin_html")
-          (re-search-forward "[ \t]*#\\+end_html" nil t)
-          (forward-line 1))
-         ((looking-at "[ \t]*#\\+begin_example")
-          (re-search-forward "[ \t]*#\\+end_example" nil t)
-          (forward-line 1))
-         ((looking-at "[ \t]*#\\+begin_src")
-          (re-search-forward "[ \t]*#\\+end_src" nil t)
-          (forward-line 1))
-         (t (progn (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
-                     (forward-line 1))))))
-      (point))))
+    (cond
+     ((org-at-table-p) (progn (goto-char (org-table-end)) (point)))
+     ((org-in-item-p) (- (org-list-bottom-point) 1))
+     (t
+      (let ((case-fold-search t)
+	    (blocks-re (regexp-opt
+			(list "latex" "html" "example" "src" "result"))))
+	(if (looking-at (concat "[ \t]*#\\+begin_" blocks-re))
+	    (re-search-forward (concat "[ \t]*#\\+end_" blocks-re) nil t)
+	  (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
+	    (forward-line 1))))
+      (point)))))
 
 (defun org-babel-result-to-file (result)
   "Convert RESULT into an `org-mode' link.
@@ -1505,9 +1552,7 @@
   (interactive "*r")
   (let ((size (count-lines beg end)))
     (save-excursion
-      (cond ((= size 0)
-	     (error (concat "This should not be impossible:"
-                            "a newline was appended to result if missing")))
+      (cond ((= size 0))	      ; do nothing for an empty result
 	    ((< size org-babel-min-lines-for-block-output)
 	     (goto-char beg)
 	     (dotimes (n size)
@@ -1517,7 +1562,7 @@
 	     (insert (if results-switches
                          (format "#+begin_example%s\n" results-switches)
                        "#+begin_example\n"))
-	     (forward-char (- end beg))
+	     (if (markerp end) (goto-char end) (forward-char (- end beg)))
 	     (insert "#+end_example\n"))))))
 
 (defun org-babel-update-block-body (new-body)
@@ -1534,8 +1579,8 @@
 This takes into account some special considerations for certain
 parameters when merging lists."
   (let ((results-exclusive-groups
-	 '(("file" "vector" "table" "scalar" "raw" "org"
-            "html" "latex" "code" "pp")
+	 '(("file" "list" "vector" "table" "scalar" "raw" "org"
+            "html" "latex" "code" "pp" "wrap")
 	   ("replace" "silent" "append" "prepend")
 	   ("output" "value")))
 	(exports-exclusive-groups
@@ -1599,7 +1644,7 @@
 	      (:tangle ;; take the latest -- always overwrite
 	       (setq tangle (or (list (cdr pair)) tangle)))
 	      (:noweb
-	       (setq noweb (e-merge '(("yes" "no")) noweb
+	       (setq noweb (e-merge '(("yes" "no" "tangle")) noweb
 				    (split-string (or (cdr pair) "")))))
 	      (:cache
 	       (setq cache (e-merge '(("yes" "no")) cache
@@ -1718,6 +1763,38 @@
   "Strip protective commas from bodies of source blocks."
   (replace-regexp-in-string "^,#" "#" body))
 
+(defun org-babel-script-escape (str)
+  "Safely convert tables into elisp lists."
+  (let (in-single in-double out)
+    (org-babel-read
+     (if (and (stringp str) (string-match "^\\[.+\\]$" str))
+	 (org-babel-read
+	  (concat
+	   "'"
+	   (progn
+	     (mapc
+	      (lambda (ch)
+		(setq
+		 out
+		 (case ch
+		   (91 (if (or in-double in-single) ; [
+			   (cons 91 out)
+			 (cons 40 out)))
+		   (93 (if (or in-double in-single) ; ]
+			   (cons 93 out)
+			 (cons 41 out)))
+		   (44 (if (or in-double in-single) (cons 44 out) out)) ; ,
+		   (39 (if in-double	; '
+			   (cons 39 out)
+			 (setq in-single (not in-single)) (cons 34 out)))
+		   (34 (if in-single	; "
+			   (append (list 34 32) out)
+			 (setq in-double (not in-double)) (cons 34 out)))
+		   (t  (cons ch out)))))
+	      (string-to-list str))
+	     (apply #'string (reverse out)))))
+       str))))
+
 (defun org-babel-read (cell)
   "Convert the string value of CELL to a number if appropriate.
 Otherwise if cell looks like lisp (meaning it starts with a
@@ -1851,7 +1928,7 @@
   (if (file-remote-p default-directory)
       (make-temp-file
        (concat (file-remote-p default-directory)
-	       (expand-file-name 
+	       (expand-file-name
 		prefix temporary-file-directory)
 	       nil suffix))
     (let ((temporary-file-directory
@@ -1865,17 +1942,22 @@
   (when (and (boundp 'org-babel-temporary-directory)
 	     (file-exists-p org-babel-temporary-directory))
     ;; taken from `delete-directory' in files.el
-    (mapc (lambda (file)
-	    ;; This test is equivalent to
-	    ;; (and (file-directory-p fn) (not (file-symlink-p fn)))
-	    ;; but more efficient
-	    (if (eq t (car (file-attributes file)))
-		(delete-directory file)
-	      (delete-file file)))
-	  ;; We do not want to delete "." and "..".
-	  (directory-files org-babel-temporary-directory 'full
-			   "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
-    (delete-directory org-babel-temporary-directory)))
+    (condition-case nil
+	(progn
+	  (mapc (lambda (file)
+		  ;; This test is equivalent to
+		  ;; (and (file-directory-p fn) (not (file-symlink-p fn)))
+		  ;; but more efficient
+		  (if (eq t (car (file-attributes file)))
+		      (delete-directory file)
+		    (delete-file file)))
+		;; We do not want to delete "." and "..".
+		(directory-files org-babel-temporary-directory 'full
+				 "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
+	  (delete-directory org-babel-temporary-directory))
+      (error
+       (message "Failed to remove temporary Org-babel directory %s"
+		org-babel-temporary-directory)))))
 
 (add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)
 
--- a/lisp/org/org-agenda.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-agenda.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -242,8 +242,12 @@
 		  (const org-agenda-prefix-format :value "  %-12:c%?-12t% s")
 		  (string))
 	    (list :tag "Number of days in agenda"
-		  (const org-agenda-ndays)
-		  (integer :value 1))
+		  (const org-agenda-span)
+		  (choice (const :tag "Day" 'day)
+			  (const :tag "Week" 'week)
+			  (const :tag "Month" 'month)
+			  (const :tag "Year" 'year)
+			  (integer :tag "Custom")))
 	    (list :tag "Fixed starting date"
 		  (const org-agenda-start-day)
 		  (string :value "2007-11-01"))
@@ -562,6 +566,33 @@
   :group 'org-agenda-todo-list
   :type 'boolean)
 
+(defcustom org-agenda-todo-ignore-timestamp nil
+  "Non-nil means don't show entries with a timestamp.
+This applies when creating the global todo list.
+Valid values are:
+
+past     Don't show entries for today or in the past.
+
+future   Don't show entries with a timestamp in the future.
+         The idea behind this is that if it has a future
+         timestamp, you don't want to think about it until the
+         date.
+
+all      Don't show any entries with a timestamp in the global todo list.
+         The idea behind this is that by setting a timestamp, you
+         have already \"taken care\" of this item.
+
+See also `org-agenda-todo-ignore-with-date'.
+See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
+to make his option also apply to the tags-todo list."
+  :group 'org-agenda-skip
+  :group 'org-agenda-todo-list
+  :type '(choice
+	  (const :tag "Ignore future timestamp todos" future)
+	  (const :tag "Ignore past or present timestamp todos" past)
+	  (const :tag "Ignore all timestamp todos" all)
+	  (const :tag "Show timestamp todos" nil)))
+
 (defcustom org-agenda-todo-ignore-scheduled nil
   "Non-nil means, ignore some scheduled TODO items when making TODO list.
 This applies when creating the global todo list.
@@ -632,7 +663,8 @@
   "Non-nil means honor todo-list ...ignore options also in tags-todo search.
 The variables
    `org-agenda-todo-ignore-with-date',
-   `org-agenda-todo-ignore-scheduled'
+   `org-agenda-todo-ignore-timestamp',
+   `org-agenda-todo-ignore-scheduled',
    `org-agenda-todo-ignore-deadlines'
 make the global TODO list skip entries that have time stamps of certain
 kinds.  If this option is set, the same options will also apply for the
@@ -860,12 +892,25 @@
   :group 'org-agenda-windows
   :type 'boolean)
 
-(defcustom org-agenda-ndays 7
+(defcustom org-agenda-ndays nil
+   "Number of days to include in overview display.
+Should be 1 or 7.
+Obsolete, see `org-agenda-span'."
+   :group 'org-agenda-daily/weekly
+   :type 'integer)
+
+(make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
+
+(defcustom org-agenda-span 'week
   "Number of days to include in overview display.
-Should be 1 or 7.
+Can be day, week, month, year, or any number of days.
 Custom commands can set this variable in the options section."
   :group 'org-agenda-daily/weekly
-  :type 'integer)
+  :type '(choice (const :tag "Day" day)
+		 (const :tag "Week" week)
+		 (const :tag "Month" month)
+		 (const :tag "Year" year)
+		 (integer :tag "Custom")))
 
 (defcustom org-agenda-start-on-weekday 1
   "Non-nil means start the overview always on the specified weekday.
@@ -922,6 +967,35 @@
   :group 'org-agenda-daily/weekly
   :type 'boolean)
 
+(defcustom org-agenda-timegrid-use-ampm nil
+  "When set, show AM/PM style timestamps on the timegrid."
+  :group 'org-agenda
+  :type 'boolean)
+
+(defun org-agenda-time-of-day-to-ampm (time)
+  "Convert TIME of a string like '13:45' to an AM/PM style time string."
+  (let* ((hour-number (string-to-number (substring time 0 -3)))
+         (minute (substring time -2))
+         (ampm "am"))
+    (cond
+     ((equal hour-number 12)
+      (setq ampm "pm"))
+     ((> hour-number 12)
+      (setq ampm "pm")
+      (setq hour-number (- hour-number 12))))
+    (concat
+     (if org-agenda-time-leading-zero
+	 (format "%02d" hour-number)
+       (format "%02s" (number-to-string hour-number)))
+     ":" minute ampm)))
+
+(defun org-agenda-time-of-day-to-ampm-maybe (time)
+  "Conditionally convert TIME to AM/PM format
+based on `org-agenda-timegrid-use-ampm'"
+  (if org-agenda-timegrid-use-ampm
+      (org-agenda-time-of-day-to-ampm time)
+    time))
+
 (defcustom org-agenda-weekend-days '(6 0)
   "Which days are weekend?
 These days get the special face `org-agenda-date-weekend' in the agenda
@@ -1211,11 +1285,11 @@
   :group 'org-agenda)
 
 (defcustom org-agenda-prefix-format
-  '((agenda  . "  %-12:c%?-12t% s")
+  '((agenda  . " %i %-12:c%?-12t% s")
     (timeline  . "  % s")
-    (todo  . "  %-12:c")
-    (tags  . "  %-12:c")
-    (search . "  %-12:c"))
+    (todo  . " %i %-12:c")
+    (tags  . " %i %-12:c")
+    (search . " %i %-12:c"))
   "Format specifications for the prefix of items in the agenda views.
 An alist with four entries, for the different agenda types.  The keys to the
 sublists are `agenda', `timeline', `todo', and `tags'.  The values
@@ -1224,6 +1298,8 @@
 
   %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.
+  %i   the icon category of the item, as give in
+       `org-agenda-category-icon-alist'.
   %T   the *last* tag of the item.  Last because inherited tags come
        first in the list.
   %t   the time-of-day specification if one applies to the entry, in the
@@ -1431,6 +1507,52 @@
 				   (string :tag "Color")
 				   (sexp :tag "Face"))))))
 
+(defcustom org-agenda-day-face-function nil
+  "Function called to determine what face should be used to display a day.
+The only argument passed to that function is the day. It should
+returns a face, or nil if does not want to specify a face and let
+the normal rules apply."
+  :group 'org-agenda-line-format
+  :type 'function)
+
+(defcustom org-agenda-category-icon-alist nil
+  "Alist of category icon to be displayed in agenda views.
+
+Each entry should have the following format:
+
+  (CATEGORY-REGEXP FILE-OR-DATA TYPE DATA-P PROPS)
+
+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 ommited safely if not needed:
+TYPE indicates the image type.
+DATA-P is a boolean indicating whether the FILE-OR-DATA string is
+image data.
+PROPS are additional image attributes to assign to the image,
+like, e.g. `:ascent center'.
+
+   (\"Org\" \"/path/to/icon.png\" nil nil :ascent center)
+
+If you want to set the display properties yourself, just put a
+list as second element:
+
+  (CATEGORY-REGEXP (MY PROPERTY LIST))
+
+For example, to display a 16px horizontal space for Emacs
+category, you can use:
+
+  (\"Emacs\" '(space . (:width (16))))"
+  :group 'org-agenda-line-format
+  :type '(alist :key-type (string :tag "Regexp matching category")
+		:value-type (choice (list :tag "Icon"
+					  (string :tag "File or data")
+					  (symbol :tag "Type")
+					  (boolean :tag "Data?")
+					  (repeat :tag "Extra image properties" :inline t symbol))
+				    (list :tag "Display properties" sexp))))
+
 (defgroup org-agenda-column-view nil
   "Options concerning column view in the agenda."
   :tag "Org Agenda Column View"
@@ -1720,19 +1842,19 @@
     ("View"
      ["Day View" org-agenda-day-view
       :active (org-agenda-check-type nil 'agenda)
-      :style radio :selected (equal org-agenda-ndays 1)
+      :style radio :selected (eq org-agenda-current-span 'day)
       :keys "v d  (or just d)"]
      ["Week View" org-agenda-week-view
       :active (org-agenda-check-type nil 'agenda)
-      :style radio :selected (equal org-agenda-ndays 7)
+      :style radio :selected (eq org-agenda-current-span 'week)
       :keys "v w  (or just w)"]
      ["Month View" org-agenda-month-view
       :active (org-agenda-check-type nil 'agenda)
-      :style radio :selected (member org-agenda-ndays '(28 29 30 31))
+      :style radio :selected (eq org-agenda-current-span 'month)
       :keys "v m"]
      ["Year View" org-agenda-year-view
       :active (org-agenda-check-type nil 'agenda)
-      :style radio :selected (member org-agenda-ndays '(365 366))
+      :style radio :selected (eq org-agenda-current-span 'year)
       :keys "v y"]
      "--"
      ["Include Diary" org-agenda-toggle-diary
@@ -2778,6 +2900,7 @@
 (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
   "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
@@ -3065,6 +3188,16 @@
 		      (progn (delete-overlay o) t)))
 		(overlays-in (point-min) (point-max)))))
 
+(defun org-agenda-get-day-face (date)
+  "Return the face DATE should be displayed with."
+  (or (and (functionp org-agenda-day-face-function)
+	   (funcall org-agenda-day-face-function date))
+      (cond ((org-agenda-todayp date)
+	     'org-agenda-date-today)
+	    ((member (calendar-day-of-week date) org-agenda-weekend-days)
+	     'org-agenda-date-weekend)
+	    (t 'org-agenda-date))))
+
 ;;; Agenda timeline
 
 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
@@ -3092,10 +3225,10 @@
 					 org-timeline-show-empty-dates))
 	 (org-deadline-warning-days 0)
 	 (org-agenda-only-exact-dates t)
-	 (today (time-to-days (current-time)))
+	 (today (org-today))
 	 (past t)
 	 args
-	 s e rtn d emptyp wd)
+	 s e rtn d emptyp)
     (setq org-agenda-redo-command
 	  (list 'progn
 		(list 'org-switch-to-buffer-other-window (current-buffer))
@@ -3129,8 +3262,7 @@
 	    (progn
 	      (setq past nil)
 	      (insert (make-string 79 ?-) "\n")))
-	(setq date (calendar-gregorian-from-absolute d)
-	      wd (calendar-day-of-week date))
+	(setq date (calendar-gregorian-from-absolute d))
 	(setq s (point))
 	(setq rtn (and (not emptyp)
 		       (apply 'org-agenda-get-day-entries entry
@@ -3144,9 +3276,7 @@
 		 (funcall org-agenda-format-date date))
 	       "\n")
 	      (put-text-property s (1- (point)) 'face
-				 (if (member wd org-agenda-weekend-days)
-				     'org-agenda-date-weekend
-				   'org-agenda-date))
+				 (org-agenda-get-day-face date))
 	      (put-text-property s (1- (point)) 'org-date-line t)
 	      (put-text-property s (1- (point)) 'org-agenda-date-header t)
 	      (if (equal d today)
@@ -3172,7 +3302,7 @@
 	     (if inactive org-ts-regexp-both org-ts-regexp)))
 	 dates dates1 date day day1 day2 ts1 ts2)
     (if force-today
-	(setq dates (list (time-to-days (current-time)))))
+	(setq dates (list (org-today))))
     (save-excursion
       (goto-char beg)
       (while (re-search-forward re end t)
@@ -3210,7 +3340,8 @@
 (defvar org-agenda-last-arguments nil
   "The arguments of the previous call to `org-agenda'.")
 (defvar org-starting-day nil) ; local variable in the agenda buffer
-(defvar org-agenda-span 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-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
@@ -3247,7 +3378,7 @@
 the daily/weekly agenda, see `org-agenda-skip-function'.")
 
 ;;;###autoload
-(defun org-agenda-list (&optional include-all start-day ndays)
+(defun org-agenda-list (&optional include-all 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.
@@ -3258,37 +3389,36 @@
 agenda instead.
 
 With a numeric prefix argument in an interactive call, the agenda will
-span INCLUDE-ALL days.  Lisp programs should instead specify NDAYS to change
-the number of days.  NDAYS defaults to `org-agenda-ndays'.
+span INCLUDE-ALL 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 ndays include-all include-all nil))
-  (setq ndays (or ndays org-agenda-ndays)
-	start-day (or start-day org-agenda-start-day))
+      (setq span include-all include-all nil))
+  (setq start-day (or start-day org-agenda-start-day))
   (if org-agenda-overriding-arguments
       (setq include-all (car org-agenda-overriding-arguments)
 	    start-day (nth 1 org-agenda-overriding-arguments)
-	    ndays (nth 2 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 ndays))
+  (setq org-agenda-last-arguments (list include-all start-day span))
   (org-compile-prefix-format 'agenda)
   (org-set-sorting-strategy 'agenda)
-  (let* ((org-agenda-start-on-weekday
-	  (if (or (equal ndays 7) (and (null ndays) (equal 7 org-agenda-ndays)))
-	      org-agenda-start-on-weekday nil))
+  (let* ((span (org-agenda-ndays-to-span (or span org-agenda-ndays org-agenda-span)))
+	 (today (org-today))
+	 (sd (or start-day today))
+	 (ndays (org-agenda-span-to-ndays span sd))
+	 (org-agenda-start-on-weekday
+	  (if (eq ndays 7)
+	      org-agenda-start-on-weekday))
 	 (thefiles (org-agenda-files nil 'ifmode))
 	 (files thefiles)
-	 (today (time-to-days
-		 (time-subtract (current-time)
-				(list 0 (* 3600 org-extend-today-until) 0))))
-	 (sd (or start-day today))
 	 (start (if (or (null org-agenda-start-on-weekday)
-			(< org-agenda-ndays 7))
+			(< ndays 7))
 		    sd
 		  (let* ((nt (calendar-day-of-week
 			      (calendar-gregorian-from-absolute sd)))
@@ -3298,24 +3428,19 @@
 	 (day-numbers (list start))
 	 (day-cnt 0)
 	 (inhibit-redisplay (not debug-on-error))
-	 s e rtn rtnall file date d start-pos end-pos todayp nd wd
-	 clocktable-start clocktable-end)
+	 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 ndays))
-    ;; Make the list of days
-    (setq ndays (or ndays org-agenda-ndays)
-	  nd ndays)
-    (while (> ndays 1)
-      (push (1+ (car day-numbers)) day-numbers)
-      (setq ndays (1- ndays)))
+	  (list 'org-agenda-list (list 'quote include-all) start-day (list 'quote span)))
+    (dotimes (n (1- ndays))
+      (push (1+ (car day-numbers)) day-numbers))
     (setq day-numbers (nreverse day-numbers))
     (setq clocktable-start (car day-numbers)
 	  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-agenda-span
-		   (org-agenda-ndays-to-span nd))
+    (org-set-local 'org-agenda-current-span (org-agenda-ndays-to-span span))
     (when (and (or include-all org-agenda-include-all-todo)
 	       (member today day-numbers))
       (setq files thefiles
@@ -3343,7 +3468,7 @@
 	(if org-agenda-overriding-header
 	    (insert (org-add-props (copy-sequence org-agenda-overriding-header)
 			nil 'face 'org-agenda-structure) "\n")
-	  (insert (capitalize (symbol-name (org-agenda-ndays-to-span nd)))
+	  (insert (org-agenda-span-name span)
 		  "-agenda"
 		  (if (< (- d2 d1) 350)
 		      (if (= w1 w2)
@@ -3356,7 +3481,6 @@
       (org-agenda-mark-header-line s))
     (while (setq d (pop day-numbers))
       (setq date (calendar-gregorian-from-absolute d)
-	    wd (calendar-day-of-week date)
 	    s (point))
       (if (or (setq todayp (= d today))
 	      (and (not start-pos) (= d sd)))
@@ -3400,19 +3524,16 @@
 	       (funcall org-agenda-format-date date))
 	     "\n")
 	    (put-text-property s (1- (point)) 'face
-			       (if (member wd org-agenda-weekend-days)
-				   'org-agenda-date-weekend
-				 'org-agenda-date))
+			       (org-agenda-get-day-face date))
 	    (put-text-property s (1- (point)) 'org-date-line t)
 	    (put-text-property s (1- (point)) 'org-agenda-date-header t)
 	    (put-text-property s (1- (point)) 'org-day-cnt day-cnt)
 	    (when todayp
-	      (put-text-property s (1- (point)) 'org-today t)
-	      (put-text-property s (1- (point)) 'face 'org-agenda-date-today))
+	      (put-text-property s (1- (point)) 'org-today t))
 	    (if rtnall (insert
 			(org-finalize-agenda-entries
 			 (org-agenda-add-time-grid-maybe
-			  rtnall nd todayp))
+			  rtnall ndays todayp))
 			"\n"))
 	    (put-text-property s (1- (point)) 'day d)
 	    (put-text-property s (1- (point)) 'org-day-cnt day-cnt))))
@@ -3425,6 +3546,15 @@
 	(setq p (plist-put p :tstart clocktable-start))
 	(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 p (plist-put p :tags (mapconcat (lambda (x)
+						  (if (string-match "[<>=]" x)
+						      ""
+						    x))
+						filter ""))))
+	(message "%s" (plist-get p :tags)) (sit-for 2)
 	(setq tbl (apply 'org-get-clocktable p))
 	(insert tbl)))
     (goto-char (point-min))
@@ -3444,7 +3574,31 @@
     (message "")))
 
 (defun org-agenda-ndays-to-span (n)
-  (cond ((< n 7) 'day) ((= n 7) 'week) ((< n 32) 'month) (t 'year)))
+  "Return a span symbol for a span of N days, or N if none matches."
+  (cond ((symbolp n) n)
+	((= n 1) 'day)
+	((= n 7) 'week)
+	(t n)))
+
+(defun org-agenda-span-to-ndays (span start-day)
+  "Return ndays from SPAN starting at START-DAY."
+  (cond ((numberp span) span)
+	((eq span 'day) 1)
+	((eq span 'week) 7)
+	((eq span 'month)
+	 (let ((date (calendar-gregorian-from-absolute start-day)))
+	   (calendar-last-day-of-month (car date) (caddr date))))
+	((eq span 'year)
+	 (let ((date (calendar-gregorian-from-absolute start-day)))
+	   (if (calendar-leap-year-p (caddr date)) 366 365)))))
+
+(defun org-agenda-span-name (span)
+  "Return a SPAN name."
+  (if (null span)
+      ""
+    (if (symbolp span)
+	(capitalize (symbol-name span))
+      (format "%d days" span))))
 
 ;;; Agenda word search
 
@@ -3723,7 +3877,7 @@
   (org-set-sorting-strategy 'todo)
   (org-prepare-agenda "TODO")
   (if (and (stringp arg) (not (string-match "\\S-" arg))) (setq arg nil))
-  (let* ((today (time-to-days (current-time)))
+  (let* ((today (org-today))
 	 (date (calendar-gregorian-from-absolute today))
 	 (kwds org-todo-keywords-for-agenda)
 	 (completion-ignore-case t)
@@ -4347,7 +4501,8 @@
   "Do we have a reason to ignore this TODO entry because it has a time stamp?"
   (when (or org-agenda-todo-ignore-with-date
 	    org-agenda-todo-ignore-scheduled
-	    org-agenda-todo-ignore-deadlines)
+	    org-agenda-todo-ignore-deadlines
+	    org-agenda-todo-ignore-timestamp)
     (setq end (or end (save-excursion (outline-next-heading) (point))))
     (save-excursion
       (or (and org-agenda-todo-ignore-with-date
@@ -4370,7 +4525,29 @@
 		 (> (org-days-to-time (match-string 1)) 0))
 		((eq org-agenda-todo-ignore-deadlines 'past)
 		 (<= (org-days-to-time (match-string 1)) 0))
-		(t (org-deadline-close (match-string 1)))))))))
+		(t (org-deadline-close (match-string 1)))))
+	  (and org-agenda-todo-ignore-timestamp
+	       (let ((buffer (current-buffer))
+		     (regexp
+		      (concat
+		       org-scheduled-time-regexp "\\|" org-deadline-time-regexp))
+		     (start (point)))
+		 ;; Copy current buffer into a temporary one
+		 (with-temp-buffer
+		   (insert-buffer-substring buffer start end)
+		   (goto-char (point-min))
+		   ;; Delete SCHEDULED and DEADLINE items
+		   (while (re-search-forward regexp end t)
+		     (delete-region (match-beginning 0) (match-end 0)))
+		   (goto-char (point-min))
+		   ;; No search for timestamp left
+		   (when (re-search-forward org-ts-regexp nil t)
+		     (cond
+		      ((eq org-agenda-todo-ignore-timestamp 'future)
+		       (> (org-days-to-time (match-string 1)) 0))
+		      ((eq org-agenda-todo-ignore-timestamp 'past)
+		       (<= (org-days-to-time (match-string 1)) 0))
+		      (t))))))))))
 
 (defconst org-agenda-no-heading-message
   "No heading for this item in buffer or region.")
@@ -4924,6 +5101,14 @@
 (defvar org-prefix-category-max-length nil
   "Used by `org-compile-prefix-format' to remember the category field width.")
 
+(defun org-agenda-get-category-icon (category)
+  "Return an image for CATEGORY according to `org-agenda-category-icon-alist'."
+  (dolist (entry org-agenda-category-icon-alist)
+    (when (org-string-match-p (car entry) category)
+      (if (listp (cadr entry))
+	  (return (cadr entry))
+      (return (apply 'create-image (cdr entry)))))))
+
 (defun org-format-agenda-item (extra txt &optional category tags dotime
 				     noprefix remove-re habitp)
   "Format TXT to be inserted into the agenda buffer.
@@ -4948,11 +5133,17 @@
 	       org-agenda-show-inherited-tags
 	       org-agenda-hide-tags-regexp))
     (let* ((category (or category
-			 org-category
+			 (if (stringp org-category)
+			     org-category
+			   (and org-category (symbol-name org-category)))
 			 (if buffer-file-name
 			     (file-name-sans-extension
 			      (file-name-nondirectory buffer-file-name))
 			   "")))
+	   (category-icon (org-agenda-get-category-icon category))
+	   (category-icon (if category-icon
+			      (propertize " " 'display category-icon)
+			    ""))
 	   ;; time, tag, effort are needed for the eval of the prefix format
 	   (tag (if tags (nth (1- (length tags)) tags) ""))
 	   time effort neffort
@@ -5038,8 +5229,15 @@
       (if noprefix
 	  (setq rtn txt)
 	;; Prepare the variables needed in the eval of the compiled format
-	(setq time (cond (s2 (concat s1 "-" s2))
-			 (s1 (concat s1 "......"))
+	(setq time (cond (s2 (concat
+			      (org-agenda-time-of-day-to-ampm-maybe s1)
+			      "-" (org-agenda-time-of-day-to-ampm-maybe s2)
+			      (if org-agenda-timegrid-use-ampm " ")))
+			 (s1 (concat
+			      (org-agenda-time-of-day-to-ampm-maybe s1)
+			      (if org-agenda-timegrid-use-ampm
+				  "........ "
+				"......")))
 			 (t ""))
 	      extra (or (and (not habitp) extra) "")
 	      category (if (symbolp category) (symbol-name category) category)
@@ -5163,11 +5361,11 @@
 	    (t "  %-12:c%?-12t% s")))
 	(start 0)
 	varform vars var e c f opt)
-    (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctse]\\)"
+    (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctsei]\\)"
 			 s start)
       (setq var (cdr (assoc (match-string 4 s)
 			    '(("c" . category) ("t" . time) ("s" . extra)
-			      ("T" . tag) ("e" . effort))))
+			      ("i" . category-icon) ("T" . tag) ("e" . effort))))
 	    c (or (match-string 3 s) "")
 	    opt (match-beginning 1)
 	    start (1+ (match-beginning 0)))
@@ -5567,6 +5765,7 @@
   (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))
 	 (cols org-agenda-columns-active)
 	 (line (org-current-line))
 	 (window-line (- line (org-current-line (window-start))))
@@ -5839,13 +6038,10 @@
     (cond
      (tdpos (goto-char tdpos))
      ((eq org-agenda-type 'agenda)
-      (let* ((sd (time-to-days
-		  (time-subtract (current-time)
-				 (list 0 (* 3600 org-extend-today-until) 0))))
-	     (comp (org-agenda-compute-time-span sd org-agenda-span))
+      (let* ((sd (org-agenda-compute-starting-span
+		  (org-today) (or org-agenda-ndays org-agenda-span)))
 	     (org-agenda-overriding-arguments org-agenda-last-arguments))
-	(setf (nth 1 org-agenda-overriding-arguments) (car comp))
-	(setf (nth 2 org-agenda-overriding-arguments) (cdr comp))
+	(setf (nth 1 org-agenda-overriding-arguments) sd)
 	(org-agenda-redo)
 	(org-agenda-find-same-or-today-or-agenda)))
      (t (error "Cannot find today")))))
@@ -5862,28 +6058,28 @@
 With prefix ARG, go forward that many times the current span."
   (interactive "p")
   (org-agenda-check-type t 'agenda)
-  (let* ((span org-agenda-span)
+  (let* ((span org-agenda-current-span)
 	 (sd org-starting-day)
 	 (greg (calendar-gregorian-from-absolute sd))
 	 (cnt (org-get-at-bol 'org-day-cnt))
-	 greg2 nd)
+	 greg2)
     (cond
      ((eq span 'day)
-      (setq sd (+ arg sd) nd 1))
+      (setq sd (+ arg sd)))
      ((eq span 'week)
-      (setq sd (+ (* 7 arg) sd) nd 7))
+      (setq sd (+ (* 7 arg) sd)))
      ((eq span 'month)
       (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg))
 	    sd (calendar-absolute-from-gregorian greg2))
-      (setcar greg2 (1+ (car greg2)))
-      (setq nd (- (calendar-absolute-from-gregorian greg2) sd)))
+      (setcar greg2 (1+ (car greg2))))
      ((eq span 'year)
       (setq greg2 (list (car greg) (nth 1 greg) (+ arg (nth 2 greg)))
 	    sd (calendar-absolute-from-gregorian greg2))
-      (setcar (nthcdr 2 greg2) (1+ (nth 2 greg2)))
-      (setq nd (- (calendar-absolute-from-gregorian greg2) sd))))
+      (setcar (nthcdr 2 greg2) (1+ (nth 2 greg2))))
+     (t
+      (setq sd (+ (* span arg) sd))))
     (let ((org-agenda-overriding-arguments
-	   (list (car org-agenda-last-arguments) sd nd t)))
+	   (list (car org-agenda-last-arguments) sd span t)))
       (org-agenda-redo)
       (org-agenda-find-same-or-today-or-agenda cnt))))
 
@@ -5926,7 +6122,6 @@
   "Switch to daily view for agenda.
 With argument DAY-OF-YEAR, switch to that day of the year."
   (interactive "P")
-  (setq org-agenda-ndays 1)
   (org-agenda-change-time-span 'day day-of-year))
 (defun org-agenda-week-view (&optional iso-week)
   "Switch to daily view for agenda.
@@ -5936,7 +6131,6 @@
 week 12 of year 2007.  Years in the range 1938-2037 can also be
 written as 2-digit years."
   (interactive "P")
-  (setq org-agenda-ndays 7)
   (org-agenda-change-time-span 'week iso-week))
 (defun org-agenda-month-view (&optional month)
   "Switch to monthly view for agenda.
@@ -5961,70 +6155,61 @@
   "Change the agenda view to SPAN.
 SPAN may be `day', `week', `month', `year'."
   (org-agenda-check-type t 'agenda)
-  (if (and (not n) (equal org-agenda-span span))
+  (if (and (not n) (equal org-agenda-current-span span))
       (error "Viewing span is already \"%s\"" span))
   (let* ((sd (or (org-get-at-bol 'day)
 		org-starting-day))
-	 (computed (org-agenda-compute-time-span sd span n))
+	 (sd (org-agenda-compute-starting-span sd span n))
 	 (org-agenda-overriding-arguments
-	  (list (car org-agenda-last-arguments)
-		(car computed) (cdr computed) t)))
+	  (list (car org-agenda-last-arguments) sd span t)))
     (org-agenda-redo)
     (org-agenda-find-same-or-today-or-agenda))
   (org-agenda-set-mode-name)
   (message "Switched to %s view" span))
 
-(defun org-agenda-compute-time-span (sd span &optional n)
-  "Compute starting date and number of days for agenda.
+(defun org-agenda-compute-starting-span (sd span &optional n)
+  "Compute starting date for agenda.
 SPAN may be `day', `week', `month', `year'.  The return value
 is a cons cell with the starting date and the number of days,
 so that the date SD will be in that range."
   (let* ((greg (calendar-gregorian-from-absolute sd))
 	 (dg (nth 1 greg))
 	 (mg (car greg))
-	 (yg (nth 2 greg))
-	 nd w1 y1 m1 thisweek)
+	 (yg (nth 2 greg)))
     (cond
      ((eq span 'day)
       (when n
 	(setq sd (+ (calendar-absolute-from-gregorian
 		     (list mg 1 yg))
-		    n -1)))
-      (setq nd 1))
+		    n -1))))
      ((eq span 'week)
       (let* ((nt (calendar-day-of-week
 		  (calendar-gregorian-from-absolute sd)))
 	     (d (if org-agenda-start-on-weekday
 		    (- nt org-agenda-start-on-weekday)
-		  0)))
+		  0))
+	     y1)
 	(setq sd (- sd (+ (if (< d 0) 7 0) d)))
 	(when n
 	  (require 'cal-iso)
-	  (setq thisweek (car (calendar-iso-from-absolute sd)))
 	  (when (> n 99)
 	    (setq y1 (org-small-year-to-year (/ n 100))
 		  n (mod n 100)))
 	  (setq sd
 		(calendar-absolute-from-iso
 		 (list n 1
-		       (or y1 (nth 2 (calendar-iso-from-absolute sd)))))))
-	(setq nd 7)))
+		       (or y1 (nth 2 (calendar-iso-from-absolute sd)))))))))
      ((eq span 'month)
-      (when (and n (> n 99))
-	(setq y1 (org-small-year-to-year (/ n 100))
-	      n (mod n 100)))
-      (setq sd (calendar-absolute-from-gregorian
-		(list (or n mg) 1 (or y1 yg)))
-	    nd (- (calendar-absolute-from-gregorian
-		   (list (1+ (or n mg)) 1 (or y1 yg)))
-		  sd)))
+      (let (y1)
+	(when (and n (> n 99))
+	  (setq y1 (org-small-year-to-year (/ n 100))
+		n (mod n 100)))
+	(setq sd (calendar-absolute-from-gregorian
+		  (list (or n mg) 1 (or y1 yg))))))
      ((eq span 'year)
       (setq sd (calendar-absolute-from-gregorian
-		(list 1 1 (or n yg)))
-	    nd (- (calendar-absolute-from-gregorian
-		   (list 1 1 (1+ (or n yg))))
-		  sd))))
-    (cons sd nd)))
+		(list 1 1 (or n yg))))))
+    sd))
 
 (defun org-agenda-next-date-line (&optional arg)
   "Jump to the next line indicating a date in agenda buffer."
@@ -6094,11 +6279,15 @@
 	   (if org-agenda-entry-text-mode "on" "off")
 	   (if (integerp arg) arg org-agenda-entry-text-maxlines)))
 
-(defun org-agenda-clockreport-mode ()
-  "Toggle clocktable mode in an agenda buffer."
-  (interactive)
+(defun org-agenda-clockreport-mode (&optional with-filter)
+  "Toggle clocktable mode in an agenda buffer.
+With prefix arg WITH-FILTER, make the clocktable respect the current
+agenda filter."
+  (interactive "P")
   (org-agenda-check-type t 'agenda)
-  (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode))
+  (if with-filter
+      (setq org-agenda-clockreport-mode 'with-filter)
+    (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode)))
   (org-agenda-set-mode-name)
   (org-agenda-redo)
   (message "Clocktable mode is %s"
@@ -6151,7 +6340,7 @@
 	   (if org-agenda-include-diary "on" "off")))
 
 (defun org-agenda-toggle-deadlines ()
-  "Toggle diary inclusion in an agenda buffer."
+  "Toggle inclusion of entries with a deadline in an agenda buffer."
   (interactive)
   (org-agenda-check-type t 'agenda)
   (setq org-agenda-include-deadlines (not org-agenda-include-deadlines))
@@ -6173,33 +6362,36 @@
 (defun org-agenda-set-mode-name ()
   "Set the mode name to indicate all the small mode settings."
   (setq mode-name
-	(concat "Org-Agenda"
-		(if (get 'org-agenda-files 'org-restrict) " []" "")
-		(if (equal org-agenda-ndays 1) " Day"    "")
-		(if (equal org-agenda-ndays 7) " Week"   "")
-		(if org-agenda-follow-mode     " Follow" "")
-		(if org-agenda-entry-text-mode " ETxt"   "")
-		(if org-agenda-include-diary   " Diary"  "")
-		(if org-agenda-include-deadlines " Ddl"  "")
-		(if org-agenda-use-time-grid   " Grid"   "")
-		(if (and (boundp 'org-habit-show-habits)
-			 org-habit-show-habits) " Habit"   "")
-		(if (consp org-agenda-show-log) " LogAll"
-		  (if org-agenda-show-log " Log" ""))
-		(if (or org-agenda-filter (get 'org-agenda-filter
-					       :preset-filter))
-		    (concat " {" (mapconcat
-				  'identity
-				  (append (get 'org-agenda-filter
-					       :preset-filter)
-					  org-agenda-filter) "") "}")
-		  "")
-		(if org-agenda-archives-mode
-		    (if (eq org-agenda-archives-mode t)
-			" Archives"
-		      (format " :%s:" org-archive-tag))
-		  "")
-		(if org-agenda-clockreport-mode " Clock"   "")))
+	(list "Org-Agenda"
+	      (if (get 'org-agenda-files 'org-restrict) " []" "")
+	      " "
+	      '(:eval (org-agenda-span-name org-agenda-current-span))
+	      (if org-agenda-follow-mode     " Follow" "")
+	      (if org-agenda-entry-text-mode " ETxt"   "")
+	      (if org-agenda-include-diary   " Diary"  "")
+	      (if org-agenda-include-deadlines " Ddl"  "")
+	      (if org-agenda-use-time-grid   " Grid"   "")
+	      (if (and (boundp 'org-habit-show-habits)
+		       org-habit-show-habits) " Habit"   "")
+	      (if (consp org-agenda-show-log) " LogAll"
+		(if org-agenda-show-log " Log" ""))
+	      (if (or org-agenda-filter (get 'org-agenda-filter
+					     :preset-filter))
+		  (concat " {" (mapconcat
+				'identity
+				(append (get 'org-agenda-filter
+					     :preset-filter)
+					org-agenda-filter) "") "}")
+		"")
+	      (if org-agenda-archives-mode
+		  (if (eq org-agenda-archives-mode t)
+		      " Archives"
+		    (format " :%s:" org-archive-tag))
+		"")
+	      (if org-agenda-clockreport-mode
+		  (if (eq org-agenda-clockreport-mode 'with-filter)
+		      " Clock{}" " Clock")
+		"")))
   (force-mode-line-update))
 
 (defun org-agenda-post-command-hook ()
@@ -6216,7 +6408,6 @@
 
 (defun org-agenda-previous-line ()
   "Move cursor to the previous line, and show if follow-mode is active."
-
   (interactive)
   (call-interactively 'previous-line)
   (org-agenda-do-context-action))
@@ -6642,8 +6833,7 @@
 	 (buffer (marker-buffer marker))
 	 (pos (marker-position marker))
 	 (hdmarker (org-get-at-bol 'org-hd-marker))
-	 (todayp (equal (org-get-at-bol 'day)
-			(time-to-days (current-time))))
+	 (todayp (org-agenda-todayp (org-get-at-bol 'day)))
 	 (inhibit-read-only t)
 	 org-agenda-headline-snapshot-before-repeat newhead just-one)
     (org-with-remote-undo buffer
@@ -7551,25 +7741,26 @@
   (eq (get-char-property (point-at-bol) 'type)
       'org-marked-entry-overlay))
 
-(defun org-agenda-bulk-mark ()
+(defun org-agenda-bulk-mark (&optional arg)
   "Mark the entry at point for future bulk action."
-  (interactive)
-  (org-agenda-check-no-diary)
-  (let* ((m (org-get-at-bol 'org-hd-marker))
-	 ov)
-    (unless (org-agenda-bulk-marked-p)
-      (unless m (error "Nothing to mark at point"))
-      (push m org-agenda-bulk-marked-entries)
-      (setq ov (make-overlay (point-at-bol) (+ 2 (point-at-bol))))
-      (org-overlay-display ov "> "
-			   (org-get-todo-face "TODO")
-			   'evaporate)
-      (overlay-put ov 'type 'org-marked-entry-overlay))
-    (beginning-of-line 2)
-    (while (and (get-char-property (point) 'invisible) (not (eobp)))
-      (beginning-of-line 2))
-    (message "%d entries marked for bulk action"
-	     (length org-agenda-bulk-marked-entries))))
+  (interactive "p")
+  (dotimes (i (max arg 1))
+    (unless (org-get-at-bol 'org-agenda-diary-link)
+      (let* ((m (org-get-at-bol 'org-hd-marker))
+	     ov)
+	(unless (org-agenda-bulk-marked-p)
+	  (unless m (error "Nothing to mark at point"))
+	  (push m org-agenda-bulk-marked-entries)
+	  (setq ov (make-overlay (point-at-bol) (+ 2 (point-at-bol))))
+	  (org-overlay-display ov "> "
+			       (org-get-todo-face "TODO")
+			       'evaporate)
+	  (overlay-put ov 'type 'org-marked-entry-overlay))
+	(beginning-of-line 2)
+	(while (and (get-char-property (point) 'invisible) (not (eobp)))
+	  (beginning-of-line 2))
+	(message "%d entries marked for bulk action"
+		 (length org-agenda-bulk-marked-entries))))))
 
 (defun org-agenda-bulk-unmark ()
   "Unmark the entry at point for future bulk action."
@@ -7619,7 +7810,7 @@
   (interactive "P")
   (unless org-agenda-bulk-marked-entries
     (error "No entries are marked"))
-  (message "Bulk: [r]efile [$]archive [A]rch->sib [t]odo [+/-]tag [s]chedule [d]eadline")
+  (message "Bulk: [r]efile [$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [S]catter [d]eadline")
   (let* ((action (read-char-exclusive))
 	 (org-log-refile (if org-log-refile 'time nil))
 	 (entries (reverse org-agenda-bulk-marked-entries))
@@ -7681,6 +7872,29 @@
 		       (if bound
 			   (fset 'read-string old)
 			 (fmakunbound 'read-string)))))))
+
+     ((eq action '?S)
+      (let ((days (read-number
+		   (format "Scatter tasks across how many %sdays: "
+			   (if arg "week" "")) 7)))
+	(setq cmd
+	      `(let ((distance (random ,(1+ days))))
+		 (if arg
+		     (let ((dist distance)
+			   (day-of-week
+			    (calendar-day-of-week
+			     (calendar-gregorian-from-absolute (org-today)))))
+		       (dotimes (i (1+ dist))
+			 (while (member day-of-week org-agenda-weekend-days)
+			   (incf distance)
+			   (incf day-of-week)
+			   (if (= day-of-week 7)
+			       (setq day-of-week 0)))
+			 (incf day-of-week)
+			 (if (= day-of-week 7)
+			     (setq day-of-week 0)))))
+		 (org-agenda-date-later distance)))))
+
      (t (error "Invalid bulk action")))
 
     ;; Sort the markers, to make sure that parents are handled before children
@@ -7792,6 +8006,9 @@
   (let* ((cnt 0) ; count added events
 	 (org-agenda-new-buffers nil)
 	 (org-deadline-warning-days 0)
+	 ;; Do not use `org-today' here because appt only takes
+	 ;; time and without date as argument, so it may pass wrong
+	 ;; information otherwise
 	 (today (org-date-to-gregorian
 		 (time-to-days (current-time))))
 	 (org-agenda-restrict nil)
@@ -7834,14 +8051,10 @@
 
 (defun org-agenda-todayp (date)
   "Does DATE mean today, when considering `org-extend-today-until'?"
-  (let (today h)
-    (if (listp date) (setq date (calendar-absolute-from-gregorian date)))
-    (setq today (calendar-absolute-from-gregorian (calendar-current-date)))
-    (setq h (nth 2 (decode-time (current-time))))
-    (or (and (>= h org-extend-today-until)
-	     (= date today))
-	(and (< h org-extend-today-until)
-	     (= date (1- today))))))
+  (let ((today (org-today))
+	(date (if (and date (listp date)) (calendar-absolute-from-gregorian date)
+		date)))
+    (eq date today)))
 
 (provide 'org-agenda)
 
--- a/lisp/org/org-archive.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-archive.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-ascii.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-ascii.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-attach.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-attach.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-bbdb.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-bbdb.el	Sat Dec 11 17:42:53 2010 +0100
@@ -7,7 +7,7 @@
 ;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-beamer.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-beamer.el	Sat Dec 11 17:42:53 2010 +0100
@@ -2,7 +2,7 @@
 ;;
 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
-;; Version: 7.3
+;; Version: 7.4
 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex
@@ -246,14 +246,14 @@
       (if (and (string-match "\\`[0-9.]+\\'" tmp)
 	       (or (= (string-to-number tmp) 1.0)
 		   (= (string-to-number tmp) 0.0)))
-	  ;; column width 1 means cloase columns, go back to full width
+	  ;; column width 1 means close columns, go back to full width
 	  (org-beamer-close-columns-maybe)
 	(when (setq ass (assoc "BEAMER_envargs" props))
 	  (let (case-fold-search)
-	    (when (string-match "C\\(\\[[^][]*\\]\\)" (cdr ass))
+	    (while (string-match "C\\(\\[[^][]*\\]\\|<[^<>]*>\\)" (cdr ass))
 	      (setq columns-option (match-string 1 (cdr ass)))
 	      (setcdr ass (replace-match "" t t (cdr ass))))
-	    (when (string-match "c\\(\\[[^][]*\\]\\)" (cdr ass))
+	    (while (string-match "c\\(\\[[^][]*\\]\\|<[^<>]*>\\)" (cdr ass))
 	      (setq column-option (match-string 1 (cdr ass)))
 	      (setcdr ass (replace-match "" t t (cdr ass))))))
 	(org-beamer-open-columns-maybe columns-option)
--- a/lisp/org/org-bibtex.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-bibtex.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Bastien Guerry <bzg at altern dot org>
 ;;         Carsten Dominik <carsten dot dominik at gmail dot com>
 ;; Keywords: org, wp, remember
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-capture.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-capture.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -133,7 +133,10 @@
                  File to the entry matching regexp
 
              (file+datetree \"path/to/file\")
-                 Will create a heading in a date tree
+                 Will create a heading in a date tree for today's date
+
+             (file+datetree+prompt \"path/to/file\")
+                 Will create a heading in a date tree, promts for date
 
              (file+function \"path/to/file\" function-finding-location)
                  A function to find the right location in the file
@@ -280,6 +283,9 @@
 		   (list :tag "File & Date tree"
 			 (const :format "" file+datetree)
 			 (file :tag "  File"))
+		   (list :tag "File & Date tree, prompt for date"
+			 (const :format "" file+datetree+prompt)
+			 (file :tag "  File"))
 		   (list :tag "File & function"
 			 (const :format "" file+function)
 			 (file :tag "  File    ")
@@ -313,6 +319,12 @@
   :group 'org-capture
   :type 'hook)
 
+(defcustom org-capture-after-finalize-hook nil
+  "Hook that is run right after a capture process is finalized.
+  Suitable for window cleanup"
+  :group 'org-capture
+  :type 'hook)
+
 ;;; The property list for keeping information about the capture process
 
 (defvar org-capture-plist nil
@@ -461,9 +473,11 @@
      (t (setq txt "* Invalid capture template")))
     (org-capture-put :template txt)))
 
-(defun org-capture-finalize ()
-  "Finalize the capture process."
-  (interactive)
+(defun org-capture-finalize (&optional stay-with-capture)
+  "Finalize the capture process.
+With prefix argument STAY-WITH-CAPTURE, jump to the location of the
+captured item after finalizing."
+  (interactive "P")
   (unless (and org-capture-mode
 	       (buffer-base-buffer (current-buffer)))
     (error "This does not seem to be a capture buffer for Org-mode"))
@@ -548,17 +562,25 @@
 
       ;; Restore the window configuration before capture
       (set-window-configuration return-wconf))
-    (when abort-note
+
+    (run-hooks 'org-capture-after-finalize-hook)
+    ;; Special cases
+    (cond
+     (abort-note
       (cond
        ((equal abort-note 'clean)
 	(message "Capture process aborted and target buffer cleaned up"))
        ((equal abort-note 'dirty)
-	(error "Capture process aborted, but target buffer could not be cleaned up correctly"))))))
+	(error "Capture process aborted, but target buffer could not be cleaned up correctly"))))
+     (stay-with-capture
+      (org-capture-goto-last-stored)))
+    ;; Return if we did store something
+    (not abort-note)))
 
 (defun org-capture-refile ()
   "Finalize the current capture and then refile the entry.
 Refiling is done from the base buffer, because the indirect buffer is then
-already gone."
+already gone.  Any prefix argument will be passed to the refile comand."
   (interactive)
   (unless (eq (org-capture-get :type 'local) 'entry)
     (error
@@ -640,19 +662,28 @@
 	      (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
 	  (error "No match for target regexp in file %s" (nth 1 target))))
 
-       ((eq (car target) 'file+datetree)
+       ((memq (car target) '(file+datetree file+datetree+prompt))
 	(require 'org-datetree)
 	(set-buffer (org-capture-target-buffer (nth 1 target)))
 	;; Make a date tree entry, with the current date (or yesterday,
 	;; if we are extending dates for a couple of hours)
 	(org-datetree-find-date-create
 	 (calendar-gregorian-from-absolute
-	  (if org-overriding-default-time
-	      (time-to-days org-overriding-default-time)
-	    (time-to-days
-	     (time-subtract (current-time)
-			    (list 0 (* 3600 org-extend-today-until) 0)))))))
+	  (cond
+
+	   (org-overriding-default-time
+	    ;; use the overriding default time
+	    (time-to-days org-overriding-default-time))
 
+	   ((eq (car target) 'file+datetree+prompt)
+	    ;; prompt for date
+	    (time-to-days (org-read-date 
+			   nil t nil "Date for tree entry:"
+			   (days-to-time (org-today)))))
+	   (t
+	    ;; current date, possible corrected for late night workers
+	    (org-today))))))
+       
        ((eq (car target) 'file+function)
 	(set-buffer (org-capture-target-buffer (nth 1 target)))
 	(funcall (nth 2 target))
@@ -1358,5 +1389,3 @@
 ;; arch-tag: 986bf41b-8ada-4e28-bf20-e8388a7205a0
 
 ;;; org-capture.el ends here
-
-
--- a/lisp/org/org-clock.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-clock.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -34,7 +34,7 @@
 (eval-when-compile
   (require 'cl))
 
-(declare-function calendar-absolute-from-iso    "cal-iso"    (&optional date))
+(declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
 (declare-function notifications-notify "notifications" (&rest params))
 (defvar org-time-stamp-formats)
 
@@ -222,9 +222,46 @@
 	  (string :tag "Program")
 	  (function :tag "Function")))
 
+(defgroup org-clocktable nil
+  "Options concerning the clock table in Org-mode."
+  :tag "Org Clock Table"
+  :group 'org-clock)
+
+(defcustom org-clocktable-defaults
+  (list
+   :maxlevel 2
+   :scope 'file
+   :block nil
+   :tstart nil
+   :tend nil
+   :step nil
+   :stepskip0 nil
+   :fileskip0 nil
+   :tags nil
+   :emphasize nil
+   :link nil
+   :narrow '40!
+   :indent t
+   :formula nil
+   :timestamp nil
+   :level nil
+   :tcolumns nil
+   :formatter nil)
+  "Default properties for clock tables."
+  :group 'org-clock
+  :type 'plist)
+
+(defcustom org-clock-clocktable-formatter 'org-clocktable-write-default
+  "Function to turn clocking data into a table.
+For more information, see `org-clocktable-write-default'."
+  :group 'org-clocktable
+  :type 'function)
+
 (defcustom org-clock-clocktable-default-properties '(:maxlevel 2 :scope file)
-  "Default properties for new clocktables."
-  :group 'org-clock
+  "Default properties for new clocktables.
+These will be inserted into the BEGIN line, to make it easy for users to
+play with them."
+  :group 'org-clocktable
   :type 'plist)
 
 (defcustom org-clock-idle-time nil
@@ -1586,7 +1623,7 @@
     (font-lock-fontify-buffer)
     (forward-line 2)
     (buffer-substring (point) (progn
-				(re-search-forward "^#\\+END" nil t)
+				(re-search-forward "^[ \t]*#\\+END" nil t)
 				(point-at-bol)))))
 
 (defun org-clock-report (&optional arg)
@@ -1611,12 +1648,68 @@
   (let ((pos (point)) start)
     (save-excursion
       (end-of-line 1)
-      (and (re-search-backward "^#\\+BEGIN:[ \t]+clocktable" nil t)
+      (and (re-search-backward "^[ \t]*#\\+BEGIN:[ \t]+clocktable" nil t)
 	   (setq start (match-beginning 0))
-	   (re-search-forward "^#\\+END:.*" nil t)
+	   (re-search-forward "^[ \t]*#\\+END:.*" nil t)
 	   (>= (match-end 0) pos)
 	   start))))
 
+(defun org-day-of-week (day month year)
+  "Returns the day of the week as an integer."
+  (nth 6
+       (decode-time
+	(date-to-time
+	 (format "%d-%02d-%02dT00:00:00" year month day)))))
+
+(defun org-quarter-to-date (quarter year)
+  "Get the date (week day year) of the first day of a given quarter."
+  (let (startday)
+    (cond
+     ((= quarter 1)
+      (setq startday (org-day-of-week 1 1 year))
+      (cond
+       ((= startday 0)
+	(list 52 7 (- year 1)))
+       ((= startday 6)
+	(list 52 6 (- year 1)))
+       ((<= startday 4)
+	(list 1 startday year))
+       ((> startday 4)
+	(list 53 startday (- year 1)))
+       )
+      )
+     ((= quarter 2)
+      (setq startday (org-day-of-week 1 4 year))
+      (cond
+       ((= startday 0)
+	(list 13 startday year))
+       ((< startday 4)
+	(list 14 startday year))
+       ((>= startday 4)
+	(list 13 startday year))
+       )
+      )
+     ((= quarter 3)
+      (setq startday (org-day-of-week 1 7 year))
+      (cond
+       ((= startday 0)
+	(list 26 startday year))
+       ((< startday 4)
+	(list 27 startday year))
+       ((>= startday 4)
+	(list 26 startday year))
+       )
+      )
+     ((= quarter 4)
+      (setq startday (org-day-of-week 1 10 year))
+      (cond
+       ((= startday 0)
+	(list 39 startday year))
+       ((<= startday 4)
+	(list 40 startday year))
+       ((> startday 4)
+	(list 39 startday year)))))))
+
 (defun org-clock-special-range (key &optional time as-strings)
   "Return two times bordering a special time range.
 Key is a symbol specifying the range and can be one of `today', `yesterday',
@@ -1633,7 +1726,12 @@
 	 (dow (nth 6 tm))
 	 (skey (symbol-name key))
 	 (shift 0)
-	 s1 m1 h1 d1 month1 y1 diff ts te fm txt w date)
+         (q (cond ((>= (nth 4 tm) 10) 4)
+                  ((>= (nth 4 tm) 7) 3)
+                  ((>= (nth 4 tm) 4) 2)
+                  ((>= (nth 4 tm) 1) 1)))
+	 s1 m1 h1 d1 month1 y1 diff ts te fm txt w date
+	 interval tmp shiftedy shiftedm shiftedq)
     (cond
      ((string-match "^[0-9]+$" skey)
       (setq y (string-to-number skey) m 1 d 1 key 'year))
@@ -1650,6 +1748,15 @@
       (setq d (nth 1 date) month (car date) y (nth 2 date)
 	    dow 1
 	    key 'week))
+      ((string-match "^\\([0-9]+\\)-[qQ]\\([1-4]\\)$" skey)
+       (require 'cal-iso)
+       (setq y (string-to-number (match-string 1 skey)))
+       (setq q (string-to-number (match-string 2 skey)))
+       (setq date (calendar-gregorian-from-absolute
+                   (calendar-absolute-from-iso (org-quarter-to-date q y))))
+       (setq d (nth 1 date) month (car date) y (nth 2 date)
+            dow 1
+            key 'quarter))
      ((string-match "^\\([0-9]+\\)-\\([0-9]\\{1,2\\}\\)-\\([0-9]\\{1,2\\}\\)$" skey)
       (setq y (string-to-number (match-string 1 skey))
 	    month (string-to-number (match-string 2 skey))
@@ -1657,12 +1764,17 @@
 	    key 'day))
      ((string-match "\\([-+][0-9]+\\)$" skey)
       (setq shift (string-to-number (match-string 1 skey))
-	    key (intern (substring skey 0 (match-beginning 1))))))
+            key (intern (substring skey 0 (match-beginning 1))))
+       (if(and (memq key '(quarter thisq)) (> shift 0))
+         (error "Looking forward with quarters isn't implemented.")
+        ())))
+
     (when (= shift 0)
-      (cond ((eq key 'yesterday) (setq key 'today shift -1))
-	    ((eq key 'lastweek)  (setq key 'week  shift -1))
-	    ((eq key 'lastmonth) (setq key 'month shift -1))
-	    ((eq key 'lastyear)  (setq key 'year  shift -1))))
+       (cond ((eq key 'yesterday) (setq key 'today   shift -1))
+            ((eq key 'lastweek)  (setq key 'week    shift -1))
+            ((eq key 'lastmonth) (setq key 'month   shift -1))
+            ((eq key 'lastyear)  (setq key 'year    shift -1))
+            ((eq key 'lastq)     (setq key 'quarter shift -1))))
     (cond
      ((memq key '(day today))
       (setq d (+ d shift) h 0 m 0 h1 24 m1 0))
@@ -1671,6 +1783,28 @@
 	    m 0 h 0 d (- d diff) d1 (+ 7 d)))
      ((memq key '(month thismonth))
       (setq d 1 h 0 m 0 d1 1 month (+ month shift) month1 (1+ month) h1 0 m1 0))
+     ((memq key '(quarter thisq))
+      ; compute if this shift remains in this year
+      ; if not, compute how many years and quarters we have to shift (via floor*)
+      ; and compute the shifted years, months and quarters
+      (cond
+       ((< (+ (- q 1) shift) 0) ; shift not in this year
+       (setq interval (* -1 (+ (- q 1) shift)))
+       ; set tmp to ((years to shift) (quarters to shift))
+       (setq tmp (org-floor* interval 4))
+       ; due to the use of floor, 0 quarters actually means 4
+       (if (= 0 (nth 1 tmp))
+           (setq shiftedy (- y (nth 0 tmp))
+                 shiftedm 1
+                 shiftedq 1)
+         (setq shiftedy (- y (+ 1 (nth 0 tmp)))
+               shiftedm (- 13 (* 3 (nth 1 tmp)))
+               shiftedq (- 5 (nth 1 tmp))))
+       (setq d 1 h 0 m 0 d1 1 month shiftedm month1 (+ 3 shiftedm) h1 0 m1 0 y shiftedy))
+       ((> (+ q shift) 0) ; shift is whitin this year
+       (setq shiftedq (+ q shift))
+       (setq shiftedy y)
+       (setq d 1 h 0 m 0 d1 1 month (+ 1 (* 3 (- (+ q shift) 1))) month1 (+ 4 (* 3 (- (+ q shift) 1))) h1 0 m1 0))))
      ((memq key '(year thisyear))
       (setq m 0 h 0 d 1 month 1 y (+ y shift) y1 (1+ y)))
      (t (error "No such time block %s" key)))
@@ -1686,11 +1820,21 @@
      ((memq key '(month thismonth))
       (setq txt (format-time-string "%B %Y" ts)))
      ((memq key '(year thisyear))
-      (setq txt (format-time-string "the year %Y" ts))))
+      (setq txt (format-time-string "the year %Y" ts)))
+     ((memq key '(quarter thisq))
+      (setq txt (concatenate 'string (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy))))
+     )
     (if as-strings
 	(list (format-time-string fm ts) (format-time-string fm te) txt)
       (list ts te txt))))
 
+(defun org-count-quarter (n)
+  (cond
+   ((= n 1) "1st")
+   ((= n 2) "2nd")
+   ((= n 3) "3rd")
+   ((= n 4) "4th")))
+
 (defun org-clocktable-shift (dir n)
   "Try to shift the :block date of the clocktable at point.
 Point must be in the #+BEGIN: line of a clocktable, or this function
@@ -1704,7 +1848,7 @@
   (and (memq dir '(left down)) (setq n (- n)))
   (save-excursion
     (goto-char (point-at-bol))
-    (if (not (looking-at "#\\+BEGIN: clocktable\\>.*?:block[ \t]+\\(\\S-+\\)"))
+    (if (not (looking-at "^[ \t]*#\\+BEGIN:[ \t]+clocktable\\>.*?:block[ \t]+\\(\\S-+\\)"))
 	(error "Line needs a :block definition before this command works")
       (let* ((b (match-beginning 1)) (e (match-end 1))
 	     (s (match-string 1))
@@ -1713,90 +1857,95 @@
 	 ((equal s "yesterday") (setq s "today-1"))
 	 ((equal s "lastweek") (setq s "thisweek-1"))
 	 ((equal s "lastmonth") (setq s "thismonth-1"))
-	 ((equal s "lastyear") (setq s "thisyear-1")))
-	(cond
-	 ((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\)\\([-+][0-9]+\\)?$" s)
-	  (setq block (match-string 1 s)
-		shift (if (match-end 2)
-			  (string-to-number (match-string 2 s))
-			0))
-	  (setq shift (+ shift n))
-	  (setq ins (if (= shift 0) block (format "%s%+d" block shift))))
-	 ((string-match "\\([0-9]+\\)\\(-\\([wW]?\\)\\([0-9]\\{1,2\\}\\)\\(-\\([0-9]\\{1,2\\}\\)\\)?\\)?" s)
-	  ;;               1        1  2   3       3  4                4  5   6                6  5   2
-	  (setq y (string-to-number (match-string 1 s))
-		wp (and (match-end 3) (match-string 3 s))
-		mw (and (match-end 4) (string-to-number (match-string 4 s)))
-		d (and (match-end 6) (string-to-number (match-string 6 s))))
-	  (cond
-	   (d (setq ins (format-time-string
-			 "%Y-%m-%d"
-			 (encode-time 0 0 0 (+ d n) m y))))
-	   ((and wp mw (> (length wp) 0))
-	    (require 'cal-iso)
-	    (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)))))
-	   (mw
-	    (setq ins (format-time-string
-		       "%Y-%m"
-		       (encode-time 0 0 0 1 (+ mw n) y))))
-	   (y
-	    (setq ins (number-to-string (+ y n))))))
-	 (t (error "Cannot shift clocktable block")))
-	(when ins
-	  (goto-char b)
-	  (insert ins)
-	  (delete-region (point) (+ (point) (- e b)))
-	  (beginning-of-line 1)
-	  (org-update-dblock)
-	  t)))))
+	 ((equal s "lastyear") (setq s "thisyear-1"))
+	 ((equal s "lastq") (setq s "thisq-1")))
+
+       (cond
+        ((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\|thisq\\)\\([-+][0-9]+\\)?$" s)
+         (setq block (match-string 1 s)
+               shift (if (match-end 2)
+                         (string-to-number (match-string 2 s))
+                       0))
+         (setq shift (+ shift n))
+         (setq ins (if (= shift 0) block (format "%s%+d" block shift))))
+	((string-match "\\([0-9]+\\)\\(-\\([wWqQ]?\\)\\([0-9]\\{1,2\\}\\)\\(-\\([0-9]\\{1,2\\}\\)\\)?\\)?" s)
+        ;;               1        1  2   3       3  4                  4  5   6                6  5   2
+         (setq y (string-to-number (match-string 1 s))
+               wp (and (match-end 3) (match-string 3 s))
+               mw (and (match-end 4) (string-to-number (match-string 4 s)))
+	       d (and (match-end 6) (string-to-number (match-string 6 s))))
+	 (cond
+	  (d (setq ins (format-time-string
+                        "%Y-%m-%d"
+                        (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 ins (format-time-string
+                      "%G-W%V"
+                      (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date)))))
+	  ((and wp (string-match "q\\|Q" wp) mw (> (length wp) 0))
+           (require 'cal-iso)
+	   ; if the 4th + 1 quarter is requested we flip to the 1st quarter of the next year
+           (if (> (+ mw n) 4)
+               (setq mw 0
+                     y (+ 1 y))
+	     ())
+	   ; if the 1st - 1 quarter is requested we flip to the 4th quarter of the previous year
+           (if (= (+ mw n) 0)
+               (setq mw 5
+                     y (- y 1))
+             ())
+           (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)))))
+          (mw
+           (setq ins (format-time-string
+                      "%Y-%m"
+		      (encode-time 0 0 0 1 (+ mw n) y))))
+	  (y
+	   (setq ins (number-to-string (+ y n))))))
+	(t (error "Cannot shift clocktable block")))
+       (when ins
+	 (goto-char b)
+	 (insert ins)
+	 (delete-region (point) (+ (point) (- e b)))
+	 (beginning-of-line 1)
+	 (org-update-dblock)
+	 t)))))
 
 (defun org-dblock-write:clocktable (params)
   "Write the standard clocktable."
+  (setq params (org-combine-plists org-clocktable-defaults params))
   (catch 'exit
-    (let* ((hlchars '((1 . "*") (2 . "/")))
-	   (ins (make-marker))
-	   (total-time nil)
-	   (scope (plist-get params :scope))
-	   (tostring (plist-get  params :tostring))
-	   (multifile (plist-get  params :multifile))
-	   (header (plist-get  params :header))
+    (let* ((scope (plist-get params :scope))
+	   (block (plist-get params :block))
+	   (ts (plist-get params :tstart))
+	   (te (plist-get params :tend))
+	   (link (plist-get params :link))
 	   (maxlevel (or (plist-get params :maxlevel) 3))
 	   (step (plist-get params :step))
-	   (emph (plist-get params :emphasize))
 	   (timestamp (plist-get params :timestamp))
-	   (ts (plist-get params :tstart))
-	   (te (plist-get params :tend))
-	   (block (plist-get params :block))
-	   (link (plist-get params :link))
-	   (tags (plist-get params :tags))
-	   (matcher (if tags (cdr (org-make-tags-matcher tags))))
-	   ipos time p level hlc hdl tsp props content recalc formula pcol
-	   cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list st)
-      (setq org-clock-file-total-minutes nil)
+	   (formatter (or (plist-get params :formatter)
+			  org-clock-clocktable-formatter
+			  '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
+	(setq cc (org-clock-special-range block nil t)
+	      ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
       (when step
+	;; Write many tables, in steps
 	(unless (or block (and ts te))
 	  (error "Clocktable `:step' can only be used with `:block' or `:tstart,:end'"))
 	(org-clocktable-steps params)
 	(throw 'exit nil))
-      (when block
-	(setq cc (org-clock-special-range block nil t)
-	      ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
-      (when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts)))
-      (when (integerp te) (setq te (calendar-gregorian-from-absolute te)))
-      (when (and ts (listp ts))
-	(setq ts (format "%4d-%02d-%02d" (nth 2 ts) (car ts) (nth 1 ts))))
-      (when (and te (listp te))
-	(setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te))))
-      ;; Now the times are strings we can parse.
-      (if ts (setq ts (org-float-time
-		       (apply 'encode-time (org-parse-time-string ts)))))
-      (if te (setq te (org-float-time
-		       (apply 'encode-time (org-parse-time-string te)))))
-      (move-marker ins (point))
-      (setq ipos (point))
+
+      (setq ipos (point)) ; remember the insertion position
 
       ;; Get the right scope
       (setq pos (point))
@@ -1810,166 +1959,271 @@
 	(setq scope (org-add-archive-files scope)))
        ((eq scope 'file-with-archives)
 	(setq scope (org-add-archive-files (list (buffer-file-name)))
-	      rm-file-column t)))
+	      one-file-with-archives t)))
       (setq scope-is-list (and scope (listp scope)))
-      (save-restriction
-	(cond
-	 ((not scope))
-	 ((eq scope 'file) (widen))
-	 ((eq scope 'subtree) (org-narrow-to-subtree))
-	 ((eq scope 'tree)
-	  (while (org-up-heading-safe))
-	  (org-narrow-to-subtree))
-	 ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$"
-					     (symbol-name scope)))
-	  (setq level (string-to-number (match-string 1 (symbol-name scope))))
-	  (catch 'exit
-	    (while (org-up-heading-safe)
-	      (looking-at outline-regexp)
-	      (if (<= (org-reduced-level (funcall outline-level)) level)
-		  (throw 'exit nil))))
-	  (org-narrow-to-subtree))
-	 (scope-is-list
+      (if scope-is-list
+	  ;; we collect from several files
 	  (let* ((files scope)
-		 (scope 'agenda)
-		 (p1 (copy-sequence params))
 		 file)
-	    (setq p1 (plist-put p1 :tostring t))
-	    (setq p1 (plist-put p1 :multifile t))
-	    (setq p1 (plist-put p1 :scope 'file))
 	    (org-prepare-agenda-buffers files)
 	    (while (setq file (pop files))
 	      (with-current-buffer (find-buffer-visiting file)
-		(setq org-clock-file-total-minutes 0)
-		(setq tbl1 (org-dblock-write:clocktable p1))
-		(when tbl1
-		  (push (org-clocktable-add-file
-			 file
-			 (concat "| |*File time*|*"
-				 (org-minutes-to-hh:mm-string
-				  org-clock-file-total-minutes)
-				 "*|\n"
-				 tbl1)) tbl)
-		  (setq total-time (+ (or total-time 0)
-				      org-clock-file-total-minutes))))))))
-	(goto-char pos)
+		(save-excursion
+		  (save-restriction
+		    (push (org-clock-get-table-data file params) tbls))))))
+	;; Just from the current file
+	(save-restriction
+	  ;; get the right range into the restriction
+	  (org-prepare-agenda-buffers (list (buffer-file-name)))
+	  (cond
+	   ((not scope))  ; use the restriction as it is now
+	   ((eq scope 'file) (widen))
+	   ((eq scope 'subtree) (org-narrow-to-subtree))
+	   ((eq scope 'tree)
+	    (while (org-up-heading-safe))
+	    (org-narrow-to-subtree))
+	   ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$"
+					       (symbol-name scope)))
+	    (setq level (string-to-number (match-string 1 (symbol-name scope))))
+	    (catch 'exit
+	      (while (org-up-heading-safe)
+		(looking-at outline-regexp)
+		(if (<= (org-reduced-level (funcall outline-level)) level)
+		    (throw 'exit nil))))
+	    (org-narrow-to-subtree)))
+	  ;; do the table, with no file name.
+	  (push (org-clock-get-table-data nil params) tbls)))
+
+      ;; OK, at this point we tbls as a list of tables, one per file
+      (setq tbls (nreverse tbls))
+
+      (setq params (plist-put params :multifile scope-is-list))
+      (setq params (plist-put params :one-file-with-archives
+			      one-file-with-archives))
+
+      (funcall formatter ipos tbls params))))
+
+(defun org-clocktable-write-default (ipos tables params)
+  "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 defintion."
+  ;; This function looks quite complicated, mainly because there are a lot
+  ;; of options which can add or remove columns.  I have massively commented
+  ;; function, to I hope it is understandable.  If someone want to write
+  ;; there own special formatter, this maybe much easier because there can
+  ;; be a fixed format with a well-defined number of columns...
+  (let* ((hlchars '((1 . "*") (2 . "/")))
+	 (multifile (plist-get params :multifile))
+	 (block (plist-get params :block))
+	 (ts (plist-get params :tstart))
+	 (te (plist-get params :tend))
+	 (header (plist-get  params :header))
+	 (narrow (plist-get params :narrow))
+	 (link (plist-get params :link))
+	 (maxlevel (or (plist-get params :maxlevel) 3))
+	 (emph (plist-get params :emphasize))
+	 (level-p (plist-get params :level))
+	 (timestamp (plist-get params :timestamp))
+	 (ntcol (max 1 (or (plist-get params :tcolumns) 100)))
+	 (rm-file-column (plist-get params :one-file-with-archives))
+	 (indent (plist-get params :indent))
+	 range-text total-time tbl level hlc formula pcol
+	 file-time entries entry headline
+	 recalc content narrow-cut-p tcol)
+
+    ;; Implement abbreviations
+    (when (plist-get params :compact)
+      (setq level nil indent t narrow (or narrow '40!) ntcol 1))
+
+    ;; Some consistency test for parameters
+      (unless (integerp ntcol)
+	(setq params (plist-put params :tcolumns (setq ntcol 100))))
+
+      (when (and narrow (integerp narrow) link)
+	;; We cannot have both integer narrow and link
+	(message
+	 "Using hard narrowing in clocktable to allow for links")
+	(setq narrow (intern (format "%d!" narrow))))
+
+      (when narrow
+	(cond
+	 ((integerp narrow))
+	 ((and (symbolp narrow)
+	       (string-match "\\`[0-9]+!\\'" (symbol-name narrow)))
+	  (setq narrow-cut-p t
+		narrow (string-to-number (substring (symbol-name narrow)
+						    0 -1))))
+	 (t
+	  (error "Invalid value %s of :narrow property in clock table"
+		 narrow))))
+
+      (when block
+	;; Get the range text for the header
+	(setq range-text (nth 2 (org-clock-special-range block nil t))))
+
+      ;; Compute the total time
+      (setq total-time (apply '+ (mapcar 'cadr tables)))
+
+      ;; Now we need to output this tsuff
+      (goto-char ipos)
+
+      ;; Insert the text *before* the actual table
+      (insert-before-markers
+       (or header
+	   ;; Format the standard header
+	   (concat
+	    "Clock summary at ["
+	    (substring
+	     (format-time-string (cdr org-time-stamp-formats))
+	     1 -1)
+	    "]"
+	    (if block (concat ", for " range-text ".") "")
+	    "\n\n")))
+
+      ;; Insert the narrowing line
+      (when (and narrow (integerp narrow) (not narrow-cut-p))
+	(insert-before-markers
+	 "|"                            ; table line starter
+	 (if multifile "|" "")          ; file column, maybe
+	 (if level-p   "|" "")          ; level column, maybe
+	 (if timestamp "|" "")          ; timestamp column, maybe
+	 (format "<%d>| |\n" narrow)))  ; headline and time columns
 
-	(unless scope-is-list
-	  (org-clock-sum ts te
-			 (unless (null matcher)
-			   (lambda ()
-			     (let ((tags-list
-				    (org-split-string
-				     (or (org-entry-get (point) "ALLTAGS") "")
-				     ":")))
-			       (eval matcher)))))
-	  (goto-char (point-min))
-	  (setq st t)
-	  (while (or (and (bobp) (prog1 st (setq st nil))
-			  (get-text-property (point) :org-clock-minutes)
-			  (setq p (point-min)))
-		     (setq p (next-single-property-change (point) :org-clock-minutes)))
-	    (goto-char p)
-	    (when (setq time (get-text-property p :org-clock-minutes))
-	      (save-excursion
-		(beginning-of-line 1)
-		(when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$"))
-			   (setq level (org-reduced-level
-					(- (match-end 1) (match-beginning 1))))
-			   (<= level maxlevel))
-		  (setq hlc (if emph (or (cdr (assoc level hlchars)) "") "")
-			hdl (if (not link)
-				(match-string 2)
-			      (org-make-link-string
-			       (format "file:%s::%s"
-				       (buffer-file-name)
-				       (save-match-data
-					 (org-make-org-heading-search-string
-					  (match-string 2))))
-			       (match-string 2)))
-			tsp (when timestamp
-			      (setq props (org-entry-properties (point)))
-			      (or (cdr (assoc "SCHEDULED" props))
-				  (cdr (assoc "TIMESTAMP" props))
-				  (cdr (assoc "DEADLINE" props))
-				  (cdr (assoc "TIMESTAMP_IA" props)))))
-		  (if (and (not multifile) (= level 1)) (push "|-" tbl))
-		  (push (concat
-			 "| " (int-to-string level) "|"
-			 (if timestamp (concat tsp "|") "")
-			 hlc hdl hlc " |"
-			 (make-string (1- level) ?|)
-			 hlc (org-minutes-to-hh:mm-string time) hlc
-			 " |") tbl))))))
-	(setq tbl (nreverse tbl))
-	(if tostring
-	    (if tbl (mapconcat 'identity tbl "\n") nil)
-	  (goto-char ins)
-	  (insert-before-markers
-	   (or header
-	       (concat
-		"Clock summary at ["
-		(substring
-		 (format-time-string (cdr org-time-stamp-formats))
-		 1 -1)
-		"]"
-		(if block (concat ", for " range-text ".") "")
-		"\n\n"))
-	   (if scope-is-list "|File" "")
-	   "|L|" (if timestamp "Timestamp|" "") "Headline|Time|\n")
-	  (setq total-time (or total-time org-clock-file-total-minutes))
-	  (insert-before-markers
-	   "|-\n|"
-	   (if scope-is-list "|" "")
-	   (if timestamp "|Timestamp|" "|")
-	   "*Total time*| *"
-	   (org-minutes-to-hh:mm-string (or total-time 0))
-	   "*|\n|-\n")
-	  (setq tbl (delq nil tbl))
-	  (if (and (stringp (car tbl)) (> (length (car tbl)) 1)
-		   (equal (substring (car tbl) 0 2) "|-"))
-	      (pop tbl))
-	  (insert-before-markers (mapconcat
-				  'identity (delq nil tbl)
-				  (if scope-is-list "\n|-\n" "\n")))
-	  (backward-delete-char 1)
-	  (if (setq formula (plist-get params :formula))
-	      (cond
-	       ((eq formula '%)
-		(setq pcol (+ (if scope-is-list 1 0) maxlevel 3))
-		(insert
-		 (format
-		  "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f"
-		  pcol
-		  2
-		  (+ 3 (if scope-is-list 1 0))
-		  (+ (if scope-is-list 1 0) 3)
-		  (1- pcol)))
-		(setq recalc t))
-	       ((stringp formula)
-		(insert "\n#+TBLFM: " formula)
-		(setq recalc t))
-	       (t (error "invalid formula in clocktable")))
-	    ;; Should we rescue an old formula?
-	    (when (stringp (setq content (plist-get params :content)))
-	      (when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content)
-		(setq recalc t)
-		(insert "\n" (match-string 1 (plist-get params :content)))
-		(beginning-of-line 0))))
-	  (goto-char ipos)
-	  (skip-chars-forward "^|")
-	  (org-table-align)
-	  (when recalc
-	    (if (eq formula '%)
-		(save-excursion (org-table-goto-column pcol nil 'force)
-				(insert "%")))
-	    (org-table-recalculate 'all))
-	  (when rm-file-column
-	    (forward-char 1)
-	    (org-table-delete-column))
-	  total-time)))))
+      ;; Insert the table header line
+      (insert-before-markers
+       "|"                              ; table line starter
+       (if multifile "File|"      "")   ; file column, maybe
+       (if level-p   "L|"         "")   ; level column, maybe
+       (if timestamp "Timestamp|" "")   ; timestamp column, maybe
+       "Headline|Time|\n")              ; headline and time columns
+
+      ;; Insert the total time in the table
+      (insert-before-markers
+       "|-\n"                           ; a hline
+       "|"                              ; table line starter
+       (if multifile "| ALL " "")       ; file column, maybe
+       (if level-p   "|"      "")       ; level column, maybe
+       (if timestamp "|"      "")       ; timestamp column, maybe
+       "*Total time*| "                 ; instead of a headline
+       "*"
+       (org-minutes-to-hh:mm-string (or total-time 0)) ; the time
+       "*|\n")                          ; close line
+
+      ;; Now iterate over the tables and insert the data
+      ;; but only if any time has been collected
+      (when (and total-time (> total-time 0))
+
+	(while (setq tbl (pop tables))
+	  ;; now tbl is the table resulting from one file.
+	  (setq file-time (nth 1 tbl))
+	  (when (or (and file-time (> file-time 0))
+		    (not (plist-get params :fileskip0)))
+	    (insert-before-markers "|-\n")  ; a hline because a new file starts
+	    ;; First the file time, if we have multiple files
+	    (when multifile
+	      ;; Summarize the time colleted from this file
+	      (insert-before-markers
+	       (format "| %s %s | %s*File time* | *%s*|\n"
+		       (file-name-nondirectory (car tbl))
+		       (if level-p   "| " "") ; level column, maybe
+		       (if timestamp "| " "") ; timestamp column, maybe
+		       (org-minutes-to-hh:mm-string (nth 1 tbl))))) ; the time
+
+	    ;; Get the list of node entries and iterate over it
+	    (setq entries (nth 2 tbl))
+	    (while (setq entry (pop entries))
+	      (setq level (car entry)
+		    headline (nth 1 entry)
+		    hlc (if emph (or (cdr (assoc level hlchars)) "") ""))
+	      (when narrow-cut-p
+		(if (and (string-match (concat "\\`" org-bracket-link-regexp
+					       "\\'")
+				       headline)
+			 (match-end 3))
+		    (setq headline
+			  (format "[[%s][%s]]"
+				  (match-string 1 headline)
+				  (org-shorten-string (match-string 3 headline)
+						      narrow)))
+		  (setq headline (org-shorten-string headline narrow))))
+	      (insert-before-markers
+	       "|"                      ; start the table line
+	       (if multifile "|" "")    ; free space for file name column?
+	       (if level-p (format "%d|" (car entry)) "")   ; level, maybe
+	       (if timestamp (concat (nth 2 entry) "|") "") ; timestamp, maybe
+	       (if indent (org-clocktable-indent-string level) "") ; indentation
+	       hlc headline hlc "|"                                ; headline
+	       (make-string (min (1- ntcol) (or (- level 1))) ?|)
+					; empty fields for higher levels
+	       hlc (org-minutes-to-hh:mm-string (nth 3 entry)) hlc ; time
+	       "|\n"                                               ; close line
+	       )))))
+      (backward-delete-char 1)
+      (if (setq formula (plist-get params :formula))
+	  (cond
+	   ((eq formula '%)
+	    ;; compute the column where the % numbers need to go
+	    (setq pcol (+ 2
+			  (if multifile 1 0)
+			  (if level-p 1 0)
+			  (if timestamp 1 0)
+			  (min maxlevel (or ntcol 100))))
+	    ;; compute the column where the total time is
+	    (setq tcol (+ 2
+			  (if multifile 1 0)
+			  (if level-p 1 0)
+			  (if timestamp 1 0)))
+	    (insert
+	     (format
+	      "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f"
+	      pcol            ; the column where the % numbers should go
+	      (if (and narrow (not narrow-cut-p)) 3 2) ; row of the total time
+	      tcol            ; column of the total time
+	      tcol (1- pcol)  ; range of columns where times can be found
+	      ))
+	    (setq recalc t))
+	   ((stringp formula)
+	    (insert "\n#+TBLFM: " formula)
+	    (setq recalc t))
+	   (t (error "invalid formula in clocktable")))
+	;; Should we rescue an old formula?
+	(when (stringp (setq content (plist-get params :content)))
+	  (when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content)
+	    (setq recalc t)
+	    (insert "\n" (match-string 1 (plist-get params :content)))
+	    (beginning-of-line 0))))
+      ;; Back to beginning, align the table, recalculate if necessary
+      (goto-char ipos)
+      (skip-chars-forward "^|")
+      (org-table-align)
+      (when org-hide-emphasis-markers
+	;; we need to align a second time
+	(org-table-align))
+      (when recalc
+	(if (eq formula '%)
+	    (save-excursion
+	      (if (and narrow (not narrow-cut-p)) (beginning-of-line 2))
+	      (org-table-goto-column pcol nil 'force)
+	      (insert "%")))
+	(org-table-recalculate 'all))
+      (when rm-file-column
+	;; The file column is actually not wanted
+	(forward-char 1)
+	(org-table-delete-column))
+      total-time))
+
+(defun org-clocktable-indent-string (level)
+  (if (= level 1)
+      ""
+    (let ((str "\\__"))
+      (while (> level 2)
+	(setq level (1- level)
+	      str (concat str "___")))
+      (concat str " "))))
 
 (defun org-clocktable-steps (params)
+  "Step through the range to make a number of clock tables."
   (let* ((p1 (copy-sequence params))
 	 (ts (plist-get p1 :tstart))
 	 (te (plist-get p1 :tend))
@@ -2008,29 +2262,107 @@
       (setq p1 (plist-put p1 :tend (format-time-string
 				    (org-time-stamp-format nil t)
 				    (seconds-to-time (setq ts (+ ts step))))))
-      (insert "\n" (if (eq step0 'day) "Daily report: " "Weekly report starting on: ")
+      (insert "\n" (if (eq step0 'day) "Daily report: "
+		     "Weekly report starting on: ")
 	      (plist-get p1 :tstart) "\n")
       (setq step-time (org-dblock-write:clocktable p1))
-      (re-search-forward "#\\+END:")
+      (re-search-forward "^[ \t]*#\\+END:")
       (when (and (equal step-time 0) stepskip0)
 	;; Remove the empty table
 	(delete-region (point-at-bol)
 		       (save-excursion
-			 (re-search-backward "^\\(Daily\\|Weekly\\) report" nil t)
+			 (re-search-backward "^\\(Daily\\|Weekly\\) report"
+					     nil t)
 			 (point))))
       (end-of-line 0))))
 
-(defun org-clocktable-add-file (file table)
-  (if table
-      (let ((lines (org-split-string table "\n"))
-	    (ff (file-name-nondirectory file)))
-	(mapconcat 'identity
-		   (mapcar (lambda (x)
-			     (if (string-match org-table-dataline-regexp x)
-				 (concat "|" ff x)
-			       x))
-			   lines)
-		   "\n"))))
+(defun org-clock-get-table-data (file params)
+  "Get the clocktable data for file FILE, with parameters PARAMS.
+FILE is only for identification - this function assumes that
+the correct buffer is current, and that the wanted restriction is
+in place.
+The return value will be a list with the file name and the total
+file time (in minutes) as 1st and 2nd elements.  The third element
+of this list will be a list of headline entries.  Each entry has the
+following structure:
+
+  (LEVEL HEADLINE TIMESTAMP TIME)
+
+LEVEL:     The level of the headline, as an integer.  This will be
+           the reduced leve, so 1,2,3,... even if only odd levels
+           are being used.
+HEADLINE:  The text of the headline.  Depending on PARAMS, this may
+           already be formatted like a link.
+TIMESTAMP: If PARAMS require it, this will be a time stamp found in the
+           entry, any of SCHEDULED, DEADLINE, NORMAL, or first inactive,
+           in this sequence.
+TIME:      The sum of all time spend in this tree, in minutes.  This time
+           will of cause be restricted to the time block and tags match
+           specified in PARAMS."
+  (let* ((maxlevel (or (plist-get params :maxlevel) 3))
+	 (timestamp (plist-get params :timestamp))
+	 (ts (plist-get params :tstart))
+	 (te (plist-get params :tend))
+	 (block (plist-get params :block))
+	 (link (plist-get params :link))
+	 (tags (plist-get params :tags))
+	 (matcher (if tags (cdr (org-make-tags-matcher tags))))
+	 cc range-text st p time level hdl props tsp tbl)
+
+    (setq org-clock-file-total-minutes nil)
+    (when block
+      (setq cc (org-clock-special-range block nil t)
+	    ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
+    (when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts)))
+    (when (integerp te) (setq te (calendar-gregorian-from-absolute te)))
+    (when (and ts (listp ts))
+      (setq ts (format "%4d-%02d-%02d" (nth 2 ts) (car ts) (nth 1 ts))))
+    (when (and te (listp te))
+      (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te))))
+    ;; Now the times are strings we can parse.
+    (if ts (setq ts (org-float-time
+		     (apply 'encode-time (org-parse-time-string ts)))))
+    (if te (setq te (org-float-time
+		     (apply 'encode-time (org-parse-time-string te)))))
+    (save-excursion
+      (org-clock-sum ts te
+		     (unless (null matcher)
+		       (lambda ()
+			 (let ((tags-list (org-get-tags-at)))
+			   (eval matcher)))))
+      (goto-char (point-min))
+      (setq st t)
+      (while (or (and (bobp) (prog1 st (setq st nil))
+		      (get-text-property (point) :org-clock-minutes)
+		      (setq p (point-min)))
+		 (setq p (next-single-property-change
+			  (point) :org-clock-minutes)))
+	(goto-char p)
+	(when (setq time (get-text-property p :org-clock-minutes))
+	  (save-excursion
+	    (beginning-of-line 1)
+	    (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$"))
+		       (setq level (org-reduced-level
+				    (- (match-end 1) (match-beginning 1))))
+		       (<= level maxlevel))
+	      (setq hdl (if (not link)
+			    (match-string 2)
+			  (org-make-link-string
+			   (format "file:%s::%s"
+				   (buffer-file-name)
+				   (save-match-data
+				     (org-make-org-heading-search-string
+				      (match-string 2))))
+			   (match-string 2)))
+		    tsp (when timestamp
+			  (setq props (org-entry-properties (point)))
+			  (or (cdr (assoc "SCHEDULED" props))
+			      (cdr (assoc "DEADLINE" props))
+			      (cdr (assoc "TIMESTAMP" props))
+			      (cdr (assoc "TIMESTAMP_IA" props)))))
+	      (when (> time 0) (push (list level hdl tsp time) tbl))))))
+      (setq tbl (nreverse tbl))
+      (list file org-clock-file-total-minutes tbl))))
 
 (defun org-clock-time% (total &rest strings)
   "Compute a time fraction in percent.
@@ -2051,7 +2383,8 @@
 	  (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
 	      (throw 'exit
 		     (/ (* 100.0 (+ (string-to-number (match-string 2 s))
-				    (* 60 (string-to-number (match-string 1 s)))))
+				    (* 60 (string-to-number
+					   (match-string 1 s)))))
 			tot))))
 	0))))
 
@@ -2081,7 +2414,8 @@
 		   (buffer-file-name b)
 		   (or (not org-clock-persist-query-save)
 		       (y-or-n-p (concat "Save current clock ("
-					 (substring-no-properties org-clock-heading)
+					 (substring-no-properties
+					  org-clock-heading)
 					 ") "))))
 	      (insert "(setq resume-clock '(\""
 		      (buffer-file-name (org-clocking-buffer))
@@ -2162,3 +2496,4 @@
 ;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
 
 ;;; org-clock.el ends here
+
--- a/lisp/org/org-colview.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-colview.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-compat.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-compat.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -372,15 +372,15 @@
       (time-to-seconds (or time (current-time)))
     (float-time time)))
 
-(defun org-string-match-p (&rest args)
-  (if (fboundp 'string-match-p)
-      (apply 'string-match-p args)
+(if (fboundp 'string-match-p)
+    (defalias 'org-string-match-p 'string-match-p)
+  (defun org-string-match-p (regexp string &optional start)
     (save-match-data
-      (apply 'string-match args))))
+      (funcall 'string-match regexp string start))))
 
-(defun org-looking-at-p (&rest args)
-  (if (fboundp 'looking-at-p)
-      (apply 'looking-at-p args)
+(if (fboundp 'looking-at-p)
+    (defalias 'org-looking-at-p 'looking-at-p)
+  (defun org-looking-at-p (&rest args)
     (save-match-data
       (apply 'looking-at args))))
 
@@ -418,6 +418,12 @@
 	      (looking-at (concat "\\(?:"  regexp "\\)\\'")))))
       (not (null pos)))))
 
+(defun org-floor* (x &optional y)
+  "Return a list of the floor of X and the fractional part of X.
+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)
 
 ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/org/org-complete.el	Sat Dec 11 17:42:53 2010 +0100
@@ -0,0 +1,279 @@
+;;; org-complete.el --- In-buffer completion code
+
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
+;;
+;; Author: Carsten Dominik <carsten at orgmode dot org>
+;;         John Wiegley <johnw at gnu dot org>
+;; Keywords: outlines, hypermedia, calendar, wp
+;; Homepage: http://orgmode.org
+;; Version: 7.4
+;;
+;; 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/>.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+;;;; Require other packages
+
+(eval-when-compile
+  (require 'cl))
+
+(require 'org-macs)
+(require 'pcomplete)
+
+(declare-function org-split-string "org" (string &optional separators))
+(declare-function org-get-current-options "org-exp" ())
+(declare-function org-make-org-heading-search-string "org"
+		  (&optional string heading))
+(declare-function org-get-buffer-tags "org" ())
+(declare-function org-get-tags "org" ())
+(declare-function org-buffer-property-keys "org"
+		  (&optional include-specials include-defaults include-columns))
+(declare-function org-entry-properties "org" (&optional pom which specific))
+
+;;;; Customization variables
+
+(defgroup org-complete nil
+  "Outline-based notes management and organizer."
+  :tag "Org"
+  :group 'org)
+
+(defun org-thing-at-point ()
+  "Examine the thing at point and let the caller know what it is.
+The return value is a string naming the thing at point."
+  (let ((beg1 (save-excursion
+		(skip-chars-backward (org-re "[:alnum:]_@"))
+		(point)))
+	(beg (save-excursion
+	       (skip-chars-backward "a-zA-Z0-9_:$")
+	       (point)))
+	(line-to-here (buffer-substring (point-at-bol) (point))))
+    (cond
+     ((string-match "\\`[ \t]*#\\+begin: clocktable[ \t]+" line-to-here)
+      (cons "block-option" "clocktable"))
+     ((string-match "\\`[ \t]*#\\+begin_src[ \t]+" line-to-here)
+      (cons "block-option" "src"))
+     ((save-excursion
+	(re-search-backward "^[ \t]*#\\+\\([A-Z_]+\\):.*"
+			    (line-beginning-position) t))
+      (cons "file-option" (match-string-no-properties 1)))
+     ((string-match "\\`[ \t]*#\\+[a-zA-Z]*\\'" line-to-here)
+      (cons "file-option" nil))
+     ((equal (char-before beg) ?\[)
+      (cons "link" nil))
+     ((equal (char-before beg) ?\\)
+      (cons "tex" nil))
+     ((string-match "\\`\\*+[ \t]+\\'"
+		    (buffer-substring (point-at-bol) beg))
+      (cons "todo" nil))
+     ((equal (char-before beg) ?*)
+      (cons "searchhead" nil))
+     ((and (equal (char-before beg1) ?:)
+	   (equal (char-after (point-at-bol)) ?*))
+      (cons "tag" nil))
+     ((and (equal (char-before beg1) ?:)
+	   (not (equal (char-after (point-at-bol)) ?*)))
+      (cons "prop" nil))
+     (t nil))))
+
+(defun org-command-at-point ()
+  "Return the qualified name of the Org completion entity at point.
+When completing for #+STARTUP, for example, this function returns
+\"file-option/startup\"."
+  (let ((thing (org-thing-at-point)))
+    (cond
+     ((string= "file-option" (car thing))
+      (concat (car thing) "/" (downcase (cdr thing))))
+     ((string= "block-option" (car thing))
+      (concat (car thing) "/" (downcase (cdr thing))))
+     (t
+      (car thing)))))
+
+(defun org-parse-arguments ()
+  "Parse whitespace separated arguments in the current region."
+  (let ((begin (line-beginning-position))
+	(end (line-end-position))
+	begins args)
+    (save-restriction
+      (narrow-to-region begin end)
+      (save-excursion
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (skip-chars-forward " \t\n[")
+	  (setq begins (cons (point) begins))
+	  (skip-chars-forward "^ \t\n[")
+	  (setq args (cons (buffer-substring-no-properties
+			    (car begins) (point))
+			   args)))
+	(cons (reverse args) (reverse begins))))))
+
+
+(defun org-complete-initial ()
+  "Calls the right completion function for first argument completions."
+  (ignore
+   (funcall (or (pcomplete-find-completion-function
+		 (car (org-thing-at-point)))
+		pcomplete-default-completion-function))))
+
+(defvar org-additional-option-like-keywords)
+(defun pcomplete/org-mode/file-option ()
+  "Complete against all valid file options."
+  (require 'org-exp)
+  (pcomplete-here
+   (org-complete-case-double
+    (mapcar (lambda (x)
+	      (if (= ?: (aref x (1- (length x))))
+		  (concat x " ")
+		x))
+	    (delq nil
+		  (pcomplete-uniqify-list
+		   (append
+		    (mapcar (lambda (x)
+			      (if (string-match "^#\\+\\([A-Z_]+:?\\)" x)
+				  (match-string 1 x)))
+			    (org-split-string (org-get-current-options) "\n"))
+		    org-additional-option-like-keywords)))))
+   (substring pcomplete-stub 2)))
+  
+(defvar org-startup-options)
+(defun pcomplete/org-mode/file-option/startup ()
+  "Complete arguments for the #+STARTUP file option."
+  (while (pcomplete-here
+	  (let ((opts (pcomplete-uniqify-list
+		       (mapcar 'car org-startup-options))))
+	    ;; Some options are mutually exclusive, and shouldn't be completed
+	    ;; against if certain other options have already been seen.
+	    (dolist (arg pcomplete-args)
+	      (cond
+	       ((string= arg "hidestars")
+		(setq opts (delete "showstars" opts)))))
+	    opts))))
+
+(defun pcomplete/org-mode/file-option/bind ()
+  "Complete arguments for the #+BIND file option, which are variable names"
+  (let (vars)
+    (mapatoms
+     (lambda (a) (if (boundp a) (setq vars (cons (symbol-name a) vars)))))
+    (pcomplete-here vars)))
+
+(defvar org-link-abbrev-alist-local)
+(defvar org-link-abbrev-alist)
+(defun pcomplete/org-mode/link ()
+  "Complete against defined #+LINK patterns."
+  (pcomplete-here
+   (pcomplete-uniqify-list (append (mapcar 'car org-link-abbrev-alist-local)
+				   (mapcar 'car org-link-abbrev-alist)))))
+
+(defvar org-entities)
+(defun pcomplete/org-mode/tex ()
+  "Complete against TeX-style HTML entity names."
+  (require 'org-entities)
+  (while (pcomplete-here
+	  (pcomplete-uniqify-list (remove nil (mapcar 'car-safe org-entities)))
+	  (substring pcomplete-stub 1))))
+
+(defvar org-todo-keywords-1)
+(defun pcomplete/org-mode/todo ()
+  "Complete against known TODO keywords."
+  (pcomplete-here (pcomplete-uniqify-list org-todo-keywords-1)))
+
+(defvar org-todo-line-regexp)
+(defun pcomplete/org-mode/searchhead ()
+  "Complete against all headings.
+This needs more work, to handle headings with lots of spaces in them."
+  (while
+   (pcomplete-here
+    (save-excursion
+      (goto-char (point-min))
+      (let (tbl)
+	(while (re-search-forward org-todo-line-regexp nil t)
+	  (push (org-make-org-heading-search-string
+		 (match-string-no-properties 3) t)
+		tbl))
+	(pcomplete-uniqify-list tbl)))
+    (substring pcomplete-stub 1))))
+
+(defvar org-tag-alist)
+(defun pcomplete/org-mode/tag ()
+  "Complete a tag name.  Omit tags already set."
+  (while (pcomplete-here
+	  (mapcar (lambda (x)
+		    (concat x ":"))
+		  (let ((lst (pcomplete-uniqify-list
+			      (or (remove
+				   nil
+				   (mapcar (lambda (x)
+					     (and (stringp (car x)) (car x)))
+					   org-tag-alist))
+				  (mapcar 'car (org-get-buffer-tags))))))
+		    (dolist (tag (org-get-tags))
+		      (setq lst (delete tag lst)))
+		    lst))
+	  (and (string-match ".*:" pcomplete-stub)
+	       (substring pcomplete-stub (match-end 0))))))
+
+(defun pcomplete/org-mode/prop ()
+  "Complete a property name.  Omit properties already set."
+  (pcomplete-here
+   (mapcar (lambda (x)
+	     (concat x ": "))
+	   (let ((lst (pcomplete-uniqify-list
+		       (org-buffer-property-keys nil t t))))
+	     (dolist (prop (org-entry-properties))
+	       (setq lst (delete (car prop) lst)))
+	     lst))
+   (substring pcomplete-stub 1)))
+
+(defun pcomplete/org-mode/block-option/src ()
+  "Complete the arguments of a begin_src block.
+Complete a language in the first field, the header arguments and switches."
+  (pcomplete-here
+   (mapcar
+    (lambda(x) (symbol-name (nth 3 x)))
+    (cdr (car (cdr (memq :key-type (plist-get
+				    (symbol-plist
+				     'org-babel-load-languages)
+				    'custom-type)))))))
+  (while (pcomplete-here
+	  '("-n" "-r" "-l"
+	    ":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
+	    ":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
+	    ":session" ":shebang" ":tangle" ":var"))))
+
+(defun pcomplete/org-mode/block-option/clocktable ()
+  "Complete keywords in a clocktable line"
+  (while (pcomplete-here '(":maxlevel" ":scope"
+			   ":tstart" ":tend" ":block" ":step"
+			   ":stepskip0" ":fileskip0"
+			   ":emphasize" ":link" ":narrow" ":indent"
+			   ":tcolumns" ":level" ":compact" ":timestamp"
+			   ":formula" ":formatter"))))
+
+(defun org-complete-case-double (list)
+  "Return list with both upcase and downcase version of all strings in LIST."
+  (let (e res)
+    (while (setq e (pop list))
+      (setq res (cons (downcase e) (cons (upcase e) res))))
+    (nreverse res)))
+
+;;;; Finish up
+
+(provide 'org-complete)
+
+;; arch-tag: 
+
+;;; org-complete.el ends here
--- a/lisp/org/org-crypt.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-crypt.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-crypt.el
-;; Version: 7.3
+;; Version: 7.4
 ;; Keywords: org-mode
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: Peter Jones <pjones@pmade.com>
--- a/lisp/org/org-ctags.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-ctags.el	Sat Dec 11 17:42:53 2010 +0100
@@ -3,10 +3,10 @@
 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Paul Sexton <eeeickythump@gmail.com>
-;; Version: 7.3
+;; Version: 7.4
 
 ;; Keywords: org, wp
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-datetree.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-datetree.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-docbook.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-docbook.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-docbook.el
-;; Version: 7.3
+;; Version: 7.4
 ;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
 ;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
 ;; Keywords: org, wp, docbook
--- a/lisp/org/org-docview.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-docview.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Jan Böcker <jan.boecker at jboecker dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-entities.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-entities.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;;         Ulf Stegemann <ulf at zeitform dot de>
 ;; Keywords: outlines, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-exp-blocks.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-exp-blocks.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -201,9 +201,6 @@
 	(interblock start (point-max))
 	(run-hooks 'org-export-blocks-postblock-hook)))))
 
-(add-hook 'org-export-preprocess-after-include-files-hook
-	  'org-export-blocks-preprocess)
-
 ;;================================================================================
 ;; type specific functions
 
--- a/lisp/org/org-exp.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-exp.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -984,7 +984,7 @@
 	  (set-process-sentinel p 'org-export-process-sentinel)
 	  (message "Background process \"%s\": started" p))
       ;; background processing not requested, or not possible
-      (if subtree-p (progn (outline-mark-subtree) (activate-mark)))
+      (if subtree-p (progn (org-mark-subtree) (activate-mark)))
       (call-interactively (nth 1 ass))
       (when (and bpos (get-buffer-window cbuf))
 	(let ((cw (selected-window)))
@@ -1080,12 +1080,18 @@
       ;; Mark end of lists
       (org-export-mark-list-ending backend)
 
+      ;; Export code blocks
+      (org-export-blocks-preprocess)
+
       ;; Handle source code snippets
       (org-export-replace-src-segments-and-examples backend)
 
       ;; Protect short examples marked by a leading colon
       (org-export-protect-colon-examples)
 
+      ;; Protected spaces
+      (org-export-convert-protected-spaces backend)
+
       ;; Normalize footnotes
       (when (plist-get parameters :footnotes)
 	(org-footnote-normalize nil t))
@@ -1536,6 +1542,26 @@
       (add-text-properties (point) (org-end-of-subtree t)
 			   '(org-protected t)))))
 
+(defun org-export-convert-protected-spaces (backend)
+  "Convert strings like \\____ to protected spaces in all backends."
+  (goto-char (point-min))
+  (while (re-search-forward "\\\\__+" nil t)
+    (org-if-unprotected-1
+     (replace-match
+      (org-add-props
+	  (cond
+	   ((eq backend 'latex)
+	    (format "\\hspace{%dex}" (- (match-end 0) (match-beginning 0))))
+	   ((eq backend 'html)
+	    (org-add-props (match-string 0) nil
+	      'org-whitespace (- (match-end 0) (match-beginning 0))))
+	   ;; ((eq backend 'docbook))
+	   ((eq backend 'ascii)
+	    (org-add-props (match-string 0) '(org-whitespace t)))
+	   (t (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
+	  '(org-protected t))
+      t t))))
+
 (defun org-export-protect-verbatim ()
   "Mark verbatim snippets with the protection property."
   (goto-char (point-min))
@@ -2100,12 +2126,13 @@
 (defun org-export-handle-include-files ()
   "Include the contents of include files, with proper formatting."
   (let ((case-fold-search t)
-	params file markup lang start end prefix prefix1 switches all)
+	params file markup lang start end prefix prefix1 switches all minlevel)
     (goto-char (point-min))
     (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
       (setq params (read (concat "(" (match-string 1) ")"))
 	    prefix (org-get-and-remove-property 'params :prefix)
 	    prefix1 (org-get-and-remove-property 'params :prefix1)
+	    minlevel (org-get-and-remove-property 'params :minlevel)
 	    file (org-symname-or-string (pop params))
 	    markup (org-symname-or-string (pop params))
 	    lang (and (member markup '("src" "SRC"))
@@ -2128,7 +2155,7 @@
 		  end  (format "#+end_%s" markup))))
 	(insert (or start ""))
 	(insert (org-get-file-contents (expand-file-name file)
-				       prefix prefix1 markup))
+				       prefix prefix1 markup minlevel))
 	(or (bolp) (newline))
 	(insert (or end ""))))
     all))
@@ -2145,7 +2172,7 @@
 	(when intersection
 	  (error "Recursive #+INCLUDE: %S" intersection))))))
 
-(defun org-get-file-contents (file &optional prefix prefix1 markup)
+(defun org-get-file-contents (file &optional prefix prefix1 markup minlevel)
   "Get the contents of FILE and return them as a string.
 If PREFIX is a string, prepend it to each line.  If PREFIX1
 is a string, prepend it to the first line instead of PREFIX.
@@ -2167,6 +2194,9 @@
 	(goto-char (match-beginning 0))
 	(insert ",")
 	(end-of-line 1)))
+    (when minlevel
+      (dotimes (lvl minlevel)
+	(org-map-region 'org-demote (point-min) (point-max))))
     (buffer-string)))
 
 (defun org-get-and-remove-property (listvar prop)
@@ -2235,8 +2265,6 @@
 (defvar org-export-latex-listings-langs) ;; defined in org-latex.el
 (defvar org-export-latex-listings-w-names) ;; defined in org-latex.el
 (defvar org-export-latex-minted-langs) ;; defined in org-latex.el
-(defvar org-export-latex-minted-with-line-numbers) ;; defined in org-latex.el
-
 (defun org-export-format-source-code-or-example
   (backend lang code &optional opts indent caption)
   "Format CODE from language LANG and return it formatted for export.
@@ -2403,8 +2431,7 @@
 				     (format "\n%s $\\equiv$ \n"
 					     (replace-regexp-in-string
 					      "_" "\\\\_" caption)))
-				   (format
-				    "\\begin{minted}[mathescape,%s\nnumbersep=5pt,\nframe=lines,\nframesep=2mm]{%s}\n" (if org-export-latex-minted-with-line-numbers "\nlinenos," "") minted-lang)
+				   (format "\\begin{minted}{%s}\n" minted-lang)
 				   rtn "\\end{minted}\n"))))
 			    (t (concat (car org-export-latex-verbatim-wrap)
 				       rtn (cdr org-export-latex-verbatim-wrap))))
@@ -2585,9 +2612,10 @@
 	;; does do the trick.
 	(if (looking-at "#[^\r\n]*")
 	    (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0))))
-	(while (re-search-forward "[\n\r]#[^\n\r]*" nil t)
-	  (append-to-buffer buffer (1+ (match-beginning 0))
-			    (min (point-max) (1+ (match-end 0))))))
+	(when (re-search-forward "^\\*+[ \t]+" nil t)
+	  (while (re-search-backward "[\n\r]#[^\n\r]*" nil t)
+	    (append-to-buffer buffer (1+ (match-beginning 0))
+			      (min (point-max) (1+ (match-end 0)))))))
       (set-buffer buffer)
       (let ((buffer-file-name file)
 	    (org-inhibit-startup t))
--- a/lisp/org/org-faces.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-faces.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -685,6 +685,15 @@
   :type 'integer
   :group 'org-faces)
 
+(defcustom org-cycle-level-faces t
+ "Non-nil means level styles cycle after level `org-n-level-faces'.
+Then so level org-n-level-faces+1 is styled like level 1.
+If nil, then all levels >=org-n-level-faces are styled like
+level org-n-level-faces"
+ :group 'org-appearance
+ :group 'org-faces
+ :type 'boolean)
+
 (defface org-latex-and-export-specials
   (let ((font (cond ((assq :inherit custom-face-attributes)
 		     '(:inherit underline))
--- a/lisp/org/org-feed.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-feed.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-footnote.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-footnote.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -303,7 +303,7 @@
      (t
       (setq re (concat "^" org-footnote-tag-for-non-org-mode-files "[ \t]*$"))
       (unless (re-search-forward re nil t)
-	(let ((max (if (and (eq major-mode 'message-mode)
+	(let ((max (if (and (derived-mode-p 'message-mode)
 			    (re-search-forward message-signature-separator nil t))
 		       (progn (beginning-of-line) (point))
 		     (goto-char (point-max)))))
--- a/lisp/org/org-freemind.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-freemind.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-gnus.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-gnus.el	Sat Dec 11 17:42:53 2010 +0100
@@ -7,7 +7,7 @@
 ;;         Tassilo Horn <tassilo at member dot fsf dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-habit.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-habit.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: John Wiegley <johnw at gnu dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -197,10 +197,7 @@
   "Determine the relative priority of a habit.
 This must take into account not just urgency, but consistency as well."
   (let ((pri 1000)
-	(now (time-to-days
-	      (or moment
-		  (time-subtract (current-time)
-				 (list 0 (* 3600 org-extend-today-until) 0)))))
+	(now (if moment (time-to-days moment) (org-today)))
 	(scheduled (org-habit-scheduled habit))
 	(deadline (org-habit-deadline habit)))
     ;; add 10 for every day past the scheduled date, and subtract for every
--- a/lisp/org/org-html.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-html.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -1213,7 +1213,11 @@
 	    (throw 'nextline nil))
 
 	  ;; Protected HTML
-	  (when (get-text-property 0 'org-protected line)
+	  (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 (par (ind (get-text-property 0 'original-indentation line)))
 	      (when (re-search-backward
 		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
@@ -2316,10 +2320,9 @@
 	 (extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
 	 (preferred (and target
 			 (cdr (assoc target org-export-preferred-target-alist))))
-	 (remove (or preferred target))
 	 (l org-level-max)
 	 snumber snu href suffix)
-    (setq extra-targets (remove remove extra-targets))
+    (setq extra-targets (remove (or preferred target) extra-targets))
     (setq extra-targets
 	  (mapconcat (lambda (x)
 		       (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
@@ -2358,12 +2361,13 @@
 		(progn
 		  (org-close-li)
 		  (if target
-		      (insert (format "<li id=\"%s\">" target) extra-targets title "<br/>\n")
+		      (insert (format "<li id=\"%s\">" (or preferred target))
+			      extra-targets title "<br/>\n")
 		    (insert "<li>" title "<br/>\n")))
 	      (aset org-levels-open (1- level) t)
 	      (org-close-par-maybe)
 	      (if target
-		  (insert (format "<ul>\n<li id=\"%s\">" target)
+		  (insert (format "<ul>\n<li id=\"%s\">" (or preferred target))
 			  extra-targets title "<br/>\n")
 		(insert "<ul>\n<li>" title "<br/>\n"))))
 	(aset org-levels-open (1- level) t)
--- a/lisp/org/org-icalendar.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-icalendar.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-id.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-id.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -600,15 +600,18 @@
 (defun org-id-store-link ()
   "Store a link to the current entry, using its ID."
   (interactive)
-  (let* ((link (org-make-link "id:" (org-id-get-create)))
-	 (case-fold-search nil)
-	 (desc (save-excursion
-		 (org-back-to-heading t)
-		 (or (and (looking-at org-complex-heading-regexp)
-			  (if (match-end 4) (match-string 4) (match-string 0)))
-		     link))))
-    (org-store-link-props :link link :description desc :type "id")
-    link))
+  (when (and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+    (let* ((link (org-make-link "id:" (org-id-get-create)))
+	   (case-fold-search nil)
+	   (desc (save-excursion
+		   (org-back-to-heading t)
+		   (or (and (looking-at org-complex-heading-regexp)
+			    (if (match-end 4)
+				(match-string 4)
+			      (match-string 0)))
+		       link))))
+      (org-store-link-props :link link :description desc :type "id")
+      link)))
 
 (defun org-id-open (id)
   "Go to the entry with id ID."
--- a/lisp/org/org-indent.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-indent.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -38,6 +38,10 @@
 (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" ())
+
 (defgroup org-indent nil
   "Options concerning dynamic virtual outline indentation."
   :tag "Org Indent"
@@ -219,35 +223,49 @@
 (defun org-indent-add-properties (beg end)
   "Add indentation properties between BEG and END.
 Assumes that BEG is at the beginning of a line."
-  (when (or t org-indent-mode)
-    (let ((inhibit-modification-hooks t)
-	  ov b e n level 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))
-	     (setq level (- (match-end 0) (match-beginning 0) 1))
-	     (setq nstars (- (* (1- level) org-indent-indentation-per-level)
-			     (1- level)))
-	     (add-text-properties
-	      (point-at-bol) (point-at-eol)
-	      (list 'line-prefix
-		    (aref org-indent-stars nstars)
-		    'wrap-prefix
-		    (aref org-indent-strings
-			  (* level org-indent-indentation-per-level)))))
-	   (when (and b (> 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 (* (or level 0) org-indent-indentation-per-level))))))))
+  (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."
@@ -255,7 +273,11 @@
   (when org-indent-mode
     (let (beg end)
       (save-excursion
-	(when (ignore-errors (org-back-to-heading))
+	(when (ignore-errors (let ((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)
@@ -268,7 +290,11 @@
   (when org-indent-mode
     (let ((beg (point)) (end limit))
       (save-excursion
-	(and (ignore-errors (org-back-to-heading t))
+	(and (ignore-errors (let ((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)))
--- a/lisp/org/org-info.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-info.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-inlinetask.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-inlinetask.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -100,6 +100,60 @@
   :group 'org-inlinetask
   :type 'boolean)
 
+(defvar org-inlinetask-export-templates
+  '((html "<pre class=\"inlinetask\"><b>%s%s</b><br>%s</pre>"
+	  '((unless (eq todo "")
+	      (format "<span class=\"%s %s\">%s%s</span> "
+		      class todo todo priority))
+	    heading content))
+    (latex "\\begin\{description\}\\item[%s%s]%s\\end\{description\}"
+	   '((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
+	     heading content))
+    (ascii "     -- %s%s%s"
+	   '((unless (eq todo "") (format "%s%s " todo priority))
+	     heading
+	     (unless (eq content "")
+	       (format "\n         ¦ %s"
+		       (mapconcat 'identity (org-split-string content "\n")
+				  "\n         ¦ ")))))
+    (docbook "<variablelist>
+<varlistentry>
+<term>%s%s</term>
+<listitem><para>%s</para></listitem>
+</varlistentry>
+</variablelist>"
+	     '((unless (eq todo "") (format "%s%s " todo priority))
+	       heading content)))
+  "Templates for inline tasks in various exporters.
+
+This variable is an alist in the shape of (BACKEND STRING OBJECTS).
+
+BACKEND is the name of the backend for the template (ascii, html...).
+
+STRING is a format control string.
+
+OBJECTS is a list of elements to be substituted into the format
+string.  They can be of any type, from a string to a form
+returning a value (thus allowing conditional insertion).  A nil
+object will be substituted as the empty string.  Obviously, there
+must be at least as many objects as %-sequences in the format
+string.
+
+Moreover, the following special keywords are provided: `todo',
+`priority', `heading', `content', `tags'.  If some of them are not
+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))
+
+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)))")
+
 (defvar org-odd-levels-only)
 (defvar org-keyword-time-regexp)
 (defvar org-drawer-regexp)
@@ -131,24 +185,56 @@
   (end-of-line -1))
 (define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)
 
+(defun org-inlinetask-outline-regexp ()
+  "Return string matching an inline task heading.
+The number of levels is controlled by `org-inlinetask-min-level'."
+  (let ((nstars (if org-odd-levels-only
+		    (1- (* org-inlinetask-min-level 2))
+		  org-inlinetask-min-level)))
+    (format "^\\(\\*\\{%d,\\}\\)[ \t]+" nstars)))
+
 (defun org-inlinetask-in-task-p ()
   "Return true if point is inside an inline task."
   (save-excursion
-    (let* ((nstars (if org-odd-levels-only
-		       (1- (* 2 (or org-inlinetask-min-level 200)))
-		     (or org-inlinetask-min-level 200)))
-	   (stars-re (concat "^\\(?:\\*\\{"
-			     (format "%d" (- nstars 1))
-			     ",\\}\\)[ \t]+"))
+    (let* ((stars-re (org-inlinetask-outline-regexp))
 	   (task-beg-re (concat stars-re "\\(?:.*\\)"))
-	   (task-end-re (concat stars-re "\\(?:END\\|end\\)")))
+	   (task-end-re (concat stars-re "\\(?:END\\|end\\)[ \t]*$")))
       (beginning-of-line)
       (or (looking-at task-beg-re)
 	  (and (re-search-forward "^\\*+[ \t]+" nil t)
 	       (progn (beginning-of-line) (looking-at task-end-re)))))))
 
-(defvar htmlp)  ; dynamically scoped into the next function
-(defvar latexp) ; dynamically scoped into the next function
+(defun org-inlinetask-goto-beginning ()
+  "Go to the beginning of the inline task at point."
+  (end-of-line)
+  (re-search-backward (org-inlinetask-outline-regexp) nil t)
+  (when (org-looking-at-p (concat (org-inlinetask-outline-regexp) "END[ \t]*$"))
+    (re-search-backward (org-inlinetask-outline-regexp) nil t)))
+
+(defun org-inlinetask-goto-end ()
+  "Go to the end of the inline task at point."
+  (beginning-of-line)
+  (cond
+   ((org-looking-at-p (concat (org-inlinetask-outline-regexp) "END[ \t]*$"))
+    (forward-line 1))
+   ((org-looking-at-p (org-inlinetask-outline-regexp))
+    (forward-line 1)
+    (when (org-inlinetask-in-task-p)
+      (re-search-forward (org-inlinetask-outline-regexp) nil t)
+      (forward-line 1)))
+   (t
+    (re-search-forward (org-inlinetask-outline-regexp) nil t)
+    (forward-line 1))))
+
+(defun org-inlinetask-get-task-level ()
+  "Get the level of the inline task around.
+This assumes the point is inside an inline task."
+  (save-excursion
+    (end-of-line)
+    (re-search-backward (org-inlinetask-outline-regexp) nil t)
+    (- (match-end 1) (match-beginning 1))))
+
+(defvar backend) ; dynamically scoped into the next function
 (defun org-inlinetask-export-handler ()
   "Handle headlines with level larger or equal to `org-inlinetask-min-level'.
 Either remove headline and meta data, or do special formatting."
@@ -158,7 +244,7 @@
 		   (or org-inlinetask-min-level 200)))
 	 (re1 (format "^\\(\\*\\{%d,\\}\\) .*\n" nstars))
 	 (re2 (concat "^[ \t]*" org-keyword-time-regexp))
-	 headline beg end stars content indent)
+	 headline beg end stars content)
     (while (re-search-forward re1 nil t)
       (setq headline (match-string 0)
 	    stars (match-string 1)
@@ -179,40 +265,34 @@
 	(delete-region beg (1+ (match-end 0))))
       (goto-char beg)
       (when org-inlinetask-export
-	(when (string-match org-complex-heading-regexp headline)
-	  (setq headline (concat
-			  (if (match-end 2)
-			      (concat
-			       (org-add-props
-				   (format
-				    "@<span class=\"%s %s\"> %s@</span>"
-				    (if (member (match-string 2 headline)
-						org-done-keywords)
-					"done" "todo")
-				    (match-string 2 headline)
-				    (match-string 2 headline))
-				   nil 'org-protected t)
-			       " ") "")
-			  (match-string 4 headline)))
-	  (when content
+	;; content formatting
+	(when content
 	    (if (not (string-match "\\S-" content))
 		(setq content nil)
 	      (if (string-match "[ \t\n]+\\'" content)
 		  (setq content (substring content 0 (match-beginning 0))))
-	      (setq content (org-remove-indentation content))
-	      (if latexp (setq content (concat "\\quad \\\\\n" content)))))
-	  (insert (make-string (org-inlinetask-get-current-indentation) ?\ )
-		  "- ")
-	  (setq indent (make-string (current-column) ?\ ))
-	  (insert headline " ::")
-	  (if content
-	      (insert (if htmlp " " (concat "\n" indent))
-		      (mapconcat 'identity (org-split-string content "\n")
-				 (concat "\n" indent)) "\n")
-	    (insert "\n"))
-	  (insert indent)
-	  (backward-delete-char 2)
-	  (insert "THISISTHEINLINELISTTEMINATOR\n"))))))
+	      (setq content (org-remove-indentation content))))
+	(setq content (or content ""))
+	;; grab elements to export
+	(when (string-match org-complex-heading-regexp headline)
+	  (let* ((todo (or (match-string 2 headline) ""))
+		 (class (or (and (eq "" todo) "")
+			    (if (member todo org-done-keywords) "done" "todo")))
+		 (priority (or (match-string 3 headline) ""))
+		 (heading (or (match-string 4 headline) ""))
+		 (tags (or (match-string 5 headline) ""))
+		 (backend-spec (assq backend org-inlinetask-export-templates))
+		 (format-str (nth 1 backend-spec))
+		 (tokens (cadr (nth 2 backend-spec)))
+		 ;; change nil arguments into empty strings
+		 (nil-to-str (lambda (el) (or (eval el) "")))
+		 ;; build and protect export string
+		 (export-str (org-add-props
+				 (eval (append '(format format-str)
+					       (mapcar nil-to-str tokens)))
+				 nil 'org-protected t)))
+	    ;; eventually insert it
+	    (insert export-str "\n")))))))
 
 (defun org-inlinetask-get-current-indentation ()
   "Get the indentation of the last non-while line above this one."
@@ -247,31 +327,11 @@
 			    org-inlinetask-min-level))
     (replace-match "")))
 
-(defun org-inlinetask-remove-terminator ()
-  (let (beg end)
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward "THISISTHEINLINELISTTEMINATOR\n" nil t)
-	(setq beg (match-beginning 0) end (match-end 0))
-	(save-excursion
-	  (beginning-of-line 1)
-	  (and (looking-at "<p\\(ara\\)?>THISISTHEINLINELISTTEMINATOR[ \t\n]*</p\\(ara\\)?>")
-	       (setq beg (point) end (match-end 0))))
-	(delete-region beg end)))))
-
 (eval-after-load "org-exp"
   '(add-hook 'org-export-preprocess-after-tree-selection-hook
 	     'org-inlinetask-export-handler))
 (eval-after-load "org"
   '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
-(eval-after-load "org-html"
-  '(add-hook 'org-export-html-final-hook 'org-inlinetask-remove-terminator))
-(eval-after-load "org-latex"
-  '(add-hook 'org-export-latex-final-hook 'org-inlinetask-remove-terminator))
-(eval-after-load "org-ascii"
-  '(add-hook 'org-export-ascii-final-hook 'org-inlinetask-remove-terminator))
-(eval-after-load "org-docbook"
-  '(add-hook 'org-export-docbook-final-hook 'org-inlinetask-remove-terminator))
 
 (provide 'org-inlinetask)
 
--- a/lisp/org/org-irc.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-irc.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-jsinfo.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-jsinfo.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-latex.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-latex.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-latex.el
-;; Version: 7.3
+;; Version: 7.4
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;; Keywords: org, wp, tex
@@ -295,7 +295,14 @@
   :group 'org-export-latex
   :type 'string)
 
-(defcustom org-export-latex-hyperref-format "\\href{%s}{%s}"
+(defcustom org-export-latex-href-format "\\href{%s}{%s}"
+  "A printf format string to be applied to href links.
+The format must contain two %s instances.  The first will be filled with
+the link, the second with the link description."
+  :group 'org-export-latex
+  :type 'string)
+
+(defcustom org-export-latex-hyperref-format "\\hyperref[%s]{%s}"
   "A printf format string to be applied to hyperref links.
 The format must contain two %s instances.  The first will be filled with
 the link, the second with the link description."
@@ -453,12 +460,6 @@
 	   (symbol :tag "Major mode       ")
 	   (string :tag "Listings language"))))
 
-(defcustom org-export-latex-minted-with-line-numbers nil
-  "Should source code line numbers be included when exporting
-with the latex minted package?"
-  :group 'org-export-latex
-  :type 'boolean)
-
 (defcustom org-export-latex-remove-from-headlines
   '(:todo nil :priority nil :tags nil)
   "A plist of keywords to remove from headlines.  OBSOLETE.
@@ -1280,12 +1281,13 @@
      (org-export-apply-macros-in-string org-export-latex-append-header)
      ;; define alert if not yet defined
      "\n\\providecommand{\\alert}[1]{\\textbf{#1}}"
+     ;; beginning of the document
+     "\n\\begin{document}\n\n"
      ;; insert the title
      (format
       "\n\n\\title{%s}\n"
       ;; convert the title
-      (org-export-latex-content
-       title '(lists tables fixed-width keywords)))
+      (org-export-latex-fontify-headline title))
      ;; insert author info
      (if (plist-get opt-plist :author-info)
 	 (format "\\author{%s}\n"
@@ -1297,8 +1299,6 @@
 	     (format-time-string
 	      (or (plist-get opt-plist :date)
 		  org-export-latex-date-format)))
-     ;; beginning of the document
-     "\n\\begin{document}\n\n"
      ;; insert the title command
      (when (string-match "\\S-" title)
        (if (string-match "%s" org-export-latex-title-command)
@@ -1325,7 +1325,7 @@
   (save-excursion
     (goto-char (or beg (point-min)))
     (let* ((pt (point))
-	   (end (if (re-search-forward "^\\*+ " end t)
+	   (end (if (re-search-forward (org-get-limited-outline-regexp) end t)
 		    (goto-char (match-beginning 0))
 		  (goto-char (or end (point-max))))))
       (prog1
@@ -1452,6 +1452,33 @@
     ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
     ;; the beginning of the buffer - inserting "\n" is safe here though.
     (insert "\n" string)
+
+    ;; Preserve math snippets
+    
+    (let* ((matchers (plist-get org-format-latex-options :matchers))
+	   (re-list org-latex-regexps)
+	   beg end re e m n block off)
+      ;; 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 off (if (member m '("$" "$1")) 1 0))
+	(when (and (member m matchers) (not (equal m "begin")))
+	  (goto-char (point-min))
+	  (while (re-search-forward re nil t)
+	    (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
+	    (add-text-properties beg end
+				 '(org-protected t org-latex-math t))))))
+
+    ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
+    (goto-char (point-min))
+    (let ((case-fold-search nil))
+      (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
+	(unless (eq (char-before (match-beginning 1)) ?\\)
+	  (org-if-unprotected-1
+	   (replace-match (org-export-latex-protect-string
+			   (concat "\\" (match-string 1)
+				   "{}")) t t)))))
     (goto-char (point-min))
     (let ((re (concat "\\\\\\([a-zA-Z]+\\)"
 		      "\\(?:<[^<>\n]*>\\)*"
@@ -2016,10 +2043,10 @@
 	      (insert (format
 		       (org-export-get-coderef-format path desc)
 		       (cdr (assoc path org-export-code-refs)))))
-	     (radiop (insert (format "\\hyperref[%s]{%s}"
+	     (radiop (insert (format org-export-latex-hyperref-format
 				     (org-solidify-link-text raw-path) desc)))
 	     ((not type)
-	      (insert (format "\\hyperref[%s]{%s}"
+	      (insert (format org-export-latex-hyperref-format
 			      (org-remove-initial-hash
 			       (org-solidify-link-text raw-path))
 			      desc)))
@@ -2030,7 +2057,7 @@
 		;; 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 (format org-export-latex-hyperref-format path desc)))
+	      (insert (format org-export-latex-href-format path desc)))
 
 	     ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
 	      ;; The link protocol has a function for formatting the link
@@ -2356,7 +2383,7 @@
 			   "\n"
 			   (match-string 1 res))
 		   t t res)))
-      (insert res "\n"))))
+      (insert res))))
 
 (defconst org-latex-entities
  '("\\!"
--- a/lisp/org/org-list.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-list.el	Sat Dec 11 17:42:53 2010 +0100
@@ -7,7 +7,7 @@
 ;;	   Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -462,7 +462,8 @@
 	(forward-line -1)
 	(catch 'exit
 	  (while t
-	    (let ((ind (org-get-indentation)))
+	    (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
+			(org-get-indentation))))
 	      (cond
 	       ((looking-at "^[ \t]*:END:")
 		(throw 'exit item-ref))
@@ -502,7 +503,8 @@
       (catch 'exit
 	(while t
 	  (skip-chars-forward " \t")
-	  (let ((ind (org-get-indentation)))
+	  (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
+			(org-get-indentation))))
 	    (cond
 	     ((or (>= (point) limit)
 		  (looking-at ":END:"))
@@ -518,7 +520,11 @@
 	      (setq ind-ref ind)
 	      (forward-line 1))
 	     ((<= ind ind-ref)
-	      (throw 'exit (point-at-bol)))
+	      (throw 'exit (progn
+			     ;; Again, ensure bottom is just after a
+			     ;; non-blank line.
+			     (skip-chars-backward " \r\t\n")
+			     (min (point-max) (1+ (point-at-eol))))))
 	     ((looking-at "#\\+begin_")
 	      (re-search-forward "[ \t]*#\\+end_")
 	      (forward-line 1))
@@ -636,7 +642,7 @@
 	    ;; insert bullet above item in order to avoid bothering
 	    ;; with possible blank lines ending last item.
 	    (goto-char (org-get-item-beginning))
-            (indent-to-column ind)
+            (org-indent-to-column ind)
 	    (insert (concat bullet (when checkbox "[ ] ") after-bullet))
 	    ;; Stay between after-bullet and before text.
 	    (save-excursion
@@ -1060,7 +1066,7 @@
 	(org-list-exchange-items actual-item next-item bottom)
 	(org-list-repair nil nil bottom)
 	(goto-char (org-get-next-item (point) bottom))
-	(move-to-column col)))))
+	(org-move-to-column col)))))
 
 (defun org-move-item-up ()
   "Move the plain list item at point up, i.e. swap with previous item.
@@ -1081,7 +1087,7 @@
 	    (error "Cannot move this item further up"))
 	(org-list-exchange-items prev-item actual-item bottom)
 	(org-list-repair nil top bottom)
-	(move-to-column col)))))
+	(org-move-to-column col)))))
 
 (defun org-insert-item (&optional checkbox)
   "Insert a new item at the current level.
@@ -1481,7 +1487,7 @@
           ;; this is not an empty line
           (let ((i (org-get-indentation)))
             (when (and (> i 0) (> (+ i delta) 0))
-              (indent-line-to (+ i delta)))))
+              (org-indent-line-to (+ i delta)))))
         (beginning-of-line 0)))))
 
 (defun org-outdent-item ()
@@ -1543,7 +1549,7 @@
 		   (ignore-errors
 		     (org-list-indent-item-generic 1 t top bottom))))
 	     (t (back-to-indentation)
-		(indent-to-column (car org-tab-ind-state))
+		(org-indent-to-column (car org-tab-ind-state))
 		(end-of-line)
 		(org-list-repair (cdr org-tab-ind-state))
 		;; Break cycle
@@ -1629,35 +1635,36 @@
 is an integer, 0 means `-', 1 means `+' etc. If WHICH is
 'previous, cycle backwards."
   (interactive "P")
-  (let* ((top (org-list-top-point))
-	 (bullet (save-excursion
-		   (goto-char (org-get-beginning-of-list top))
-		   (org-get-bullet)))
-	 (current (cond
-		   ((string-match "\\." bullet) "1.")
-		   ((string-match ")" bullet) "1)")
-		   (t bullet)))
-	 (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules)))
-	 (bullet-list (append '("-" "+" )
-			      ;; *-bullets are not allowed at column 0
-			      (unless (and bullet-rule-p
-					   (looking-at "\\S-")) '("*"))
-			      ;; Description items cannot be numbered
-			      (unless (and bullet-rule-p
-					   (or (eq org-plain-list-ordered-item-terminator ?\))
-					       (org-at-item-description-p))) '("1."))
-			      (unless (and bullet-rule-p
-					   (or (eq org-plain-list-ordered-item-terminator ?.)
-					       (org-at-item-description-p))) '("1)"))))
-	 (len (length bullet-list))
-	 (item-index (- len (length (member current bullet-list))))
-	 (get-value (lambda (index) (nth (mod index len) bullet-list)))
-	 (new (cond
-	       ((member which bullet-list) which)
-	       ((numberp which) (funcall get-value which))
-	       ((eq 'previous which) (funcall get-value (1- item-index)))
-	       (t (funcall get-value (1+ item-index))))))
-    (org-list-repair new top)))
+  (save-excursion
+    (let* ((top (org-list-top-point))
+	   (bullet (progn
+		     (goto-char (org-get-beginning-of-list top))
+		     (org-get-bullet)))
+	   (current (cond
+		     ((string-match "\\." bullet) "1.")
+		     ((string-match ")" bullet) "1)")
+		     (t bullet)))
+	   (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules)))
+	   (bullet-list (append '("-" "+" )
+				;; *-bullets are not allowed at column 0
+				(unless (and bullet-rule-p
+					     (looking-at "\\S-")) '("*"))
+				;; Description items cannot be numbered
+				(unless (and bullet-rule-p
+					     (or (eq org-plain-list-ordered-item-terminator ?\))
+						 (org-at-item-description-p))) '("1."))
+				(unless (and bullet-rule-p
+					     (or (eq org-plain-list-ordered-item-terminator ?.)
+						 (org-at-item-description-p))) '("1)"))))
+	   (len (length bullet-list))
+	   (item-index (- len (length (member current bullet-list))))
+	   (get-value (lambda (index) (nth (mod index len) bullet-list)))
+	   (new (cond
+		 ((member which bullet-list) which)
+		 ((numberp which) (funcall get-value which))
+		 ((eq 'previous which) (funcall get-value (1- item-index)))
+		 (t (funcall get-value (1+ item-index))))))
+      (org-list-repair new top))))
 
 ;;; Checkboxes
 
@@ -2029,7 +2036,7 @@
     (while (org-search-forward-unenclosed org-item-beginning-re end t)
       (save-excursion
 	(beginning-of-line)
-	(setq ltype (cond ((looking-at-p "^[ \t]*[0-9]") 'ordered)
+	(setq ltype (cond ((org-looking-at-p "^[ \t]*[0-9]") 'ordered)
 			  ((org-at-item-description-p) 'descriptive)
 			  (t 'unordered))))
       (let* ((indent1 (org-get-indentation))
--- a/lisp/org/org-mac-message.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-mac-message.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: John Wiegley <johnw@gnu.org>
 ;;         Christopher Suckling <suckling at gmail dot com>
 
-;; Version: 7.3
+;; Version: 7.4
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
--- a/lisp/org/org-macs.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-macs.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -46,9 +46,16 @@
      (if (or (> emacs-major-version 23)
 	     (and (>= emacs-major-version 23)
 		  (>= emacs-minor-version 2)))
-	 (called-interactively-p ,kind)
+	 (with-no-warnings (called-interactively-p ,kind)) ;; defined with no argument in <=23.1
        (interactive-p))))
 
+(if (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)))
+
 (defmacro org-bound-and-true-p (var)
   "Return the value of symbol VAR if it is bound, else nil."
   `(and (boundp (quote ,var)) ,var))
--- a/lisp/org/org-mew.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-mew.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/org-mhe.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-mhe.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mks.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-mks.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mobile.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-mobile.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mouse.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-mouse.el	Sat Dec 11 17:42:53 2010 +0100
@@ -1,11 +1,10 @@
 ;;; org-mouse.el --- Better mouse support for org-mode
 
-;; Copyright (C) 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -1101,10 +1100,10 @@
 	 "--"
 	 ["Day View" org-agenda-day-view
 	  :active (org-agenda-check-type nil 'agenda)
-	  :style radio :selected (equal org-agenda-ndays 1)]
+	  :style radio :selected (eq org-agenda-current-span 'day)]
 	 ["Week View" org-agenda-week-view
 	  :active (org-agenda-check-type nil 'agenda)
-	  :style radio :selected (equal org-agenda-ndays 7)]
+	  :style radio :selected (eq org-agenda-current-span 'week)]
 	 "--"
 	 ["Show Logbook entries" org-agenda-log-mode
 	  :style toggle :selected org-agenda-show-log
--- a/lisp/org/org-plot.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-plot.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-protocol.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-protocol.el	Sat Dec 11 17:42:53 2010 +0100
@@ -9,7 +9,7 @@
 ;; Author: Ross Patterson <me AT rpatterson DOT net>
 ;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
 ;; Keywords: org, emacsclient, wp
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -313,7 +313,7 @@
       (let* ((start (match-beginning 0))
 	     (end (match-end 0))
 	     (hex (match-string 0 str))
-	     (replacement (org-protocol-unhex-compound hex)))
+	     (replacement (org-protocol-unhex-compound (upcase hex))))
 	(setq tmp (concat tmp (substring str 0 start) replacement))
 	(setq str (substring str end))))
     (setq tmp (concat tmp str))
--- a/lisp/org/org-publish.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-publish.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 7.3
+;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-remember.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-remember.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-rmail.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-rmail.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-src.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-src.el	Sat Dec 11 17:42:53 2010 +0100
@@ -8,7 +8,7 @@
 ;;         Dan Davison <davison at stats dot ox dot ac dot uk>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -240,8 +240,8 @@
 	    block-nindent (nth 5 info)
 	    lang-f (intern (concat lang "-mode"))
 	    begline (save-excursion (goto-char beg) (org-current-line)))
-      (if (and mark (>= mark beg) (<= mark end))
-	  (save-excursion (goto-char mark)
+      (if (and mark (>= mark beg) (<= mark (1+ end)))
+	  (save-excursion (goto-char (min mark end))
 			  (setq markline (org-current-line)
 				markcol (current-column))))
       (if (equal lang-f 'table.el-mode)
--- a/lisp/org/org-table.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-table.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -48,6 +48,12 @@
 (defvar org-export-html-table-tag) ; defined in org-exp.el
 (defvar constants-unit-system)
 
+(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, othewise, if table is not sent, the functions 
+are not run.")
+
 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
   "Non-nil means use the optimized table editor version for `orgtbl-mode'.
 In the optimized version, the table editor takes over all simple keys that
@@ -3729,7 +3735,8 @@
 	  (call-interactively 'org-table-recalculate)
 	(org-table-maybe-recalculate-line))
       (call-interactively 'org-table-align)
-      (orgtbl-send-table 'maybe))
+      (when (orgtbl-send-table 'maybe)
+	(run-hooks 'orgtbl-after-send-table-hook)))
      ((eq action 'recalc)
       (save-excursion
 	(beginning-of-line 1)
@@ -3943,7 +3950,10 @@
 	  (orgtbl-send-replace-tbl name txt))
 	(setq ntbl (1+ ntbl)))
       (message "Table converted and installed at %d receiver location%s"
-	       ntbl (if (> ntbl 1) "s" "")))))
+			   ntbl (if (> ntbl 1) "s" ""))
+      (if (> ntbl 0)
+	  ntbl
+	nil))))
 
 (defun org-remove-by-index (list indices &optional i0)
   "Remove the elements in LIST with indices in INDICES.
--- a/lisp/org/org-taskjuggler.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-taskjuggler.el	Sat Dec 11 17:42:53 2010 +0100
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-taskjuggler.el
-;; Version: 7.3
+;; Version: 7.4
 ;; Author: Christian Egli
 ;; Maintainer: Christian Egli
 ;; Keywords: org, taskjuggler, project planning
--- a/lisp/org/org-timer.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-timer.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-vm.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-vm.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-w3m.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-w3m.el	Sat Dec 11 17:42:53 2010 +0100
@@ -5,7 +5,7 @@
 ;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-wl.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-wl.el	Sat Dec 11 17:42:53 2010 +0100
@@ -7,7 +7,7 @@
 ;;         David Maus <dmaus at ictsoc dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-xoxo.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org-xoxo.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org.el	Sat Dec 11 17:41:04 2010 +0200
+++ b/lisp/org/org.el	Sat Dec 11 17:42:53 2010 +0100
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 7.3
+;; Version: 7.4
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -75,6 +75,7 @@
   (require 'gnus-sum))
 
 (require 'calendar)
+
 ;; Emacs 22 calendar compatibility:  Make sure the new variables are available
 (when (fboundp 'defvaralias)
   (unless (boundp 'calendar-view-holidays-initially-flag)
@@ -98,6 +99,7 @@
 (require 'org-compat)
 (require 'org-faces)
 (require 'org-list)
+(require 'org-complete)
 (require 'org-src)
 (require 'org-footnote)
 
@@ -186,7 +188,7 @@
 
 ;;; Version
 
-(defconst org-version "7.3"
+(defconst org-version "7.4"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -1383,12 +1385,15 @@
 (defcustom org-context-in-file-links t
   "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'.
+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 
+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')
 negates this setting for the duration of the command."
   :group 'org-link-store
-  :type 'boolean)
+  :type '(choice boolean integer))
 
 (defcustom org-keep-stored-link-after-insertion nil
   "Non-nil means keep link in list for entire session.
@@ -1958,7 +1963,7 @@
 action steps, or as different types of TODO items.  The first
 keywords are states requiring action - these states will select a headline
 for inclusion into the global TODO list Org-mode produces.  If one of
-the \"keywords\" is the vertical bat \"|\" the remaining keywords
+the \"keywords\" is the vertical bar, \"|\", the remaining keywords
 signify that no further action is necessary.  If \"|\" is not found,
 the last keyword is treated as the only DONE state of the sequence.
 
@@ -2473,6 +2478,16 @@
   :group 'org-priorities
   :type 'boolean)
 
+(defcustom org-get-priority-function nil
+  "Function to extract the priority from a string.
+The string is normally the headline.  If this is nil Org computes the
+priority from the priority cookie like [#A] in the headline.  It returns
+an integer, increasing by 1000 for each priority level.
+The user can set a different function here, which should take a string
+as an argument and return the numeric priority."
+  :group 'org-priorities
+  :type 'function)
+
 (defgroup org-time nil
   "Options concerning time stamps and deadlines in Org-mode."
   :tag "Org Time"
@@ -2613,7 +2628,7 @@
   :group 'org-agenda 
   :group 'org-time 
   :type '(choice
-	  (const :tag "Use org-aread-date-prefer-future"
+	  (const :tag "Use org-read-date-prefer-future"
 		 org-read-date-prefer-future)
 	  (const :tag "Never" nil)
 	  (const :tag "Always" t)))
@@ -2719,10 +2734,10 @@
 (defcustom org-complete-tags-always-offer-all-agenda-tags nil
   "If non-nil, always offer completion for all tags of all agenda files.
 Instead of customizing this variable directly, you might want to
-set it locally for remember buffers, because there no list of
+set it locally for capture buffers, because there no list of
 tags in that file can be created dynamically (there are none).
 
-  (add-hook 'org-remember-mode-hook
+  (add-hook 'org-capture-mode-hook
             (lambda ()
               (set (make-local-variable
                     'org-complete-tags-always-offer-all-agenda-tags)
@@ -3422,7 +3437,7 @@
 (defcustom org-emphasis-regexp-components
   '(" \t('\"{" "- \t.,:!?;'\")}\\" " \t\r\n,\"'" "." 1)
   "Components used to build the regular expression for emphasis.
-This is a list with 6 entries.  Terminology:  In an emphasis string
+This is a list with five entries.  Terminology:  In an emphasis string
 like \" *strong word* \", we call the initial space PREMATCH, the final
 space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters
 and \"trong wor\" is the body.  The different components in this variable
@@ -3506,8 +3521,8 @@
   :type 'boolean)
 
 (defcustom org-completion-fallback-command 'hippie-expand
-  "The expansion command called by \\[org-complete] in normal context.
-Normal means no org-mode-specific context."
+  "The expansion command called by \\[pcomplete] in normal context.
+Normal means, no org-mode-specific context."
   :group 'org-completion
   :type 'function)
 
@@ -3555,10 +3570,13 @@
 		  "org-agenda" (&optional end))
 (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
+(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
+(declare-function org-inlinetask-goto-end "org-inlinetask" ())
 (declare-function org-indent-mode "org-indent" (&optional arg))
 (declare-function parse-time-string "parse-time" (string))
 (declare-function org-attach-reveal "org-attach" (&optional if-exists))
 (declare-function org-export-latex-fix-inputenc "org-latex" ())
+(declare-function orgtbl-send-table "org-table" (&optional maybe))
 (defvar remember-data-file)
 (defvar texmathp-why)
 (declare-function speedbar-line-directory "speedbar" (&optional depth))
@@ -4739,6 +4757,17 @@
   ;; Turn on org-beamer-mode?
   (and org-startup-with-beamer-mode (org-beamer-mode 1))
 
+  ;; Setup the pcomplete hooks
+  (set (make-local-variable 'pcomplete-command-completion-function)
+       'org-complete-initial)
+  (set (make-local-variable 'pcomplete-command-name-function)
+       'org-command-at-point)
+  (set (make-local-variable 'pcomplete-default-completion-function)
+       'ignore)
+  (set (make-local-variable 'pcomplete-parse-arguments-function)
+       'org-parse-arguments)
+  (set (make-local-variable 'pcomplete-termination-string) "")
+
   ;; If empty file that did not turn on org-mode automatically, make it to.
   (if (and org-insert-mode-line-in-empty-file
 	   (interactive-p)
@@ -4773,6 +4802,12 @@
 		       (nthcdr 2 time))))
     (current-time)))
 
+(defun org-today ()
+  "Return today date, considering `org-extend-today-until'."
+  (time-to-days
+   (time-subtract (current-time)
+		  (list 0 (* 3600 org-extend-today-until) 0))))
+
 ;;;; Font-Lock stuff, including the activators
 
 (defvar org-mouse-map (make-sparse-keymap))
@@ -5581,14 +5616,17 @@
 (defvar org-l nil)
 (defvar org-f nil)
 (defun org-get-level-face (n)
-  "Get the right face for match N in font-lock matching of headlines."
-  (setq org-l (- (match-end 2) (match-beginning 1) 1))
-  (if org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
-  (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces))
-  (cond
-   ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
-   ((eq n 2) org-f)
-   (t (if org-level-color-stars-only nil org-f))))
+ "Get the right face for match N in font-lock matching of headlines."
+ (setq org-l (- (match-end 2) (match-beginning 1) 1))
+ (if org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
+ (if org-cycle-level-faces
+     (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces))
+   (setq org-f (nth (1- (min org-l org-n-level-faces)) org-level-faces)))
+ (cond
+  ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
+  ((eq n 2) org-f)
+  (t (if org-level-color-stars-only nil org-f))))
+
 
 (defun org-get-todo-face (kwd)
   "Get the right face for a TODO keyword KWD.
@@ -6040,8 +6078,8 @@
   (interactive)
   (let (org-show-entry-below state)
     (save-excursion
-      (goto-char (point-max))
-      (while (re-search-backward
+      (goto-char (point-min))
+      (while (re-search-forward
 	      "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)"
 	      nil t)
 	(setq state (match-string 1))
@@ -6982,11 +7020,12 @@
   "Return the level of the current entry, or nil if before the first headline.
 The level is the number of stars at the beginning of the headline."
   (save-excursion
-    (condition-case nil
-	(progn
-	  (org-back-to-heading t)
-	  (funcall outline-level))
-      (error nil))))
+    (let ((outline-regexp (org-get-limited-outline-regexp)))
+      (condition-case nil
+	  (progn
+	    (org-back-to-heading t)
+	    (funcall outline-level))
+	(error nil)))))
 
 (defun org-get-previous-line-level ()
   "Return the outline depth of the last headline before the current line.
@@ -7501,12 +7540,13 @@
       (narrow-to-region
        (progn (org-back-to-heading t) (point))
        (progn (org-end-of-subtree t t)
-	      (if (org-on-heading-p) (backward-char 1))
+	      (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
 	      (point))))))
 
 (eval-when-compile
   (defvar org-property-drawer-re))
 
+(defvar org-property-start-re)  ;; defined below
 (defun org-clone-subtree-with-time-shift (n &optional shift)
   "Clone the task (subtree) at point N times.
 The clones will be inserted as siblings.
@@ -7570,7 +7610,7 @@
 	    (and idprop (if org-clone-delete-id
 			    (org-entry-delete nil "ID")
 			  (org-id-get-create t)))
-	    (while (re-search-forward org-property-drawer-re nil t)
+	    (while (re-search-forward org-property-start-re nil t)
 	      (org-remove-empty-drawer-at "PROPERTIES" (point)))
 	    (goto-char (point-min))
 	    (when doshift
@@ -8468,7 +8508,8 @@
 (defun org-make-org-heading-search-string (&optional string heading)
   "Make search string for STRING or current headline."
   (interactive)
-  (let ((s (or string (org-get-heading))))
+  (let ((s (or string (org-get-heading)))
+	(lines org-context-in-file-links))
     (unless (and string (not heading))
       ;; We are using a headline, clean up garbage in there.
       (if (string-match org-todo-regexp s)
@@ -8482,6 +8523,13 @@
       (while (string-match org-ts-regexp s)
 	(setq s (replace-match "" t t s))))
     (or string (setq s (concat "*" s)))  ; Add * for headlines
+    (when (and string (integerp lines) (> lines 0))
+      (let ((slines (org-split-string s "\n")))
+	(when (< lines (length slines))
+	  (setq s (mapconcat 
+		   'identity
+		   (reverse (nthcdr (- (length slines) lines) 
+				    (reverse slines))) "\n")))))
     (mapconcat 'identity (org-split-string s "[ \t]+") " ")))
 
 (defun org-make-link (&rest strings)
@@ -9054,7 +9102,8 @@
 	(progn (require 'org-attach) (org-attach-reveal 'if-exists))))
    ((run-hook-with-args-until-success 'org-open-at-point-functions))
    ((org-at-timestamp-p t) (org-follow-timestamp-link))
-   ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p))
+   ((and (or (org-footnote-at-reference-p) (org-footnote-at-definition-p))
+	 (not (org-in-regexp org-bracket-link-regexp)))
     (org-footnote-action))
    (t
     (let (type path link line search (pos (point)))
@@ -9170,10 +9219,6 @@
 	      (dired path)
 	    (org-open-file path in-emacs line search)))
 
-	 ((string= type "news")
-	  (require 'org-gnus)
-	  (org-gnus-follow-link path))
-
 	 ((string= type "shell")
 	  (let ((cmd path))
 	    (if (or (not org-confirm-shell-link-function)
@@ -10464,6 +10509,7 @@
   "Update the dynamic block at point.
 This means to empty the block, parse for parameters and then call
 the correct writing function."
+  (interactive)
   (save-window-excursion
     (let* ((pos (point))
 	   (line (org-current-line))
@@ -10505,6 +10551,7 @@
 (defun org-update-all-dblocks ()
   "Update all dynamic blocks in the buffer.
 This function can be used in a hook."
+  (interactive)
   (when (org-mode-p)
     (org-map-dblocks 'org-update-dblock)))
 
@@ -10512,10 +10559,10 @@
 ;;;; Completion
 
 (defconst org-additional-option-like-keywords
-  '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML"
-    "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook"
+  '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML:"
+    "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook:"
     "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:"
-    "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX"
+    "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX:"
     "BEGIN:" "END:"
     "ORGTBL" "TBLFM:" "TBLNAME:"
     "BEGIN_EXAMPLE" "END_EXAMPLE"
@@ -10523,11 +10570,17 @@
     "BEGIN_VERSE" "END_VERSE"
     "BEGIN_CENTER" "END_CENTER"
     "BEGIN_SRC" "END_SRC"
-    "CATEGORY" "COLUMNS" "PROPERTY"
-    "CAPTION" "LABEL"
-    "SETUPFILE"
-    "BIND"
-    "MACRO"))
+    "BEGIN_RESULT" "END_RESULT"
+    "SOURCE:" "SRCNAME:" "FUNCTION:"
+    "RESULTS:"
+    "HEADER:" "HEADERS:"
+    "BABEL:"
+    "CATEGORY:" "COLUMNS:" "PROPERTY:"
+    "CAPTION:" "LABEL:"
+    "SETUPFILE:"
+    "INCLUDE:"
+    "BIND:"
+    "MACRO:"))
 
 (defcustom org-structure-template-alist
   '(
@@ -10609,137 +10662,6 @@
     (insert rpl)
     (if (re-search-backward "\\?" start t) (delete-char 1))))
 
-
-(defun org-complete (&optional arg)
-  "Perform completion on word at point.
-At the beginning of a headline, this completes TODO keywords as given in
-`org-todo-keywords'.
-If the current word is preceded by a backslash, completes the TeX symbols
-that are supported for HTML support.
-If the current word is preceded by \"#+\", completes special words for
-setting file options.
-In the line after \"#+STARTUP:, complete valid keywords.\"
-At all other locations, this simply calls the value of
-`org-completion-fallback-command'."
-  (interactive "P")
-  (org-without-partial-completion
-   (catch 'exit
-     (let* ((a nil)
-	    (end (point))
-	    (beg1 (save-excursion
-		    (skip-chars-backward (org-re "[:alnum:]_@#%"))
-		    (point)))
-	    (beg (save-excursion
-		   (skip-chars-backward "a-zA-Z0-9_:$")
-		   (point)))
-	    (confirm (lambda (x) (stringp (car x))))
-	    (searchhead (equal (char-before beg) ?*))
-	    (struct
-	     (when (and (member (char-before beg1) '(?. ?<))
-			(setq a (assoc (buffer-substring beg1 (point))
-				       org-structure-template-alist)))
-	       (org-complete-expand-structure-template (1- beg1) a)
-	       (throw 'exit t)))
-	    (tag (and (equal (char-before beg1) ?:)
-		      (equal (char-after (point-at-bol)) ?*)))
-	    (prop (or (and (equal (char-before beg1) ?:)
-			   (not (equal (char-after (point-at-bol)) ?*)))
-		      (string-match "^#\\+PROPERTY:.*"
-				    (buffer-substring (point-at-bol) (point)))))
-	    (texp (equal (char-before beg) ?\\))
-	    (link (equal (char-before beg) ?\[))
-	    (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
-					  beg)
-			"#+"))
-	    (startup (string-match "^#\\+STARTUP:.*"
-				   (buffer-substring (point-at-bol) (point))))
-	    (completion-ignore-case opt)
-	    (type nil)
-	    (tbl nil)
-	    (table (cond
-		    (opt
-		     (setq type :opt)
-		     (require 'org-exp)
-		     (append
-		      (delq nil
-			    (mapcar
-			     (lambda (x)
-			       (if (string-match
-				    "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
-				   (cons (match-string 2 x)
-					 (match-string 1 x))))
-			     (org-split-string (org-get-current-options) "\n")))
-		      (mapcar 'list org-additional-option-like-keywords)))
-		    (startup
-		     (setq type :startup)
-		     org-startup-options)
-		    (link (append org-link-abbrev-alist-local
-				  org-link-abbrev-alist))
-		    (texp
-		     (setq type :tex)
-		     (append org-entities-user org-entities))
-		    ((string-match "\\`\\*+[ \t]+\\'"
-				   (buffer-substring (point-at-bol) beg))
-		     (setq type :todo)
-		     (mapcar 'list org-todo-keywords-1))
-		    (searchhead
-		     (setq type :searchhead)
-		     (save-excursion
-		       (goto-char (point-min))
-		       (while (re-search-forward org-todo-line-regexp nil t)
-			 (push (list
-				(org-make-org-heading-search-string
-				 (match-string 3) t))
-			       tbl)))
-		     tbl)
-		    (tag (setq type :tag beg beg1)
-			 (or org-tag-alist (org-get-buffer-tags)))
-		    (prop (setq type :prop beg beg1)
-			  (mapcar 'list (org-buffer-property-keys nil t t)))
-		    (t (progn
-			 (call-interactively org-completion-fallback-command)
-			 (throw 'exit nil)))))
-	    (pattern (buffer-substring-no-properties beg end))
-	    (completion (try-completion pattern table confirm)))
-       (cond ((eq completion t)
-	      (if (not (assoc (upcase pattern) table))
-		  (message "Already complete")
-		(if (and (equal type :opt)
-			 (not (member (car (assoc (upcase pattern) table))
-				      org-additional-option-like-keywords)))
-		    (insert (substring (cdr (assoc (upcase pattern) table))
-				       (length pattern)))
-		  (if (memq type '(:tag :prop)) (insert ":")))))
-	     ((null completion)
-	      (message "Can't find completion for \"%s\"" pattern)
-	      (ding))
-	     ((not (string= pattern completion))
-	      (delete-region beg end)
-	      (if (string-match " +$" completion)
-		  (setq completion (replace-match "" t t completion)))
-	      (insert completion)
-	      (if (get-buffer-window "*Completions*")
-		  (delete-window (get-buffer-window "*Completions*")))
-	      (if (assoc completion table)
-		  (if (eq type :todo) (insert " ")
-		    (if (and (memq type '(:tag :prop))
-			     (not (string-match "^#[ \t]*\\+property:"
-						(org-current-line-string t))))
-			(insert ":"))))
-	      (if (and (equal type :opt) (assoc completion table))
-		  (message "%s" (substitute-command-keys
-				 "Press \\[org-complete] again to insert example settings"))))
-	     (t
-	      (message "Making completion list...")
-	      (let ((list (sort (all-completions pattern table confirm)
-				'string<)))
-		(with-output-to-temp-buffer "*Completions*"
-		  (condition-case nil
-		      ;; Protection needed for XEmacs and emacs 21
-		      (display-completion-list list pattern)
-		    (error (display-completion-list list)))))
-	      (message "Making completion list...%s" "done")))))))
-
 ;;;; TODO, DEADLINE, Comments
 
 (defun org-toggle-comment ()
@@ -11962,13 +11884,13 @@
 m      Show entries selected by a tags/property match.
 p      Enter a property name and its value (both with completion on existing
        names/values) and show entries with that property.
-/      Show entries matching a regular expression (`r' can be used as well)
+r      Show entries matching a regular expression (`/' can be used as well)
 d      Show deadlines due within `org-deadline-warning-days'.
 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: [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty [d]eadlines\n             [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")
     (setq ans (read-char-exclusive))
     (cond
      ((equal ans ?d)
@@ -12213,11 +12135,13 @@
 
 (defun org-get-priority (s)
   "Find priority cookie and return priority."
-  (save-match-data
-    (if (not (string-match org-priority-regexp s))
-	(* 1000 (- org-lowest-priority org-default-priority))
-      (* 1000 (- org-lowest-priority
-		 (string-to-char (match-string 2 s)))))))
+  (if (functionp org-get-priority-function)
+      (funcall org-get-priority-function)
+    (save-match-data
+      (if (not (string-match org-priority-regexp s))
+	  (* 1000 (- org-lowest-priority org-default-priority))
+	(* 1000 (- org-lowest-priority
+		   (string-to-char (match-string 2 s))))))))
 
 ;;;; Tags
 
@@ -12458,7 +12382,7 @@
 	minus tag mm
 	tagsmatch todomatch tagsmatcher todomatcher kwd matcher
 	orterms term orlist re-p str-p level-p level-op time-p
-	prop-p pn pv po cat-p gv rest)
+	prop-p pn pv po gv rest)
     (if (string-match "/+" match)
 	;; match contains also a todo-matching request
 	(progn
@@ -12498,7 +12422,6 @@
 		     (setq pn (match-string 5 term)
 			   po (match-string 6 term)
 			   pv (match-string 7 term)
-			   cat-p (equal pn "CATEGORY")
 			   re-p (equal (string-to-char pv) ?{)
 			   str-p (equal (string-to-char pv) ?\")
 			   time-p (save-match-data
@@ -13459,7 +13382,7 @@
 POM may also be nil, in which case the current entry is used.
 If WHICH is nil or `all', get all properties.  If WHICH is
 `special' or `standard', only get that subclass.  If WHICH
-is a string only get exactly this property.  Specific can be a string, the
+is a string only get exactly this property.  SPECIFIC can be a string, the
 specific property we are interested in.  Specifying it can speed
 things up because then unnecessary parsing is avoided."
   (setq which (or which 'all))
@@ -15025,7 +14948,7 @@
 			      (org-current-line)
 			      (buffer-file-name) sexp)
                      (sleep-for 2))))))
-    (cond ((stringp result) result)
+    (cond ((stringp result) (split-string result "; "))
 	  ((and (consp result)
 		(not (consp (cdr result)))
 		(stringp (cdr result))) (cdr result))
@@ -16285,9 +16208,9 @@
 (org-defkey org-mode-map "\C-i"       'org-cycle)
 (org-defkey org-mode-map [(tab)]      'org-cycle)
 (org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived)
-(org-defkey org-mode-map [(meta tab)] 'org-complete)
-(org-defkey org-mode-map "\M-\t" 'org-complete)
-(org-defkey org-mode-map "\M-\C-i"      'org-complete)
+(org-defkey org-mode-map [(meta tab)] 'pcomplete)
+(org-defkey org-mode-map "\M-\t" 'pcomplete)
+(org-defkey org-mode-map "\M-\C-i"      'pcomplete)
 ;; The following line is necessary under Suse GNU/Linux
 (unless (featurep 'xemacs)
   (org-defkey org-mode-map [S-iso-lefttab]  'org-shifttab))
@@ -16352,7 +16275,7 @@
   (org-defkey org-mode-map [?\C-c (right)] 'org-shiftright)
   (org-defkey org-mode-map [?\C-c ?\C-x (right)] 'org-shiftcontrolright)
   (org-defkey org-mode-map [?\C-c ?\C-x (left)] 'org-shiftcontrolleft)
-  (org-defkey org-mode-map [?\e (tab)] 'org-complete)
+  (org-defkey org-mode-map [?\e (tab)] 'pcomplete)
   (org-defkey org-mode-map [?\e (shift return)] 'org-insert-todo-heading)
   (org-defkey org-mode-map [?\e (shift left)]   'org-shiftmetaleft)
   (org-defkey org-mode-map [?\e (shift right)]  'org-shiftmetaright)
@@ -16433,6 +16356,7 @@
 (org-defkey org-mode-map "\C-c\C-xf"    'org-footnote-action)
 (org-defkey org-mode-map "\C-c\C-x\C-mg"    'org-mobile-pull)
 (org-defkey org-mode-map "\C-c\C-x\C-mp"    'org-mobile-push)
+(org-defkey org-mode-map "\C-c@" 'org-mark-subtree)
 (org-defkey org-mode-map [?\C-c (control ?*)] 'org-list-make-subtree)
 ;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree)
 
@@ -16506,7 +16430,7 @@
     ("^" . org-sort)
     ("w" . org-refile)
     ("a" . org-archive-subtree-default-with-confirmation)
-    ("." . outline-mark-subtree)
+    ("." . org-mark-subtree)
     ("Clock Commands")
     ("I" . org-clock-in)
     ("O" . org-clock-out)
@@ -17246,11 +17170,13 @@
    ((org-edit-fixed-width-region))
    ((org-at-table.el-p)
     (org-edit-src-code))
-   ((org-at-table-p)
+   ((or (org-at-table-p)
+	(save-excursion
+	  (beginning-of-line 1)
+	  (looking-at "[ \t]*#\\+TBLFM:")))
     (call-interactively 'org-table-edit-formulas))
    (t (call-interactively 'ffap))))
 
-
 (defun org-ctrl-c-ctrl-c (&optional arg)
   "Set tags in headline, or update according to changed information at point.
 
@@ -17324,7 +17250,8 @@
       (if arg
 	  (call-interactively 'org-table-recalculate)
 	(org-table-maybe-recalculate-line))
-      (call-interactively 'org-table-align))
+      (call-interactively 'org-table-align)
+      (orgtbl-send-table 'maybe))
      ((or (org-footnote-at-reference-p)
 	  (org-footnote-at-definition-p))
       (call-interactively 'org-footnote-action))
@@ -17681,7 +17608,7 @@
      ("Select keyword"
       ["Next keyword" org-shiftright (org-on-heading-p)]
       ["Previous keyword" org-shiftleft (org-on-heading-p)]
-      ["Complete Keyword" org-complete (assq :todo-keyword (org-context))]
+      ["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))])
      ["Show TODO Tree" org-show-todo-tree :active t :keys "C-c / t"]
@@ -18066,6 +17993,23 @@
       (setq l (- l (get-text-property b 'org-dwidth-n s))))
     l))
 
+(defun org-shorten-string (s maxlength)
+  "Shorten string S so tht it is no longer than MAXLENGTH characters.
+If the string is shorter or has length MAXLENGTH, just return the
+original string.  If it is longer, the functions finds a space in the
+string, breaks this string off at that locations and adds three dots
+as ellipsis.  Including the ellipsis, the string will not be longer
+than MAXLENGTH.  If finding a good breaking point in the string does
+not work, the string is just chopped off in the middle of a word
+if necessary."
+  (if (<= (length s) maxlength)
+      s
+    (let* ((n (max (- maxlength 4) 1))
+	   (re (concat "\\`\\(.\\{1," (int-to-string n) "\\}[^ ]\\)\\([ ]\\|\\'\\)")))
+      (if (string-match re s)
+	  (concat (match-string 1 s) "...")
+	(concat (substring s 0 (max (- maxlength 3) 0)) "...")))))
+
 (defun org-get-indentation (&optional line)
   "Get the indentation of the current line, interpreting tabs.
 When LINE is given, assume it represents a line and compute its indentation."
@@ -18636,11 +18580,36 @@
   (message
    "Entry marked for action; press `k' at desired date in agenda or calendar"))
 
+(defun org-mark-subtree ()
+  "Mark the current subtree.
+This puts point at the start of the current subtree, and mark at the end.
+
+If point is in an inline task, mark that task instead."
+  (interactive)
+  (let ((inline-task-p
+	 (and (featurep 'org-inlinetask)
+	      (org-inlinetask-in-task-p)))
+	(beg))
+    ;; Get beginning of subtree
+    (cond
+     (inline-task-p (org-inlinetask-goto-beginning))
+     ((org-at-heading-p) (beginning-of-line))
+     (t (let ((outline-regexp (org-get-limited-outline-regexp)))
+	  (outline-previous-visible-heading 1))))
+    (setq beg (point))
+    ;; Get end of it
+    (if	inline-task-p
+	(org-inlinetask-goto-end)
+      (org-end-of-subtree))
+    ;; Mark zone
+    (push-mark (point) nil t)
+    (goto-char beg)))
+
 ;;; Paragraph filling stuff.
 ;; We want this to be just right, so use the full arsenal.
 
 (defun org-indent-line-function ()
-  "Indent line like previous, but further if previous was headline or item."
+  "Indent line depending on context."
   (interactive)
   (let* ((pos (point))
 	 (itemp (org-at-item-p))
@@ -18648,14 +18617,16 @@
 	 (org-drawer-regexp (or org-drawer-regexp "\000"))
 	 (inline-task-p (and (featurep 'org-inlinetask)
 			     (org-inlinetask-in-task-p)))
-	 column bpos bcol tpos tcol bullet btype bullet-type)
-    ;; Find the previous relevant line
+	 column bpos bcol tpos tcol)
     (beginning-of-line 1)
     (cond
      ;; Comments
-     ((looking-at "#") (setq column 0))
+     ((looking-at "# ") (setq column 0))
      ;; Headings
      ((looking-at "\\*+ ") (setq column 0))
+     ;; Literal examples
+     ((looking-at "[ \t]*:[ \t]")
+      (setq column (org-get-indentation))) ; do nothing
      ;; Drawers
      ((and (looking-at "[ \t]*:END:")
 	   (save-excursion (re-search-backward org-drawer-regexp nil t)))
@@ -18683,36 +18654,29 @@
       (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\(:?\\[@\\(:?start:\\)?[0-9]+\\][ \t]*\\)?\\[[- X]\\][ \t]*\\|.*? :: \\)?")
       (setq bpos (match-beginning 1) tpos (match-end 0)
 	    bcol (progn (goto-char bpos) (current-column))
-	    tcol (progn (goto-char tpos) (current-column))
-	    bullet (match-string 1)
-	    bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
+	    tcol (progn (goto-char tpos) (current-column)))
       (if (> tcol (+ bcol org-description-max-indent))
 	  (setq tcol (+ bcol 5)))
-      (if (not itemp)
-	  (setq column tcol)
-	(beginning-of-line 1)
-	(goto-char pos)
-	(if (looking-at "\\S-")
-	    (progn
-	      (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
-	      (setq bullet (match-string 1)
-		    btype (if (string-match "[0-9]" bullet) "n" bullet))
-	      (setq column (if (equal btype bullet-type) bcol tcol)))
-	  (setq column (org-get-indentation)))))
-     ;; This line has nothing special, look upside to get a clue about
-     ;; what to do.
+      (goto-char pos)
+      (setq column (if itemp (org-get-indentation) tcol)))
+     ;; This line has nothing special, look at the previous relevant
+     ;; line to compute indentation
      (t
       (beginning-of-line 0)
       (while (and (not (bobp))
+		  (not (looking-at org-drawer-regexp))
 		  ;; skip comments, verbatim, empty lines, tables,
-		  ;; inline tasks
-		  (or (looking-at "[ \t]*[\n:#|]")
+		  ;; inline tasks, lists, drawers and blocks
+		  (or (and (looking-at "[ \t]*:END:")
+			   (re-search-backward org-drawer-regexp nil t))
+		      (and (looking-at "[ \t]*#\\+end_")
+			   (re-search-backward "[ \t]*#\\+begin_"nil t))
+		      (looking-at "[ \t]*[\n:#|]")
 		      (and (org-in-item-p) (goto-char (org-list-top-point)))
 		      (and (not inline-task-p)
 			   (featurep 'org-inlinetask)
-			   (org-inlinetask-in-task-p)))
-      		  (not (looking-at "[ \t]*:END:"))
-      		  (not (looking-at org-drawer-regexp)))
+			   (org-inlinetask-in-task-p)
+			   (or (org-inlinetask-goto-beginning) t))))
       	(beginning-of-line 0))
       (cond
        ;; There was an heading above.
@@ -18721,20 +18685,18 @@
 	    (setq column 0)
 	  (goto-char (match-end 0))
 	  (setq column (current-column))))
-       ;; A drawer had started and is unfinished: indent consequently.
+       ;; A drawer had started and is unfinished
        ((looking-at org-drawer-regexp)
 	(goto-char (1- (match-beginning 1)))
 	(setq column (current-column)))
-       ;; The drawer had ended: indent like its :END: line.
-       ((looking-at "\\([ \t]*\\):END:")
-	(goto-char (match-end 1))
-	(setq column (current-column)))
        ;; Else, nothing noticeable found: get indentation and go on.
        (t (setq column (org-get-indentation))))))
+    ;; Now apply indentation and move cursor accordingly
     (goto-char pos)
     (if (<= (current-column) (current-indentation))
 	(org-indent-line-to column)
       (save-excursion (org-indent-line-to column)))
+    ;; Special polishing for properties, see `org-property-format'
     (setq column (current-column))
     (beginning-of-line 1)
     (if (looking-at
@@ -19005,8 +18967,6 @@
 
 (define-key org-mode-map "\C-a" 'org-beginning-of-line)
 (define-key org-mode-map "\C-e" 'org-end-of-line)
-(define-key org-mode-map [home] 'org-beginning-of-line)
-(define-key org-mode-map [end]  'org-end-of-line)
 
 (defun org-backward-sentence (&optional arg)
   "Go to beginning of sentence, or beginning of table field.