changeset 99139:8fa7ef477c04

2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-format-agenda-item) (org-agenda-filter-make-matcher): Make sure tags are stored and compared donwcased. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org.el (org-insert-todo-heading): Fix bug with force-heading argument. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-as-ascii): Handle the case that we are bulishing from an indirect buffer. * org-table.el (org-table-copy-down): Fix bug with time stamp increment. * org-mouse.el (org-mouse-features): New option. (org-mode-hook): Turn on features depending on `org-mouse-features'. * org.el (org-insert-heading-respect-content): Force heading creation. (org-insert-heading): keep the folding state of the heading before the inserted one. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-archive.el (org-archive-to-archive-sibling): Handle top level headlines better. 2008-10-26 Bastien Guerry <bzg@altern.org> * org-export-latex.el (org-export-latex-classes): Added \usepackage{graphicx} to the default list of packages. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-filter): Renamed from `org-agenda-filter-tags'. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org.el (org-entry-properties): Add CATEGORY property, iven if it is not defined as a property in this entry. (org-add-log-note): Mask prefix argument when immediately storing the note. * org-agenda.el (org-agenda-filter-effort-default-operator): New option. 2008-10-26 James TD Smith <ahktenzero@mohorovi.cc> * org.el (org-add-log-setup): Bugfix; code to find insertion point after drawers was skipping ahead one line too many, so notes were inserted after the first note instead of before it. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-filter-tags,org-agenda-filter-form): New variables. (org-prepare-agenda): Reset the filter tags. (org-agenda-filter-by-tag, org-agenda-filter-by-tag-show-all): Show filter tags in mode line. * org-table.el (orgtbl-to-html): Bind `html-table-tag' for the formatter. * org-export-latex.el (org-latex-entities-regexp): New constant. (org-export-as-pdf): Use two calls to `shell-command'. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-export-latex.el (org-export-latex-treat-sub-super-char): Honor the {} value of the subsuperscript setting. Make sure that longer subsuperscripts are typeset in a roman font. * org.el (org-clock-update-time-maybe): Compute negative clock intervals correctly. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org.el (org-add-log-setup): Respect `org-log-state-notes-insert-after-drawers'. (org-log-state-notes-insert-after-drawers): New option. (org-todo-trigger-tag-changes): New function. (org-todo): Call `org-todo-trigger-tag-changes'. 2008-10-26 James TD Smith <ahktenzero@mohorovi.cc> * org.el (org-add-log-setup): Only skip drawers if the are immediately after the scheduling keywords. * org-clock.el (org-clock-in-switch-to-state): Allow this to be a function (org-clock-in): If `org-clock-in-switch-to-state' is a function, call it with the current todo state to get the state to switch to when clocking in. (org-clock-in): Use org-indent-line-function to indent clock lines. (org-clock-find-position): Fix indentation of empty clock drawers. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-publish.el (org-publish-org-to): Handle case when org-export-to-pdf does return a file name, not a buffer. (org-publish-org-to-pdf): New function. * org-export-latex.el (org-export-as-pdf) (org-export-as-pdf-and-open): New commands. * org-table.el (org-table-eval-formula): Avoid parsing Calc's HMS forms as ranges. * org-export-latex.el (org-export-latex-lists): Ignore lists-like things in protexted regions. 2008-10-26 Carsten Dominik <dominik@science.uva.nl> * org-export-latex.el (org-export-latex-preprocess): Improve quoting of LaTeX environments.
author Carsten Dominik <dominik@science.uva.nl>
date Sat, 25 Oct 2008 21:32:46 +0000
parents a479c7f4849d
children 5fb166c21cc9
files doc/misc/org.texi etc/refcards/orgcard.tex lisp/org/org-agenda.el lisp/org/org-archive.el lisp/org/org-attach.el lisp/org/org-bbdb.el lisp/org/org-bibtex.el lisp/org/org-clock.el lisp/org/org-colview.el lisp/org/org-compat.el lisp/org/org-exp.el lisp/org/org-export-latex.el lisp/org/org-faces.el lisp/org/org-gnus.el lisp/org/org-id.el lisp/org/org-info.el lisp/org/org-irc.el lisp/org/org-jsinfo.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-mouse.el lisp/org/org-plot.el lisp/org/org-publish.el lisp/org/org-remember.el lisp/org/org-rmail.el lisp/org/org-table.el lisp/org/org-vm.el lisp/org/org-wl.el lisp/org/org.el
diffstat 32 files changed, 710 insertions(+), 315 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/org.texi	Sat Oct 25 20:59:38 2008 +0000
+++ b/doc/misc/org.texi	Sat Oct 25 21:32:46 2008 +0000
@@ -3,7 +3,7 @@
 @setfilename ../../info/org
 @settitle The Org Manual
 
-@set VERSION 6.09a
+@set VERSION 6.10c
 @set DATE October 2008
 
 @dircategory Emacs
@@ -291,7 +291,7 @@
 * The export dispatcher::       How to access exporter commands
 * ASCII export::                Exporting to plain ASCII
 * HTML export::                 Exporting to HTML
-* LaTeX export::                Exporting to LaTeX
+* LaTeX and PDF export::        Exporting to LaTeX, and processing to PDF
 * XOXO export::                 Exporting to XOXO
 * iCalendar export::            Exporting in iCalendar format
 
@@ -321,9 +321,9 @@
 * CSS support::                 Changing the appearance of the output
 * Javascript support::          Info and Folding in a web browser
 
-LaTeX export
-
-* LaTeX export commands::       How to invoke LaTeX export
+LaTeX and PDF export
+
+* LaTeX/PDF export commands::   
 * Quoting LaTeX code::          Incorporating literal LaTeX code
 * Sectioning structure::        Changing sectioning in LaTeX output
 
@@ -541,7 +541,7 @@
 documentation.}
 @end iftex
 
-Add the following lines to your @file{.emacs} file.  The last two lines
+Add the following lines to your @file{.emacs} file.  The last three lines
 define @emph{global} keys for the commands @command{org-store-link},
 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
 keys yourself.
@@ -859,11 +859,14 @@
 @example
 @key{TAB}         @r{Cycle visibility.}
 @key{down} / @key{up}   @r{Next/previous visible headline.}
+@key{RET}         @r{Select this location.}
+@kbd{/}           @r{Do a Sparse-tree search}
+@r{The following keys work if you turn off @code{org-goto-auto-isearch}}
 n / p        @r{Next/previous visible headline.}
 f / b        @r{Next/previous headline same level.}
 u            @r{One level up.}
 0-9          @r{Digit argument.}
-@key{RET}         @r{Select this location.}
+q            @r{Quit}
 @end example
 @end table
 
@@ -897,8 +900,9 @@
 after the end of the subtree.
 @kindex C-@key{RET}
 @item C-@key{RET}
-Just like @kbd{M-@key{RET}}, but if the heading is inserted after the current,
-insert it actually after the entire subtree.
+Just like @kbd{M-@key{RET}}, except when adding a new heading below the
+current heading, the new heading is placed after the body instead of before
+it.  This command works from anywhere in the entry.
 @kindex M-S-@key{RET}
 @item M-S-@key{RET}
 Insert new TODO entry with same level as current heading.
@@ -927,9 +931,7 @@
 @item M-S-@key{down}
 Move subtree down (swap with next subtree of same level).
 @kindex C-c C-x C-w
-@kindex C-c C-x C-k
 @item C-c C-x C-w
-@itemx C-c C-x C-k
 Kill subtree, i.e. remove it from buffer but save in kill ring.
 With a numeric prefix argument N, kill N sequential subtrees.
 @kindex C-c C-x M-w
@@ -2272,12 +2274,10 @@
 @cindex plot tables using gnuplot
 
 Org Plot can produce 2D and 3D graphs of information stored in org tables
-using @file{Gnuplot} (see @uref{http://www.gnuplot.info/, the Gnuplot
-website}) and @file{gnuplot-mode} (see
-@uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html, the
-gnuplot-mode website}).  To see this in action ensure that you have both
-Gnuplot and Gnuplot-mode installed on your system, then call
-@code{org-plot/gnuplot} on the following table.
+using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
+@uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
+this in action ensure that you have both Gnuplot and Gnuplot-mode installed
+on your system, then call @code{org-plot/gnuplot} on the following table.
 
 @example
 @group
@@ -2296,8 +2296,8 @@
 Further control over the labels, type, content, and appearance of plots can
 be exercised through the @code{#+Plot:} lines preceding a table.  See below
 for a complete list of Org plot options.  For more information and examples
-@uref{http://orgmode.org/worg/org-tutorials/org-plot.php, the org-plot
-tutorial}.
+see the org-plot tutorial at
+@uref{http://legito.org/worg/org-tutorials/org-plot.php}.
 
 @subsubheading Plot Options
 
@@ -2312,8 +2312,10 @@
 Specify which column of the table to use as the @code{x} axis.
 
 @item deps
-Specify (as a comma seperated list with no spaces) which columns of the table
-to graph against the ind (defaults to all other columns).
+Specify the columns to graph as a lisp style list, surrounded by parenthesis
+and separated by spaces for example @code{dep:(3 4)} to graph the third and
+fourth columns (defaults to graphing all other columns aside from the ind
+column).
 
 @item type
 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
@@ -2895,6 +2897,10 @@
 Insert a new TODO entry below the current one.
 @end table
 
+@noindent
+Changing a TODO state can also trigger tag changes.  See the docstring of the
+option @code{org-todo-state-tags-triggers} for details.
+
 @node TODO extensions, Progress logging, TODO basics, TODO Items
 @section Extended use of TODO keywords
 @cindex extended TODO keywords
@@ -3225,7 +3231,6 @@
   :END:
 @end example
 
-
 @node Priorities, Breaking down tasks, Progress logging, TODO Items
 @section Priorities
 @cindex priorities
@@ -3471,8 +3476,8 @@
 also a special command for inserting tags:
 
 @table @kbd
-@kindex C-c C-c
-@item C-c C-c
+@kindex C-c C-q
+@item C-c C-q
 @cindex completion, of tags
 Enter new tags for the current headline.  Org mode will either offer
 completion or a special single-key interface for setting tags, see
@@ -3481,6 +3486,9 @@
 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
+When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
 @end table
 
 Org will support tag insertion based on a @emph{list of tags}.  By
@@ -4857,10 +4865,10 @@
 @end example
 
 @noindent
-or you can set up these values globally by customizing the variables
-@code{org-global-properties} and @code{org-columns-default-format}.  In
-particular if you want to use this setup also in the agenda, a global setup
-may be advised.
+or, even better, you can set up these values globally by customizing the
+variables @code{org-global-properties} and @code{org-columns-default-format}.
+In particular if you want to use this setup also in the agenda, a global
+setup may be advised.
 
 The way to assign estimates to individual items is then to switch to column
 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
@@ -4876,6 +4884,10 @@
 appointments on a day that take place over a specified time interval will
 then also be added to the load estimate of the day.
 
+Effort estimates can be used in secondary agenda filtering that is triggered
+with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
+these estimates defined consistently, two or three key presses will narrow
+down the list to stuff that fits into an available time slot.
 
 @node Capture, Agenda Views, Dates and Times, Top
 @chapter Capture
@@ -5829,9 +5841,7 @@
 
 Sorting can be customized using the variable
 @code{org-agenda-sorting-strategy}, and may also include criteria based on
-the estimated effort of an entry.
-@c FIXME: link!!!!!!!!
-
+the estimated effort of an entry (@pxref{Effort estimates}).
 
 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
 @section Commands in the agenda buffer
@@ -5988,17 +5998,48 @@
 @code{org-columns-default-format}), will be used in the agenda.
 
 @tsubheading{Secondary filtering and query editing}
+@cindex filtering, by tag and effort, in agenda
+@cindex tag filtering, in agenda
+@cindex effort filtering, in agenda
 @cindex query editing, in agenda
 
 @kindex /
 @item /
-Filter the current agenda view with respect to a tag.  You will be prompted
-for a tag selection letter.  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 with prefix arg, remove the entries that
-@emph{do} have the tag.  A second @kbd{/} at the prompt will unhide any
-hidden entries.
+Filter the current agenda view with respect to a tag and/or effort estimates.
+The difference between this and a custom agenda commands is that filtering is
+very fast, so that you can switch quickly between different filters without
+having to recreate the agenda.
+
+You will be prompted for a tag selection letter.  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 with prefix arg, remove the
+entries that @emph{do} have the tag.  A second @kbd{/} at the prompt will
+turn off the filter and unhide any hidden entries.  If the first key you
+press is either @kbd{+} or @kbd{-}, the previous filter will be narrowed by
+requiring or forbidding the selected additional tag.  Instead of pressing
+@kbd{+} or @kbd{-}, you can also use the @kbd{\} command.
+
+In order to filter for effort estimates, you should set-up allowed
+efforts globally, for example
+@lisp
+(setq org-global-properties
+    '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
+@end lisp
+You can then filter for an effort by first typing an operator, one of @kbd{<},
+@kbd{>}, and @kbd{=}, and then the one-digit index of an effort estimate in
+your array of allowed values, where @kbd{0} means the 10th value.  The filter
+will then restrict to entries with effort smaller-or-equal, equal, or
+larger-or-equal than the selected value.  If the digits 0-9 are not used as
+fast access keys to tags, you can also simply press the index digit directly
+without an operator.  In this case, @kbd{<} will be assumed.
+
+@kindex \
+@item \
+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.
 
 @kindex [
 @kindex ]
@@ -6520,7 +6561,8 @@
 emacs -f org-batch-store-agenda-views -kill
 @end example
 @noindent
-or, if you need to modify some parameters
+or, if you need to modify some parameters@footnote{Quoting may depend on the
+system you use, please check th FAQ for examples.}
 @example
 emacs -eval '(org-batch-store-agenda-views                      \
               org-agenda-ndays 30                               \
@@ -6930,7 +6972,7 @@
 * The export dispatcher::       How to access exporter commands
 * ASCII export::                Exporting to plain ASCII
 * HTML export::                 Exporting to HTML
-* LaTeX export::                Exporting to LaTeX
+* LaTeX and PDF export::        Exporting to LaTeX, and processing to PDF
 * XOXO export::                 Exporting to XOXO
 * iCalendar export::            Exporting in iCalendar format
 @end menu
@@ -7454,7 +7496,7 @@
 the layout relative to the first line.  Should there be lines with less
 indentation than the first, these are left alone.
 
-@node HTML export, LaTeX export, ASCII export, Exporting
+@node HTML export, LaTeX and PDF export, ASCII export, Exporting
 @section HTML export
 @cindex HTML export
 
@@ -7698,19 +7740,23 @@
 @code{org-infojs-options}.  If you always want to apply the script to your
 pages, configure the variable @code{org-export-html-use-infojs}.
 
-@node LaTeX export, XOXO export, HTML export, Exporting
-@section LaTeX export
+@node LaTeX and PDF export, XOXO export, HTML export, Exporting
+@section LaTeX and PDF export
 @cindex LaTeX export
-
-Org mode contains a La@TeX{} exporter written by Bastien Guerry.
+@cindex PDF export
+
+Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
+further processing, this backend is also used 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 export commands::       How to invoke LaTeX export
+* LaTeX/PDF export commands::   
 * Quoting LaTeX code::          Incorporating literal LaTeX code
 * Sectioning structure::        Changing sectioning in LaTeX output
 @end menu
 
-@node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
+@node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
 @subsection LaTeX export commands
 
 @table @kbd
@@ -7738,6 +7784,12 @@
 @item M-x org-replace-region-by-latex
 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
 code.
+@kindex C-c C-e p
+@item C-c C-e p
+Export as LaTeX and then process to PDF.
+@kindex C-c C-e d
+@item C-c C-e d
+Export as LaTeX and then process to PDF, then open the resulting PDF file.
 @end table
 
 @cindex headline levels, for exporting
@@ -7757,7 +7809,7 @@
 @noindent
 creates two levels of headings and does the rest as items.
 
-@node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
+@node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
 @subsection Quoting LaTeX code
 
 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
@@ -7778,7 +7830,7 @@
 #+END_LaTeX
 @end example
 
-@node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
+@node   Sectioning structure,  , Quoting LaTeX code, LaTeX and PDF export
 @subsection Sectioning structure
 @cindex LaTeX class
 @cindex LaTeX sectioning structure
@@ -7786,13 +7838,13 @@
 By default, the La@TeX{} output uses the class @code{article}.
 
 You can change this globally by setting a different value for
-@code{org-export-latex-default-class} or locally by adding an option
-like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
-listed in @code{org-export-latex-classes}, where you can also define the
-sectioning structure for each class.
-
-
-@node XOXO export, iCalendar export, LaTeX export, Exporting
+@code{org-export-latex-default-class} or locally by adding an option like
+@code{#+LaTeX_CLASS: myclass} in your file.  The class should be listed in
+@code{org-export-latex-classes}, where you can also define the sectioning
+structure for each class, as well as defining additonal classes.
+
+
+@node XOXO export, iCalendar export, LaTeX and PDF export, Exporting
 @section XOXO export
 @cindex XOXO export
 
@@ -7984,14 +8036,14 @@
 @cindex action, for publishing
 
 Publishing means that a file is copied to the destination directory and
-possibly transformed in the process.  The default transformation is to
-export Org files as HTML files, and this is done by the function
-@code{org-publish-org-to-html} which calls the HTML exporter
-(@pxref{HTML export}). But you also can publish your files in La@TeX{} by
-using the function @code{org-publish-org-to-latex} instead. Other files
-like images only need to be copied to the publishing destination. For
-non-Org files, you need to specify the publishing function.
-
+possibly transformed in the process.  The default transformation is to export
+Org files as HTML files, and this is done by the function
+@code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
+export}). But you also can publish your files in La@TeX{} by using the
+function @code{org-publish-org-to-latex} instead, or as PDF files using
+@code{org-publish-org-to-pdf}.  Other files like images only need to be
+copied to the publishing destination. For non-Org files, you need to provide
+your own publishing function:
 
 @multitable @columnfractions 0.3 0.7
 @item @code{:publishing-function}
@@ -8633,7 +8685,7 @@
 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
-@item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
+@item @kbd{M-@key{right}}   @tab @kbd{C-c C-x i}           @tab @kbd{@key{Esc} @key{right}}
 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
--- a/etc/refcards/orgcard.tex	Sat Oct 25 20:59:38 2008 +0000
+++ b/etc/refcards/orgcard.tex	Sat Oct 25 21:32:46 2008 +0000
@@ -1,5 +1,5 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{6.09a}
+\def\orgversionnumber{6.10c}
 \def\versionyear{2008}          % latest update
 \def\year{2008}                 % latest copyright year
 
@@ -539,8 +539,8 @@
 
 \section{Tags}
 
-\key{set tags for current heading}{C-c C-c}
-\key{realign tags in all headings}{C-u C-c C-c}
+\key{set tags for current heading}{C-c C-q}
+\key{realign tags in all headings}{C-u C-c C-q}
 \key{create sparse tree with matching tags}{C-c \\}
 \key{globally (agenda) match tags at cursor}{C-c C-o}
 
@@ -607,7 +607,7 @@
 \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, ODO kwds, properties}{C-c a m$^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$}
--- a/lisp/org/org-agenda.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-agenda.el	Sat Oct 25 21:32:46 2008 +0000
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -32,6 +32,7 @@
 
 (require 'org)
 (eval-when-compile
+  (require 'cl)
   (require 'calendar))
 
 (declare-function diary-add-to-list "diary-lib"
@@ -386,6 +387,14 @@
 	  (repeat :tag "Projects are *not* stuck if they have an entry with TAG being any of" (string))
 	  (regexp :tag "Projects are *not* stuck if this regexp matches\ninside the subtree")))
 
+(defcustom org-agenda-filter-effort-default-operator "<"
+  "The default operator for effort estimate filtering.
+If you select an effort estimate limit with first pressing an operator,
+this one will be used."
+  :group 'org-agenda-custom-commands
+  :type '(choice (const :tag "less or equal" "<")
+		 (const :tag "greater or equal"">")
+		 (const :tag "equal" "=")))
 
 (defgroup org-agenda-skip nil
  "Options concerning skipping parts of agenda files."
@@ -1092,6 +1101,7 @@
 (org-defkey org-agenda-mode-map "t"        'org-agenda-todo)
 (org-defkey org-agenda-mode-map "a"        'org-agenda-toggle-archive-tag)
 (org-defkey org-agenda-mode-map ":"        'org-agenda-set-tags)
+(org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
 (org-defkey org-agenda-mode-map "."        'org-agenda-goto-today)
 (org-defkey org-agenda-mode-map "j"        'org-agenda-goto-date)
 (org-defkey org-agenda-mode-map "d"        'org-agenda-day-view)
@@ -1167,6 +1177,7 @@
 (org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
 (org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
 (org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
+(org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
 
 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
   "Local keymap for agenda entries from Org-mode.")
@@ -1953,9 +1964,11 @@
 (defvar org-pre-agenda-window-conf nil)
 (defvar org-agenda-columns-active nil)
 (defvar org-agenda-name nil)
+(defvar org-agenda-filter nil)
 (defun org-prepare-agenda (&optional name)
   (setq org-todo-keywords-for-agenda nil)
   (setq org-done-keywords-for-agenda nil)
+  (setq org-agenda-filter nil)
   (if org-agenda-multi
       (progn
 	(setq buffer-read-only nil)
@@ -3737,7 +3750,7 @@
 
       ;; And finally add the text properties
       (org-add-props rtn nil
-	'org-category (downcase category) 'tags tags
+	'org-category (downcase category) 'tags (mapcar 'downcase tags)
 	'org-highest-priority org-highest-priority
 	'org-lowest-priority org-lowest-priority
 	'prefix-length (- (length rtn) (length txt))
@@ -3934,7 +3947,7 @@
 	  (t nil))))
 
 (defsubst org-cmp-tag (a b)
-  "Compare the string values of categories of strings A and B."
+  "Compare the string values of the first tags of A and B."
   (let ((ta (car (last (get-text-property 1 'tags a))))
 	(tb (car (last (get-text-property 1 'tags b)))))
     (cond ((not ta) +1)
@@ -4101,6 +4114,7 @@
 When this is the global TODO list, a prefix argument will be interpreted."
   (interactive)
   (let* ((org-agenda-keep-modes t)
+	 (filter org-agenda-filter)
 	 (cols org-agenda-columns-active)
 	 (line (org-current-line))
 	 (window-line (- line (org-current-line (window-start))))
@@ -4111,52 +4125,138 @@
     (setq org-agenda-undo-list nil
 	  org-agenda-pending-undo-list nil)
     (message "Rebuilding agenda buffer...done")
+    (and filter (org-agenda-filter-apply filter))
     (and cols (interactive-p) (org-agenda-columns))
     (goto-line line)
     (recenter window-line)))
 
+
 (defvar org-global-tags-completion-table nil)
-(defun org-agenda-filter-by-tag (strip &optional char)
+(defvar org-agenda-filter-form nil)
+(defun org-agenda-filter-by-tag (strip &optional char narrow)
   "Keep only those lines in the agenda buffer that have a specific tag.
 The tag is selected with its fast selection letter, as configured.
-With prefix argument STRIP, remove all lines that do have the tag."
+With prefix argument STRIP, remove all lines that do have the tag.
+A lisp caller can specify CHAR.  NARROW means that the new tag should be
+used to narrow the search - the interactive user can also press `-' or `+'
+to switch to narrowing."
   (interactive "P")
-  (let (char a tag tags (inhibit-read-only t))
-      (message "Select tag [%s] or no tag [ ], [TAB] to complete, [/] to restore: "
-	       (mapconcat
-		(lambda (x) (if (cdr x) (char-to-string (cdr x)) ""))
-		org-tag-alist-for-agenda ""))
+  (let* ((alist org-tag-alist-for-agenda)
+	(tag-chars (mapconcat 
+		    (lambda (x) (if (cdr x) (char-to-string (cdr x)) ""))
+		    alist ""))
+	(efforts (org-split-string
+		  (or (cdr (assoc (concat org-effort-property "_ALL")
+				  org-global-properties))
+		      "0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00"		      "")))
+	(effort-op org-agenda-filter-effort-default-operator)
+	(effort-prompt "")
+	(inhibit-read-only t)
+	(current org-agenda-filter)
+	char a n tag tags)
+    (unless char
+      (message 
+       "%s by tag [%s ], [TAB], [/]:off, [+-]:narrow, [>=<]:effort: "
+       (if narrow "Narrow" "Filter") tag-chars)
+      (setq char (read-char)))
+    (when (member char '(?+ ?-))
+      ;; Narrowing down
+      (cond ((equal char ?-) (setq strip t narrow t))
+	    ((equal char ?+) (setq strip nil narrow t)))
+      (message 
+       "Narrow by tag [%s ], [TAB], [/]:off, [>=<]:effort: " tag-chars)
+      (setq char (read-char)))
+    (when (member char '(?< ?> ?=))
+      ;; An effort operator
+      (setq effort-op (char-to-string char))
+      (loop for i from 0 to 9 do
+	    (setq effort-prompt
+		  (concat
+		   effort-prompt " ["
+		   (if (= i 9) "0" (int-to-string (1+ i)))
+		   "]" (nth i efforts))))
+      (setq alist nil) ; to make sure it will be interpreted as effort.
+      (message "Effort%s: %s " effort-op effort-prompt)
       (setq char (read-char))
-      (when (equal char ?\t)
-	(unless (local-variable-p 'org-global-tags-completion-table)
-	  (org-set-local 'org-global-tags-completion-table
-			 (org-global-tags-completion-table)))
-	(let ((completion-ignore-case t))
-	  (setq tag (completing-read
-		     "Tag: " org-global-tags-completion-table))))
-      (cond
-       ((equal char ?/) (org-agenda-filter-by-tag-show-all))
-       ((or (equal char ?\ )
-	    (setq a (rassoc char org-tag-alist-for-agenda))
-	    (and tag (setq a (cons tag nil))))
-	(org-agenda-filter-by-tag-show-all)
-	(setq tag (car a))
-	(save-excursion
-	  (goto-char (point-min))
-	  (while (not (eobp))
-	    (if (get-text-property (point) 'org-marker)
-		(progn
-		  (setq tags (get-text-property (point) 'tags))
-		  (if (not tag)
-		      (if (or (and strip (not tags))
-			      (and (not strip) tags))
-			  (org-agenda-filter-by-tag-hide-line))
-		    (if (or (and (member tag tags) strip)
-			    (and (not (member tag tags)) (not strip)))
-			(org-agenda-filter-by-tag-hide-line)))
-		  (beginning-of-line 2))
-	      (beginning-of-line 2)))))
-       (t (error "Invalid tag selection character %c" char)))))
+      (when (or (< char ?0) (> char ?9))
+	(error "Need 1-9,0 to select effort" )))
+    (when (equal char ?\t)
+      (unless (local-variable-p 'org-global-tags-completion-table (current-buffer))
+	(org-set-local 'org-global-tags-completion-table
+		       (org-global-tags-completion-table)))
+      (let ((completion-ignore-case t))
+	(setq tag (completing-read
+		   "Tag: " org-global-tags-completion-table))))
+    (cond
+     ((equal char ?/) (org-agenda-filter-by-tag-show-all))
+     ((or (equal char ?\ )
+	  (setq a (rassoc char alist))
+	  (and (>= char ?0) (<= char ?9)
+	       (setq n (if (= char ?0) 9 (- char ?0 1))
+		     tag (concat effort-op (nth n efforts))
+		     a (cons tag nil)))
+	  (and tag (setq a (cons tag nil))))
+      (org-agenda-filter-by-tag-show-all)
+      (setq tag (car a))
+      (setq org-agenda-filter
+	    (cons (concat (if strip "-" "+") tag)
+		  (if narrow current nil)))
+      (org-agenda-filter-apply org-agenda-filter))
+     (t (error "Invalid tag selection character %c" char)))))
+
+(defun org-agenda-filter-by-tag-refine (strip &optional char)
+  "Refine the current filter.  See `org-agenda-filter-by-tag."
+  (interactive "P")
+  (org-agenda-filter-by-tag strip char 'refine))
+
+(defun org-agenda-filter-make-matcher ()
+  "Create the form that tests a line for the agenda filter."
+  (let (f f1)
+    (dolist (x org-agenda-filter)
+      (if (member x '("-" "+"))
+	  (setq f1 '(not tags))
+	(if (string-match "[<=>]" x)
+	    (setq f1 (org-agenda-filter-effort-form x))
+	  (setq f1 (list 'member (downcase (substring x 1)) 'tags)))
+	(if (equal (string-to-char x) ?-)
+	    (setq f1 (list 'not f1))))
+      (push f1 f))
+    (cons 'and (nreverse f))))
+
+(defun org-agenda-filter-effort-form (e)
+  "Return the form to compare the effort of the current line with what E says.
+E looks line \"+<2:25\"."
+  (let (op)
+    (setq e (substring e 1))
+    (setq op (string-to-char e) e (substring e 1))
+    (setq op (if (equal op ?<) '<= (if (equal op ?>) '>= '=)))
+    (list 'org-agenda-compare-effort (list 'quote op)
+	  (org-hh:mm-string-to-minutes e))))
+
+(defun org-agenda-compare-effort (op value)
+  "Compare the effort of the current line with VALUE, using OP.
+If the line does not have an effort defined, return nil."
+  (let ((eff (get-text-property (point) 'effort-minutes)))
+    (if (not eff)
+	nil ; we don't have an effort defined
+      (funcall op eff value))))
+
+(defun org-agenda-filter-apply (filter)
+  "Set FILTER as the new agenda filter and apply it."
+  (let (tags)
+    (setq org-agenda-filter filter
+	  org-agenda-filter-form (org-agenda-filter-make-matcher))
+    (org-agenda-set-mode-name)
+    (save-excursion
+      (goto-char (point-min))
+      (while (not (eobp))
+	(if (get-text-property (point) 'org-marker)
+	    (progn
+	      (setq tags (get-text-property (point) 'tags))
+	      (if (not (eval org-agenda-filter-form))
+		  (org-agenda-filter-by-tag-hide-line))
+	      (beginning-of-line 2))
+	  (beginning-of-line 2))))))
 
 (defvar org-agenda-filter-overlays nil)
 
@@ -4168,9 +4268,23 @@
     (org-overlay-put ov 'type 'tags-filter)
     (push ov org-agenda-filter-overlays)))
 
+(defun org-agenda-fix-tags-filter-overlays-at (&optional pos)
+  (setq pos (or pos (point)))
+  (save-excursion
+    (dolist (ov (org-overlays-at pos))
+      (when (and (org-overlay-get ov 'invisible)
+		 (eq (org-overlay-get ov 'type) 'tags-filter))
+	(goto-char pos)
+	(if (< (org-overlay-start ov) (point-at-eol))
+	    (org-move-overlay ov (point-at-eol)
+			      (org-overlay-end ov)))))))
+
 (defun org-agenda-filter-by-tag-show-all ()
   (mapc 'org-delete-overlay org-agenda-filter-overlays)
-  (setq org-agenda-filter-overlays nil))
+  (setq org-agenda-filter-overlays nil)
+  (setq org-agenda-filter nil)
+  (setq org-agenda-filter-form nil)
+  (org-agenda-set-mode-name))
 
 (defun org-agenda-manipulate-query-add ()
   "Manipulate the query by adding a search term with positive selection.
@@ -4509,6 +4623,9 @@
 		(if org-agenda-include-diary   " Diary"  "")
 		(if org-agenda-use-time-grid   " Grid"   "")
 		(if org-agenda-show-log        " Log"    "")
+		(if org-agenda-filter
+		    (concat " {" (mapconcat 'identity org-agenda-filter "") "}")
+		  "")
 		(if org-agenda-archives-mode
 		    (if (eq org-agenda-archives-mode t)
 			" Archives"
@@ -5002,13 +5119,15 @@
 (defun org-agenda-show-new-time (marker stamp &optional prefix)
   "Show new date stamp via text properties."
   ;; We use text properties to make this undoable
-  (let ((inhibit-read-only t))
+  (let ((inhibit-read-only t)
+	(buffer-invisibility-spec))
     (setq stamp (concat " " prefix " => " stamp))
     (save-excursion
       (goto-char (point-max))
       (while (not (bobp))
 	(when (equal marker (get-text-property (point) 'org-marker))
 	  (org-move-to-column (- (window-width) (length stamp)) t)
+	  (org-agenda-fix-tags-filter-overlays-at (point))
           (if (featurep 'xemacs)
 	      ;; Use `duplicable' property to trigger undo recording
               (let ((ex (make-extent nil nil))
--- a/lisp/org/org-archive.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-archive.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -322,12 +322,13 @@
       (setq pos (point))
       (condition-case nil
 	  (outline-up-heading 1 t)
-	(error (goto-char (point-min))))
+	(error (setq e (point-max)) (goto-char (point-min))))
       (setq b (point))
-      (condition-case nil
-	  (org-end-of-subtree t t)
-	(error (goto-char (point-max))))
-      (setq e (point))
+      (unless e
+	(condition-case nil
+	    (org-end-of-subtree t t)
+	  (error (goto-char (point-max))))
+	(setq e (point)))
       (goto-char b)
       (unless (re-search-forward
 	       (concat "^" (regexp-quote leader)
--- a/lisp/org/org-attach.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-attach.el	Sat Oct 25 21:32:46 2008 +0000
@@ -4,7 +4,7 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 6.09a
+;; Version: 6.10c
 
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-bbdb.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-bbdb.el	Sat Oct 25 21:32:46 2008 +0000
@@ -6,7 +6,7 @@
 ;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-bibtex.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-bibtex.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Bastien Guerry <bzg at altern dot org>
 ;;         Carsten Dominik <carsten dot dominik at gmail dot com>
 ;; Keywords: org, wp, remember
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-clock.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-clock.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -67,12 +67,16 @@
 
 (defcustom org-clock-in-switch-to-state nil
   "Set task to a special todo state while clocking it.
-The value should be the state to which the entry should be switched."
+The value should be the state to which the entry should be
+switched. If the value is a function, it must take one
+parameter (the current TODO state of the item) and return the
+state to switch it to."
   :group 'org-clock
   :group 'org-todo
   :type '(choice
 	  (const :tag "Don't force a state" nil)
-	  (string :tag "State")))
+	  (string :tag "State")
+	  (symbol :tag "Function")))
 
 (defcustom org-clock-history-length 5
   "Number of clock tasks to remember in history."
@@ -265,12 +269,16 @@
 	  (org-back-to-heading t)
 	  (or interrupting (move-marker org-clock-interrupted-task nil))
 	  (org-clock-history-push)
-	  (when (and org-clock-in-switch-to-state
-		     (not (looking-at (concat outline-regexp "[ \t]*"
-					      org-clock-in-switch-to-state
-					      "\\>"))))
-	    (org-todo org-clock-in-switch-to-state))
-	  (setq org-clock-heading-for-remember 
+	  (cond ((functionp org-clock-in-switch-to-state)
+		 (looking-at org-complex-heading-regexp)
+		 (let ((newstate (funcall org-clock-in-switch-to-state (match-string 2))))
+		   (if newstate (org-todo newstate))))
+		((and org-clock-in-switch-to-state
+		      (not (looking-at (concat outline-regexp "[ \t]*"
+					       org-clock-in-switch-to-state
+					       "\\>"))))
+		 (org-todo org-clock-in-switch-to-state)))
+	  (setq org-clock-heading-for-remember
 		(and (looking-at org-complex-heading-regexp)
 		     (match-end 4)
 		     (org-trim (buffer-substring (match-end 1) (match-end 4)))))
@@ -283,9 +291,9 @@
 		      (t "???")))
 	  (setq org-clock-heading (org-propertize org-clock-heading 'face nil))
 	  (org-clock-find-position)
-	  
+
 	  (insert "\n") (backward-char 1)
-	  (indent-relative)
+	  (org-indent-line-function)
 	  (insert org-clock-string " ")
 	  (setq org-clock-start-time (current-time))
 	  (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
@@ -348,11 +356,12 @@
 	(or (bolp) (newline)))
       (when (eq t org-clock-into-drawer)
 	(insert ":CLOCK:\n:END:\n")
-	(beginning-of-line -1)
+	(beginning-of-line 0)
 	(org-indent-line-function)
+	(beginning-of-line 0)
 	(org-flag-drawer t)
-	(beginning-of-line 2)
-	(org-indent-line-function)))))
+	(org-indent-line-function)
+	(beginning-of-line 2)))))
 
 (defun org-clock-out (&optional fail-quietly)
   "Stop the currently running clock.
--- a/lisp/org/org-colview.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-colview.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-compat.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-compat.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -176,7 +176,7 @@
    ((fboundp 'add-to-invisibility-spec)
     (add-to-invisibility-spec arg))
    ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t))
-	(setq buffer-invisibility-spec (list arg)))
+    (setq buffer-invisibility-spec (list arg)))
    (t
     (setq buffer-invisibility-spec
 	  (cons arg buffer-invisibility-spec)))))
@@ -197,56 +197,56 @@
 
 (defun org-indent-to-column (column &optional minimum buffer)
   "Work around a bug with extents with invisibility in XEmacs."
- (if (featurep 'xemacs)
-     (let ((ext-inv (extent-list
-                     nil (point-at-bol) (point-at-eol)
-                     'all-extents-closed-open 'invisible))
-           ext-inv-specs)
-       (dolist (ext ext-inv)
-         (when (extent-property ext 'invisible)
-           (add-to-list 'ext-inv-specs (list ext (extent-property
-						  ext 'invisible)))
-           (set-extent-property ext 'invisible nil)))
-       (indent-to-column column minimum buffer)
-       (dolist (ext-inv-spec ext-inv-specs)
-         (set-extent-property (car ext-inv-spec) 'invisible
-			      (cadr ext-inv-spec))))
-   (indent-to-column column minimum)))
+  (if (featurep 'xemacs)
+      (let ((ext-inv (extent-list
+		      nil (point-at-bol) (point-at-eol)
+		      'all-extents-closed-open 'invisible))
+	    ext-inv-specs)
+	(dolist (ext ext-inv)
+	  (when (extent-property ext 'invisible)
+	    (add-to-list 'ext-inv-specs (list ext (extent-property
+						   ext 'invisible)))
+	    (set-extent-property ext 'invisible nil)))
+	(indent-to-column column minimum buffer)
+	(dolist (ext-inv-spec ext-inv-specs)
+	  (set-extent-property (car ext-inv-spec) 'invisible
+			       (cadr ext-inv-spec))))
+    (indent-to-column column minimum)))
 
 (defun org-indent-line-to (column)
   "Work around a bug with extents with invisibility in XEmacs."
- (if (featurep 'xemacs)
-     (let ((ext-inv (extent-list
-                     nil (point-at-bol) (point-at-eol)
-                     'all-extents-closed-open 'invisible))
-           ext-inv-specs)
-       (dolist (ext ext-inv)
-         (when (extent-property ext 'invisible)
-           (add-to-list 'ext-inv-specs (list ext (extent-property
-						  ext 'invisible)))
-           (set-extent-property ext 'invisible nil)))
-       (indent-line-to column)
-       (dolist (ext-inv-spec ext-inv-specs)
-         (set-extent-property (car ext-inv-spec) 'invisible
-			      (cadr ext-inv-spec))))
-   (indent-line-to column)))
+  (if (featurep 'xemacs)
+      (let ((ext-inv (extent-list
+		      nil (point-at-bol) (point-at-eol)
+		      'all-extents-closed-open 'invisible))
+	    ext-inv-specs)
+	(dolist (ext ext-inv)
+	  (when (extent-property ext 'invisible)
+	    (add-to-list 'ext-inv-specs (list ext (extent-property
+						   ext 'invisible)))
+	    (set-extent-property ext 'invisible nil)))
+	(indent-line-to column)
+	(dolist (ext-inv-spec ext-inv-specs)
+	  (set-extent-property (car ext-inv-spec) 'invisible
+			       (cadr ext-inv-spec))))
+    (indent-line-to column)))
 
 (defun org-move-to-column (column &optional force buffer)
- (if (featurep 'xemacs)
-     (let ((ext-inv (extent-list
-                     nil (point-at-bol) (point-at-eol)
-                     'all-extents-closed-open 'invisible))
-           ext-inv-specs)
-       (dolist (ext ext-inv)
-         (when (extent-property ext 'invisible)
-           (add-to-list 'ext-inv-specs (list ext (extent-property ext
-								  'invisible)))
-           (set-extent-property ext 'invisible nil)))
-       (move-to-column column force buffer)
-       (dolist (ext-inv-spec ext-inv-specs)
-         (set-extent-property (car ext-inv-spec) 'invisible
-			      (cadr ext-inv-spec))))
-   (move-to-column column force)))
+  (if (featurep 'xemacs)
+      (let ((ext-inv (extent-list
+		      nil (point-at-bol) (point-at-eol)
+		      'all-extents-closed-open 'invisible))
+	    ext-inv-specs)
+	(dolist (ext ext-inv)
+	  (when (extent-property ext 'invisible)
+	    (add-to-list 'ext-inv-specs (list ext (extent-property ext
+								   'invisible)))
+	    (set-extent-property ext 'invisible nil)))
+	(move-to-column column force buffer)
+	(dolist (ext-inv-spec ext-inv-specs)
+	  (set-extent-property (car ext-inv-spec) 'invisible
+			       (cadr ext-inv-spec))))
+    (move-to-column column force)))
 
 (defun org-get-x-clipboard-compat (value)
   "Get the clipboard value on XEmacs or Emacs 21"
@@ -263,7 +263,7 @@
   (if (featurep 'xemacs)
       (add-text-properties 0 (length string) properties string)
     (apply 'propertize string properties)))
- 
+
 (provide 'org-compat)
 
 ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
--- a/lisp/org/org-exp.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-exp.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -856,6 +856,7 @@
 must accept the property list as an argument, and must return the (possibly
 modified) list.")
 
+;; FIXME: should we fold case here?
 (defun org-infile-export-plist ()
   "Return the property list with file-local settings for export."
   (save-excursion
@@ -1008,6 +1009,8 @@
 \[x] export as XOXO
 
 \[l] export as LaTeX
+\[p] export as LaTeX and process to PDF
+\[d] export as LaTeX, process to PDF, and open the resulting PDF document
 \[L] export as LaTeX to temporary buffer
 
 \[i] export current file as iCalendar file
@@ -1028,6 +1031,8 @@
 	    (?R org-export-region-as-html nil)
 	    (?x org-export-as-xoxo t)
 	    (?l org-export-as-latex t)
+	    (?p org-export-as-pdf t)
+	    (?d org-export-as-pdf-and-open t)
 	    (?L org-export-as-latex-to-buffer nil)
 	    (?i org-export-icalendar-this-file t)
 	    (?I org-export-icalendar-all-agenda-files t)
@@ -1041,12 +1046,17 @@
       (delete-other-windows)
       (with-output-to-temp-buffer "*Org Export/Publishing Help*"
 	(princ help))
+      (if (fboundp 'fit-window-to-buffer)
+	  (fit-window-to-buffer (get-buffer-window
+				 "*Org Export/Publishing Help*")))
       (message "Select command: ")
       (setq r1 (read-char-exclusive)))
     (setq r2 (if (< r1 27) (+ r1 96) r1))
     (unless (setq ass (assq r2 cmds))
       (error "No command associated with key %c" r1))
-    (if (and bg (nth 2 ass))
+    (if (and bg (nth 2 ass)
+	     (not (buffer-base-buffer))
+	     (not (org-region-active-p)))
 	;; execute in background
 	(let ((p (start-process
 		  (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
@@ -1496,7 +1506,6 @@
       ;; Remove or replace comments
       (org-export-handle-comments (plist-get parameters :comments))
 
-
       (setq rtn (buffer-string)))
     (kill-buffer " org-mode-tmp")
     rtn))
@@ -2181,16 +2190,17 @@
 	 (umax nil)
 	 (umax-toc nil)
 	 (case-fold-search nil)
+	 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
          (filename (concat (file-name-as-directory
 			    (org-export-directory :ascii opt-plist))
 			   (file-name-sans-extension
 			    (or (and subtree-p
 				     (org-entry-get (region-beginning)
 						    "EXPORT_FILE_NAME" t))
-				(file-name-nondirectory buffer-file-name)))
+				(file-name-nondirectory bfname)))
 			   ".txt"))
 	 (filename (if (equal (file-truename filename)
-			      (file-truename buffer-file-name))
+			      (file-truename bfname))
 		       (concat filename ".txt")
 		     filename))
 	 (buffer (find-file-noselect filename))
@@ -2204,7 +2214,7 @@
 				(plist-get opt-plist :skip-before-1st-heading))
 			       (org-export-grab-title-from-buffer))
 			  (file-name-sans-extension
-			   (file-name-nondirectory buffer-file-name))))
+			   (file-name-nondirectory bfname))))
 	 (email       (plist-get opt-plist :email))
 	 (language    (plist-get opt-plist :language))
 	 (quote-re0   (concat "^[ \t]*" org-quote-string "\\>"))
--- a/lisp/org/org-export-latex.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-export-latex.el	Sat Oct 25 21:32:46 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 6.09a
+;; Version: 6.10c
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
@@ -36,6 +36,8 @@
 ;; The interactive functions are similar to those of the HTML exporter:
 ;;
 ;; M-x `org-export-as-latex'
+;; M-x `org-export-as-pdf'
+;; M-x `org-export-as-pdf-and-open'
 ;; M-x `org-export-as-latex-batch'
 ;; M-x `org-export-as-latex-to-buffer'
 ;; M-x `org-export-region-as-latex'
@@ -88,6 +90,7 @@
      "\\documentclass[11pt,a4paper]{article}
 \\usepackage[utf8]{inputenc}
 \\usepackage[T1]{fontenc}
+\\usepackage{graphicx}
 \\usepackage{hyperref}"
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
@@ -98,6 +101,7 @@
      "\\documentclass[11pt,a4paper]{report}
 \\usepackage[utf8]{inputenc}
 \\usepackage[T1]{fontenc}
+\\usepackage{graphicx}
 \\usepackage{hyperref}"
      ("\\part{%s}" . "\\part*{%s}")
      ("\\chapter{%s}" . "\\chapter*{%s}")
@@ -108,6 +112,7 @@
      "\\documentclass[11pt,a4paper]{book}
 \\usepackage[utf8]{inputenc}
 \\usepackage[T1]{fontenc}
+\\usepackage{graphicx}
 \\usepackage{hyperref}"
      ("\\part{%s}" . "\\part*{%s}")
      ("\\chapter{%s}" . "\\chapter*{%s}")
@@ -120,30 +125,38 @@
 
   \(class-name
     header-string
-    (unnumbered-section numbered-section\)
+    (numbered-section . unnumbered-section\)
     ...\)
 
 A %s formatter is mandatory in each section string and will be
-replaced by the title of the section."
+replaced by the title of the section.
+
+Instead of a cons cell (numbered . unnumbered), you can also provide a list
+of 2-4 elements,
+
+  (numbered-open numbered-close)
+
+or
+
+  (numbered-open numbered-close unnumbered-open unnumbered-close)
+
+providing opening and closing strings for an environment that should
+represent the document section.  The opening clause should have a %s
+to represent the section title."
   :group 'org-export-latex
-  :type '(repeat
+  :type '(repeat 
 	  (list (string :tag "LaTeX class")
 		(string :tag "LaTeX header")
-		(cons :tag "Level 1"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 2"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 3"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 4"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 5"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered")))))
+		(repeat :tag "Levels" :inline t
+			(choice
+			 (cons :tag "Heading"
+			       (string :tag "numbered")
+			       (string :tag "unnumbered)"))
+			 (list :tag "Environment"
+			       (string :tag "Opening (numbered)  ")
+			       (string :tag "Closing (numbered)  ")
+			       (string :tag "Opening (unnumbered)")
+			       (string :tag "Closing (unnumbered)")))))))
 
 (defcustom org-export-latex-emphasis-alist
   '(("*" "\\textbf{%s}" nil)
@@ -224,6 +237,18 @@
   :group 'org-export-latex
   :type 'coding-system)
 
+(defgroup org-export-pdf nil
+  "Options for exporting Org-mode files to PDF, via LaTeX."
+  :tag "Org Export LaTeX"
+  :group 'org-export-latex
+  :group 'org-export)
+
+(defcustom org-export-pdf-remove-logfiles t
+  "Non-nil means, remove the logfiles produced by PDF production.
+These are the .aux, .log, .out, and .toc files."
+  :group 'org-export-latex
+  :type 'boolean)
+
 ;;; Autoload functions:
 
 ;;;###autoload
@@ -454,6 +479,44 @@
 	  (current-buffer))
       (set-window-configuration wcf))))
 
+;;;###autoload
+(defun org-export-as-pdf (arg &optional hidden ext-plist
+			      to-buffer body-only pub-dir)
+  "Export as LaTeX, then process through to PDF."
+  (interactive "P")
+  (message "Exporting to PDF...")
+  (let* ((wconfig (current-window-configuration))
+	 (lbuf (org-export-as-latex arg hidden ext-plist
+				    to-buffer body-only pub-dir))
+	 (file (buffer-file-name lbuf))
+	 (base (file-name-sans-extension (buffer-file-name lbuf)))
+	 (pdffile (concat base ".pdf")))
+    (and (file-exists-p pdffile) (delete-file pdffile))
+    (message "Processing LaTeX file...")
+    (shell-command (format "pdflatex -interaction nonstopmode %s"
+			   (shell-quote-argument file)))
+    (shell-command (format "pdflatex -interaction nonstopmode %s"
+			   (shell-quote-argument file)))
+    (message "Processing LaTeX file...done")
+    (if (not (file-exists-p pdffile))
+	(error "PDF file was not produced")
+      (set-window-configuration wconfig)
+      (when org-export-pdf-remove-logfiles
+	(dolist (ext '("aux" "log" "out" "toc"))
+	  (setq file (concat base "." ext))
+	  (and (file-exists-p file) (delete-file file))))
+      (message "Exporting to PDF...done")
+      pdffile)))
+
+;;;###autoload
+(defun org-export-as-pdf-and-open (arg)
+  "Export as LaTeX, then process through to PDF, and open."
+  (interactive "P")
+  (let ((pdffile (org-export-as-pdf arg)))
+    (if pdffile
+	(org-open-file pdffile)
+      (error "PDF file was not produced"))))
+
 ;;; Parsing functions:
 
 (defun org-export-latex-parse-global (level odd)
@@ -554,12 +617,18 @@
     (cond
      ;; Normal conversion
      ((<= level org-export-latex-sectioning-depth)
-      (let ((sec (nth (1- level) org-export-latex-sectioning)))
-	(insert (format (if num (car sec) (cdr sec)) heading) "\n"))
-      (when label (insert (format "\\label{%s}\n" label)))
-      (insert (org-export-latex-content content))
-      (cond ((stringp subcontent) (insert subcontent))
-	    ((listp subcontent) (org-export-latex-sub subcontent))))
+      (let* ((sec (nth (1- level) org-export-latex-sectioning))
+	     start end)
+	(if (consp (cdr sec))
+	    (setq start (nth (if num 0 2) sec)
+		  end (nth (if num 1 3) sec))
+	  (setq start (if num (car sec) (cdr sec))))
+	(insert (format start heading) "\n")
+	(when label (insert (format "\\label{%s}\n" label)))
+	(insert (org-export-latex-content content))
+	(cond ((stringp subcontent) (insert subcontent))
+	      ((listp subcontent) (org-export-latex-sub subcontent)))
+	(if end (insert end "\n"))))
      ;; At a level under the hl option: we can drop this subsection
      ((> level org-export-latex-sectioning-depth)
       (cond ((eq org-export-latex-low-levels 'description)
@@ -877,12 +946,15 @@
 			  ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after)
 			   (format "%s%s{%s}" string-before char
 				   (match-string 1 string-after))))))
-	       ((and subsup
-		     (> (length string-after) 1)
+	       ((and (> (length string-after) 1)
+		     (or (eq subsup t)
+			 (and (equal subsup '{}) (eq (string-to-char string-after) ?\{)))
 		     (string-match "[({]?\\([^)}]+\\)[)}]?" string-after))
-		(format "$%s%s{%s}$" string-before char
-			(match-string 1 string-after)))
-	       (subsup (concat "$" string-before char string-after "$"))
+		(format "%s$%s{%s}$" string-before char
+			(if (> (match-end 1) (1+ (match-beginning 1)))
+			    (concat "\\mathrm{" (match-string 1 string-after) "}")
+			(match-string 1 string-after))))
+	       ((eq subsup t) (concat string-before "$" char string-after "$"))
 	       (t (org-export-latex-protect-string
 		   (concat string-before "\\" char "{}" string-after)))))
 	(t (org-export-latex-protect-string
@@ -1084,6 +1156,7 @@
 	     (t (insert "\\texttt{" desc "}")))))))
 
 (defvar org-latex-entities)   ; defined below
+(defvar org-latex-entities-regexp)   ; defined below
 
 (defun org-export-latex-preprocess ()
   "Clean stuff in the LaTeX export."
@@ -1096,11 +1169,12 @@
 
   ;; Preserve latex environments
   (goto-char (point-min))
-  (while (search-forward "\\begin{" nil t)
-    (let ((start (progn (beginning-of-line) (point)))
-          (end (or (and (search-forward "\\end{" nil t)
-                        (end-of-line) (point))
-                   (point-max))))
+  (while (re-search-forward "^[ \t]*\\begin{\\([a-zA-Z]+\\)}" nil t)
+    (let* ((start (progn (beginning-of-line) (point)))
+	   (end (or (and (re-search-forward 
+			  (concat "^[ \t]*\\end{" (match-string 1) "}" nil t)
+			  (point-at-eol)))
+		    (point-max))))
       (add-text-properties start end '(org-protected t))))
 
   ;; Convert LaTeX to \LaTeX{}
@@ -1139,7 +1213,7 @@
 
   ;; Protect LaTeX entities
   (goto-char (point-min))
-  (while (re-search-forward (regexp-opt org-latex-entities) nil t)
+  (while (re-search-forward org-latex-entities-regexp nil t)
     (add-text-properties (match-beginning 0) (match-end 0)
 			 '(org-protected t)))
 
@@ -1204,8 +1278,9 @@
   "Convert lists to LaTeX."
   (goto-char (point-min))
   (while (re-search-forward org-list-beginning-re nil t)
-    (beginning-of-line)
-    (insert (org-list-to-latex (org-list-parse-list t)) "\n")))
+    (org-if-unprotected
+     (beginning-of-line)
+     (insert (org-list-to-latex (org-list-parse-list t)) "\n"))))
 
 (defconst org-latex-entities
  '("\\!"
@@ -1383,6 +1458,15 @@
    "\\vspace")
  "A list of LaTeX commands to be protected when performing conversion.")
 
+(defconst org-latex-entities-regexp
+  (let (names rest)
+    (dolist (x org-latex-entities)
+      (if (string-match "[a-z][A-Z]$" x)
+	  (push x names)
+	(push x rest)))
+    (concat "\\(" (regexp-opt (nreverse names)) "\\>\\)"
+	    "\\|\\(" (regexp-opt (nreverse rest)) "\\)")))
+
 (provide 'org-export-latex)
 
 ;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
--- a/lisp/org/org-faces.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-faces.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-gnus.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-gnus.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-id.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-id.el	Sat Oct 25 21:32:46 2008 +0000
@@ -4,7 +4,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -116,7 +116,8 @@
   :group 'org-id
   :type 'boolean)
 
-(defcustom org-id-locations-file (convert-standard-filename "~/.org-id-locations")
+(defcustom org-id-locations-file (convert-standard-filename
+				  "~/.org-id-locations")
   "The file for remembering the last ID number generated."
   :group 'org-id
   :type 'file)
--- a/lisp/org/org-info.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-info.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-irc.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-irc.el	Sat Oct 25 21:32:46 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-jsinfo.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-jsinfo.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-list.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-list.el	Sat Oct 25 21:32:46 2008 +0000
@@ -6,7 +6,7 @@
 ;;         Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mac-message.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-mac-message.el	Sat Oct 25 21:32:46 2008 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2008 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.09a
+;; Version: 6.10c
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
--- a/lisp/org/org-macs.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-macs.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mew.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-mew.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/org-mhe.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-mhe.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mouse.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-mouse.el	Sat Oct 25 21:32:46 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -166,6 +166,18 @@
   :group 'org-mouse
   :type 'string)
 
+(defcustom org-mouse-features
+  '(context-menu yank-link activate-stars activate-bullets activate-checkboxes)
+  "The features of org-mouse that should be activated.
+Changing this variable requires a restart of Emacs to get activated."
+  :group 'org-mouse
+  :type '(set :greedy t
+	      (const :tag "Mouse-3 shows context menu" context-menu)
+	      (const :tag "C-mouse-1 and mouse-3 move trees" move-tree)
+	      (const :tag "S-mouse-2 and drag-mouse-3 yank link" yank-link)
+	      (const :tag "Activate headline stars" activate-stars)
+	      (const :tag "Activate item bullets" activate-bullets)
+	      (const :tag "Activate checkboxes" activate-checkboxes)))	      
 
 (defun org-mouse-re-search-line (regexp)
   "Search the current line for a given regular expression."
@@ -410,7 +422,7 @@
 
 (defun org-mouse-tag-menu ()		;todo
   (append
-   (let ((tags (org-split-string (org-get-tags) ":")))
+   (let ((tags (org-get-tags)))
      (org-mouse-keyword-menu
       (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp)
       `(lambda (tag)
@@ -890,26 +902,42 @@
   '(lambda ()
      (setq org-mouse-context-menu-function 'org-mouse-context-menu)
 
-;     (define-key org-mouse-map [follow-link] 'mouse-face)
-     (define-key org-mouse-map (if (featurep 'xemacs) [button3] [mouse-3]) nil)
-     (define-key org-mode-map [mouse-3] 'org-mouse-show-context-menu)
+     (when (memq 'context-menu org-mouse-features)
+       (define-key org-mouse-map (if (featurep 'xemacs) [button3] [mouse-3]) nil)
+       (define-key org-mode-map [mouse-3] 'org-mouse-show-context-menu))
      (define-key org-mode-map [down-mouse-1] 'org-mouse-down-mouse)
-     (define-key org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree)
-     (define-key org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start)
-     (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link)
-     (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link)
-     (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree)
-     (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start)
+     (when (memq 'context-menu org-mouse-features)
+       (define-key org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree)
+       (define-key org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start))
+     (when (memq 'yank-link org-mouse-features)
+       (define-key org-mode-map [S-mouse-2] 'org-mouse-yank-link)
+       (define-key org-mode-map [drag-mouse-3] 'org-mouse-yank-link))
+     (when (memq 'move-tree org-mouse-features)
+       (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree)
+       (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start))
 
-     (font-lock-add-keywords nil
+     (when (memq 'activate-stars org-mouse-features)
+       (font-lock-add-keywords
+	nil
 	`((,outline-regexp
 	   0 `(face org-link mouse-face highlight keymap ,org-mouse-map)
-	   'prepend)
-	  ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +"
-	   (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) 'prepend))
-	  ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
+	   'prepend))
+ 	t))
+
+     (when (memq 'activate-bullets org-mouse-features)
+       (font-lock-add-keywords
+	nil
+	`(("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +"
+	   (1 `(face org-link keymap ,org-mouse-map mouse-face highlight)
+	      'prepend)))
+ 	t))
+
+     (when (memq 'activate-checkboxes org-mouse-features)
+       (font-lock-add-keywords
+	nil
+	`(("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
 	   (2 `(face bold keymap ,org-mouse-map mouse-face highlight) t)))
- 	t)
+ 	t))
 
      (defadvice org-open-at-point (around org-mouse-open-at-point activate)
        (let ((context (org-context)))
--- a/lisp/org/org-plot.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-plot.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
 ;; Homepage: http://orgmode.org
-;; Version: 6.06b
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-publish.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-publish.el	Sat Oct 25 21:32:46 2008 +0000
@@ -4,7 +4,7 @@
 ;; Author: David O'Toole <dto@gnu.org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: hypermedia, outlines, wp
-;; Version: 6.09a
+;; Version: 6.10c
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -276,8 +276,8 @@
   :group 'org-publish
   :type 'boolean)
 
-(defcustom org-publish-timestamp-directory
-  (convert-standard-filename "~/.org-timestamps/")
+(defcustom org-publish-timestamp-directory (convert-standard-filename 
+					    "~/.org-timestamps/")
   "Name of directory in which to store publishing timestamps."
   :group 'org-publish
   :type 'directory)
@@ -479,38 +479,48 @@
   (require 'org)
   (unless (file-exists-p pub-dir)
     (make-directory pub-dir t))
-  (let* ((visiting (find-buffer-visiting filename))
-	 (plist (cons :buffer-will-be-killed (cons t plist)))
-	 (init-buf (or visiting (find-file filename)))
-	 (init-point (point))
-	 (init-buf-string (buffer-string)) export-buf)
-    ;; run hooks before exporting
-    (run-hooks 'org-publish-before-export-hook)
-    ;; export the possibly modified buffer
-    (setq export-buf
-	  (funcall (intern (concat "org-export-as-" format))
-		   (plist-get plist :headline-levels)
-		   nil plist nil nil pub-dir))
-    (set-buffer export-buf)
-    ;; run hooks after export and save export
-    (and (run-hooks 'org-publish-after-export-hook)
-	 (if (buffer-modified-p) (save-buffer)))
-    (kill-buffer export-buf)
-    ;; maybe restore buffer's content
-    (set-buffer init-buf)
-    (when (buffer-modified-p init-buf)
-      (erase-buffer)
-      (insert init-buf-string)
-      (save-buffer)
-      (goto-char init-point))
-    (unless visiting
-      (kill-buffer init-buf))))
+  (let ((visiting (find-buffer-visiting filename)))
+    (save-excursion
+      (switch-to-buffer (or visiting (find-file filename)))
+      (let* ((plist (cons :buffer-will-be-killed (cons t plist)))
+	     (init-buf (current-buffer))
+	     (init-point (point))
+	     (init-buf-string (buffer-string))
+	     export-buf-or-file)
+	;; run hooks before exporting
+	(run-hooks 'org-publish-before-export-hook)
+	;; export the possibly modified buffer
+	(setq export-buf-or-file
+	      (funcall (intern (concat "org-export-as-" format))
+		       (plist-get plist :headline-levels)
+		       nil plist nil nil pub-dir))
+	(when (and (bufferp export-buf-or-file)
+		   (buffer-live-p export-buf-or-file))
+	  (set-buffer export-buf-or-file)
+	  ;; run hooks after export and save export
+	  (and (run-hooks 'org-publish-after-export-hook)
+	       (if (buffer-modified-p) (save-buffer)))
+	  (kill-buffer export-buf-or-file))
+	;; maybe restore buffer's content
+	(set-buffer init-buf)
+	(when (buffer-modified-p init-buf)
+	  (erase-buffer)
+	  (insert init-buf-string)
+	  (save-buffer)
+	  (goto-char init-point))
+	(unless visiting
+	  (kill-buffer init-buf))))))
 
 (defun org-publish-org-to-latex (plist filename pub-dir)
   "Publish an org file to LaTeX.
 See `org-publish-org-to' to the list of arguments."
   (org-publish-org-to "latex" plist filename pub-dir))
 
+(defun org-publish-org-to-pdf (plist filename pub-dir)
+  "Publish an org file to PDF (via LaTeX).
+See `org-publish-org-to' to the list of arguments."
+  (org-publish-org-to "pdf" plist filename pub-dir))
+
 (defun org-publish-org-to-html (plist filename pub-dir)
   "Publish an org file to HTML.
 See `org-publish-org-to' to the list of arguments."
@@ -667,6 +677,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Interactive publishing functions
 
+;;;###autoload
 (defalias 'org-publish-project 'org-publish)
 
 ;;;###autoload
--- a/lisp/org/org-remember.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-remember.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-rmail.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-rmail.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-table.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-table.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -43,7 +43,7 @@
 (declare-function org-format-org-table-html "org-exp" (lines &optional splice))
 (defvar orgtbl-mode) ; defined below
 (defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized
-
+(defvar org-export-html-table-tag) ; defined in org-exp.el
 (defvar constants-unit-system)
 
 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
@@ -894,7 +894,7 @@
 	  (insert txt)
 	  (org-move-to-column col)
 	  (if (and org-table-copy-increment (org-at-timestamp-p t))
-	      (org-timestamp-up 1)
+	      (org-timestamp-up-day)
 	    (org-table-maybe-recalculate-line))
 	  (org-table-align)
 	  (org-move-to-column col))
@@ -2116,7 +2116,8 @@
 	;; Check for old vertical references
 	(setq form (org-rewrite-old-row-references form))
 	;; Insert complex ranges
-	(while (string-match org-table-range-regexp form)
+	(while (and (string-match org-table-range-regexp form)
+		    (> (length (match-string 0 form)) 1))
 	  (setq form
 		(replace-match
 		 (save-match-data
@@ -3926,6 +3927,7 @@
 this function is called.  The function does *not* use `orgtbl-to-generic',
 so you cannot specify parameters for it."
   (let* ((splicep (plist-get params :splice))
+	 (html-table-tag org-export-html-table-tag)
 	 html)
     ;; Just call the formatter we already have
     ;; We need to make text lines for it, so put the fields back together.
--- a/lisp/org/org-vm.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-vm.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-wl.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org-wl.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org.el	Sat Oct 25 20:59:38 2008 +0000
+++ b/lisp/org/org.el	Sat Oct 25 21:32:46 2008 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.09a
+;; Version: 6.10c
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -92,7 +92,7 @@
 
 ;;; Version
 
-(defconst org-version "6.09a"
+(defconst org-version "6.10c"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -1140,6 +1140,7 @@
   '(
     (auto-mode . emacs)
     ("\\.x?html?\\'" . default)
+    ("\\.pdf\\'" . default)
     )
   "External applications for opening `file:path' items in a document.
 Org-mode uses system defaults for different file types, but
@@ -1426,6 +1427,27 @@
   :group 'org-todo
   :type 'hook)
 
+(defcustom org-todo-state-tags-triggers nil
+  "Tag changes that should be triggered by TODO state changes.
+This is a list.  Each entry is
+
+  (state-change (tag . flag) .......)
+
+State-change can be a string with a state, and empty string to indicate the
+state that has no TODO keyword, or it can be one of the symbols `todo'
+or `done', meaning any not-done or done state, respectively."
+  :group 'org-todo
+  :group 'org-tags
+  :type '(repeat
+	  (cons (choice :tag "When changing to"
+		 (const :tag "Not-done state" todo)
+		 (const :tag "Done state" done)
+		 (string :tag "State"))
+		(repeat
+		 (cons :tag "Tag action"
+		       (string :tag "Tag")
+		       (choice (const :tag "Add" t) (const :tag "Remove" nil)))))))
+
 (defcustom org-log-done nil
   "Non-nil means, record a CLOSED timestamp when moving an entry to DONE.
 When equal to the list (done), also prompt for a closing note.
@@ -1491,6 +1513,16 @@
 (unless (assq 'note org-log-note-headings)
   (push '(note . "%t") org-log-note-headings))
 
+(defcustom org-log-state-notes-insert-after-drawers nil
+  "Non-nil means, insert state change notes after any drawers in entry.
+Only the drawers that *immediately* follow the headline and the
+deadline/scheduled line are skipped.
+When nil, insert notes right after the heading and perhaps the line
+with deadline/scheduling if present."
+  :group 'org-todo
+  :group 'org-progress
+  :type 'boolean)
+
 (defcustom org-log-states-order-reversed t
   "Non-nil means, the latest state change note will be directly after heading.
 When nil, the notes will be orderer according to time."
@@ -1690,7 +1722,7 @@
 
 IMPORTANT:  This is a feature whose implementation is and likely will
 remain incomplete.  Really, it is only here because past midnight seems to
-ne the favorite working time of John Wiegley :-)"
+be the favorite working time of John Wiegley :-)"
   :group 'org-time
   :type 'number)
 
@@ -2490,7 +2522,7 @@
       (let ((re (concat "[ \t]*" org-clock-string
 			" *[[<]\\([^]>]+\\)[]>]\\(-+[[<]\\([^]>]+\\)[]>]"
 			"\\([ \t]*=>.*\\)?\\)?"))
-	    ts te h m s)
+	    ts te h m s neg)
 	(cond
 	 ((not (looking-at re))
 	  nil)
@@ -2512,11 +2544,13 @@
 		      (apply 'encode-time (org-parse-time-string te)))
 		     (time-to-seconds
 		      (apply 'encode-time (org-parse-time-string ts))))
+		neg (< s 0)
+		s (abs s)
 		h (floor (/ s 3600))
 		s (- s (* 3600 h))
 		m (floor (/ s 60))
 		s (- s (* 60 s)))
-	  (insert " => " (format "%2d:%02d" h m))
+	  (insert " => " (format (if neg "-%d:%02d" "%2d:%02d") h m))
 	  t))))))
 
 (defun org-check-running-clock ()
@@ -4573,7 +4607,7 @@
 			   (match-string 0))
 		       (error "*"))))
 	     (blank (cdr (assq 'heading org-blank-before-new-entry)))
-	     pos)
+	     pos hide-previous)
 	(cond
 	 ((and (org-on-heading-p) (bolp)
 	       (or (bobp)
@@ -4588,6 +4622,9 @@
 	  nil)
 	 (t
 	  ;; in the middle of the line
+          (save-excursion
+            (end-of-line)
+            (setq hide-previous (org-invisible-p)))
 	  (org-show-entry)
 	  (let ((split
 		 (org-get-alist-option org-M-RET-may-split-line 'headline))
@@ -4618,6 +4655,10 @@
 	(setq pos (point))
 	(end-of-line 1)
 	(unless (= (point) pos) (just-one-space) (backward-delete-char 1))
+        (when (and org-insert-heading-respect-content hide-previous)
+	  (save-excursion
+	    (outline-previous-visible-heading 1)
+	    (hide-entry)))
 	(run-hooks 'org-insert-heading-hook)))))
 
 (defun org-get-heading (&optional no-tags)
@@ -4641,20 +4682,20 @@
 (defun org-insert-heading-respect-content ()
   (interactive)
   (let ((org-insert-heading-respect-content t))
-    (call-interactively 'org-insert-heading)))
-
-(defun org-insert-todo-heading-respect-content ()
-  (interactive)
+    (org-insert-heading t)))
+
+(defun org-insert-todo-heading-respect-content (&optional force-state)
+  (interactive "P")
   (let ((org-insert-heading-respect-content t))
-    (call-interactively 'org-insert-todo-todo-heading)))
-
-(defun org-insert-todo-heading (arg)
+    (org-insert-todo-heading force-state t)))
+
+(defun org-insert-todo-heading (arg &optional force-heading)
   "Insert a new heading with the same level and TODO state as current heading.
 If the heading has no TODO state, or if the state is DONE, use the first
 state (TODO by default).  Also with prefix arg, force first state."
   (interactive "P")
-  (when (not (org-insert-item 'checkbox))
-    (org-insert-heading)
+  (when (or force-heading (not (org-insert-item 'checkbox)))
+    (org-insert-heading force-heading)
     (save-excursion
       (org-back-to-heading)
       (outline-previous-heading)
@@ -7209,7 +7250,7 @@
 
 At the target location, the entry is filed as a subitem of the target heading.
 Depending on `org-reverse-note-order', the new subitem will either be the
-first of the last subitem.
+first or the last subitem.
 
 With prefix arg GOTO, the command will only visit the target location,
 not actually move anything.
@@ -7876,6 +7917,7 @@
 	    ;; This is a non-nil state, and we need to log it
 	    (org-add-log-setup 'state state 'findpos dolog)))
 	;; Fixup tag positioning
+	(org-todo-trigger-tag-changes state)
 	(and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
 	(when org-provide-todo-statistics
 	  (org-update-parent-todo-statistics))
@@ -7942,6 +7984,21 @@
    (let (org-log-done org-log-states)   ; turn off logging
      (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
 ")
+
+(defun org-todo-trigger-tag-changes (state)
+  "Apply the changes defined in `org-todo-state-tags-triggers'."
+  (let ((l org-todo-state-tags-triggers)
+	changes)
+    (when (or (not state) (equal state ""))
+      (setq changes (append changes (cdr (assoc "" l)))))
+    (when (and (stringp state) (> (length state) 0))
+      (setq changes (append changes (cdr (assoc state l)))))
+    (when (member state org-not-done-keywords)
+      (setq changes (append changes (cdr (assoc 'todo l)))))
+    (when (member state org-done-keywords)
+      (setq changes (append changes (cdr (assoc 'done l)))))
+    (dolist (c changes)
+      (org-toggle-tag (car c) (if (cdr c) 'on 'off)))))
 	 
 (defun org-local-logging (value)
   "Get logging settings from a property VALUE."
@@ -8346,13 +8403,19 @@
 	(org-back-to-heading t)
 	(narrow-to-region (point) (save-excursion 
 				    (outline-next-heading) (point)))
-	(while (re-search-forward
-		(concat "\\(" org-drawer-regexp "\\|" org-property-end-re "\\)")
-		(point-max) t) (forward-line))
 	(looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
 			    "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
 			    "[^\r\n]*\\)?"))
 	(goto-char (match-end 0))
+	(when (and org-log-state-notes-insert-after-drawers
+		   (save-excursion
+		     (forward-line) (looking-at org-drawer-regexp)))
+	    (progn (forward-line)
+		   (while (looking-at org-drawer-regexp)
+		     (goto-char (match-end 0))
+		     (re-search-forward org-property-end-re (point-max) t)
+		     (forward-line))
+		   (forward-line -1)))
 	(unless org-log-states-order-reversed
 	  (and (= (char-after) ?\n) (forward-char 1))
 	  (org-skip-over-state-notes)
@@ -8383,7 +8446,7 @@
   (org-switch-to-buffer-other-window "*Org Note*")
   (erase-buffer)
   (if (memq org-log-note-how '(time state))
-      (org-store-log-note)
+      (let (current-prefix-arg)	(org-store-log-note))
     (let ((org-inhibit-startup t)) (org-mode))
     (insert (format "# Insert note for %s.
 # Finish with C-c C-c, or cancel with C-c C-k.\n\n"
@@ -9127,6 +9190,15 @@
 	  (org-move-to-column (min ncol col) t))
       (goto-char pos))))
 
+(defun org-set-tags-command (&optional arg just-align)
+  "Call the set-tags command for the current entry."
+  (interactive "P")
+  (if (org-on-heading-p)
+      (org-set-tags arg just-align)
+    (save-excursion
+      (org-back-to-heading t)
+      (org-set-tags arg just-align))))
+
 (defun org-set-tags (&optional arg just-align)
   "Set the tags for the current headline.
 With prefix ARG, realign all tags in headings in the current buffer."
@@ -9756,6 +9828,11 @@
 			  (org-columns-number-to-string (/ (float clocksum) 60.)
 						       'add_times))
 		    props))
+	  (unless (assoc "CATEGORY" props)
+	    (setq value (or (org-get-category)
+			    (progn (org-refresh-category-properties)
+				   (org-get-category))))
+	    (push (cons "CATEGORY" value) props))
 	  (append sum-props (nreverse props)))))))
 
 (defun org-entry-get (pom property &optional inherit)
@@ -12042,6 +12119,7 @@
 (org-defkey org-mode-map "\C-c\C-xb" 'org-tree-to-indirect-buffer)
 (org-defkey org-mode-map "\C-c\C-j" 'org-goto)
 (org-defkey org-mode-map "\C-c\C-t" 'org-todo)
+(org-defkey org-mode-map "\C-c\C-q" 'org-set-tags-command)
 (org-defkey org-mode-map "\C-c\C-s" 'org-schedule)
 (org-defkey org-mode-map "\C-c\C-d" 'org-deadline)
 (org-defkey org-mode-map "\C-c;"    'org-toggle-comment)
@@ -12850,7 +12928,7 @@
      ["Priority Up" org-shiftup t]
      ["Priority Down" org-shiftdown t])
     ("TAGS and Properties"
-     ["Set Tags" 'org-ctrl-c-ctrl-c (org-at-heading-p)]
+     ["Set Tags" 'org-set-tags-command t]
      ["Change tag in region" 'org-change-tag-in-region (org-region-active-p)]
      "--"
      ["Set property" 'org-set-property t]