changeset 100267:c851df8e004e

2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-locations-file): Wrap file name with `convert-standard-filename'. (org-id-files): New variable. (org-id-use-hash): New option. (org-id-update-id-locations): Also search in all files current listed in `org-id-files'. Convert the resulting alist to a hash if the user customation says so. (org-id-locations-save): Handle he case if `org-id-locations' is a hash. (org-id-locations-load): Convert the alist to a hash. (org-id-add-location): Handle the hast case. (kill-emacs-hook): Make sure id locations are saved when Emacs is exited. (org-id-hash-to-alist, org-id-alist-to-hash) (org-id-paste-tracker): New functions. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-goto-calendar): Remove duplicate let bindings of calendar variables. * org-table.el (org-table-find-row-type): Renamed from `org-find-row-type'. (org-table-rewrite-old-row-references): Renamed from `org-rewrite-old-row-references'. (org-table-shift-refpart): Renamed from `org-shift-refpart'. (org-table-cleanup-narrow-column-properties): Renamed from `org-cleanup-narrow-column-properties'. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-find-row-type): New arguments DESC and CLINE, for better error messages. (org-table-get-descriptor-line): Supply the new arguments to `org-find-row-type'. (org-table-error-on-row-ref-crossing-hline): New option. * org.el (org-target-link-regexp): Make buffer-local. (org-move-subtree-down): Fix bug with trees at beginning of buffer. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-faces.el (org-set-tag-faces): New function. (org-tags-special-faces-re): New variable. * org.el (org-font-lock-add-tag-faces, org-get-tag-face): New functions. * org-faces.el (org-tag-faces): New option. (org-tag): Mention `org-tag-faces' in the docstring. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-style-default): Implement new quoting. * org-jsinfo.el (org-infojs-template): Implement new quoting. * org-w3m.el (w3m-minor-mode-hook): Also add the special copy command to the `w3m-minor-mode-map'. * org-archive.el (org-archive-to-archive-sibling): Protect `this-command' to avoid appending kills during archiving. * org-exp.el (org-export-with-priority): New variable. (org-export-add-options-to-plist): Use `org-export-plist-vars' instead of internal list of strings and properties. (org-print-icalendar-entries): Retrieve the location property with inheritance. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-with-todo-keywords): New option. (org-export-plist-vars): Include also the keys for the #+OPTIONS line. (org-default-export-plist, org-export-add-options-to-plist) (org-export-as-ascii, org-export-as-html): Use the new structure of `org-export-plist-vars'. * org.el (org-map-entries): Return all values. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-matcher-time): Recognize more special values. * org-gnus.el (fboundp): Fix defvaralias for XEmacs. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-tags-exclude-from-inheritance): New option. (org-tag-inherit-p, org-remove-uniherited-tags): Respect `org-tags-exclude-from-inheritance'. * org-agenda.el (org-agenda-show-inherited-tags): New option. (org-format-agenda-item): Add inherited tags to the agenda line string, and make sure that properties are kept when downcasing the tags list. (org-agenda-add-inherited-tags): New function. (org-downcase-keep-props): New function. * org.el (org-scan-tags): Mark inherited tags with a text property. (org-get-tags-at): Mark inherited tags with a text property. (org-add-prop-inherited): New function. * org-agenda.el (org-agenda-add-inherited-tags): New function. (org-agenda-show-inherited-tags): New option. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-modules): Add org-w3m to the default modules. * org-table.el (orgtbl-self-insert-command): Make S-SPC work in orgtbl-mode. (orgtabl-create-or-convert-from-region): New command. * org-exp.el (org-export-as-ascii): Remove the handling of targets. (org-export-ascii-preprocess): Handle targets already in this function. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-timer.el (org-timer-start-time): Define this variable. (org-timer-item): Make argument optional. * org-list.el (org-insert-item): Automatically insert a timer item if the current list is a timer list. * org-timer.el: New file. * org-publish.el (org-publish-org-index): Only exclude the index file in the main directory from being added to the site-map. (org-publish-get-project-from-filename): If the current project is a component, start publishing from the parent project. 2008-12-07 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (orgtbl-ret): Fix RET at beginning-of-buffer. * org-publish.el (org-publish-org-index): Improve removal of temporary buffers.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 07 Dec 2008 18:36:02 +0000
parents d74ef243141c
children b1b9e6c5c96c
files 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 30 files changed, 777 insertions(+), 352 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/org/org-agenda.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-agenda.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -945,6 +945,10 @@
 	  (integer :tag "Minutes")
 	  (const :tag "No default duration")))
 
+(defcustom org-agenda-show-inherited-tags t
+  "Non-nil means, show inherited tags in each agenda line."
+  :group 'org-agenda-line-format
+  :type 'boolean)
 
 (defcustom org-agenda-remove-tags nil
   "Non-nil means, remove the tags from the headline copy in the agenda.
@@ -1298,7 +1302,7 @@
      ["Show Logbook entries" org-agenda-log-mode
       :style toggle :selected org-agenda-show-log
       :active (org-agenda-check-type nil 'agenda 'timeline)]
-     ["Include archived trees" org-agenda-archives-mode 
+     ["Include archived trees" org-agenda-archives-mode
       :style toggle :selected org-agenda-archives-mode :active t]
      ["Include archive files" (org-agenda-archives-mode t)
       :style toggle :selected (eq org-agenda-archives-mode t) :active t
@@ -1907,7 +1911,7 @@
 	     (cond
 	      ((string-match "\\.html?\\'" file)
 	       (set-buffer (htmlize-buffer (current-buffer)))
-	       
+
 	       (when (and org-agenda-export-html-style
 			  (string-match "<style>" org-agenda-export-html-style))
 		 ;; replace <style> section with org-agenda-export-html-style
@@ -2978,7 +2982,7 @@
   "Get the (Emacs Calendar) diary entries for DATE."
   (require 'diary-lib)
   (let* ((diary-fancy-buffer "*temporary-fancy-diary-buffer*")
-         (fancy-diary-buffer diary-fancy-buffer)
+	 (fancy-diary-buffer diary-fancy-buffer)
 	 (diary-display-hook '(fancy-diary-display))
 	 (diary-display-function 'fancy-diary-display)
 	 (pop-up-frames nil)
@@ -3412,7 +3416,7 @@
 	 (items (if (consp org-agenda-show-log)
 		    org-agenda-show-log
 		  org-agenda-log-mode-items))
-	 (parts 
+	 (parts
 	  (delq nil
 		(list
 		 (if (memq 'closed items) (concat "\\<" org-closed-string))
@@ -3737,6 +3741,9 @@
   (save-match-data
     ;; Diary entries sometimes have extra whitespace at the beginning
     (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt)))
+    (when org-agenda-show-inherited-tags
+      ;; Fix the tags part in txt
+      (setq txt (org-agenda-add-inherited-tags txt tags)))
     (let* ((category (or category
 			 org-category
 			 (if buffer-file-name
@@ -3836,7 +3843,8 @@
 
       ;; And finally add the text properties
       (org-add-props rtn nil
-	'org-category (downcase category) 'tags (mapcar 'downcase tags)
+	'org-category (downcase category)
+	'tags (mapcar 'org-downcase-keep-props tags)
 	'org-highest-priority org-highest-priority
 	'org-lowest-priority org-lowest-priority
 	'prefix-length (- (length rtn) (length txt))
@@ -3849,6 +3857,34 @@
 	'extra extra
 	'dotime dotime))))
 
+(defun org-agenda-add-inherited-tags (txt tags)
+  "Remove tags string from TXT, and add complete list of tags.
+The new list includes inherited tags.  If any inherited tags are present,
+a double colon separates inherited tags from local tags."
+  (if (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$") txt)
+      (setq txt (substring txt 0 (match-beginning 0))))
+  (when tags
+    (let ((have-i (get-text-property 0 'inherited (car tags)))
+	  i)
+      (setq txt (concat txt " :"
+			(mapconcat
+			 (lambda (x)
+			   (setq i (get-text-property 0 'inherited x))
+			   (if (and have-i (not i))
+			       (progn
+				 (setq have-i nil)
+				 (concat ":" x))
+			     x))
+			 tags ":")
+			(if have-i "::" ":")))))
+  txt)
+
+(defun org-downcase-keep-props (s)
+  (let ((props (text-properties-at 0 s)))
+    (setq s (downcase s))
+    (add-text-properties 0 (length s) props s)
+    s))
+
 (defvar org-agenda-sorting-strategy) ;; because the def is in a let form
 (defvar org-agenda-sorting-strategy-selected nil)
 
@@ -4024,7 +4060,7 @@
 	 (tb (or (get-text-property 1 'todo-state b) ""))
 	 (la (- (length (member ta org-todo-keywords-for-agenda))))
 	 (lb (- (length (member tb org-todo-keywords-for-agenda))))
-	 (donepa (member ta org-done-keywords-for-agenda)) 
+	 (donepa (member ta org-done-keywords-for-agenda))
 	 (donepb (member tb org-done-keywords-for-agenda)))
     (cond ((and donepa (not donepb)) -1)
 	  ((and (not donepa) donepb) +1)
@@ -4228,7 +4264,7 @@
 to switch to narrowing."
   (interactive "P")
   (let* ((alist org-tag-alist-for-agenda)
-	(tag-chars (mapconcat 
+	(tag-chars (mapconcat
 		    (lambda (x) (if (cdr x) (char-to-string (cdr x)) ""))
 		    alist ""))
 	(efforts (org-split-string
@@ -4241,7 +4277,7 @@
 	(current org-agenda-filter)
 	char a n tag tags)
     (unless char
-      (message 
+      (message
        "%s by tag [%s ], [TAB], [/]:off, [+-]:narrow, [>=<]:effort: "
        (if narrow "Narrow" "Filter") tag-chars)
       (setq char (read-char)))
@@ -4249,7 +4285,7 @@
       ;; Narrowing down
       (cond ((equal char ?-) (setq strip t narrow t))
 	    ((equal char ?+) (setq strip nil narrow t)))
-      (message 
+      (message
        "Narrow by tag [%s ], [TAB], [/]:off, [>=<]:effort: " tag-chars)
       (setq char (read-char)))
     (when (member char '(?< ?> ?=))
@@ -5101,7 +5137,9 @@
 	(goto-char (match-beginning 1))
 	(insert (org-add-props
 		    (make-string (max 1 (- c (current-column))) ?\ )
-		    (text-properties-at (point))))))))
+		    (text-properties-at (point)))))
+      (goto-char (point-min))
+      (org-font-lock-add-tag-faces (point-max)))))
 
 (defun org-agenda-priority-up ()
   "Increase the priority of line at point, also in Org-mode file."
@@ -5369,7 +5407,7 @@
 	      (widen)
 	      (goto-char org-agenda-action-marker)
 	      (eval form))))))))
-  
+
 (defun org-agenda-clock-in (&optional arg)
   "Start the clock on the currently selected item."
   (interactive "P")
@@ -5512,8 +5550,6 @@
 	 (calendar-view-holidays-initially-flag nil)
 	 (calendar-view-diary-initially-flag nil)
 	 (view-calendar-holidays-initially nil)
-	 (calendar-view-diary-initially-flag nil)
-	 (calendar-view-holidays-initially-flag nil)
 	 (view-diary-entries-initially nil))
     (calendar)
     (calendar-goto-date date)))
--- a/lisp/org/org-archive.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-archive.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -345,7 +345,7 @@
       (org-end-of-subtree t t)
       (save-excursion
 	(goto-char pos)
-	(org-cut-subtree))
+	(let ((this-command this-command)) (org-cut-subtree)))
       (org-paste-subtree (org-get-valid-level level 1))
       (org-set-property
        "ARCHIVE_TIME"
--- a/lisp/org/org-attach.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-attach.el	Sun Dec 07 18:36:02 2008 +0000
@@ -4,7 +4,7 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 6.13a
+;; Version: 6.14
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -181,7 +181,7 @@
 		 " git add .; "
 		 " git ls-files --deleted -z | xargs -0 git rm; "
 		 " git commit -m 'Synchronized attachments')")))))
-  
+
 (defun org-attach-tag (&optional off)
   "Turn the autotag on or (if OFF is set) off."
   (when org-attach-auto-tag
@@ -266,7 +266,7 @@
   (when org-attach-file-list-property
     (org-entry-delete (point) org-attach-file-list-property))
   (let ((attach-dir (org-attach-dir)))
-    (when 
+    (when
 	(and attach-dir
 	     (or force
 		 (y-or-n-p "Are you sure you want to remove all attachments of this entry? ")))
--- a/lisp/org/org-bbdb.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-bbdb.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -259,8 +259,8 @@
           (multiple-value-bind (m d y)
               (funcall org-bbdb-extract-date-fun (car split))
             (setq tmp (gethash (list m d) org-bbdb-anniv-hash))
-            (puthash (list m d) (cons (list y 
-                                            (bbdb-record-name rec) 
+            (puthash (list m d) (cons (list y
+                                            (bbdb-record-name rec)
                                             (cadr split))
                                       tmp)
                      org-bbdb-anniv-hash))))))
@@ -292,7 +292,7 @@
          (annivs (gethash (list m d) org-bbdb-anniv-hash))
          (text ())
          split class form rec recs)
-    
+
     ;; we don't want to miss people born on Feb. 29th
     (when (and (= m 3) (= d 1)
                (not (null (gethash (list 2 29) org-bbdb-anniv-hash)))
@@ -303,7 +303,7 @@
 
     (when annivs
       (while (setq rec (pop annivs))
-        (when rec 
+        (when rec
           (let* ((class (or (nth 2 rec)
                             org-bbdb-default-anniversary-format))
                  (form (or (cdr (assoc class
--- a/lisp/org/org-bibtex.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-bibtex.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-clock.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-clock.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -118,7 +118,8 @@
 	  (const :tag "Clock and history" t)
 	  (const :tag "No persistence" nil)))
 
-(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
+(defcustom org-clock-persist-file (convert-standard-filename
+				   "~/.emacs.d/org-clock-save.el")
   "File to save clock data to"
   :group 'org-clock
   :type 'string)
@@ -187,7 +188,7 @@
   "Select a task that recently was associated with clocking."
   (interactive)
   (let (sel-list rpl file task (i 0) s)
-    (save-window-excursion 
+    (save-window-excursion
       (org-switch-to-buffer-other-window
        (get-buffer-create "*Clock Task Select*"))
       (erase-buffer)
@@ -285,13 +286,13 @@
 		     (marker-position org-clock-marker)
 		     (marker-buffer org-clock-marker))
 	(org-clock-out t))
-      
+
       (when (equal select '(16))
 	;; Mark as default clocking task
 	(save-excursion
 	  (org-back-to-heading t)
 	  (move-marker org-clock-default-task (point))))
-      
+
       (setq target-pos (point))  ;; we want to clock in at this location
       (save-excursion
 	(when (and selected-task (marker-buffer selected-task))
@@ -991,8 +992,8 @@
 	      (cond
 	       ((eq formula '%)
 		(setq pcol (+ (if scope-is-list 1 0) maxlevel 3))
-		(insert 
-		 (format 
+		(insert
+		 (format
 		  "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f"
 		  pcol
 		  2
@@ -1160,7 +1161,7 @@
 	(when (and resume-clock org-clock-persist
 		   (file-exists-p (car resume-clock))
 		   (or (not org-clock-persist-query-resume)
-		       (y-or-n-p 
+		       (y-or-n-p
 			(concat
 			 "Resume clock ("
 			 (with-current-buffer (find-file (car resume-clock))
--- a/lisp/org/org-colview.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-colview.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -220,7 +220,7 @@
 
 (defun org-columns-add-ellipses (string width)
   "Truncate STRING with WIDTH characters, with ellipses."
-  (cond 
+  (cond
    ((<= (length string) width) string)
    ((<= width (length org-columns-ellipses))
     (substring org-columns-ellipses 0 width))
--- a/lisp/org/org-compat.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-compat.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-exp.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-exp.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -204,6 +204,18 @@
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-with-todo-keywords t
+  "Non-nil means, include TODO keywords in export.
+When nil, remove all these keywords from the export."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-priority nil
+  "Non-nil means, include priority cookies in export.
+When nil, remove priority cookies for export."
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-preserve-breaks nil
   "Non-nil means, preserve all line breaks when exporting.
 Normally, in HTML output paragraphs will be reformatted.  In ASCII
@@ -314,7 +326,7 @@
 <h2 class=\"footnotes\">%s: </h2>
 <div id=\"footnotes-text\">
 %s
-</div> 
+</div>
 </div>"
   "Format for the footnotes section.
 Should contain a two instances of %s.  The first will be replaced with the
@@ -512,7 +524,7 @@
 
 (defconst org-export-html-style-default
 "<style type=\"text/css\">
- <![CDATA[
+ <!--/*--><![CDATA[/*><!--*/
   html { font-family: Times, serif; font-size: 12pt; }
   .title  { text-align: center; }
   .todo   { color: red; }
@@ -539,7 +551,7 @@
                                white-space:nowrap; }
   .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
                                  font-weight:bold; }
- ]]>
+  /*]]>*/-->
 </style>"
   "The default style specification for exported HTML files.
 Please use the variables `org-export-html-style' and
@@ -821,57 +833,67 @@
 (defvar org-current-export-dir nil) ; dynamically scoped parameter
 
 (defconst org-export-plist-vars
-  '((:link-up              . org-export-html-link-up)
-    (:link-home            . org-export-html-link-home)
-    (:language             . org-export-default-language)
-    (:customtime           . org-display-custom-times)
-    (:headline-levels      . org-export-headline-levels)
-    (:section-numbers      . org-export-with-section-numbers)
-    (:section-number-format . org-export-section-number-format)
-    (:table-of-contents    . org-export-with-toc)
-    (:preserve-breaks      . org-export-preserve-breaks)
-    (:archived-trees       . org-export-with-archived-trees)
-    (:emphasize            . org-export-with-emphasize)
-    (:sub-superscript      . org-export-with-sub-superscripts)
-    (:special-strings      . org-export-with-special-strings)
-    (:footnotes            . org-export-with-footnotes)
-    (:drawers              . org-export-with-drawers)
-    (:tags                 . org-export-with-tags)
-    (:TeX-macros           . org-export-with-TeX-macros)
-    (:LaTeX-fragments      . org-export-with-LaTeX-fragments)
-    (:skip-before-1st-heading . org-export-skip-text-before-1st-heading)
-    (:fixed-width          . org-export-with-fixed-width)
-    (:timestamps           . org-export-with-timestamps)
-    (:author-info          . org-export-author-info)
-    (:creator-info         . org-export-creator-info)
-    (:time-stamp-file      . org-export-time-stamp-file)
-    (:tables               . org-export-with-tables)
-    (:table-auto-headline  . org-export-highlight-first-table-line)
-    (:style-include-default . org-export-html-style-include-default)
-    (:style                . org-export-html-style)
-    (:style-extra          . org-export-html-style-extra)
-    (:agenda-style         . org-agenda-export-html-style)
-    (:convert-org-links    . org-export-html-link-org-files-as-html)
-    (:inline-images        . org-export-html-inline-images)
-    (:html-extension       . org-export-html-extension)
-    (:html-table-tag       . org-export-html-table-tag)
-    (:expand-quoted-html   . org-export-html-expand)
-    (:timestamp            . org-export-html-with-timestamp)
-    (:publishing-directory . org-export-publishing-directory)
-    (:preamble             . org-export-html-preamble)
-    (:postamble            . org-export-html-postamble)
-    (:auto-preamble        . org-export-html-auto-preamble)
-    (:auto-postamble       . org-export-html-auto-postamble)
-    (:author               . user-full-name)
-    (:email                . user-mail-address)
-    (:select-tags          . org-export-select-tags)
-    (:exclude-tags         . org-export-exclude-tags)))
+  '((:link-up                 nil         org-export-html-link-up)
+    (:link-home               nil         org-export-html-link-home)
+    (:language                nil         org-export-default-language)
+    (:customtime              nil         org-display-custom-times)
+    (:headline-levels         "H"         org-export-headline-levels)
+    (:section-numbers         "num"       org-export-with-section-numbers)
+    (:section-number-format   nil         org-export-section-number-format)
+    (:table-of-contents       "toc"       org-export-with-toc)
+    (:preserve-breaks         "\\n"       org-export-preserve-breaks)
+    (:archived-trees          nil         org-export-with-archived-trees)
+    (:emphasize               "*"         org-export-with-emphasize)
+    (:sub-superscript         "^"         org-export-with-sub-superscripts)
+    (:special-strings         "-"         org-export-with-special-strings)
+    (:footnotes               "f"         org-export-with-footnotes)
+    (:drawers                 "d"         org-export-with-drawers)
+    (:tags                    "tags"      org-export-with-tags)
+    (:todo-keywords           "todo"      org-export-with-todo-keywords)
+    (:priority                "pri"       org-export-with-priority)
+    (:TeX-macros              "TeX"       org-export-with-TeX-macros)
+    (:LaTeX-fragments         "LaTeX"     org-export-with-LaTeX-fragments)
+    (:skip-before-1st-heading "skip"      org-export-skip-text-before-1st-heading)
+    (:fixed-width             ":"         org-export-with-fixed-width)
+    (:timestamps              "<"         org-export-with-timestamps)
+    (:author-info             "author"    org-export-author-info)
+    (:creator-info            "creator"   org-export-creator-info)
+    (:time-stamp-file         "timestamp" org-export-time-stamp-file)
+    (:tables                  "|"         org-export-with-tables)
+    (:table-auto-headline     nil         org-export-highlight-first-table-line)
+    (:style-include-default   nil         org-export-html-style-include-default)
+    (:style                   nil         org-export-html-style)
+    (:style-extra             nil         org-export-html-style-extra)
+    (:agenda-style            nil         org-agenda-export-html-style)
+    (:convert-org-links       nil         org-export-html-link-org-files-as-html)
+    (:inline-images           nil         org-export-html-inline-images)
+    (:html-extension          nil         org-export-html-extension)
+    (:html-table-tag          nil         org-export-html-table-tag)
+    (:expand-quoted-html      "@"         org-export-html-expand)
+    (:timestamp               nil         org-export-html-with-timestamp)
+    (:publishing-directory    nil         org-export-publishing-directory)
+    (:preamble                nil         org-export-html-preamble)
+    (:postamble               nil         org-export-html-postamble)
+    (:auto-preamble           nil         org-export-html-auto-preamble)
+    (:auto-postamble          nil         org-export-html-auto-postamble)
+    (:author                  nil         user-full-name)
+    (:email                   nil         user-mail-address)
+    (:select-tags             nil         org-export-select-tags)
+    (:exclude-tags            nil         org-export-exclude-tags))
+  "List of properties that represent export/publishing variables.
+Each element is a list of 3 items:
+1. The property that is used internally, and also for org-publish-project-alist
+2. The string that can be used in the OPTION lines to set this option,
+   or nil if this option cannot be changed in this way
+3. The customization variable that sets the default for this option."
+
+)
 
 (defun org-default-export-plist ()
   "Return the property list with default settings for the export variables."
   (let ((l org-export-plist-vars) rtn e)
     (while (setq e (pop l))
-      (setq rtn (cons (car e) (cons (symbol-value (cdr e)) rtn))))
+      (setq rtn (cons (car e) (cons (symbol-value (nth 2 e)) rtn))))
     rtn))
 
 (defvar org-export-inbuffer-options-extra nil
@@ -964,35 +986,17 @@
   "Parse an OPTONS line and set values in the property list P."
   (let (o)
     (when options
-      (let ((op '(("H"     . :headline-levels)
-		  ("num"   . :section-numbers)
-		  ("toc"   . :table-of-contents)
-		  ("\\n"   . :preserve-breaks)
-		  ("@"     . :expand-quoted-html)
-		  (":"     . :fixed-width)
-		  ("|"     . :tables)
-		  ("^"     . :sub-superscript)
-		  ("-"     . :special-strings)
-		  ("f"     . :footnotes)
-		  ("d"     . :drawers)
-		  ("tags"  . :tags)
-		  ("*"     . :emphasize)
-		  ("TeX"   . :TeX-macros)
-		  ("LaTeX" . :LaTeX-fragments)
-		  ("skip"  . :skip-before-1st-heading)
-		  ("author" . :author-info)
-		  ("creator" . :creator-info)
-		  ("timestamp" . :time-stamp-file)))
-	    o)
+      (let ((op org-export-plist-vars) a)
 	(while (setq o (pop op))
-	  (if (string-match (concat (regexp-quote (car o))
-				    ":\\([^ \t\n\r;,.]*\\)")
-			    options)
-	      (setq p (plist-put p (cdr o)
+	  (if (and (nth 1 o)
+		   (string-match (concat (regexp-quote (nth 1 o))
+					 ":\\([^ \t\n\r;,.]*\\)")
+				 options))
+	      (setq p (plist-put p (car o)
 				 (car (read-from-string
 				       (match-string 1 options))))))))))
   p)
-  
+
 (defun org-export-add-subtree-options (p pos)
   "Add options in subtree at position POS to property list P."
   (save-excursion
@@ -1447,14 +1451,14 @@
       ;; The caller markes some stuff fo killing, stuff that has been
       ;; used to create the page title, for example.
       (org-export-kill-licensed-text)
-      
+
       (let ((org-inhibit-startup t)) (org-mode))
       (setq case-fold-search t)
       (untabify (point-min) (point-max))
-      
+
       ;; Handle include files
       (org-export-handle-include-files)
-      
+
       ;; Get rid of excluded trees
       (org-export-handle-export-tags (plist-get parameters :select-tags)
 				     (plist-get parameters :exclude-tags))
@@ -1462,10 +1466,13 @@
       ;; Handle source code snippets
       (org-export-replace-src-segments)
       
+      ;; Find all headings and compute the targets for them
+      (setq target-alist (org-export-define-heading-targets target-alist))
+
       ;; Get rid of drawers
       (org-export-remove-or-extract-drawers drawers
 					    (plist-get parameters :drawers))
-      
+
       ;; Get the correct stuff before the first headline
       (when (plist-get parameters :skip-before-1st-heading)
 	(goto-char (point-min))
@@ -1476,12 +1483,12 @@
       (when (plist-get parameters :add-text)
 	(goto-char (point-min))
 	(insert (plist-get parameters :add-text) "\n"))
-      
+
       ;; Get rid of archived trees
       (org-export-remove-archived-trees archived-trees)
-      
-      ;; Find all headings and compute the targets for them
-      (setq target-alist (org-export-define-heading-targets target-alist))
+
+      ;; Remove todo-keywords before exporting, if the user has requested so
+      (org-export-remove-headline-metadata parameters)
 
       ;; Find targets in comments and move them out of comments,
       ;; but mark them as targets that should be invisible
@@ -1506,7 +1513,6 @@
       ;; Remove comment environment and comment subtrees
       (org-export-remove-comment-blocks-and-subtrees)
 
-
       ;; Find matches for radio targets and turn them into internal links
       (org-export-mark-radio-links)
 
@@ -1564,18 +1570,22 @@
 The new targets are added to TARGET-ALIST, which is also returned."
   (goto-char (point-min))
   (org-init-section-numbers)
-  (let ((re (concat "^" org-outline-regexp))
+  (let ((re (concat "^" org-outline-regexp
+		    "\\| [ \t]*:ID:[ \t]*\\([^ \t\r\n]+\\)"))
 	level target)
     (while (re-search-forward re nil t)
-      (setq level (org-reduced-level
-		   (save-excursion (goto-char (point-at-bol))
-				   (org-outline-level))))
-      (setq target (org-solidify-link-text
-		    (format "sec-%s" (org-section-number level))))
-      (push (cons target target) target-alist)
-      (add-text-properties
-       (point-at-bol) (point-at-eol)
-       (list 'target target))))
+      (if (match-end 1)
+	  (push (cons (org-match-string-no-properties 1)
+		      target) target-alist)
+	(setq level (org-reduced-level
+		     (save-excursion (goto-char (point-at-bol))
+				     (org-outline-level))))
+	(setq target (org-solidify-link-text
+		      (format "sec-%s" (org-section-number level))))
+	(push (cons target target) target-alist)
+	(add-text-properties
+	 (point-at-bol) (point-at-eol)
+	 (list 'target target)))))
   target-alist)
 
 (defun org-export-handle-invisible-targets (target-alist)
@@ -1604,9 +1614,11 @@
   target-alist)
 
 (defun org-export-target-internal-links (target-alist)
-  "Find all internal links and assign target to them.
+  "Find all internal links and assign targets to them.
 If a link has a fuzzy match (i.e. not a *dedicated* target match),
-let the link  point to the corresponding section."
+let the link  point to the corresponding section.
+This function also handles the id links, if they have a match in
+the current file."
   (goto-char (point-min))
   (while (re-search-forward org-bracket-link-regexp nil t)
     (org-if-unprotected
@@ -1618,6 +1630,8 @@
 	    (target
 	     (cond
 	      ((cdr (assoc slink target-alist)))
+	      ((and (string-match "^id:" link)
+		    (cdr (assoc (substring link 3) target-alist))))
 	      ((string-match org-link-types-re link) nil)
 	      ((or (file-name-absolute-p link)
 		   (string-match "^\\." link))
@@ -1735,6 +1749,24 @@
 		b (org-end-of-subtree t))
 	  (if (> b a) (delete-region a b)))))))
 
+(defun org-export-remove-headline-metadata (opts)
+  "Remove meta data from the headline, according to user options."
+  (let ((re org-complex-heading-regexp)
+	(todo (plist-get opts :todo-keywords))
+	(tags (plist-get opts :tags))
+	(pri  (plist-get opts :priority))
+	rpl)
+    (when (or (not todo) (not tags) (not pri))
+      ;; OK, something needs to be removed
+      (setq rpl (concat "\\1"
+			(if todo " \\2" "")
+			(if pri  " \\3" "")
+			" \\4"
+			(if tags " \\5" "")))
+      (goto-char (point-min))
+      (while (re-search-forward re nil t)
+	(replace-match rpl t nil)))))
+
 (defun org-export-protect-quoted-subtrees ()
   "Mark quoted subtrees with the protection property."
   (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
@@ -1905,7 +1937,7 @@
 		  "]")))
 	 (put-text-property 0 (length s) 'face 'org-link s)
 	 (replace-match s t t))))))
-  
+
 (defun org-export-concatenate-multiline-links ()
   "Find multi-line links and put it all into a single line.
 This is to make sure that the line-processing export backends
@@ -2071,7 +2103,7 @@
       res)))
 
 (org-number-to-roman 1961)
-   
+
 
 ;;; Include files
 
@@ -2227,7 +2259,7 @@
 	      (goto-char rbeg)
 	      (and (org-at-heading-p)
 		   (>= (org-end-of-subtree t t) rend)))))
-	 (opt-plist (if subtree-p 
+	 (opt-plist (if subtree-p
 			(org-export-add-subtree-options opt-plist rbeg)
 		      opt-plist))
 	 (custom-times org-display-custom-times)
@@ -2278,6 +2310,9 @@
 		  :skip-before-1st-heading
 		  (plist-get opt-plist :skip-before-1st-heading)
 		  :drawers (plist-get opt-plist :drawers)
+		  :tags (plist-get opt-plist :tags)
+		  :priority (plist-get opt-plist :priority)
+		  :todo-keywords (plist-get opt-plist :todo-keywords)
 		  :verbatim-multiline t
 		  :select-tags (plist-get opt-plist :select-tags)
 		  :exclude-tags (plist-get opt-plist :exclude-tags)
@@ -2307,7 +2342,7 @@
     ;; create local variables for all options, to make sure all called
     ;; functions get the correct information
     (mapc (lambda (x)
-	    (set (make-local-variable (cdr x))
+	    (set (make-local-variable (nth 2 x))
 		 (plist-get opt-plist (car x))))
 	  org-export-plist-vars)
     (org-set-local 'org-odd-levels-only odd)
@@ -2397,10 +2432,7 @@
     (while (setq line (pop lines))
       ;; Remove the quoted HTML tags.
       (setq line (org-html-expand-for-ascii line))
-      ;; Remove targets
-      (while (string-match "<<<?[^<>]*>>>?[ \t]*\n?" line)
-	(setq line (replace-match "" t t line)))
-      ;; Replace internal links
+      ;; Replace links with the description when possible
       (while (string-match org-bracket-link-regexp line)
 	(setq line (replace-match
 		    (if (match-end 3) "[\\3]" "[\\1]")
@@ -2483,13 +2515,18 @@
 
 (defun org-export-ascii-preprocess ()
   "Do extra work for ASCII export"
+  ;; Put quotes around verbatim text
   (goto-char (point-min))
   (while (re-search-forward org-verbatim-re nil t)
     (goto-char (match-end 2))
     (backward-delete-char 1) (insert "'")
     (goto-char (match-beginning 2))
     (delete-char 1) (insert "`")
-    (goto-char (match-end 2))))
+    (goto-char (match-end 2)))
+  (goto-char (point-min))
+  ;; Remove target markers
+  (while (re-search-forward  "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t)
+    (replace-match "\\1\\2")))
 
 (defun org-search-todo-below (line lines level)
   "Search the subtree below LINE for any TODO entries."
@@ -2643,7 +2680,7 @@
 #+EMAIL:     %s
 #+DATE:      %s
 #+LANGUAGE:  %s
-#+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s
+#+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
 %s
 #+EXPORT_SELECT_TAGS: %s
 #+EXPORT_EXCLUDE_TAGS: %s
@@ -2678,6 +2715,8 @@
    org-export-with-LaTeX-fragments
    org-export-skip-text-before-1st-heading
    org-export-with-drawers
+   org-export-with-todo-keywords
+   org-export-with-priority
    org-export-with-tags
    (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "")
    (mapconcat 'identity org-export-select-tags " ")
@@ -2871,7 +2910,7 @@
 		(goto-char rbeg)
 		(and (org-at-heading-p)
 		     (>= (org-end-of-subtree t t) rend))))))
-	 (opt-plist (if subtree-p 
+	 (opt-plist (if subtree-p
 			(org-export-add-subtree-options opt-plist rbeg)
 		      opt-plist))
 	 ;; The following two are dynamically scoped into other
@@ -2951,6 +2990,9 @@
 	    :skip-before-1st-heading
 	    (plist-get opt-plist :skip-before-1st-heading)
 	    :drawers (plist-get opt-plist :drawers)
+	    :todo-keywords (plist-get opt-plist :todo-keywords)
+	    :tags (plist-get opt-plist :tags)
+	    :priority (plist-get opt-plist :priority)
 	    :archived-trees
 	    (plist-get opt-plist :archived-trees)
 	    :select-tags (plist-get opt-plist :select-tags)
@@ -3002,7 +3044,7 @@
       ;; create local variables for all options, to make sure all called
       ;; functions get the correct information
       (mapc (lambda (x)
-	      (set (make-local-variable (cdr x))
+	      (set (make-local-variable (nth 2 x))
 		   (plist-get opt-plist (car x))))
 	    org-export-plist-vars)
       (setq umax (if arg (prefix-numeric-value arg)
@@ -3259,7 +3301,7 @@
 		     "<a href=\"#"
 		     (org-solidify-link-text
 		      (save-match-data (org-link-unescape path)) nil)
-		     "\"" attr ">" 
+		     "\"" attr ">"
 		     (org-export-html-format-desc desc)
 		     "</a>")))
 	     ((member type '("http" "https"))
@@ -3272,7 +3314,7 @@
 					attr (concat attr " alt=\"" path "\""))
 				    "/>"))
 		(setq link (concat type ":" path))
-		(setq rpl (concat "<a href=\"" 
+		(setq rpl (concat "<a href=\""
 				  (org-export-html-format-href link)
 				  "\"" attr ">"
 				  (org-export-html-format-desc desc)
@@ -3282,7 +3324,7 @@
 	      (setq link (concat type ":" path))
 	      (setq rpl (concat "<a href=\""
 				(org-export-html-format-href link)
-				"\"" attr ">" 
+				"\"" attr ">"
 				(org-export-html-format-desc desc)
 				"</a>")))
 
@@ -3460,7 +3502,7 @@
 		(insert (cond
 			 ((equal item-type "u") "<ul>\n<li>\n")
 			 ((equal item-type "o") "<ol>\n<li>\n")
-			 ((equal item-type "d") 
+			 ((equal item-type "d")
 			  (format "<dl>\n<dt>%s</dt><dd>\n" item-tag))))
 		(push item-type local-list-type)
 		(push ind local-list-indent)
@@ -4356,7 +4398,7 @@
 			  (and org-icalendar-include-body (org-get-entry)))
 		      t org-icalendar-include-body)
 		location (org-icalendar-cleanup-string
-			  (org-entry-get nil "LOCATION"))
+			  (org-entry-get nil "LOCATION" 'selective))
 		uid (if org-icalendar-store-UID
 			(org-id-get-create)
 		      (or (org-id-get) (org-id-new)))
@@ -4450,7 +4492,7 @@
 	      (insert sexp "\n"))))
 	(princ (org-diary-to-ical-string sexp-buffer))
 	(kill-buffer sexp-buffer))
-      
+
       (when org-icalendar-include-todo
 	(setq prefix "TODO-")
 	(goto-char (point-min))
@@ -4478,7 +4520,7 @@
 			      (and org-icalendar-include-body (org-get-entry)))
 			  t org-icalendar-include-body)
 		    location (org-icalendar-cleanup-string
-			      (org-entry-get nil "LOCATION"))
+			      (org-entry-get nil "LOCATION" 'selective))
 		    due (and (member 'todo-due org-icalendar-use-deadline)
 			     (org-entry-get nil "DEADLINE"))
 		    start (and (member 'todo-start org-icalendar-use-scheduled)
@@ -4501,7 +4543,7 @@
 		(setq pri org-default-priority))
 	      (setq pri (floor (- 9 (* 8. (/ (float (- org-lowest-priority pri))
 					     (- org-lowest-priority org-highest-priority))))))
-	      
+
 	      (princ (format "BEGIN:VTODO
 UID: %s
 %s
--- a/lisp/org/org-export-latex.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-export-latex.el	Sun Dec 07 18:36:02 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 6.13a
+;; Version: 6.14
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
@@ -144,7 +144,7 @@
 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")
 		(repeat :tag "Levels" :inline t
@@ -423,6 +423,9 @@
 	   region :emph-multiline t
 		  :for-LaTeX t
 		  :comments nil
+		  :tags (plist-get opt-plist :tags)
+		  :priority (plist-get opt-plist :priority)
+		  :todo-keywords (plist-get opt-plist :todo-keywords)
 		  :add-text (if (eq to-buffer 'string) nil text)
 		  :skip-before-1st-heading skip
 		  :select-tags (plist-get opt-plist :select-tags)
@@ -1175,7 +1178,7 @@
   (goto-char (point-min))
   (while (re-search-forward "^[ \t]*\\begin{\\([a-zA-Z]+\\)}" nil t)
     (let* ((start (progn (beginning-of-line) (point)))
-	   (end (or (and (re-search-forward 
+	   (end (or (and (re-search-forward
 			  (concat "^[ \t]*\\end{" (match-string 1) "}" nil t)
 			  (point-at-eol)))
 		    (point-max))))
--- a/lisp/org/org-faces.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-faces.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -163,7 +163,7 @@
 The following faces apply, with this priority.
 
 1. The color of the reference face.  This is normally the level fact that
-   is used in the outline.  In agenda-mode, it will be the face of the 
+   is used in the outline.  In agenda-mode, it will be the face of the
    first character in the line.  The color is explicitly retained to
    make sure that the column line still looks a bit like the structure
    line it is masking.
@@ -269,7 +269,9 @@
 
 (defface org-tag
   '((t (:bold t)))
-  "Face for tags."
+  "Default face for tags.
+Note that the variable `org-tag-faces' can be used to overrule this face for
+specific tags."
   :group 'org-faces)
 
 (defface org-todo ; font-lock-warning-face
@@ -313,6 +315,31 @@
 	   (string :tag "keyword")
 	   (sexp :tag "face"))))
 
+(defvar org-tags-special-faces-re nil)
+(defun org-set-tag-faces (var value)
+  (set var value)
+  (if (not value)
+      (setq org-tags-special-faces-re nil)
+    (setq org-tags-special-faces-re
+	  (concat ":\\(" (mapconcat 'car value "\\|") "\\):"))))
+
+(defcustom org-tag-faces nil
+  "Faces for specific tags.
+This is a list of cons cells, with tags in the car and faces in the cdr.
+The face can be a symbol, or a property list of attributes,
+like (:foreground \"blue\" :weight bold :underline t).
+If you set this variable through customize, it will immediately be effective
+in new buffers and in modified lines.
+If you set it with Lisp, a restart of Emacs is required to activate the
+changes."
+  :group 'org-faces
+  :group 'org-tags
+  :set 'org-set-tag-faces
+  :type '(repeat
+	  (cons
+	   (string :tag "Tag")
+	   (sexp :tag "Face"))))
+
 (defface org-table ;; originally copied from font-lock-function-name-face
   (org-compatible-face nil
     '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
--- a/lisp/org/org-gnus.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-gnus.el	Sun Dec 07 18:36:02 2008 +0000
@@ -6,7 +6,7 @@
 ;;         Tassilo Horn <tassilo at member dot fsf dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -39,8 +39,7 @@
 ;; Customization variables
 
 (when (fboundp 'defvaralias)
-  (defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links
-    "Deprecated name for `org-gnus-prefer-web-links'."))
+  (defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links))
 
 (defcustom org-gnus-prefer-web-links nil
   "Non-nil means, `org-store-link' will create web links to Google groups.
@@ -140,6 +139,7 @@
       (setq desc (org-email-link-description)
 	    link (org-gnus-article-link group newsgroups message-id x-no-archive))
       (org-add-link-props :link link :description desc)
+      (gnus-summary-toggle-header -1)
       link))))
 
 (defun org-gnus-open (path)
--- a/lisp/org/org-id.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-id.el	Sun Dec 07 18:36:02 2008 +0000
@@ -1,10 +1,10 @@
-;;; org-id.el --- Global identifier for Org-mode entries
+;;; org-id.el --- Global identifiers for Org-mode entries
 ;; Copyright (C) 2008 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -116,17 +116,42 @@
   :group 'org-id
   :type 'boolean)
 
+(defcustom org-id-track-globally t
+  "Non-nil means, track ID's trhough files, so that links work globally.
+This work by maintaining a hash table for ID's and writing this table
+to disk when exiting Emacs.  Because of this, it works best if you use
+a single Emacs process, not many.
+
+When nil, ID's are not tracked.  Links to ID's will still work within
+a buffer, but not if the entry is located in another file.
+ID's can still be used if the entry with the id is in the same file as
+the link."
+  :group 'org-id
+  :type 'boolean)
+
 (defcustom org-id-locations-file (convert-standard-filename
-				  "~/.org-id-locations")
-  "The file for remembering the last ID number generated."
+				  "~/.emacs.d/.org-id-locations")
+  "The file for remembering in which file an ID was defined.
+This variable is only relevant when `org-id-track-globally' is set."
   :group 'org-id
   :type 'file)
 
 (defvar org-id-locations nil
-  "List of files with ID's in those files.")
+  "List of files with ID's in those files.
+Depending on `org-id-use-hash' this can also be a hash table mapping ID's
+to files.")
+
+(defvar org-id-files nil
+  "List of files that contain ID's.")
 
 (defcustom org-id-extra-files 'org-agenda-text-search-extra-files
-  "Files to be searched for ID's, besides the agenda files."
+  "Files to be searched for ID's, besides the agenda files.
+When Org reparses files to remake the list of files and ID's it is tracking,
+it will normally scan the agenda files, the archives related to agenda files,
+any files that are listed as ID containing in the current register, and
+any Org-mode files currently visited by Emacs.
+You can list additional files here.
+This variable is only relevant when `org-id-track-globally' is set."
   :group 'org-id
   :type
   '(choice
@@ -134,6 +159,14 @@
     (repeat :tag "List of files"
 	    (file))))
 
+(defcustom org-id-search-archives t
+  "Non-nil means, search also the archive files of agenda files for entries.
+This is a possibility to reduce overhead, but it measn that entries moved
+to the archives can no longer be found by ID.
+This variable is only relevant when `org-id-track-globally' is set."
+  :group 'org-id
+  :type 'boolean)
+
 ;;; The API functions
 
 ;;;###autoload
@@ -145,13 +178,13 @@
   (when force
     (org-entry-put (point) "ID" nil))
   (org-id-get (point) 'create))
-  
+
 ;;;###autoload
 (defun org-id-copy ()
   "Copy the ID of the entry at point to the kill ring.
 Create an ID if necessary."
   (interactive)
-  (kill-new (org-id-get nil 'create)))  
+  (kill-new (org-id-get nil 'create)))
 
 ;;;###autoload
 (defun org-id-get (&optional pom create prefix)
@@ -180,10 +213,10 @@
 eligible.
 It returns the ID of the entry.  If necessary, the ID is created."
   (let* ((org-refile-targets (or targets '((nil . (:maxlevel . 10)))))
-	 (org-refile-use-outline-path 
+	 (org-refile-use-outline-path
 	  (if (caar org-refile-targets) 'file t))
 	 (spos (org-refile-get-location "Entry: "))
-	 (pom (and spos (move-marker (make-marker) (nth 3 spos) 
+	 (pom (and spos (move-marker (make-marker) (nth 3 spos)
 				     (get-file-buffer (nth 1 spos))))))
     (prog1 (org-id-get pom 'create)
       (move-marker pom nil))))
@@ -202,14 +235,14 @@
 (defun org-id-goto (id)
   "Switch to the buffer containing the entry with id ID.
 Move the cursor to that entry in that buffer."
-  (interactive)
+  (interactive "sID: ")
   (let ((m (org-id-find id 'marker)))
     (unless m
       (error "Cannot find entry with ID \"%s\"" id))
     (switch-to-buffer (marker-buffer m))
     (goto-char m)
     (move-marker m nil)
-    (org-show-context)))    
+    (org-show-context)))
 
 ;;;###autoload
 (defun org-id-find (id &optional markerp)
@@ -326,77 +359,153 @@
 
 ;; Storing ID locations (files)
 
-(defun org-id-update-id-locations ()
+(defun org-id-update-id-locations (&optional files check)
   "Scan relevant files for ID's.
-Store the relation between files and corresponding ID's."
+Store the relation between files and corresponding ID's.
+This will scan all agenda files, all associated archives, and all
+files currently mentioned in `org-id-locations'.
+When FILES is given, scan these files instead."
   (interactive)
-  (let ((files (append (org-agenda-files)
-		       (if (symbolp org-id-extra-files)
-			   (symbol-value org-id-extra-files)
-			 org-id-extra-files)))
-	org-agenda-new-buffers
-	file ids reg found id)
-    (while (setq file (pop files))
-      (setq ids nil)
-      (with-current-buffer (org-get-agenda-file-buffer file)
-	(save-excursion
-	  (save-restriction
-	    (widen)
-	    (goto-char (point-min))
-	    (while (re-search-forward "^[ \t]*:ID:[ \t]+\\(\\S-+\\)[ \t]*$"
-				      nil t)
-	      (setq id (org-match-string-no-properties 1))
-	      (if (member id found)
-		  (error "Duplicate ID \"%s\"" id))
-	      (push id found)
-	      (push id ids))
-	    (push (cons file ids) reg)))))
-    (org-release-buffers org-agenda-new-buffers)
-    (setq org-agenda-new-buffers nil)
-    (setq org-id-locations reg)
-    (org-id-locations-save)))
+  (if (not org-id-track-globally)
+      (error "Please turn on `org-id-track-globally' if you want to track id's.")
+    (let ((files
+	   (or files
+	       (append
+		;; Agenda files and all associated archives
+		(org-agenda-files t org-id-search-archives)
+		;; Explicit extra files
+		(if (symbolp org-id-extra-files)
+		    (symbol-value org-id-extra-files)
+		  org-id-extra-files)
+	      ;; Files associated with live org-mode buffers
+		(delq nil
+		      (mapcar (lambda (b)
+				(with-current-buffer b
+				  (and (org-mode-p) (buffer-file-name))))
+			      (buffer-list)))
+		;; All files known to have id's
+		org-id-files)))
+	  org-agenda-new-buffers
+	  file nfiles tfile ids reg found id seen (ndup 0))
+      (setq nfiles (length files))
+      (while (setq file (pop files))
+	(message "Finding ID locations (%d/%d files): %s"
+		 (- nfiles (length files)) nfiles file)
+	(setq tfile (file-truename file))
+	(when (and (file-exists-p file) (not (member tfile seen)))
+	  (push tfile seen)
+	  (setq ids nil)
+	  (with-current-buffer (org-get-agenda-file-buffer file)
+	    (save-excursion
+	      (save-restriction
+		(widen)
+		(goto-char (point-min))
+		(while (re-search-forward "^[ \t]*:ID:[ \t]+\\(\\S-+\\)[ \t]*$"
+					  nil t)
+		  (setq id (org-match-string-no-properties 1))
+		  (if (member id found)
+		      (progn
+			(message "Duplicate ID \"%s\"" id)
+			(setq ndup (1+ ndup)))
+		    (push id found)
+		    (push id ids)))
+		(push (cons (abbreviate-file-name file) ids) reg))))))
+      (org-release-buffers org-agenda-new-buffers)
+      (setq org-agenda-new-buffers nil)
+      (setq org-id-locations reg)
+      (setq org-id-files (mapcar 'car org-id-locations))
+      (org-id-locations-save) ;; this function can also handle the alist form
+      ;; now convert to a hash
+      (setq org-id-locations (org-id-alist-to-hash org-id-locations))
+      (if (> ndup 0)
+	  (message "WARNING: %d duplicate ID's found, check *Messages* buffer" ndup)
+	(message "%d unique files scanned for ID's" (length org-id-files)))
+      org-id-locations)))
 
 (defun org-id-locations-save ()
   "Save `org-id-locations' in `org-id-locations-file'."
-  (with-temp-file org-id-locations-file
-    (print org-id-locations (current-buffer))))
+  (when org-id-track-globally
+    (let ((out (if (hash-table-p org-id-locations)
+		   (org-id-hash-to-alist org-id-locations)
+		 org-id-locations)))
+      (with-temp-file org-id-locations-file
+	(print out (current-buffer))))))
 
 (defun org-id-locations-load ()
   "Read the data from `org-id-locations-file'."
   (setq org-id-locations nil)
-  (with-temp-buffer
-    (condition-case nil
-        (progn
-          (insert-file-contents-literally org-id-locations-file)
-          (goto-char (point-min))
-          (setq org-id-locations (read (current-buffer))))
-      (error
-       (message "Could not read org-id-values from %s. Setting it to nil."
-                org-id-locations-file)))))
+  (when org-id-track-globally
+    (with-temp-buffer
+      (condition-case nil
+	  (progn
+	    (insert-file-contents-literally org-id-locations-file)
+	    (goto-char (point-min))
+	    (setq org-id-locations (read (current-buffer))))
+	(error
+	 (message "Could not read org-id-values from %s. Setting it to nil."
+		  org-id-locations-file))))
+    (setq org-id-files (mapcar 'car org-id-locations))
+    (setq org-id-locations (org-id-alist-to-hash org-id-locations))))
 
 (defun org-id-add-location (id file)
   "Add the ID with location FILE to the database of ID loations."
-  (when (and id file) ; don't error when called from a buffer with no file
+  ;; Only if global tracking is on, and when the buffer has a file
+  (when (and org-id-track-globally id file) 
     (unless org-id-locations (org-id-locations-load))
-    (catch 'exit
-      (let ((locs org-id-locations) list)
-	(while (setq list (pop locs))
-	  (when (equal (file-truename file) (file-truename (car list)))
-	    (setcdr list (cons id (cdr list)))
-	    (throw 'exit t))))
-      (push (list file id) org-id-locations))
-    (org-id-locations-save)))
+    (puthash id (abbreviate-file-name file) org-id-locations)
+    (add-to-list 'org-id-files (abbreviate-file-name file))))
+
+(add-hook 'kill-emacs-hook 'org-id-locations-save)
+
+(defun org-id-hash-to-alist (hash)
+  "Turn an org-id hash into an alist, so that it can be written to a file."
+  (let (res x)
+    (maphash
+     (lambda (k v)
+       (if (setq x (member v res))
+	   (push k (cdr x))
+	 (push (list v k) res)))
+     hash)
+    res))
+
+(defun org-id-alist-to-hash (list)
+  "Turn an org-id location list into a hash table."
+  (let ((res (make-hash-table
+	      :test 'equal
+	      :size (apply '+ (mapcar 'length list))))
+	f i)
+    (mapc
+     (lambda (x)
+       (setq f (car x))
+       (mapc (lambda (i) (puthash i f res)) (cdr x)))
+     list)
+    res))
+
+(defun org-id-paste-tracker (txt &optional buffer-or-file)
+  "Update any ID's in TXT and assign BUFFER-OR-FILE to them."
+  (when org-id-track-globally
+    (save-match-data
+      (setq buffer-or-file (or buffer-or-file (current-buffer)))
+      (when (bufferp buffer-or-file)
+	(setq buffer-or-file (or (buffer-base-buffer buffer-or-file)
+				 buffer-or-file))
+	(setq buffer-or-file (buffer-file-name buffer-or-file)))
+      (when buffer-or-file
+	(let ((fname (abbreviate-file-name buffer-or-file))
+	      (s 0))
+	  (while (string-match "^[ \t]*:ID:[ \t]+\\([^ \t\n\r]+\\)" txt s)
+	    (setq s (match-end 0))
+	    (org-id-add-location (match-string 1 txt) fname)))))))
 
 ;; Finding entries with specified id
 
 (defun org-id-find-id-file (id)
   "Query the id database for the file in which this ID is located."
   (unless org-id-locations (org-id-locations-load))
-  (catch 'found
-    (mapc (lambda (x) (if (member id (cdr x))
-			  (throw 'found (car x))))
-	  org-id-locations)
-    nil))
+  (or (gethash id org-id-locations)
+      ;; ball back on current buffer
+      (buffer-file-name (or (buffer-base-buffer (current-buffer))
+			    (current-buffer)))))
 
 (defun org-id-find-id-in-file (id file &optional markerp)
   "Return the position of the entry ID in FILE.
@@ -415,8 +524,35 @@
 		(move-marker (make-marker) pos buf)
 	      (cons file pos))))))))
 
+;; id link type
+
+;; Calling the following function is hard-coded into `org-store-link',
+;; so we do have to add it to `org-store-link-functions'.
+
+(defun org-id-store-link ()
+  "Store a link to the current entry, using it's ID."
+  (interactive)
+  (let* ((link (org-make-link "id:" (org-id-get-create)))
+	 (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."
+  (org-mark-ring-push)
+  (switch-to-buffer-other-window (current-buffer))
+  (org-id-goto id))
+
+(org-add-link-type "id" 'org-id-open)
+
 (provide 'org-id)
 
 ;;; org-id.el ends here
 
 ;; arch-tag: e5abaca4-e16f-4b25-832a-540cfb63a712
+
+
--- a/lisp/org/org-info.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-info.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-irc.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-irc.el	Sun Dec 07 18:36:02 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-jsinfo.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-jsinfo.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -106,10 +106,10 @@
 (defcustom org-infojs-template
   "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\"></script>
 <script type=\"text/javascript\" >
-/* <![CDATA[ */
+<!--/*--><![CDATA[/*><!--*/
 %MANAGER_OPTIONS
 org_html_manager.setup();  // activate after the parameterd are set
-/* ]]> */
+/*]]>*/-->
 </script>"
   "The template for the export style additions when org-info.js is used.
 Option settings will replace the %MANAGER-OPTIONS cookie."
--- a/lisp/org/org-list.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-list.el	Sun Dec 07 18:36:02 2008 +0000
@@ -6,7 +6,7 @@
 ;;         Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -45,6 +45,7 @@
 (declare-function org-skip-whitespace "org" ())
 (declare-function org-trim "org" (s))
 (declare-function org-get-indentation "org" (&optional line))
+(declare-function org-timer-item "org-timer" (&optional arg))
 
 (defgroup org-plain-lists nil
   "Options concerning plain lists in Org-mode."
@@ -185,35 +186,42 @@
 	   (descp (save-excursion (goto-char (match-beginning 0))
 				  (beginning-of-line 1)
 				  (save-match-data
-				    (looking-at "[ \t]*.*? ::"))))
+				    (and (looking-at "[ \t]*\\(.*?\\) ::")
+					 (match-string 1)))))
+	   (timerp (and descp
+			(save-match-data
+			  (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$"
+					descp))))
 	   (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
 				(match-end 0)))
 	   (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
 	   pos)
       (if descp (setq checkbox nil))
-      (cond
-       ((and (org-at-item-p) (<= (point) eow))
-	;; before the bullet
-	(beginning-of-line 1)
-	(open-line (if blank 2 1)))
-       ((<= (point) eow)
-	(beginning-of-line 1))
-       (t
-	(unless (org-get-alist-option org-M-RET-may-split-line 'item)
-	  (end-of-line 1)
-	  (delete-horizontal-space))
-	(newline (if blank 2 1))))
-      (insert bul
-	      (if checkbox "[ ]" "")
-	      (if descp (concat (if checkbox " " "")
-				(read-string "Term: ") " :: ") ""))
-      (just-one-space)
-      (setq pos (point))
-      (end-of-line 1)
-      (unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
-    (org-maybe-renumber-ordered-list)
-    (and checkbox (org-update-checkbox-count-maybe))
-    t))
+      (if timerp
+	  (progn (org-timer-item) t)
+	(cond
+	 ((and (org-at-item-p) (<= (point) eow))
+	  ;; before the bullet
+	  (beginning-of-line 1)
+	  (open-line (if blank 2 1)))
+	 ((<= (point) eow)
+	  (beginning-of-line 1))
+	 (t
+	  (unless (org-get-alist-option org-M-RET-may-split-line 'item)
+	    (end-of-line 1)
+	    (delete-horizontal-space))
+	  (newline (if blank 2 1))))
+	(insert bul
+		(if checkbox "[ ]" "")
+		(if descp (concat (if checkbox " " "")
+				  (read-string "Term: ") " :: ") ""))
+	(just-one-space)
+	(setq pos (point))
+	(end-of-line 1)
+	(unless (= (point) pos) (just-one-space) (backward-delete-char 1)))
+      (org-maybe-renumber-ordered-list)
+      (and checkbox (org-update-checkbox-count-maybe))
+      t)))
 
 ;;; Checkboxes
 
--- a/lisp/org/org-mac-message.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-mac-message.el	Sun Dec 07 18:36:02 2008 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2008 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.13a
+;; Version: 6.14
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
--- a/lisp/org/org-macs.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-macs.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mew.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-mew.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/org/org-mhe.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-mhe.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mouse.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-mouse.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -177,7 +177,7 @@
 	      (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)))	      
+	      (const :tag "Activate checkboxes" activate-checkboxes)))
 
 (defun org-mouse-re-search-line (regexp)
   "Search the current line for a given regular expression."
--- a/lisp/org/org-plot.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-plot.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -119,7 +119,7 @@
   "Export TABLE to DATA-FILE in a format readable by gnuplot.
 Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
   (with-temp-file
-      data-file 
+      data-file
     (make-local-variable 'org-plot-timestamp-fmt)
     (setq org-plot-timestamp-fmt (or
                                   (plist-get params :timefmt)
--- a/lisp/org/org-publish.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-publish.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -263,7 +263,7 @@
                          generates a plain list of links to all files
                          in the project.
   :index-style           Can be `list' (index is just an itemized list
-                         of the titles of the files involved) or 
+                         of the titles of the files involved) or
                          `tree' (the directory structure of the source
                          files is reflected in the index).  Defaults to
                          `tree'."
@@ -276,7 +276,7 @@
   :group 'org-publish
   :type 'boolean)
 
-(defcustom org-publish-timestamp-directory (convert-standard-filename 
+(defcustom org-publish-timestamp-directory (convert-standard-filename
 					    "~/.org-timestamps/")
   "Name of directory in which to store publishing timestamps."
   :group 'org-publish
@@ -422,7 +422,7 @@
 		      rest))
 	(push p rtn)))
     (nreverse (org-publish-delete-dups (delq nil rtn)))))
-	
+
 (defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir)
   "Set `org-publish-temp-files' with files from BASE-DIR directory.
 If RECURSE is non-nil, check BASE-DIR recursively.  If MATCH is
@@ -461,7 +461,7 @@
 				  ;; for skip-file and skip-dir?
 				  exclude-regexp exclude-regexp)
     (mapc (lambda (f)
-	    (pushnew 
+	    (pushnew
 	     (expand-file-name (concat base-dir f))
 	     org-publish-temp-files))
 	  include-list)
@@ -470,7 +470,10 @@
 (defun org-publish-get-project-from-filename (filename)
   "Return the project FILENAME belongs."
   (let* ((project-name (cdr (assoc (expand-file-name filename)
-				   org-publish-files-alist))))
+                                   org-publish-files-alist))))
+    (dolist (prj org-publish-project-alist)
+      (if (member project-name (plist-get (cdr prj) :components))
+          (setq project-name (car prj))))
     (assoc project-name org-publish-project-alist)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -619,20 +622,20 @@
 			  (concat "Index for project " (car project))))
 	 (index-style (or (plist-get project-plist :index-style)
 			  'tree))
-	 (index-buffer (find-buffer-visiting index-filename))
+	 (visiting (find-buffer-visiting index-filename))
 	 (ifn (file-name-nondirectory index-filename))
-	 file)
-    ;; if buffer is already open, kill it to prevent error message
-    (if index-buffer
-	(kill-buffer index-buffer))
-    (with-temp-buffer
+	 file index-buffer)
+    (with-current-buffer (setq index-buffer
+			       (or visiting (find-file index-filename)))
+      (erase-buffer)
       (insert (concat "#+TITLE: " index-title "\n\n"))
       (while (setq file (pop files))
 	(let ((fn (file-name-nondirectory file))
 	      (link (file-relative-name file dir))
 	      (oldlocal localdir))
 	  ;; index shouldn't index itself
-	  (unless (string= fn ifn)
+	  (unless (equal (file-truename index-filename)
+			 (file-truename file))
 	    (if (eq index-style 'list)
 		(message "Generating list-style index for %s" index-title)
 	      (message "Generating tree-style index for %s" index-title)
@@ -662,10 +665,9 @@
 	    ;; This is common to 'flat and 'tree
 	    (insert (concat indent-str " + [[file:" link "]["
 			    (org-publish-find-title file)
-			    "]]\n"))
-	    )))
-      (write-file index-filename)
-      (kill-buffer (current-buffer)))))
+			    "]]\n")))))
+      (save-buffer))
+    (or visiting (kill-buffer index-buffer))))
 
 (defun org-publish-find-title (file)
   "Find the title of file in project."
--- a/lisp/org/org-remember.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-remember.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -55,7 +55,7 @@
   "Non-nil means, `C-c C-c' stores remember note without further prompts.
 It then uses the file and headline specified by the template or (if the
 template does not specify them) by the variables `org-default-notes-file'
-and `org-remember-default-headline'.  To force prompting anyway, use 
+and `org-remember-default-headline'.  To force prompting anyway, use
 `C-u C-c C-c' to file the note.
 
 When this variable is nil, `C-c C-c' gives you the prompts, and
@@ -349,7 +349,7 @@
 		ct))
 	     (tpl (car entry))
 	     (plist-p (if org-store-link-plist t nil))
-	     (file (if (and (nth 1 entry) 
+	     (file (if (and (nth 1 entry)
 			    (or (and (stringp (nth 1 entry))
 				     (string-match "\\S-" (nth 1 entry)))
 				(functionp (nth 1 entry))))
@@ -589,7 +589,7 @@
 		 (point)))
   (message "%s"
 	   (format
-	    (substitute-command-keys 
+	    (substitute-command-keys
 	     "Restore window configuration with \\[jump-to-register] %c")
 	    remember-register)))
 
--- a/lisp/org/org-rmail.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-rmail.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-table.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-table.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -244,6 +244,14 @@
   :group 'org-table-calculation
   :type 'boolean)
 
+(defcustom org-table-error-on-row-ref-crossing-hline t
+  "Non-nil means, a relative row reference that tries to cross a hline errors.
+When nil, the reference will silently be to the field just next to the hline.
+Coming from below, it will be the field below the hline, coming from
+above, it will be the field above the hline."
+  :group 'org-table
+  :type 'boolean)
+
 (defgroup org-table-import-export nil
   "Options concerning table import and export in Org-mode."
   :tag "Org Table Import Export"
@@ -2114,7 +2122,7 @@
 	      lispp (and (> (length form) 2)(equal (substring form 0 2) "'(")))
 	(if (and lispp literal) (setq lispp 'literal))
 	;; Check for old vertical references
-	(setq form (org-rewrite-old-row-references form))
+	(setq form (org-table-rewrite-old-row-references form))
 	;; Insert complex ranges
 	(while (and (string-match org-table-range-regexp form)
 		    (> (length (match-string 0 form)) 1))
@@ -2288,26 +2296,32 @@
       (if (and (not hn) on (not odir))
 	  (error "should never happen");;(aref org-table-dlines on)
 	(if (and hn (> hn 0))
-	    (setq i (org-find-row-type table i 'hline (equal hdir "-") nil hn)))
+	    (setq i (org-table-find-row-type table i 'hline (equal hdir "-")
+					     nil hn cline desc)))
 	(if on
-	    (setq i (org-find-row-type table i 'dline (equal odir "-") rel on)))
+	    (setq i (org-table-find-row-type table i 'dline (equal odir "-")
+					     rel on cline desc)))
 	(+ bline i)))))
 
-(defun org-find-row-type (table i type backwards relative n)
+(defun org-table-find-row-type (table i type backwards relative n cline desc)
+  "FIXME: Needs more documentation."
   (let ((l (length table)))
     (while (> n 0)
       (while (and (setq i (+ i (if backwards -1 1)))
 		  (>= i 0) (< i l)
 		  (not (eq (aref table i) type))
 		  (if (and relative (eq (aref table i) 'hline))
-		      (progn (setq i (- i (if backwards -1 1)) n 1) nil)
+		      (if org-table-error-on-row-ref-crossing-hline
+			  (error "Row descriptor %s used in line %d crosses hline" desc cline)
+			(progn (setq i (- i (if backwards -1 1)) n 1) nil))
 		    t)))
       (setq n (1- n)))
     (if (or (< i 0) (>= i l))
-	(error "Row descriptor leads outside table")
+	(error "Row descriptor %s used in line %d leads outside table"
+	       desc cline)
       i)))
 
-(defun org-rewrite-old-row-references (s)
+(defun org-table-rewrite-old-row-references (s)
   (if (string-match "&[-+0-9I]" s)
       (error "Formula contains old &row reference, please rewrite using @-syntax")
     s))
@@ -2746,10 +2760,10 @@
   (or (match-end n) (error "Cannot shift reference in this direction"))
   (goto-char (match-beginning n))
   (and (looking-at (regexp-quote (match-string n)))
-       (replace-match (org-shift-refpart (match-string 0) decr hline)
+       (replace-match (org-table-shift-refpart (match-string 0) decr hline)
 		      t t)))
 
-(defun org-shift-refpart (ref &optional decr hline)
+(defun org-table-shift-refpart (ref &optional decr hline)
   "Shift a refrence part REF.
 If DECR is set, decrease the references row/column, else increase.
 If HLINE is set, this may be a hline reference, it certainly is not
@@ -3238,7 +3252,7 @@
 	  (easy-menu-add orgtbl-mode-menu)
 	  (run-hooks 'orgtbl-mode-hook))
       (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
-      (org-cleanup-narrow-column-properties)
+      (org-table-cleanup-narrow-column-properties)
       (org-remove-from-invisibility-spec '(org-cwidth))
       (remove-hook 'before-change-functions 'org-before-change-function t)
       (when (fboundp 'font-lock-remove-keywords)
@@ -3247,7 +3261,7 @@
       (easy-menu-remove orgtbl-mode-menu)
       (force-mode-line-update 'all))))
 
-(defun org-cleanup-narrow-column-properties ()
+(defun org-table-cleanup-narrow-column-properties ()
   "Remove all properties related to narrow-column invisibility."
   (let ((s 1))
     (while (setq s (text-property-any s (point-max)
@@ -3323,7 +3337,6 @@
 	  '("\C-c'"              org-table-edit-formulas)
 	  '("\C-c`"              org-table-edit-field)
 	  '("\C-c*"              org-table-recalculate)
-	  '("\C-c|"              org-table-create-or-convert-from-region)
 	  '("\C-c^"              org-table-sort-lines)
 	  '([(control ?#)]       org-table-rotate-recalc-marks)))
 	elt key fun cmd)
@@ -3357,6 +3370,8 @@
 			   [(meta return)] "\M-\C-m"))
 
     (org-defkey orgtbl-mode-map "\C-c\C-c" 'orgtbl-ctrl-c-ctrl-c)
+    (org-defkey orgtbl-mode-map "\C-c|" 'orgtbl-create-or-convert-from-region)
+
     (when orgtbl-optimized
       ;; If the user wants maximum table support, we need to hijack
       ;; some standard editing functions
@@ -3367,6 +3382,9 @@
       (org-defkey orgtbl-mode-map "|" 'org-force-self-insert))
     (easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu"
       '("OrgTbl"
+	["Create or convert" org-table-create-or-convert-from-region
+	 :active (not (org-at-table-p)) :keys "C-c |" ]
+	"--"
 	["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"]
 	["Next Field" org-cycle :active (org-at-table-p) :keys "TAB"]
 	["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"]
@@ -3451,6 +3469,16 @@
      (t (let (orgtbl-mode)
 	  (call-interactively (key-binding "\C-c\C-c")))))))
 
+(defun orgtbl-create-or-convert-from-region (arg)
+  "Create table or convert region to table, if no conflicting binding.
+This installs the table binding `C-c |', but only if there is no
+conflicting binding to this key outside orgtbl-mode."
+  (interactive "P")
+  (let* (orgtbl-mode (cmd (key-binding "\C-c|")))
+    (if cmd
+	(call-interactively cmd)
+      (call-interactively 'org-table-create-or-convert-from-region))))
+
 (defun orgtbl-tab (arg)
   "Justification and field motion for `orgtbl-mode'."
   (interactive "P")
@@ -3461,8 +3489,10 @@
 (defun orgtbl-ret ()
   "Justification and field motion for `orgtbl-mode'."
   (interactive)
-  (org-table-justify-field-maybe)
-  (org-table-next-row))
+  (if (bobp)
+      (newline)
+    (org-table-justify-field-maybe)
+    (org-table-next-row)))
 
 (defun orgtbl-self-insert-command (N)
   "Like `self-insert-command', use overwrite-mode for whitespace in tables.
@@ -3490,12 +3520,13 @@
 	(self-insert-command N))
     (setq org-table-may-need-update t)
     (let (orgtbl-mode a)
-      (call-interactively 
-       (key-binding
-	(or (and (listp function-key-map)
-		 (setq a (assoc last-input-event function-key-map))
-		 (cdr a))
-	    (vector last-input-event)))))))
+      (call-interactively
+       (or (key-binding
+	    (or (and (listp function-key-map)
+		     (setq a (assoc last-input-event function-key-map))
+		     (cdr a))
+		(vector last-input-event)))
+	   'self-insert-command)))))
 
 (defvar orgtbl-exp-regexp "^\\([-+]?[0-9][0-9.]*\\)[eE]\\([-+]?[0-9]+\\)$"
   "Regular expression matching exponentials as produced by calc.")
@@ -3569,7 +3600,7 @@
   (unless txt
     (unless (org-at-table-p)
       (error "No table at point")))
-  (let* ((txt (or txt 
+  (let* ((txt (or txt
 		  (buffer-substring-no-properties (org-table-begin)
 						  (org-table-end))))
 	 (lines (org-split-string txt "[ \t]*\n[ \t]*")))
--- a/lisp/org/org-vm.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-vm.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-wl.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org-wl.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org.el	Sun Dec 07 18:34:56 2008 +0000
+++ b/lisp/org/org.el	Sun Dec 07 18:36:02 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.13a
+;; Version: 6.14
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -92,7 +92,7 @@
 
 ;;; Version
 
-(defconst org-version "6.13a"
+(defconst org-version "6.14"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -143,7 +143,7 @@
   (let ((a (member 'org-infojs org-modules)))
     (and a (setcar a 'org-jsinfo))))
 
-(defcustom org-modules '(org-bbdb org-bibtex org-gnus org-info org-jsinfo org-irc org-mew org-mhe org-rmail org-vm org-wl)
+(defcustom org-modules '(org-bbdb org-bibtex org-gnus org-info org-jsinfo org-irc org-mew org-mhe org-rmail org-vm org-w3m org-wl)
   "Modules that should always be loaded together with org.el.
 If a description starts with <C>, the file is not part of Emacs
 and loading it will require that you have downloaded and properly installed
@@ -172,6 +172,7 @@
 	(const :tag "   rmail:             Links to RMAIL folders/messages" org-rmail)
 	(const :tag "   vm:                Links to VM folders/messages" org-vm)
 	(const :tag "   wl:                Links to Wanderlust folders/messages" org-wl)
+	(const :tag "   w3m:               Special cut/past from w3m to Org." org-w3m)
 	(const :tag "   mouse:             Additional mouse support" org-mouse)
 
 	(const :tag "C  annotate-file:     Annotate a file with org syntax" org-annotate-file)
@@ -955,6 +956,40 @@
   :group 'org-link-store
   :type 'regexp)
 
+(defcustom org-link-to-org-use-id 'create-if-interactive
+  "Non-nil means, storing a link to an Org file will use entry ID's.
+
+Note that before this variable is even considered, org-id must be loaded,
+to please customize `org-modules' and turn it on.
+
+The variable can have the following values:
+
+t     Create an ID if needed to make a link to the current entry.
+
+create-if-interactive
+      If `org-store-link' is called directly (interactively, as a user
+      command), do create an ID to support the link.  But when doing the
+      job for remember, only use the ID if it already exists.  The
+      purpose of this setting is to avoid proliferation of unwanted
+      ID's, just because you happen to be in an Org file when you
+      call `org-remember' that automatically and preemptively
+      creates a link.  If you do want to get an ID link in a remember
+      template to an entry not having an ID, create it first by
+      explicitly creating a link to it, using `C-c C-l' first.
+
+use-existing
+      Use existing ID, do not create one.
+
+nil   Never use an ID to make a link, instead link using a text search for
+      the headline text."
+  :group 'org-link-store
+  :type '(choice
+	  (const :tag "Create ID to make link" t)
+	  (const :tag "Create if string link interactively"
+		 'create-if-interactive)
+	  (const :tag "Only use existing" 'use-existing)
+	  (const :tag "Do not use ID to create link" nil)))
+
 (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
@@ -1881,13 +1916,16 @@
 (defcustom org-use-tag-inheritance t
   "Non-nil means, tags in levels apply also for sublevels.
 When nil, only the tags directly given in a specific line apply there.
+This may also be a list of tags that should be inherited, or a regexp that
+matches tags that should be inherited.  Additional control is possible
+with the variable  `org-tags-exclude-from-inheritance' which gives an
+explicit list of tags to be excluded from inheritance., even if the value of
+`org-use-tag-inheritance' would select it for inheritance.
+
 If this option is t, a match early-on in a tree can lead to a large
-number of matches in the subtree.  If you only want to see the first
-match in a tree during a search, check out the variable
-`org-tags-match-list-sublevels'.
-
-This may also be a list of tags that should be inherited, or a regexp that
-matches tags that should be inherited."
+number of matches in the subtree when constructing the agenda or creating
+a sparse tree.  If you only want to see the first match in a tree during
+a search, check out the variable `org-tags-match-list-sublevels'."
   :group 'org-tags
   :type '(choice
 	  (const :tag "Not" nil)
@@ -1895,9 +1933,18 @@
 	  (repeat :tag "Specific tags" (string :tag "Tag"))
 	  (regexp :tag "Tags matched by regexp")))
 
+(defcustom org-tags-exclude-from-inheritance nil
+  "List of tags that should never be inherited.
+This is a way to exclude a few tags from inheritance.  For way to do
+the opposite, to actively allow inheritance for selected tags,
+see the variable `org-use-tag-inheritance'."
+  :group 'org-tags
+  :type '(repeat (string :tag "Tag")))
+
 (defun org-tag-inherit-p (tag)
   "Check if TAG is one that should be inherited."
   (cond
+   ((member tag org-tags-exclude-from-inheritance) nil)
    ((eq org-use-tag-inheritance t) t)
    ((not org-use-tag-inheritance) nil)
    ((stringp org-use-tag-inheritance)
@@ -1917,7 +1964,11 @@
 
 As a special case, if the tag search is restricted to TODO items, the
 value of this variable is ignored and sublevels are always checked, to
-make sure all corresponding TODO items find their way into the list."
+make sure all corresponding TODO items find their way into the list.
+
+This variable is semi-obsolete and probably should always be true.  It
+is better to limit inheritance to certain tags using the variables
+`org-use-tag-inheritanc'e and `org-tags-exclude-from-inheritance'."
   :group 'org-tags
   :type 'boolean)
 
@@ -2353,9 +2404,9 @@
   :group 'org)
 
 (defcustom org-completion-use-ido nil
-  "Non-ni means, use ido completion wherever possible."
+  "Non-nil means, use ido completion wherever possible."
   :group 'org-completion
-  :type 'boolean)  
+  :type 'boolean)
 
 (defcustom org-completion-fallback-command 'hippie-expand
   "The expansion command called by \\[org-complete] in normal context.
@@ -2640,6 +2691,17 @@
   (when (org-match-line "#\\+BEGIN: clocktable\\>")
     (org-clocktable-shift dir n)))
 
+;; Autoload org-timer.el
+
+;(declare-function org-timer "org-timer")
+
+(eval-and-compile
+  (org-autoload
+   "org-timer"
+   '(org-timer-start org-timer org-timer-item
+		     org-timer-change-times-in-region)))
+
+
 ;; Autoload archiving code
 ;; The stuff that is needed for cycling and tags has to be defined here.
 
@@ -2778,11 +2840,12 @@
 
 ;; Autoload ID code
 
+(declare-function org-id-store-link "org-id")
 (org-autoload "org-id"
  '(org-id-get-create org-id-new org-id-copy org-id-get
    org-id-get-with-outline-path-completion
    org-id-get-with-outline-drilling
-   org-id-goto org-id-find))
+   org-id-goto org-id-find org-id-store-link))
 
 ;;; Variables for pre-computed regular expressions, all buffer local
 
@@ -3693,6 +3756,7 @@
 
 (defvar org-target-link-regexp nil
   "Regular expression matching radio targets in plain text.")
+(make-variable-buffer-local 'org-target-link-regexp)
 (defvar org-target-regexp "<<\\([^<>\n\r]+\\)>>"
   "Regular expression matching a link target.")
 (defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
@@ -3915,6 +3979,8 @@
 	     nil)
 	   ;; Priorities
 	   (list (concat "\\[#[A-Z0-9]\\]") '(0 'org-special-keyword t))
+	   ;; Tags
+	   '(org-font-lock-add-tag-faces)
 	   ;; Special keywords
 	   (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
 	   (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
@@ -3974,6 +4040,22 @@
       (and (member kwd org-done-keywords) 'org-done)
       'org-todo))
 
+(defun org-font-lock-add-tag-faces (limit)
+  "Add the special tag faces."
+  (when (and org-tag-faces org-tags-special-faces-re)
+    (while (re-search-forward org-tags-special-faces-re limit t)
+      (add-text-properties (match-beginning 1) (match-end 1)
+			   (list 'face (org-get-tag-face 1)
+				 'font-lock-fontified t))
+      (backward-char 1))))
+
+(defun org-get-tag-face (kwd)
+  "Get the right face for a TODO keyword KWD.
+If KWD is a number, get the corresponding match group."
+  (if (numberp kwd) (setq kwd (match-string kwd)))
+  (or (cdr (assoc kwd org-tag-faces))
+      'org-tag))
+
 (defun org-unfontify-region (beg end &optional maybe_loudly)
   "Remove fontification and activation overlays from links."
   (font-lock-default-unfontify-region beg end)
@@ -5060,8 +5142,8 @@
     (setq txt (buffer-substring beg end))
     (org-save-markers-in-region beg end)
     (delete-region beg end)
-    (outline-flag-region (1- beg) beg nil)
-    (outline-flag-region (1- (point)) (point) nil)
+    (or (= beg (point-min)) (outline-flag-region (1- beg) beg nil))
+    (or (bobp) (outline-flag-region (1- (point)) (point) nil))
     (let ((bbb (point)))
       (insert-before-markers txt)
       (org-reinstall-markers-in-region bbb)
@@ -5221,6 +5303,7 @@
     (beginning-of-line 1)
     (unless for-yank (org-back-over-empty-lines))
     (setq beg (point))
+    (and (fboundp 'org-id-paste-tracker) (org-id-paste-tracker txt))
     (insert-before-markers txt)
     (unless (string-match "\n\\'" txt) (insert "\n"))
     (setq newend (point))
@@ -6094,7 +6177,6 @@
       (setcdr (assoc type org-link-protocols) (list follow export))
     (push (list type follow export) org-link-protocols)))
 
-
 ;;;###autoload
 (defun org-store-link (arg)
   "\\<org-mode-map>Store an org-link to the current location.
@@ -6155,14 +6237,34 @@
 	    link (org-make-link cpltxt)))
 
      ((and buffer-file-name (org-mode-p))
-      ;; Just link to current headline
-      (setq cpltxt (concat "file:"
-			   (abbreviate-file-name buffer-file-name)))
-      ;; Add a context search string
-      (when (org-xor org-context-in-file-links arg)
-	;; Check if we are on a target
-	(if (org-in-regexp "<<\\(.*?\\)>>")
-	    (setq cpltxt (concat cpltxt "::" (match-string 1)))
+      (cond
+       ((org-in-regexp "<<\\(.*?\\)>>")
+	(setq cpltxt
+	      (concat "file:"
+		      (abbreviate-file-name buffer-file-name)
+		      "::" (match-string 1))
+	      link (org-make-link cpltxt)))
+       ((and (featurep 'org-id)
+	     (or (eq org-link-to-org-use-id t)
+		 (and (eq org-link-to-org-use-id 'create-if-interactive)
+		      (interactive-p))
+		 (and org-link-to-org-use-id
+		      (condition-case nil
+			  (org-entry-get nil "ID")
+			(error nil)))))
+	;; We can make a link using the ID.
+	(setq link (condition-case nil
+		       (org-id-store-link)
+		     (error
+		      ;; probably before first headling, link to file only
+		      (concat "file:"
+			      (abbreviate-file-name buffer-file-name))))))
+       (t
+	;; Just link to current headline
+	(setq cpltxt (concat "file:"
+			     (abbreviate-file-name buffer-file-name)))
+	;; Add a context search string
+	(when (org-xor org-context-in-file-links arg)
 	  (setq txt (cond
 		     ((org-on-heading-p) nil)
 		     ((org-region-active-p)
@@ -6174,10 +6276,10 @@
 			  (condition-case nil
 			      (org-make-org-heading-search-string txt)
 			    (error "")))
-		  desc "NONE"))))
-      (if (string-match "::\\'" cpltxt)
-	  (setq cpltxt (substring cpltxt 0 -2)))
-      (setq link (org-make-link cpltxt)))
+		  desc "NONE")))
+	(if (string-match "::\\'" cpltxt)
+	    (setq cpltxt (substring cpltxt 0 -2)))
+	(setq link (org-make-link cpltxt)))))
 
      ((buffer-file-name (buffer-base-buffer))
       ;; Just link to this file here.
@@ -6889,7 +6991,7 @@
 			   (format "Execute \"%s\" as elisp? "
 				   (org-add-props cmd nil
 				     'face 'org-warning))))
-	      (message "%s => %s" cmd 
+	      (message "%s => %s" cmd
 		       (if (equal (string-to-char cmd) ?\()
 			   (eval (read cmd))
 			 (call-interactively (read cmd))))
@@ -9026,8 +9128,14 @@
 	  ;; compile tags for current headline
 	  (setq tags-list
 		(if org-use-tag-inheritance
-		    (apply 'append (mapcar 'cdr tags-alist))
+		    (apply 'append (mapcar 'cdr (reverse tags-alist)))
 		  tags))
+	  (when org-use-tag-inheritance
+	    (setcdr (car tags-alist)
+		    (mapcar (lambda (x)
+			      (setq x (copy-sequence x))
+			      (org-add-prop-inherited x))
+			    (cdar tags-alist))))
 	  (when (and tags org-use-tag-inheritance
 		     (not (eq t org-use-tag-inheritance)))
 	    ;; selective inheritance, remove uninherited ones
@@ -9083,15 +9191,22 @@
 (defun org-remove-uniherited-tags (tags)
   "Remove all tags that are not inherited from the list TAGS."
   (cond
-   ((eq org-use-tag-inheritance t) tags)
+   ((eq org-use-tag-inheritance t)
+    (if org-tags-exclude-from-inheritance
+	(org-delete-all org-tags-exclude-from-inheritance tags)
+      tags))
    ((not org-use-tag-inheritance) nil)
    ((stringp org-use-tag-inheritance)
     (delq nil (mapcar
-	       (lambda (x) (if (string-match org-use-tag-inheritance x) x nil))
+	       (lambda (x)
+		 (if (and (string-match org-use-tag-inheritance x)
+			  (not (member x org-tags-exclude-from-inheritance)))
+		     x nil))
 	       tags)))
    ((listp org-use-tag-inheritance)
     (delq nil (mapcar
-	       (lambda (x) (if (member x org-use-tag-inheritance) x nil))
+	       (lambda (x)
+		 (if (member x org-use-tag-inheritance) x nil))
 	       tags)))))
 
 (defvar todo-only) ;; dynamically scoped
@@ -9301,12 +9416,20 @@
 		     (append '(0 0 0) (nthcdr 3 (decode-time))))))
 
 (defun org-matcher-time (s)
-  (cond
-   ((string= s "<now>") (float-time))
-   ((string= s "<today>") (org-time-today))
-   ((string= s "<tomorrow>") (+ 86400.0 (org-time-today)))
-   ((string= s "<yesterday>") (- (org-time-today) 86400.0))
-   (t (org-2ft s))))
+  "Interprete a time comparison value."
+  (save-match-data
+    (cond
+     ((string= s "<now>") (float-time))
+     ((string= s "<today>") (org-time-today))
+     ((string= s "<tomorrow>")   (+ 86400.0 (org-time-today)))
+     ((string= s "<yesterday>")  (- (org-time-today) 86400.0))
+     ((string-match "^<\\([-+][0-9]+\\)\\([dwmy]\\)>$" s)
+      (+ (org-time-today)
+	 (* (string-to-number (match-string 1 s))
+	    (cdr (assoc (match-string 2 s)
+			'(("d" . 86400.0)   ("w" . 604800.0)
+			  ("m" . 2678400.0) ("y" . 31557600.0)))))))
+     (t (org-2ft s)))))
 
 (defun org-match-any-p (re list)
   "Does re match any element of list?"
@@ -9348,6 +9471,8 @@
 		    (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$"))
 		      (setq ltags (org-split-string
 				   (org-match-string-no-properties 1) ":"))
+		      (when parent
+			(setq ltags (mapcar 'org-add-prop-inherited ltags)))
 		      (setq tags (append
 				  (if parent
 				      (org-remove-uniherited-tags ltags)
@@ -9360,6 +9485,10 @@
 	      (error nil)))))
       (append (org-remove-uniherited-tags org-file-tags) tags))))
 
+(defun org-add-prop-inherited (s)
+  (add-text-properties 0 (length s) '(inherited t) s)
+  s)
+
 (defun org-toggle-tag (tag &optional onoff)
   "Toggle the tag TAG for the current line.
 If ONOFF is `on' or `off', don't toggle but set to this state."
@@ -9842,7 +9971,7 @@
 	 (org-agenda-skip-function
 	  (car (org-delete-all '(comment archive) skip)))
 	 (org-tags-match-list-sublevels t)
-	 matcher pos file
+	 matcher pos file res
 	 org-todo-keywords-for-agenda
 	 org-done-keywords-for-agenda
 	 org-todo-keyword-alist-for-agenda
@@ -9851,7 +9980,7 @@
     (cond
      ((eq match t)   (setq matcher t))
      ((eq match nil) (setq matcher t))
-     (t (setq matcher (if match (org-make-tags-matcher match) t))))
+     (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t))))
 
     (when (eq scope 'tree)
       (org-back-to-heading t)
@@ -9884,7 +10013,8 @@
 	    (save-restriction
 	      (widen)
 	      (goto-char (point-min))
-	      (org-scan-tags func matcher))))))))
+	      (setq res (append res (org-scan-tags func matcher)))))))
+      res)))
 
 ;;;; Properties
 
@@ -10484,6 +10614,7 @@
 IDENT can be a string, a symbol or a number, this function will search for
 the string representation of it.
 Return the position where this entry starts, or nil if there is no such entry."
+  (interactive "sID: ")
   (let ((id (cond
 	     ((stringp ident) ident)
 	     ((symbol-name ident) (symbol-name ident))
@@ -12418,6 +12549,10 @@
 (org-defkey org-mode-map "\C-c\C-xp"    'org-set-property)
 (org-defkey org-mode-map "\C-c\C-xi"    'org-insert-columns-dblock)
 
+(org-defkey org-mode-map "\C-c\C-x."    'org-timer)
+(org-defkey org-mode-map "\C-c\C-x-"    'org-timer-item)
+(org-defkey org-mode-map "\C-c\C-x0"    'org-timer-start)
+
 (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns)
 
 (when (featurep 'xemacs)
@@ -13191,7 +13326,11 @@
       :style radio :selected org-display-custom-times]
      "--"
      ["Goto Calendar" org-goto-calendar t]
-     ["Date from Calendar" org-date-from-calendar t])
+     ["Date from Calendar" org-date-from-calendar t]
+     "--"
+     ["Start/restart timer" org-timer-start t]
+     ["Insert timer string" org-timer t]
+     ["Insert timer item" org-timer-item t])
     ("Logging work"
      ["Clock in" org-clock-in t]
      ["Clock out" org-clock-out t]