changeset 99849:621e15919df0

2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-dblock-write:clocktable): Make sure the clocktable sees the first line. (org-clock-in): Warn if the clock cannot be resumed. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-open-at-point): Fix mixup about interactive and non-interactive elisp links. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-preprocess-string): Allow one comment line before the first headline to always be included. This is to not miss a commented target. * org-mouse.el (org-mouse-insert-item): Call `org-indent-to-column' instead of `indent-to', for XEmacs compatibility. * org.el (org-refile-targets): Fix customize definition so that it works also in XEmacs. (org-fixup-indentation): Call `org-indent-to-column' instead of `indent-to', for XEmacs compatibility. 2008-11-23 Tokuya Kameshima <kames@fa2.so-net.ne.jp> * org-mew.el (org-mew-store-link): Get the correct case folder for refiled messages. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-ascii): Remove the "\\" forced line break indicators. * org.el (org-ido-completing-read): Remove the "i:" prefix for ido-completion propts. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-apply-template): Use `org-substring-no-properties'. * org-compat.el (org-substring-no-properties): New function. * org-remember.el (org-remember-apply-template): Use `org-substring-no-properties' for compatibility. * org-list.el (org-list-two-spaces-after-bullet-regexp): New option. (org-fix-bullet-type): respect `org-list-two-spaces-after-bullet-regexp'. * org-clock.el (org-clock-load): Clean up the code. * org.el (org-adaptive-fill-function): Allow two spaces after "1." as a list bullet. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-save, org-clock-load): Check for live buffers, existing files, and buffer file names to ensure consistent information. (org-clock-persist): Make `clock' a special value of this variable, and improve docstring. * org-list.el (org-cycle-list-bullet, org-fix-bullet-type) (org-get-string-indentation): Adapt indentation when the bullet width changes. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-finalize): Make interactive. (org-remember-kill): New command. (org-remember-finish-immediately): Call `org-remember-finalize' directly. (org-remember-finalize): Make `org-remember-finalize' an interactive function. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-apply-template): No ido completion for free prompts in remember templates. (org-remember-before-finalize-hook): New hook. (org-remember-mode): New minor mode. (org-remember-apply-template): Turn on `org-remember-mode'. * org-id.el (org-id-add-location): Avoid error when no file is given. * org-remember.el (org-remember-apply-template): Fix the way how the list of allowed properties is retrieved from the target file. * org.el (org-insert-link): Improve file link matching. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-colview.el (org-columns-display-here): New argument DATELINE, to trigger using the new face. (org-agenda-colview-summarize): Call `org-columns-display-here' with the new argument. * org-faces.el (org-agenda-column-dateline): New face. * org-publish.el (org-publish-org-index): Use index-title at page title, not as section. * org-exp.el (org-export-html-format-desc): Respect the org-protect property. (org-export-as-html): Protect image specifiers that are in the description part of a link. * org.el (org-sort-entries-or-items, org-completing-read) (org-refile-get-location, org-olpath-completing-read, org-todo) (org-show-todo-tree, org-sparse-tree, org-make-tags-matcher) (org-set-tags, org-change-tag-in-region, org-fast-tag-selection) (org-set-property, org-delete-property) (org-delete-property-globally): Use `org-ido-completing-read'. * org-remember.el (org-remember-apply-template): Use `org-ido-completing-read'. * org-publish.el (org-publish): Use `org-ido-completing-read'. * org-colview.el (org-columns-edit-value, org-columns-new) (org-insert-columns-dblock): Use `org-ido-completing-read'. * org-colview-xemacs.el (org-columns-edit-value) (org-columns-new, org-insert-columns-dblock): Use `org-ido-completing-read'. * org-attach.el (org-attach-delete-one, org-attach-open): Use `org-ido-completing-read'. * org-agenda.el (org-todo-list, org-agenda-filter-by-tag): Use `org-ido-completing-read'. * org.el (org-time-today): New function. (org-matcher-time): Use `org-time-today'. Add special treatment for "<tomorrow>" and "<yesterday>". (org-ido-completing-read): New function. (org-completion-use-ido): New option. * org-exp.el (org-export-format-source-code): Fix bug in require htmlize code. (org-export-target-internal-links): Fix bug in search for text property. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-subcontent): Interprete target aliases as additonal labels. * org-exp.el (org-export-target-aliases): New variable. (org-export-preprocess-string) (org-export-handle-invisible-targets): Fill the alias alist. (org-export-as-html): Remove the &nbsp; from the anchor, and also assign an id. (org-html-level-start): Insert the target aliases as additonal anchors. * org.el (org-edit-fixed-width-region): Fix bug when starting a new picture area. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-open-at-mouse): Ensure correct link abbreviations when following a link with the mouse from the agenda. * org-exp.el (org-export-as-html): Avoid lone </div> when no headlines are created. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-link-translation-function): New option. (org-open-at-point): Call `org-link-translation-function' if non-nil. (org-translate-link): New function. (org-translate-link-from-planner): New function. (org-open-at-point): Allow interactive commands in elisp links. * org-exp.el (org-icalendar-cleanup-string): Restore the old iCalendar quoting. The new one seems to caus problems with applications. * org.el (org-yank): Set `this-command' to `yank', so that `yank-pop' will work. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-icalendar-cleanup-string): Improve RFC2455 compliance as far as quoting is concerned. * org.el (org-link-expand-abbrev): Implement %h as an escape for a hexified version of the tag. * org-vm.el (org-vm-follow-link): Require `vm-search'. * org.el (org-up-heading-safe, org-forward-same-level): Always call `org-back-to-heading' instead of `outline-back-to-heading'. (org-back-to-heading): New wrapper around outline-back-to-heading, with a useful error message telling where the error happened. * org-list.el (org-update-checkbox-count): Always call `org-back-to-heading' instead of `outline-back-to-heading'. * org-exp.el (org-export-as-html): Make sure that each <img> tag has an `alt' attribute, to ensure XHTML validation. 2008-11-23 Carsten Dominik <carsten.dominik@gmail.com> * org-publish.el (org-publish-attachment): Allow publishing to overwrite attachment files. * org-agenda.el (org-agenda-timerange-leaders): New option. (org-agenda-get-blocks): Use `org-agenda-timerange-leaders'. * org.el (org-edit-src-exit): Untabify ASCII image before returning.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 23 Nov 2008 13:37:44 +0000
parents 80e53e313ff5
children 8e9b6f2f7e31
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, 811 insertions(+), 425 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/org/org-agenda.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-agenda.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -878,6 +878,20 @@
   :group 'org-agenda-line-format
   :type 'string)
 
+(defcustom org-agenda-timerange-leaders '("" "(%d/%d): ")
+  "Text preceding timerange entries in the agenda view.
+This is a list with two strings.  The first applies when the range
+is entirely on one day.  The second applies if the range spans several days.
+The strings may have two \"%d\" format specifiers which will be filled
+with the sequence number of the days, and the total number of days in the
+range, respectively."
+  :group 'org-agenda-line-format
+  :type '(list
+	  (string :tag "Deadline today   ")
+	  (choice :tag "Deadline relative"
+		  (string :tag "Format string")
+		  (function))))
+
 (defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ")
   "Text preceeding scheduled items in the agenda view.
 This is a list with two strings.  The first applies when the item is
@@ -2722,7 +2736,7 @@
 	 rtn rtnall files file pos)
     (when (equal arg '(4))
       (setq org-select-this-todo-keyword
-	    (completing-read "Keyword (or KWD1|K2D2|...): "
+	    (org-ido-completing-read "Keyword (or KWD1|K2D2|...): "
 			     (mapcar 'list kwds) nil nil)))
     (and (equal 0 arg) (setq org-select-this-todo-keyword nil))
     (org-set-local 'org-last-arg arg)
@@ -3384,7 +3398,7 @@
 	  (push txt ee))))
     (nreverse ee)))
 
-(defalias 'org-get-closed 'org-agenda-get-progress)
+(defalias 'org-get-closed 'org-get-progress)
 (defun org-agenda-get-progress ()
   "Return the logged TODO entries for agenda display."
   (let* ((props (list 'mouse-face 'highlight
@@ -3398,7 +3412,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))
@@ -3677,8 +3691,10 @@
 			 (org-entry-is-done-p)
 			 (throw :skip t))
 		    (setq txt (org-format-agenda-item
-			       (format (if (= d1 d2) "" "(%d/%d): ")
-				       (1+ (- d0 d1)) (1+ (- d2 d1)))
+			       (format
+				(nth (if (= d1 d2) 0 1)
+				     org-agenda-timerange-leaders)
+				(1+ (- d0 d1)) (1+ (- d2 d1)))
 			       head category tags
 			       (if (= d0 d1) timestr))))
 		(setq txt org-agenda-no-heading-message))
@@ -4255,7 +4271,7 @@
 	(org-set-local 'org-global-tags-completion-table
 		       (org-global-tags-completion-table)))
       (let ((completion-ignore-case t))
-	(setq tag (completing-read
+	(setq tag (org-ido-completing-read
 		   "Tag: " org-global-tags-completion-table))))
     (cond
      ((equal char ?/) (org-agenda-filter-by-tag-show-all))
--- a/lisp/org/org-archive.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-archive.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-attach.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-attach.el	Sun Nov 23 13:37:44 2008 +0000
@@ -4,7 +4,7 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 6.12a
+;; Version: 6.13
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -153,6 +153,9 @@
   "Return the directory associated with the current entry.
 If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil,
 the directory and the corresponding ID will be created."
+  (when (and (not (buffer-file-name (buffer-base-buffer)))
+	     (not (file-name-absolute-p org-attach-directory)))
+    (error "Need absolute `org-attach-directory' to attach in buffers without filename."))
   (let ((uuid (org-id-get (point) create-if-not-exists-p)))
     (when (or uuid create-if-not-exists-p)
       (unless uuid
@@ -245,7 +248,7 @@
   (let* ((attach-dir (org-attach-dir t))
 	 (files (org-attach-file-list attach-dir))
 	 (file (or file
-		   (completing-read
+		   (org-ido-completing-read
 		    "Delete attachment: "
 		    (mapcar (lambda (f)
 			      (list (file-name-nondirectory f)))
@@ -320,7 +323,7 @@
 	 (files (org-attach-file-list attach-dir))
 	 (file (if (= (length files) 1)
 		   (car files)
-		 (completing-read "Open attachment: "
+		 (org-ido-completing-read "Open attachment: "
 				  (mapcar 'list files) nil t))))
     (org-open-file (expand-file-name file attach-dir) in-emacs)))
 
--- a/lisp/org/org-bbdb.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-bbdb.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-bibtex.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-bibtex.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-clock.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-clock.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -104,9 +104,19 @@
 
 (defcustom org-clock-persist nil
   "When non-nil, save the running clock when emacs is closed, and
-  resume it next time emacs is started."
+  resume it next time emacs is started.
+When this is t, both the running clock, and the entire clock
+history are saved.  When this is the symbol `clock', only the
+running clock is saved.
+
+When Emacs restarts with saved clock information, the file containing the
+running clock as well as all files mentioned in the clock history will
+be visited."
   :group 'org-clock
-  :type 'boolean)
+  :type '(choice
+	  (const :tag "Just the running clock" clock)
+	  (const :tag "Clock and history" t)
+	  (const :tag "No persistence" nil)))
 
 (defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
   "File to save clock data to"
@@ -246,7 +256,7 @@
 			     'help-echo (concat help-text ": " org-clock-heading))
 	       (org-propertize clock-string 'help-echo help-text)))
 	   'local-map org-clock-mode-map
-	   'mouse-face '(face mode-line-highlight)))
+	   'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)))
     (force-mode-line-update)))
 
 (defvar org-clock-mode-line-entry nil
@@ -260,88 +270,102 @@
 is as the default task, a special task that will always be offered in
 the clocking selection, associated with the letter `d'."
   (interactive "P")
-  (let ((interrupting (marker-buffer org-clock-marker))
-	ts selected-task target-pos)
-    (when (equal select '(4))
-      (setq selected-task (org-clock-select-task "Clock-in on task: "))
-      (if selected-task
-	  (setq selected-task (copy-marker selected-task))
-	(error "Abort")))
-    (when interrupting
-      ;; We are interrupting the clocking of a differnt task.
-      ;; Save a marker to this task, so that we can go back.
-      (move-marker org-clock-interrupted-task
-		   (marker-position org-clock-marker)
-		   (marker-buffer org-clock-marker))
-      (org-clock-out t))
-    
-    (when (equal select '(16))
-      ;; Mark as default clocking task
-      (save-excursion
-	(org-back-to-heading t)
-	(move-marker org-clock-default-task (point))))
-    
-    (setq target-pos (point))  ;; we want to clock in at this location
-    (save-excursion
-      (when (and selected-task (marker-buffer selected-task))
-	;; There is a selected task, move to the correct buffer
-	;; and set the new target position.
-	(set-buffer (org-base-buffer (marker-buffer selected-task)))
-	(setq target-pos (marker-position selected-task))
-	(move-marker selected-task nil))
-      (save-excursion
-	(save-restriction
-	  (widen)
-	  (goto-char target-pos)
+  (catch 'abort
+    (let ((interrupting (marker-buffer org-clock-marker))
+	  ts selected-task target-pos)
+      (when (equal select '(4))
+	(setq selected-task (org-clock-select-task "Clock-in on task: "))
+	(if selected-task
+	    (setq selected-task (copy-marker selected-task))
+	  (error "Abort")))
+      (when interrupting
+	;; We are interrupting the clocking of a differnt task.
+	;; Save a marker to this task, so that we can go back.
+	(move-marker org-clock-interrupted-task
+		     (marker-position org-clock-marker)
+		     (marker-buffer org-clock-marker))
+	(org-clock-out t))
+      
+      (when (equal select '(16))
+	;; Mark as default clocking task
+	(save-excursion
 	  (org-back-to-heading t)
-	  (or interrupting (move-marker org-clock-interrupted-task nil))
-	  (org-clock-history-push)
-	  (cond ((functionp org-clock-in-switch-to-state)
-		 (looking-at org-complex-heading-regexp)
-		 (let ((newstate (funcall org-clock-in-switch-to-state (match-string 2))))
-		   (if newstate (org-todo newstate))))
-		((and org-clock-in-switch-to-state
-		      (not (looking-at (concat outline-regexp "[ \t]*"
-					       org-clock-in-switch-to-state
-					       "\\>"))))
-		 (org-todo org-clock-in-switch-to-state)))
-	  (setq org-clock-heading-for-remember
-		(and (looking-at org-complex-heading-regexp)
-		     (match-end 4)
-		     (org-trim (buffer-substring (match-end 1) (match-end 4)))))
-	  (setq org-clock-heading
-		(cond ((and org-clock-heading-function
-			    (functionp org-clock-heading-function))
-		       (funcall org-clock-heading-function))
-		      ((looking-at org-complex-heading-regexp)
-		       (match-string 4))
-		      (t "???")))
-	  (setq org-clock-heading (org-propertize org-clock-heading 'face nil))
-	  (org-clock-find-position)
-	  (if (and org-clock-in-resume
-		   (looking-at (concat "^[ \\t]* " org-clock-string
-				       " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
-				       " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\]$")))
-	      (progn (message "Matched %s" (match-string 1))
-		     (setq ts (concat "[" (match-string 1) "]"))
-		     (goto-char (match-end 1))
-		     (setq org-clock-start-time
-			   (apply 'encode-time (org-parse-time-string (match-string 1)))))
-	    (progn
+	  (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))
+	  ;; There is a selected task, move to the correct buffer
+	  ;; and set the new target position.
+	  (set-buffer (org-base-buffer (marker-buffer selected-task)))
+	  (setq target-pos (marker-position selected-task))
+	  (move-marker selected-task nil))
+	(save-excursion
+	  (save-restriction
+	    (widen)
+	    (goto-char target-pos)
+	    (org-back-to-heading t)
+	    (or interrupting (move-marker org-clock-interrupted-task nil))
+	    (org-clock-history-push)
+	    (cond ((functionp org-clock-in-switch-to-state)
+		   (looking-at org-complex-heading-regexp)
+		   (let ((newstate (funcall org-clock-in-switch-to-state
+					    (match-string 2))))
+		     (if newstate (org-todo newstate))))
+		  ((and org-clock-in-switch-to-state
+			(not (looking-at (concat outline-regexp "[ \t]*"
+						 org-clock-in-switch-to-state
+						 "\\>"))))
+		   (org-todo org-clock-in-switch-to-state)))
+	    (setq org-clock-heading-for-remember
+		  (and (looking-at org-complex-heading-regexp)
+		       (match-end 4)
+		       (org-trim (buffer-substring (match-end 1)
+						   (match-end 4)))))
+	    (setq org-clock-heading
+		  (cond ((and org-clock-heading-function
+			      (functionp org-clock-heading-function))
+			 (funcall org-clock-heading-function))
+			((looking-at org-complex-heading-regexp)
+			 (match-string 4))
+			(t "???")))
+	    (setq org-clock-heading (org-propertize org-clock-heading
+						    'face nil))
+	    (org-clock-find-position)
+	    (cond
+	     ((and org-clock-in-resume
+		   (looking-at
+		    (concat "^[ \\t]* " org-clock-string
+			    " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}"
+			    " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$")))
+	      (message "Matched %s" (match-string 1))
+	      (setq ts (concat "[" (match-string 1) "]"))
+	      (goto-char (match-end 1))
+	      (setq org-clock-start-time
+		    (apply 'encode-time
+			   (org-parse-time-string (match-string 1)))))
+	     ((eq org-clock-in-resume 'auto-restart)
+	      ;; called from org-clock-load during startup,
+	      ;; do not interrupt, but warn!
+	      (message "Cannot restart clock because task does not contain unfinished clock")
+	      (ding)
+	      (sit-for 2)
+	      (throw 'abort nil))
+	     (t
 	      (insert "\n") (backward-char 1)
 	      (org-indent-line-function)
 	      (insert org-clock-string " ")
 	      (setq org-clock-start-time (current-time))
 	      (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive))))
-	  (move-marker org-clock-marker (point) (buffer-base-buffer))
-	  (or global-mode-string (setq global-mode-string '("")))
-	  (or (memq 'org-mode-line-string global-mode-string)
-	      (setq global-mode-string
-		    (append global-mode-string '(org-mode-line-string))))
-	  (org-update-mode-line)
-	  (setq org-mode-line-timer
-		(run-with-timer 60 60 'org-update-mode-line))
-	  (message "Clock started at %s" ts))))))
+	    (move-marker org-clock-marker (point) (buffer-base-buffer))
+	    (or global-mode-string (setq global-mode-string '("")))
+	    (or (memq 'org-mode-line-string global-mode-string)
+		(setq global-mode-string
+		      (append global-mode-string '(org-mode-line-string))))
+	    (org-update-mode-line)
+	    (setq org-mode-line-timer
+		  (run-with-timer 60 60 'org-update-mode-line))
+	    (message "Clock started at %s" ts)))))))
 
 (defun org-clock-find-position ()
   "Find the location where the next clock line should be inserted."
@@ -820,7 +844,7 @@
 	   (block (plist-get params :block))
 	   (link (plist-get params :link))
 	   ipos time p level hlc hdl content recalc formula pcol
-	   cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list)
+	   cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list st)
       (setq org-clock-file-total-minutes nil)
       (when step
 	(unless (or block (and ts te))
@@ -902,7 +926,11 @@
 	(unless scope-is-list
 	  (org-clock-sum ts te)
 	  (goto-char (point-min))
-	  (while (setq p (next-single-property-change (point) :org-clock-minutes))
+	  (setq st t)
+	  (while (or (and (bobp) (prog1 st (setq st nil))
+			  (get-text-property (point) :org-clock-minutes)
+			  (setq p (point-min)))
+		     (setq p (next-single-property-change (point) :org-clock-minutes)))
 	    (goto-char p)
 	    (when (setq time (get-text-property p :org-clock-minutes))
 	      (save-excursion
@@ -1062,71 +1090,92 @@
 	0))))
 
 (defun org-clock-save ()
-  "Persist various clock-related data to disk"
-  (with-current-buffer (find-file (expand-file-name org-clock-persist-file))
-    (progn (delete-region (point-min) (point-max))
-	   ;;Store clock
-	   (insert (format ";; org-persist.el - %s at %s\n"
-			   system-name (format-time-string
-					(cdr org-time-stamp-formats))))
-	   (if (and org-clock-persist (marker-buffer org-clock-marker)
-		    (or (not org-clock-persist-query-save)
-			(y-or-n-p (concat "Save current clock ("
-					  (substring-no-properties org-clock-heading)
-					  ")"))))
-	       (insert "(setq resume-clock '(\""
-		       (buffer-file-name (marker-buffer org-clock-marker))
-		       "\" . " (int-to-string (marker-position org-clock-marker))
-		       "))\n"))
-	   ;;Store clocked task history. Tasks are stored reversed to make
-	   ;;reading simpler
-	   (if org-clock-history
-	       (insert "(setq stored-clock-history '("
-		       (mapconcat
-			(lambda (m)
-			  (when (marker-buffer m)
-			    (concat "(\"" (buffer-file-name (marker-buffer m))
-				    "\" . " (int-to-string (marker-position m))
-				")")))
-			(reverse org-clock-history) " ") "))\n"))
-	   (save-buffer)
-	   (kill-buffer (current-buffer)))))
+  "Persist various clock-related data to disk.
+The details of what will be saved are regulated by the variable
+`org-clock-persist'."
+  (when org-clock-persist
+    (let (b)
+      (with-current-buffer (find-file (expand-file-name org-clock-persist-file))
+	(progn
+	  (delete-region (point-min) (point-max))
+	  ;;Store clock
+	  (insert (format ";; org-persist.el - %s at %s\n"
+			  system-name (format-time-string
+				       (cdr org-time-stamp-formats))))
+	  (if (and (setq b (marker-buffer org-clock-marker))
+		   (setq b (or (buffer-base-buffer b) b))
+		   (buffer-live-p b)
+		   (buffer-file-name b)
+		   (or (not org-clock-persist-query-save)
+		       (y-or-n-p (concat "Save current clock ("
+					 (substring-no-properties org-clock-heading)
+					 ") "))))
+	      (insert "(setq resume-clock '(\""
+		      (buffer-file-name (marker-buffer org-clock-marker))
+		      "\" . " (int-to-string (marker-position org-clock-marker))
+		      "))\n"))
+	  ;; Store clocked task history. Tasks are stored reversed to make
+	  ;; reading simpler
+	  (when (and org-clock-history (eq org-clock-persist t))
+	    (insert
+	     "(setq stored-clock-history '("
+	     (mapconcat
+	      (lambda (m)
+		(when (and (setq b (marker-buffer m))
+			   (setq b (or (buffer-base-buffer b) b))
+			   (buffer-live-p b)
+			   (buffer-file-name b))
+		  (concat "(\"" (buffer-file-name b)
+			  "\" . " (int-to-string (marker-position m))
+			  ")")))
+	      (reverse org-clock-history) " ") "))\n"))
+	  (save-buffer)
+	  (kill-buffer (current-buffer)))))))
 
-(defvar org-clock-loaded nil)
+(defvar org-clock-loaded nil
+  "Was the clock file loaded?")
 
 (defun org-clock-load ()
   "Load various clock-related data from disk, optionally resuming
 a stored clock"
-  (if (not org-clock-loaded)
-      (let ((filename (expand-file-name org-clock-persist-file))
-	    (org-clock-in-resume t))
-	(if (file-readable-p filename)
-	    (progn
-	      (message "%s" "Restoring clock data")
-	      (setq org-clock-loaded t)
-	      (load-file filename)
-	      ;; load history
-	      (if (boundp 'stored-clock-history)
-		  (save-window-excursion
-		    (mapc (lambda (task)
-			    (org-clock-history-push (cdr task)
-						    (find-file (car task))))
-			  stored-clock-history)))
-	      ;; resume clock
-	      (if (and (boundp 'resume-clock) org-clock-persist
-		       (or (not org-clock-persist-query-resume)
-			   (y-or-n-p 
-			    (concat
-			     "Resume clock ("
-			     (with-current-buffer (find-file (car resume-clock))
-			       (progn (goto-char (cdr resume-clock))
-				      (looking-at org-complex-heading-regexp)
-				      (match-string 4))) ")"))))
-		  (with-current-buffer (find-file (car resume-clock))
-		    (progn (goto-char (cdr resume-clock))
-			   (org-clock-in)))))
+  (when (and org-clock-persist (not org-clock-loaded))
+    (let ((filename (expand-file-name org-clock-persist-file))
+	  (org-clock-in-resume 'auto-restart)
+	  resume-clock stored-clock-history)
+      (if (not (file-readable-p filename))
 	  (message "Not restoring clock data; %s not found"
-		   org-clock-persist-file)))))
+		   org-clock-persist-file)
+	(message "%s" "Restoring clock data")
+	(setq org-clock-loaded t)
+	(load-file filename)
+	;; load history
+	(when stored-clock-history
+	  (save-window-excursion
+	    (mapc (lambda (task)
+		    (if (file-exists-p (car task))
+			(org-clock-history-push (cdr task)
+						(find-file (car task)))))
+		  stored-clock-history)))
+	;; resume clock
+	(when (and resume-clock org-clock-persist
+		   (file-exists-p (car resume-clock))
+		   (or (not org-clock-persist-query-resume)
+		       (y-or-n-p 
+			(concat
+			 "Resume clock ("
+			 (with-current-buffer (find-file (car resume-clock))
+			   (save-excursion
+			     (goto-char (cdr resume-clock))
+			     (org-back-to-heading t)
+			     (and (looking-at org-complex-heading-regexp)
+				  (match-string 4))))
+			 ") "))))
+	  (when (file-exists-p (car resume-clock))
+	    (with-current-buffer (find-file (car resume-clock))
+	      (goto-char (cdr resume-clock))
+	      (org-clock-in)
+	      (if (org-invisible-p)
+		  (org-show-context)))))))))
 
 ;;;###autoload
 (defun org-clock-persistence-insinuate ()
--- a/lisp/org/org-colview.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-colview.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -130,7 +130,7 @@
     (push ov org-columns-overlays)
     ov))
 
-(defun org-columns-display-here (&optional props)
+(defun org-columns-display-here (&optional props dateline)
   "Overlay the current line with column display."
   (interactive)
   (let* ((fmt org-columns-current-fmt-compiled)
@@ -145,6 +145,7 @@
 		       'default))
 	 (color (list :foreground (face-attribute ref-face :foreground)))
 	 (face (list color 'org-column ref-face))
+	 (face1 (list color 'org-agenda-column-dateline ref-face))
 	 (pl (or (get-text-property (point-at-bol) 'prefix-length) 0))
 	 (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp))
 	 pom property ass width f string ov column val modval s1 s2 title)
@@ -189,7 +190,7 @@
       ;; Create the overlay
       (org-unmodified
        (setq ov (org-columns-new-overlay
-		 beg (setq beg (1+ beg)) string face))
+		 beg (setq beg (1+ beg)) string (if dateline face1 face)))
        (org-overlay-put ov 'keymap org-columns-map)
        (org-overlay-put ov 'org-columns-key property)
        (org-overlay-put ov 'org-columns-value (cdr ass))
@@ -425,7 +426,7 @@
      (t
       (setq allowed (org-property-get-allowed-values pom key 'table))
       (if allowed
-	  (setq nval (completing-read "Value: " allowed nil t))
+	  (setq nval (org-ido-completing-read "Value: " allowed nil t))
 	(setq nval (read-string "Edit: " value)))
       (setq nval (org-trim nval))
       (when (not (equal nval value))
@@ -675,7 +676,7 @@
   (interactive)
   (let ((editp (and prop (assoc prop org-columns-current-fmt-compiled)))
 	cell)
-    (setq prop (completing-read
+    (setq prop (org-ido-completing-read
 		"Property: " (mapcar 'list (org-buffer-property-keys t nil t))
 		nil nil prop))
     (setq title (read-string (concat "Column title [" prop "]: ") (or title prop)))
@@ -683,7 +684,7 @@
     (if (string-match "\\S-" width)
 	(setq width (string-to-number width))
       (setq width nil))
-    (setq fmt (completing-read "Summary [none]: "
+    (setq fmt (org-ido-completing-read "Summary [none]: "
 			       '(("none") ("add_numbers") ("currency") ("add_times") ("checkbox") ("checkbox-n-of-m") ("checkbox-percent"))
 			       nil t))
     (if (string-match "\\S-" fmt)
@@ -1151,7 +1152,7 @@
   "Create a dynamic block capturing a column view table."
   (interactive)
   (let ((defaults '(:name "columnview" :hlines 1))
-	(id (completing-read
+	(id (org-ido-completing-read
 	     "Capture columns (local, global, entry with :ID: property) [local]: "
 	     (append '(("global") ("local"))
 		     (mapcar 'list (org-property-values "ID"))))))
@@ -1282,7 +1283,7 @@
 			  0 (length lsum) 'face 'bold lsum)
 			 (cons prop lsum))))
 		     fmt))
-	      (org-columns-display-here props)
+	      (org-columns-display-here props 'dateline)
 	      (org-set-local 'org-agenda-columns-active t)))
 	  (if (bobp) (throw 'exit t))
 	  (beginning-of-line 0))))))
--- a/lisp/org/org-compat.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-compat.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -277,9 +277,16 @@
 
 (defun org-propertize (string &rest properties)
   (if (featurep 'xemacs)
-      (add-text-properties 0 (length string) properties string)
+      (progn
+	(add-text-properties 0 (length string) properties string)
+	string)
     (apply 'propertize string properties)))
 
+(defun org-substring-no-properties (string &optional from to)
+  (if (featurep 'xemacs)
+      (org-no-properties (substring string from to))
+    (substring-no-properties string from to)))
+
 (provide 'org-compat)
 
 ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
--- a/lisp/org/org-exp.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-exp.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -1415,6 +1415,9 @@
 
 ;;; General functions for all backends
 
+(defvar org-export-target-aliases nil
+  "Alist of targets with invisible aliases.")
+
 (defun org-export-preprocess-string (string &rest parameters)
   "Cleanup STRING so that that the true exported has a more consistent source.
 This function takes STRING, which should be a buffer-string of an org-file
@@ -1431,6 +1434,8 @@
 	 (outline-regexp "\\*+ ")
 	 target-alist rtn)
 
+    (setq org-export-target-aliases nil)
+
     (with-current-buffer (get-buffer-create " org-mode-tmp")
       (erase-buffer)
       (insert string)
@@ -1464,7 +1469,7 @@
       ;; Get the correct stuff before the first headline
       (when (plist-get parameters :skip-before-1st-heading)
 	(goto-char (point-min))
-	(when (re-search-forward "^\\*+[ \t]" nil t)
+	(when (re-search-forward "\\(^#.*\n\\)^\\*+[ \t]" nil t)
 	  (delete-region (point-min) (match-beginning 0))
 	  (goto-char (point-min))
 	  (insert "\n")))
@@ -1576,7 +1581,7 @@
 (defun org-export-handle-invisible-targets (target-alist)
   "Find targets in comments and move them out of comments.
 Mark them as invisible targets."
-  (let (target tmp)
+  (let (target tmp a)
     (goto-char (point-min))
     (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t)
       ;; Check if the line before or after is a headline with a target
@@ -1587,8 +1592,13 @@
 	    (setq tmp (match-string 2))
 	    (replace-match "")
 	    (and (looking-at "\n") (delete-char 1))
-	    (push (cons (org-solidify-link-text tmp) target)
-		  target-alist))
+	    (push (cons (setq tmp (org-solidify-link-text tmp)) target)
+		  target-alist)
+	    (setq a (or (assoc target org-export-target-aliases)
+			(progn
+			  (push (list target) org-export-target-aliases)
+			  (car org-export-target-aliases))))
+	    (push tmp (cdr a)))
 	;; Make an invisible target
 	(replace-match "\\1(INVISIBLE)"))))
   target-alist)
@@ -1622,8 +1632,8 @@
 		   (or (get-text-property (point) 'target)
 		       (get-text-property
 			(max (point-min)
-			     (1- (previous-single-property-change
-				  (point) 'target)))
+			     (1- (or (previous-single-property-change
+				      (point) 'target) 0)))
 			'target))))))))
        (when target
 	 (set-match-data md)
@@ -1885,7 +1895,8 @@
       (goto-char (1- (match-end 0)))
       (org-if-unprotected
        (let* ((xx (save-match-data
-		    (org-link-expand-abbrev (match-string 1))))
+		    (org-translate-link
+		     (org-link-expand-abbrev (match-string 1)))))
 	      (s (concat
 		  "[[" xx "]"
 		  (if (match-end 3)
@@ -2149,7 +2160,7 @@
     (cond
      (htmlp
       ;; We are exporting to HTML
-      (condition-case nil (require 'htmlize) (nil t))
+      (require 'htmlize nil t)
       (if (not (fboundp 'htmlize-region-for-paste))
 	  (progn
 	    ;; we do not have htmlize.el, or an old version of it
@@ -2423,6 +2434,9 @@
 		   "\n") "\n")))
        (t
 	(setq line (org-fix-indentation line org-ascii-current-indentation))
+	;; Remove forced line breaks
+	(if (string-match "\\\\\\\\[ \t]*$" line)
+	    (setq line (replace-match "" t t line)))
 	(if (and org-export-with-fixed-width
 		 (string-match "^\\([ \t]*\\)\\(:\\)" line))
 	    (setq line (replace-match "\\1" nil nil line)))
@@ -3183,9 +3197,10 @@
 	    (cond
 	     ((match-end 2)
 	      (setq line (replace-match
-			  (concat "@<a name=\""
-				  (org-solidify-link-text (match-string 1 line))
-				  "\">\\nbsp@</a>")
+			  (format
+			   "@<a name=\"%s\" id=\"%s\">@</a>"
+			   (org-solidify-link-text (match-string 1 line))
+			   (org-solidify-link-text (match-string 1 line)))
 			  t t line)))
 	     ((and org-export-with-toc (equal (string-to-char line) ?*))
 	      ;; FIXME: NOT DEPENDENT on TOC?????????????????????
@@ -3233,7 +3248,9 @@
 	      (save-match-data
 		(if (string-match "^file:" desc)
 		    (setq desc (substring desc (match-end 0)))))
-	      (setq desc (concat "<img src=\"" desc "\"/>")))
+	      (setq desc (org-add-props
+			     (concat "<img src=\"" desc "\"/>")
+			     '(org-protected t))))
 	    ;; FIXME: do we need to unescape here somewhere?
 	    (cond
 	     ((equal type "internal")
@@ -3250,7 +3267,10 @@
 	      (if (and (or (eq t org-export-html-inline-images)
 			   (and org-export-html-inline-images (not descp)))
 		       (org-file-image-p path))
-		  (setq rpl (concat "<img src=\"" type ":" path "\"" attr "/>"))
+		  (setq rpl (concat "<img src=\"" type ":" path "\""
+				    (if (string-match "\\<alt=" attr)
+					attr (concat attr " alt=\"" path "\""))
+				    "/>"))
 		(setq link (concat type ":" path))
 		(setq rpl (concat "<a href=\"" 
 				  (org-export-html-format-href link)
@@ -3308,7 +3328,11 @@
 				   (or (eq t org-export-html-inline-images)
 				       (and org-export-html-inline-images
 					    (not descp))))
-			      (concat "<img src=\"" thefile "\"" attr "/>")
+			      (concat "<img src=\"" thefile "\""
+				      (if (string-match "alt=" attr)
+					  attr
+					(concat attr " alt=\""
+						thefile "\"")) "/>")
 			    (concat "<a href=\"" thefile "\"" attr ">"
 				    (org-export-html-format-desc desc)
 				    "</a>")))
@@ -3503,7 +3527,7 @@
 			    (and org-export-with-toc (<= level umax))
 			    head-count)
       ;; the </div> to close the last text-... div.
-      (insert "</div>\n")
+      (when (and (> umax 0) first-heading-pos) (insert "</div>\n"))
 
       (save-excursion
 	(goto-char (point-min))
@@ -3604,7 +3628,7 @@
 
 (defun org-export-html-format-desc (s)
   "Make sure the S is valid as a description in a link."
-  (if s
+  (if (and s (not (get-text-property 1 'org-protected s)))
       (save-match-data
 	(org-html-do-expand s))
     s))
@@ -4143,9 +4167,15 @@
   "Insert a new level in HTML export.
 When TITLE is nil, just close all open levels."
   (org-close-par-maybe)
-  (let ((target (and title (org-get-text-property-any 0 'target title)))
-	(l org-level-max)
-	snumber)
+  (let* ((target (and title (org-get-text-property-any 0 'target title)))
+	 (extra-targets
+	  (mapconcat (lambda (x)
+		       (format "<a name=\"%s\" id=\"%s\"></a>"
+			       x x))
+		     (cdr (assoc target org-export-target-aliases))
+		     ""))
+	 (l org-level-max)
+	 snumber)
     (while (>= l level)
       (if (aref org-levels-open (1- l))
 	  (progn
@@ -4173,13 +4203,13 @@
 		(progn
 		  (org-close-li)
 		  (if target
-		      (insert (format "<li id=\"%s\">" target) title "<br/>\n")
+		      (insert (format "<li id=\"%s\">" target) extra-targets title "<br/>\n")
 		    (insert "<li>" title "<br/>\n")))
 	      (aset org-levels-open (1- level) t)
 	      (org-close-par-maybe)
 	      (if target
 		  (insert (format "<ul>\n<li id=\"%s\">" target)
-			  title "<br/>\n")
+			  extra-targets title "<br/>\n")
 		(insert "<ul>\n<li>" title "<br/>\n"))))
 	(aset org-levels-open (1- level) t)
 	(setq snumber (org-section-number level))
@@ -4187,8 +4217,8 @@
 	    (setq title (concat snumber " " title)))
 	(setq level (+ level org-export-html-toplevel-hlevel -1))
 	(unless (= head-count 1) (insert "\n</div>\n"))
-	(insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d\">\n<h%d id=\"sec-%s\">%s</h%d>\n<div id=\"text-%s\">\n"
-			snumber level level snumber title level snumber))
+	(insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d\">\n<h%d id=\"sec-%s\">%s%s</h%d>\n<div id=\"text-%s\">\n"
+			snumber level level snumber extra-targets title level snumber))
 	(org-open-par)))))
 
 (defun org-get-text-property-any (pos prop &optional object)
@@ -4523,10 +4553,10 @@
       (while (string-match "\\([,;]\\)" s start)
 	(setq start (+ (match-beginning 0) 2)
 	      s (replace-match "\\\\\\1" nil nil s))))
+    (setq s (org-trim s))
     (when is-body
       (while (string-match "[ \t]*\n[ \t]*" s)
 	(setq s (replace-match "\\n" t t s))))
-    (setq s (org-trim s))
     (if is-body
 	(if maxlength
 	    (if (and (numberp maxlength)
@@ -4534,6 +4564,32 @@
 		(setq s (substring s 0 maxlength)))))
     s))
 
+(defun org-icalendar-cleanup-string-rfc2455 (s &optional is-body maxlength)
+  "Take out stuff and quote what needs to be quoted.
+When IS-BODY is non-nil, assume that this is the body of an item, clean up
+whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
+characters.
+This seems to be more like RFC 2455, but it causes problems, so it is
+not used right now."
+  (if (not s)
+      nil
+    (if is-body
+	(let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
+	      (re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
+	  (while (string-match re s) (setq s (replace-match "" t t s)))
+	  (while (string-match re2 s) (setq s (replace-match "" t t s)))
+	  (setq s (org-trim s))
+	  (while (string-match "[ \t]*\n[ \t]*" s)
+	    (setq s (replace-match "\\n" t t s)))
+	  (if maxlength
+	      (if (and (numberp maxlength)
+		       (> (length s) maxlength))
+		  (setq s (substring s 0 maxlength)))))
+      (setq s (org-trim s)))
+    (while (string-match "\"" s) (setq s (replace-match "''" t t s)))
+    (when (string-match "[;,:]" s) (setq s (concat "\"" s "\"")))
+    s))
+
 (defun org-get-entry ()
   "Clean-up description string."
   (save-excursion
--- a/lisp/org/org-export-latex.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-export-latex.el	Sun Nov 23 13:37:44 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 6.12a
+;; Version: 6.13
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
@@ -613,7 +613,9 @@
 	 (occur (number-to-string (cdr (assoc 'occur subcontent))))
 	 (content (cdr (assoc 'content subcontent)))
 	 (subcontent (cadr (assoc 'subcontent subcontent)))
-	 (label (org-get-text-property-any 0 'target heading)))
+	 (label (org-get-text-property-any 0 'target heading))
+	 (label-list (cons label (cdr (assoc label
+					     org-export-target-aliases)))))
     (cond
      ;; Normal conversion
      ((<= level org-export-latex-sectioning-depth)
@@ -624,7 +626,9 @@
 		  end (nth (if num 1 3) sec))
 	  (setq start (if num (car sec) (cdr sec))))
 	(insert (format start heading) "\n")
-	(when label (insert (format "\\label{%s}\n" label)))
+	(when label
+	  (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
+			     label-list "\n") "\n"))
 	(insert (org-export-latex-content content))
 	(cond ((stringp subcontent) (insert subcontent))
 	      ((listp subcontent) (org-export-latex-sub subcontent)))
--- a/lisp/org/org-faces.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-faces.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -203,6 +203,12 @@
 		      :height (face-attribute 'default :height)
 		      :family (face-attribute 'default :family)))
 
+(defface org-agenda-column-dateline
+  (org-compatible-face 'org-column
+    '((t nil)))
+  "Face used in agenda column view for datelines with summaries."
+  :group 'org-faces)
+
 (defface org-warning
   (org-compatible-face 'font-lock-warning-face
     '((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t))
--- a/lisp/org/org-gnus.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-gnus.el	Sun Nov 23 13:37:44 2008 +0000
@@ -3,9 +3,10 @@
 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
+;;         Tassilo Horn <tassilo at member dot fsf dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -37,7 +38,11 @@
 
 ;; Customization variables
 
-(defcustom org-usenet-links-prefer-google nil
+(when (fboundp 'defvaralias)
+  (defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links
+    "Deprecated name for `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.
 When nil, Gnus will be used for such links.
 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
@@ -57,50 +62,83 @@
 (add-hook 'org-store-link-functions 'org-gnus-store-link)
 
 ;; Implementation
+
+(defun org-gnus-group-link (group)
+  "Create a link to the Gnus group GROUP.
+If GROUP is a newsgroup and `org-gnus-prefer-web-links' is
+non-nil, create a link to groups.google.com or gmane.org.
+Otherwise create a link to the group inside Gnus.
+
+If `org-store-link' was called with a prefix arg the meaning of
+`org-gnus-prefer-web-links' is reversed."
+  (let ((unprefixed-group (replace-regexp-in-string "^[^:]+:" "" group)))
+    (if (and (string-match "^nntp" group) ;; Only for nntp groups
+	     (org-xor current-prefix-arg
+		      org-gnus-prefer-web-links))
+	(concat (if (string-match "gmane" unprefixed-group)
+		    "http://news.gmane.org/"
+		  "http://groups.google.com/group/")
+		unprefixed-group)
+      (concat "gnus:" group))))
+
+(defun org-gnus-article-link (group newsgroups message-id x-no-archive)
+  "Create a link to a Gnus article.
+The article is specified by its MESSAGE-ID.  Additional
+parameters are the Gnus GROUP, the NEWSGROUPS the article was
+posted to and the X-NO-ARCHIVE header value of that article.
+
+If GROUP is a newsgroup and `org-gnus-prefer-web-links' is
+non-nil, create a link to groups.google.com or gmane.org.
+Otherwise create a link to the article inside Gnus.
+
+If `org-store-link' was called with a prefix arg the meaning of
+`org-gnus-prefer-web-links' is reversed."
+  (if (and (org-xor current-prefix-arg org-gnus-prefer-web-links)
+	   newsgroups	  ;; Make web links only for nntp groups
+	   (not x-no-archive)) ;; and if X-No-Archive isn't set.
+      (format (if (string-match "gmane\\." newsgroups)
+		  "http://mid.gmane.org/%s"
+		"http://groups.google.com/groups/search?as_umsgid=%s")
+	      (org-fixup-message-id-for-http
+	       (replace-regexp-in-string "[<>]" "" message-id)))
+    (org-make-link "gnus:" group "#" message-id)))
+
 (defun org-gnus-store-link ()
   "Store a link to a Gnus folder or message."
   (cond
    ((eq major-mode 'gnus-group-mode)
-    (let ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
-			(gnus-group-group-name))         ; version
-		       ((fboundp 'gnus-group-name)
-			(gnus-group-name))
-		       (t "???")))
-	  desc link)
+    (let* ((group (cond ((fboundp 'gnus-group-group-name) ; depending on Gnus
+			 (gnus-group-group-name))         ; version
+			((fboundp 'gnus-group-name)
+			 (gnus-group-name))
+			(t "???")))
+	   desc link)
       (unless group (error "Not on a group"))
       (org-store-link-props :type "gnus" :group group)
-      (setq desc (concat
-		  (if (org-xor current-prefix-arg
-			       org-usenet-links-prefer-google)
-		      "http://groups.google.com/groups?group="
-		    "gnus:")
-		  group)
+      (setq desc (org-gnus-group-link group)
 	    link (org-make-link desc))
       (org-add-link-props :link link :description desc)
       link))
 
    ((memq major-mode '(gnus-summary-mode gnus-article-mode))
-    (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary))
+    (and (eq major-mode 'gnus-summary-mode) (gnus-summary-show-article))
     (let* ((group gnus-newsgroup-name)
-	   (article (gnus-summary-article-number))
-	   (header (gnus-summary-article-header article))
-	   (from (mail-header-from header))
-	   (message-id (mail-header-id header))
-	   (date (mail-header-date header))
-	   (extra (mail-header-extra header))
-	   (to (cdr (assoc 'To extra)))
+	   (header (with-current-buffer gnus-article-buffer
+		     (gnus-summary-toggle-header 1)
+		     (goto-char (point-min))
+		     (mail-header-extract-no-properties)))
+	   (from (mail-header 'from header))
+	   (message-id (mail-header 'message-id header))
+	   (date (mail-header 'date header))
+	   (to (mail-header 'to header))
+	   (newsgroups (mail-header 'newsgroups header))
+	   (x-no-archive (mail-header 'x-no-archive header))
 	   (subject (gnus-summary-subject-string))
 	   desc link)
       (org-store-link-props :type "gnus" :from from :subject subject
 			    :message-id message-id :group group :to to)
-      (setq desc (org-email-link-description))
-      (if (org-xor current-prefix-arg org-usenet-links-prefer-google)
-	  (setq link
-		(format "http://groups.google.com/groups?as_umsgid=%s"
-			(org-fixup-message-id-for-http message-id)))
-	(setq link (org-make-link "gnus:" group "#"
-				  (or message-id
-				      (number-to-string article)))))
+      (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)
       link))))
 
--- a/lisp/org/org-id.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-id.el	Sun Nov 23 13:37:44 2008 +0000
@@ -4,7 +4,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -376,15 +376,16 @@
 
 (defun org-id-add-location (id file)
   "Add the ID with location FILE to the database of ID loations."
-  (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))
+  (when (and id file) ; don't error when called from a buffer with no 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)))
 
 ;; Finding entries with specified id
 
--- a/lisp/org/org-info.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-info.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-irc.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-irc.el	Sun Nov 23 13:37:44 2008 +0000
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -27,7 +27,7 @@
 ;; Org-mode loads this module by default - if this is not what you want,
 ;; configure the variable `org-modules'.
 ;;
-;; Please customize the variable `org-default-extensions' to select
+;; Please customize the variable `org-modules' to select
 ;; extensions you would like to use, and to deselect those which you don't
 ;; want.
 ;;
--- a/lisp/org/org-jsinfo.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-jsinfo.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-list.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-list.el	Sun Nov 23 13:37:44 2008 +0000
@@ -6,7 +6,7 @@
 ;;         Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -72,6 +72,18 @@
 		 (const :tag "paren like in \"2)\"" ?\))
 		 (const :tab "both" t)))
 
+(defcustom org-list-two-spaces-after-bullet-regexp nil
+  "A regular expression matching bullets that should have 2 spaces after them.
+When nil, no bullet will have two spaces after them.
+When a string, it will be used as a regular expression.  When the bullet
+type of a list is changed, the new bullet type will be matched against this
+regexp.  If it matches, there will be two spaces instead of one after
+the bullet in each item of he list."
+  :group 'org-plain-list
+  :type '(choice
+	  (const :tag "never" nil)
+	  (regexp)))
+
 (defcustom org-empty-line-terminates-plain-lists nil
   "Non-nil means, an empty line ends all plain list levels.
 When nil, empty lines are part of the preceeding item."
@@ -259,7 +271,7 @@
  (save-excursion
    (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
 	  (beg (condition-case nil
-		   (progn (outline-back-to-heading) (point))
+		   (progn (org-back-to-heading) (point))
 		 (error (point-min))))
 	  (end (move-marker (make-marker)
 			    (progn (outline-next-heading) (point))))
@@ -589,7 +601,7 @@
    (beginning-of-line 1)
    (let ((current (match-string 0))
 	 (prevp (eq which 'previous))
-	 new)
+	 new old)
      (setq new (cond
 		((and (numberp which)
 		      (nth (1- which) '("-" "+" "*" "1." "1)"))))
@@ -597,10 +609,14 @@
 		((string-match "\\+" current)
 		 (if prevp "-" (if (looking-at "\\S-") "1." "*")))
 		((string-match "\\*" current) (if prevp "+" "1."))
-		((string-match "\\." current) (if prevp "*" "1)"))
+		((string-match "\\." current)
+		 (if prevp (if (looking-at "\\S-") "+" "*") "1)"))
 		((string-match ")" current) (if prevp "1." "-"))
 		(t (error "This should not happen"))))
-     (and (looking-at "\\([ \t]*\\)\\S-+") (replace-match (concat "\\1" new)))
+     (and (looking-at "\\([ \t]*\\)\\(\\S-+\\)")
+	  (setq old (match-string 2))
+	  (replace-match (concat "\\1" new)))
+     (org-shift-item-indentation (- (length new) (length old)))
      (org-fix-bullet-type)
      (org-maybe-renumber-ordered-list))))
 
@@ -629,7 +645,7 @@
 	      (buffer-substring (point-at-bol) (match-beginning 3))))
 	;; (term (substring (match-string 3) -1))
 	ind1 (n (1- arg))
-	fmt bobp)
+	fmt bobp old new)
     ;; find where this list begins
     (org-beginning-of-item-list)
     (setq bobp (bobp))
@@ -647,26 +663,32 @@
 	  (if (> ind1 ind) (throw 'next t))
 	  (if (< ind1 ind) (throw 'exit t))
 	  (if (not (org-at-item-p)) (throw 'exit nil))
+	  (setq old (match-string 2))
 	  (delete-region (match-beginning 2) (match-end 2))
 	  (goto-char (match-beginning 2))
-	  (insert (format fmt (setq n (1+ n)))))))
+	  (insert (setq new (format fmt (setq n (1+ n)))))
+	  (org-shift-item-indentation (- (length new) (length old))))))
     (goto-line line)
     (org-move-to-column col)))
 
 (defun org-fix-bullet-type ()
-  "Make sure all items in this list have the same bullet as the firsst item."
+  "Make sure all items in this list have the same bullet as the first item.
+Also, fix the indentation."
   (interactive)
   (unless (org-at-item-p) (error "This is not a list"))
   (let ((line (org-current-line))
 	(col (current-column))
 	(ind (current-indentation))
-	ind1 bullet)
+	ind1 bullet oldbullet)
     ;; find where this list begins
     (org-beginning-of-item-list)
     (beginning-of-line 1)
     ;; find out what the bullet type is
     (looking-at "[ \t]*\\(\\S-+\\)")
-    (setq bullet (match-string 1))
+    (setq bullet (concat (match-string 1) " "))
+    (if (and org-list-two-spaces-after-bullet-regexp
+	     (string-match org-list-two-spaces-after-bullet-regexp bullet))
+	(setq bullet (concat bullet " ")))
     ;; walk forward and replace these numbers
     (beginning-of-line 0)
     (catch 'exit
@@ -680,13 +702,31 @@
 	  (if (< ind1 ind) (throw 'exit t))
 	  (if (not (org-at-item-p)) (throw 'exit nil))
 	  (skip-chars-forward " \t")
-	  (looking-at "\\S-+")
-	  (replace-match bullet))))
+	  (looking-at "\\S-+ *")
+	  (setq oldbullet (match-string 0))
+	  (replace-match bullet)
+	  (org-shift-item-indentation (- (length bullet) (length oldbullet))))))
     (goto-line line)
     (org-move-to-column col)
     (if (string-match "[0-9]" bullet)
 	(org-renumber-ordered-list 1))))
 
+(defun org-shift-item-indentation (delta)
+  "Shift the indentation in current item by DELTA."
+  (save-excursion
+    (let ((beg (point-at-bol))
+	  (end (progn (org-end-of-item) (point)))
+	  i)
+      (goto-char end)
+      (beginning-of-line 0)
+      (while (> (point) beg)
+	(when (looking-at "[ \t]*\\S-")
+	  ;; this is not an empty line
+	  (setq i (org-get-indentation))
+	  (if (and (> i 0) (> (setq i (+ i delta)) 0))
+	      (indent-line-to i)))
+	(beginning-of-line 0)))))
+
 (defun org-beginning-of-item-list ()
   "Go to the beginning of the current item list.
 I.e. to the first item in this list."
--- a/lisp/org/org-mac-message.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-mac-message.el	Sun Nov 23 13:37:44 2008 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2008 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.12a
+;; Version: 6.13
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
--- a/lisp/org/org-macs.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-macs.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mew.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-mew.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 
 ;; This file is part of GNU Emacs.
 
@@ -34,21 +34,23 @@
 (require 'org)
 
 (defgroup org-mew nil
- "Options concerning the Mew link."
- :tag "Org Startup"
- :group 'org-link)
+  "Options concerning the Mew link."
+  :tag "Org Startup"
+  :group 'org-link)
 
 (defcustom org-mew-link-to-refile-destination t
- "Create a link to the refile destination if the message is marked as refile."
- :group 'org-mew
- :type 'boolean)
+  "Create a link to the refile destination if the message is marked as refile."
+  :group 'org-mew
+  :type 'boolean)
 
 ;; Declare external functions and variables
 (declare-function mew-cache-hit "ext:mew-cache" (fld msg &optional must-hit))
+(declare-function mew-case-folder "ext:mew-func" (case folder))
 (declare-function mew-header-get-value "ext:mew-header"
 		  (field &optional as-list))
 (declare-function mew-init "ext:mew" ())
 (declare-function mew-refile-get "ext:mew-refile" (msg))
+(declare-function mew-sinfo-get-case "ext:mew-summary" ())
 (declare-function mew-summary-display "ext:mew-summary2" (&optional redisplay))
 (declare-function mew-summary-folder-name "ext:mew-syntax" (&optional ext))
 (declare-function mew-summary-get-mark "ext:mew-mark" ())
@@ -69,17 +71,18 @@
 
 ;; Implementation
 (defun org-mew-store-link ()
- "Store a link to a Mew folder or message."
- (when (memq major-mode '(mew-summary-mode mew-virtual-mode))
-   (let* ((msgnum (mew-summary-message-number2))
+  "Store a link to a Mew folder or message."
+  (when (memq major-mode '(mew-summary-mode mew-virtual-mode))
+    (let* ((msgnum (mew-summary-message-number2))
 	   (mark-info (mew-summary-get-mark))
 	   (folder-name
 	    (if (and org-mew-link-to-refile-destination
 		     (eq mark-info ?o))	; marked as refile
-		(nth 1 (mew-refile-get msgnum))
+		(mew-case-folder (mew-sinfo-get-case)
+				 (nth 1 (mew-refile-get msgnum)))
 	      (mew-summary-folder-name)))
 	   message-id from to subject desc link)
-     (save-window-excursion
+      (save-window-excursion
 	(if (fboundp 'mew-summary-set-message-buffer)
 	    (mew-summary-set-message-buffer folder-name msgnum)
 	  (set-buffer (mew-cache-hit folder-name msgnum t)))
@@ -87,35 +90,35 @@
 	(setq from (mew-header-get-value "From:"))
 	(setq to (mew-header-get-value "To:"))
 	(setq subject (mew-header-get-value "Subject:")))
-     (org-store-link-props :type "mew" :from from :to to
+      (org-store-link-props :type "mew" :from from :to to
 			    :subject subject :message-id message-id)
-     (setq message-id (org-remove-angle-brackets message-id))
-     (setq desc (org-email-link-description))
-     (setq link (org-make-link "mew:" folder-name
+      (setq message-id (org-remove-angle-brackets message-id))
+      (setq desc (org-email-link-description))
+      (setq link (org-make-link "mew:" folder-name
 				"#" message-id))
-     (org-add-link-props :link link :description desc)
-     link)))
+      (org-add-link-props :link link :description desc)
+      link)))
 
 (defun org-mew-open (path)
- "Follow the Mew message link specified by PATH."
- (let (folder msgnum)
-   (cond ((string-match "\\`\\(+.*\\)+\\+\\([0-9]+\\)\\'" path) ; for Bastien's
+  "Follow the Mew message link specified by PATH."
+  (let (folder msgnum)
+    (cond ((string-match "\\`\\(+.*\\)+\\+\\([0-9]+\\)\\'" path) ; for Bastien's
 	   (setq folder (match-string 1 path))
 	   (setq msgnum (match-string 2 path)))
 	  ((string-match "\\`\\(\\(%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path)
 	   (setq folder (match-string 1 path))
 	   (setq msgnum (match-string 4 path)))
 	  (t (error "Error in Mew link")))
-   (require 'mew)
-   (mew-window-push)
-   (unless mew-init-p (mew-init))
-   (mew-summary-visit-folder folder)
-   (when msgnum
-     (if (not (string-match "\\`[0-9]+\\'" msgnum))
+    (require 'mew)
+    (mew-window-push)
+    (unless mew-init-p (mew-init))
+    (mew-summary-visit-folder folder)
+    (when msgnum
+      (if (not (string-match "\\`[0-9]+\\'" msgnum))
 	  (let* ((pattern (concat "message-id=" msgnum))
 		 (msgs (mew-summary-pick-with-mewl pattern folder nil)))
 	    (setq msgnum (car msgs))))
-     (if (mew-summary-search-msg msgnum)
+      (if (mew-summary-search-msg msgnum)
 	  (if mew-summary-goto-line-then-display
 	      (mew-summary-display))
 	(error "Message not found")))))
--- a/lisp/org/org-mhe.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-mhe.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-mouse.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-mouse.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -144,7 +144,7 @@
 (defvar org-agenda-undo-list)
 (defvar org-agenda-custom-commands)
 (declare-function org-agenda-change-all-lines "org-agenda"
-		  (newhead hdmarker &optional fixface just-this))
+		  (newhead hdmarker &optional fixface))
 (declare-function org-verify-change-for-undo "org-agenda" (l1 l2))
 
 (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
@@ -584,7 +584,7 @@
      (beginning-of-line)
      (looking-at "[ \t]*")
      (open-line 1)
-     (indent-to (- (match-end 0) (match-beginning 0)))
+     (org-indent-to-column (- (match-end 0) (match-beginning 0)))
      (insert "+ "))
 
     (:middle			; insert after
--- a/lisp/org/org-plot.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-plot.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-publish.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-publish.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -626,7 +626,7 @@
     (if index-buffer
 	(kill-buffer index-buffer))
     (with-temp-buffer
-      (insert (concat "* " index-title "\n\n"))
+      (insert (concat "#+TITLE: " index-title "\n\n"))
       (while (setq file (pop files))
 	(let ((fn (file-name-nondirectory file))
 	      (link (file-relative-name file dir))
@@ -703,7 +703,7 @@
 	    (if force nil org-publish-use-timestamps-flag)))
       (org-publish-projects
        (list (or project
-		 (assoc (completing-read
+		 (assoc (org-ido-completing-read
 			 "Publish project: "
 			 org-publish-project-alist nil t)
 			org-publish-project-alist)))))))
--- a/lisp/org/org-remember.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-remember.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -54,7 +54,7 @@
 (defcustom org-remember-store-without-prompt t
   "Non-nil means, `C-c C-c' stores remember note without further prompts.
 It then uses the file and headline specified by the template or (if the
-themplate does not specify them) by the variables `org-default-notes-file'
+template does not specify them) by the variables `org-default-notes-file'
 and `org-remember-default-headline'.  To force prompting anyway, use 
 `C-u C-c C-c' to file the note.
 
@@ -195,6 +195,26 @@
 			 (symbol :tag "Major mode"))
 		 (function :tag "Perform a check against function")))))
 
+(defcustom org-remember-before-finalize-hook nil
+  "Hook that is run right before a remember process is finalized.
+The remember buffer is still current when this hook runs."
+  :group 'org-remember
+  :type 'hook)
+
+(defvar org-remember-mode-map (make-sparse-keymap)
+  "Keymap for org-remember-mode, a minor mode.
+Use this map to set additional keybindings for when Org-mode is used
+for a Remember buffer.")
+(defvar org-remember-mode-hook nil
+  "Hook for the minor `org-remember-mode'.")
+
+(define-minor-mode org-remember-mode
+  "Minor mode for special key bindings in a remember buffer."
+  nil " Rem" org-remember-mode-map
+  (run-hooks 'org-remember-mode-hook))
+(define-key org-remember-mode-map "\C-c\C-c" 'org-remember-finalize)
+(define-key org-remember-mode-map "\C-c\C-k" 'org-remember-kill)
+
 (defcustom org-remember-clock-out-on-exit 'query
   "Non-nil means, stop the clock when exiting a clocking remember buffer.
 This only applies if the clock is running in the remember buffer.  If the
@@ -360,7 +380,7 @@
 		    v-a))
 	     (v-n user-full-name)
 	     (v-k (if (marker-buffer org-clock-marker)
-		      (substring-no-properties org-clock-heading)))
+		      (org-substring-no-properties org-clock-heading)))
 	     (v-K (if (marker-buffer org-clock-marker)
 		      (org-make-link-string
 		       (buffer-file-name (marker-buffer org-clock-marker))
@@ -446,8 +466,7 @@
 		 (replace-match x t t))))
 
 	;; Turn on org-mode in the remember buffer, set local variables
-	(let ((org-inhibit-startup t)) (org-mode))
-	(org-set-local 'org-finish-function 'org-remember-finalize)
+	(let ((org-inhibit-startup t)) (org-mode) (org-remember-mode 1))
 	(if (and file (string-match "\\S-" file) (not (file-directory-p file)))
 	    (org-set-local 'org-default-notes-file file))
 	(if headline
@@ -474,7 +493,7 @@
 		    (org-global-tags-completion-table
 		     (if (equal char "G") (org-agenda-files) (and file (list file)))))
 		   (org-add-colon-after-tag-completion t)
-		   (ins (completing-read
+		   (ins (org-ido-completing-read
 			 (if prompt (concat prompt ": ") "Tags: ")
 			 'org-tags-completion-function nil nil nil
 			 'org-tags-history)))
@@ -501,17 +520,23 @@
 						   (car clipboards))))))
 	   ((equal char "p")
 	    (let*
-		((prop (substring-no-properties prompt))
-		 (allowed (with-current-buffer
-			      (get-buffer (file-name-nondirectory file))
-			    (org-property-get-allowed-values nil prop 'table)))
+		((prop (org-substring-no-properties prompt))
+		 (pall (concat prop "_ALL"))
+		 (allowed
+		  (with-current-buffer
+		      (get-buffer (file-name-nondirectory file))
+		    (or (cdr (assoc pall org-file-properties))
+			(cdr (assoc pall org-global-properties))
+			(cdr (assoc pall org-global-properties-fixed)))))
 		 (existing (with-current-buffer
 			       (get-buffer (file-name-nondirectory file))
 			     (mapcar 'list (org-property-values prop))))
 		 (propprompt (concat "Value for " prop ": "))
 		 (val (if allowed
-			  (org-completing-read propprompt allowed nil
-					       'req-match)
+			  (org-completing-read
+			   propprompt
+			   (mapcar 'list (org-split-string allowed "[ \t]+"))
+			   nil 'req-match)
 			(org-completing-read propprompt existing nil nil
 					     "" nil ""))))
 	      (org-set-property prop val)))
@@ -524,17 +549,17 @@
 				   (member char '("u" "U"))
 				   nil nil (list org-end-time-was-given)))
 	   (t
-	    (insert (org-completing-read
-		     (concat (if prompt prompt "Enter string")
-			     (if default (concat " [" default "]"))
-			     ": ")
-		     completions nil nil nil histvar default)))))
+	    (let (org-completion-use-ido)
+	      (insert (org-completing-read
+		       (concat (if prompt prompt "Enter string")
+			       (if default (concat " [" default "]"))
+			       ": ")
+		       completions nil nil nil histvar default))))))
 	(goto-char (point-min))
 	(if (re-search-forward "%\\?" nil t)
 	    (replace-match "")
 	  (and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
-    (let ((org-inhibit-startup t)) (org-mode))
-    (org-set-local 'org-finish-function 'org-remember-finalize))
+    (let ((org-inhibit-startup t)) (org-mode) (org-remember-mode 1)))
   (when (save-excursion
 	  (goto-char (point-min))
 	  (re-search-forward "%&" nil t))
@@ -551,8 +576,7 @@
 This should be run in `post-command-hook' and will remove itself
 from that hook."
   (remove-hook 'post-command-hook 'org-remember-finish-immediately)
-  (when org-finish-function
-    (funcall org-finish-function)))
+  (org-remember-finalize))
 
 (defun org-remember-visit-immediately ()
   "File remember note immediately.
@@ -572,6 +596,10 @@
 (defvar org-clock-marker) ; Defined in org.el
 (defun org-remember-finalize ()
   "Finalize the remember process."
+  (interactive)
+  (unless org-remember-mode
+    (error "This does not seem to be a remember buffer for Org-mode"))
+  (run-hooks 'org-remember-before-finalize-hook)
   (unless (fboundp 'remember-finalize)
     (defalias 'remember-finalize 'remember-buffer))
   (when (and org-clock-marker
@@ -587,6 +615,12 @@
     (setq buffer-file-name nil))
   (remember-finalize))
 
+(defun org-remember-kill ()
+  "Abort the current remember process."
+  (interactive)
+  (let ((org-note-abort t))
+    (org-remember-finalize)))
+
 ;;;###autoload
 (defun org-remember (&optional goto org-force-remember-template-char)
   "Call `remember'.  If this is already a remember buffer, re-apply template.
@@ -610,7 +644,7 @@
     ;; `org-select-remember-template'
     (setq org-select-template-temp-major-mode major-mode)
     (setq org-select-template-original-buffer (current-buffer))
-    (if (eq org-finish-function 'org-remember-finalize)
+    (if org-remember-mode
 	(progn
 	  (when (< (length org-remember-templates) 2)
 	    (error "No other template available"))
@@ -769,6 +803,10 @@
 		 (not fastp))
 	(org-refile nil (or visiting (find-file-noselect file)))
 	(and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
+	(save-excursion
+	  (bookmark-jump "org-refile-last-stored")
+	  (bookmark-set "org-remember-last-stored")
+	  (move-marker org-remember-last-stored-marker (point)))
 	(throw 'quit t))
       ;; Find the file
       (if (not visiting) (find-file-noselect file))
--- a/lisp/org/org-rmail.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-rmail.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-table.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-table.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org-vm.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-vm.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -111,6 +111,7 @@
     (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly)
     (sit-for 0.1)
     (when article
+      (require 'vm-search)
       (vm-select-folder-buffer)
       (widen)
       (let ((case-fold-search t))
--- a/lisp/org/org-wl.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org-wl.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
--- a/lisp/org/org.el	Sun Nov 23 13:37:03 2008 +0000
+++ b/lisp/org/org.el	Sun Nov 23 13:37:44 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.12a
+;; Version: 6.13
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -92,7 +92,7 @@
 
 ;;; Version
 
-(defconst org-version "6.12a"
+(defconst org-version "6.13"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -125,7 +125,7 @@
   "Have the modules been loaded already?")
 
 (defun org-load-modules-maybe (&optional force)
-  "Load all extensions listed in `org-default-extensions'."
+  "Load all extensions listed in `org-modules'."
   (when (or force (not org-modules-loaded))
     (mapc (lambda (ext)
 	    (condition-case nil (require ext)
@@ -180,7 +180,9 @@
 	(const :tag "C  depend:            TODO dependencies for Org-mode" org-depend)
 	(const :tag "C  elisp-symbol:      Org links to emacs-lisp symbols" org-elisp-symbol)
 	(const :tag "C  eval:              Include command output as text" org-eval)
+	(const :tag "C  eval-light:        Evaluate inbuffer-code on demand" org-eval-light)
 	(const :tag "C  expiry:            Expiry mechanism for Org entries" org-expiry)
+	(const :tag "C  exp-blocks:        Pre-process blocks for export" org-exp-blocks)
 	(const :tag "C  id:                Global id's for identifying entries" org-id)
 	(const :tag "C  interactive-query: Interactive modification of tags query" org-interactive-query)
 	(const :tag "C  mairix:            Hook mairix search into Org for different MUAs" org-mairix)
@@ -843,7 +845,9 @@
      [[linkkey:tag][description]]
 
 If REPLACE is a string, the tag will simply be appended to create the link.
-If the string contains \"%s\", the tag will be inserted there.
+If the string contains \"%s\", the tag will be inserted there.  Alternatively,
+the placeholder \"%h\" will cause a url-encoded version of the tag to
+be inserted at that point (see the function `url-hexify-string').
 
 REPLACE may also be a function that will be called with the tag as the
 only argument to create the link, which should be returned as a string.
@@ -979,6 +983,20 @@
   :tag "Org Follow Link"
   :group 'org-link)
 
+(defcustom org-link-translation-function nil
+  "Function to translate links with different syntax to Org syntax.
+This can be used to translate links created for example by the Planner
+or emacs-wiki packages to Org syntax.
+The function must accept two parameters, a TYPE containing the link
+protocol name like \"rmail\" or \"gnus\" as a string, and the linked path,
+which is everything after the link protocol.  It should return a cons
+with possibly modifed values of type and path.
+Org contains a function for this, so if you set this variable to
+`org-translate-link-from-planner', you should be able follow many
+links created by planner."
+  :group 'org-link-follow
+  :type 'function)
+
 (defcustom org-follow-link-hook nil
   "Hook that is run after a link has been followed."
   :group 'org-link-follow
@@ -1304,11 +1322,11 @@
 		   (const :tag "Current buffer" nil)
 		   (function) (variable) (file))
 	   (choice :tag "Identify target headline by"
-	    (cons :tag "Specific tag" (const :tag) (string))
-	    (cons :tag "TODO keyword" (const :todo) (string))
-	    (cons :tag "Regular expression" (const :regexp) (regexp))
-	    (cons :tag "Level number" (const :level) (integer))
-	    (cons :tag "Max Level number" (const :maxlevel) (integer))))))
+	    (cons :tag "Specific tag" (const :value :tag) (string))
+	    (cons :tag "TODO keyword" (const :value :todo) (string))
+	    (cons :tag "Regular expression" (const :value :regexp) (regexp))
+	    (cons :tag "Level number" (const :value :level) (integer))
+	    (cons :tag "Max Level number" (const :value :maxlevel) (integer))))))
 
 (defcustom org-refile-use-outline-path nil
   "Non-nil means, provide refile targets as paths.
@@ -1699,7 +1717,7 @@
 org-mode generates a time duration."
   :group 'org-time
   :type 'string)
-  
+
 (defcustom org-deadline-warning-days 14
   "No. of days before expiration during which a deadline becomes active.
 This variable governs the display in sparse trees and in the agenda.
@@ -1996,7 +2014,8 @@
 
 (defcustom org-global-properties nil
   "List of property/value pairs that can be inherited by any entry.
-You can set buffer-local values for this by adding lines like
+You can set buffer-local values for the same purpose in the variable
+`org-file-properties' this by adding lines like
 
 #+PROPERTY: NAME VALUE"
   :group 'org-properties
@@ -2319,6 +2338,11 @@
   :tag "Org Completion"
   :group 'org)
 
+(defcustom org-completion-use-ido nil
+  "Non-ni means, use ido completion wherever possible."
+  :group 'org-completion
+  :type 'boolean)  
+
 (defcustom org-completion-fallback-command 'hippie-expand
   "The expansion command called by \\[org-complete] in normal context.
 Normal means, no org-mode-specific context."
@@ -2357,11 +2381,12 @@
 		  (extra txt &optional category tags dotime noprefix remove-re))
 (declare-function org-agenda-new-marker "org-agenda" (&optional pos))
 (declare-function org-agenda-change-all-lines "org-agenda"
-		  (newhead hdmarker &optional fixface just-this))
+		  (newhead hdmarker &optional fixface))
 (declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
 (declare-function org-agenda-maybe-redo "org-agenda" ())
 (declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
 		  (beg end))
+(declare-function org-agenda-copy-local-variable "org-agenda" (var))
 (declare-function parse-time-string "parse-time" (string))
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
@@ -2565,7 +2590,7 @@
 		     (<= org-clock-marker (point-at-eol)))
 	    ;; The clock is running here
 	    (setq org-clock-start-time
-		  (apply 'encode-time 
+		  (apply 'encode-time
 			 (org-parse-time-string (match-string 1))))
 	    (org-update-mode-line)))
 	 (t
@@ -2612,17 +2637,19 @@
 (defcustom org-archive-location "%s_archive::"
   "The location where subtrees should be archived.
 
-Otherwise, the value of this variable is a string, consisting of two
-parts, separated by a double-colon.
-
-The first part is a file name - when omitted, archiving happens in the same
-file.  %s will be replaced by the current file name (without directory part).
-Archiving to a different file is useful to keep archived entries from
-contributing to the Org-mode Agenda.
-
-The part after the double colon is a headline.  The archived entries will be
-filed under that headline.  When omitted, the subtrees are simply filed away
-at the end of the file, as top-level entries.
+The value of this variable is a string, consisting of two parts,
+separated by a double-colon.  The first part is a filename and
+the second part is a headline.
+
+When the filename is omitted, archiving happens in the same file.
+%s in the filename will be replaced by the current file
+name (without the directory part).  Archiving to a different file
+is useful to keep archived entries from contributing to the
+Org-mode Agenda.
+
+The archived entries will be filed as subtrees of the specified
+headline.  When the headline is omitted, the subtrees are simply
+filed away at the end of the file, as top-level entries.
 
 Here are a few examples:
 \"%s_archive::\"
@@ -2738,8 +2765,8 @@
 ;; Autoload ID code
 
 (org-autoload "org-id"
- '(org-id-get-create org-id-new org-id-copy org-id-get 
-   org-id-get-with-outline-path-completion 
+ '(org-id-get-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))
 
@@ -3397,6 +3424,8 @@
    "Matches a link with spaces, optional angular brackets around it.")
 (defvar org-link-re-with-space2 nil
    "Matches a link with spaces, optional angular brackets around it.")
+(defvar org-link-re-with-space3 nil
+   "Matches a link with spaces, only for internal part in bracket links.")
 (defvar org-angle-link-re nil
    "Matches link with angular brackets, spaces are allowed.")
 (defvar org-plain-link-re nil
@@ -3432,6 +3461,11 @@
 	 "\\([^" org-non-link-chars " ]"
 	 "[^\t\n\r]*"
 	 "[^" org-non-link-chars " ]\\)>?")
+	org-link-re-with-space3
+	(concat
+	 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
+	 "\\([^" org-non-link-chars " ]"
+	 "[^\t\n\r]*\\)")
 	org-angle-link-re
 	(concat
 	 "<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
@@ -4915,7 +4949,7 @@
 	  (goto-char (match-end 0))
 	  (setq col (current-column))
 	  (if (< diff 0) (replace-match ""))
-	  (indent-to (+ diff col))))
+	  (org-indent-to-column (+ diff col))))
       (move-marker end nil))))
 
 (defun org-convert-to-odd-levels ()
@@ -5094,7 +5128,7 @@
 (defun org-paste-subtree (&optional level tree for-yank)
   "Paste the clipboard as a subtree, with modification of headline level.
 The entire subtree is promoted or demoted in order to match a new headline
-level.  
+level.
 
 If the cursor is at the beginning of a headline, the same level as
 that headline is used to paste the tree
@@ -5369,13 +5403,13 @@
 
       (and (= (downcase sorting-type) ?f)
            (setq getkey-func
-                 (completing-read "Sort using function: "
+                 (org-ido-completing-read "Sort using function: "
                                   obarray 'fboundp t nil nil))
            (setq getkey-func (intern getkey-func)))
 
       (and (= (downcase sorting-type) ?r)
            (setq property
-                 (completing-read "Property: "
+                 (org-ido-completing-read "Property: "
 				  (mapcar 'list (org-buffer-property-keys t))
                                   nil t))))
 
@@ -5585,8 +5619,8 @@
     (beginning-of-line 1)
     (if (looking-at "[ \t]*[^:\n \t]")
 	nil
-      (if (looking-at "[ \t]*\\(\n\\|\\'\\)]")
-	  (setq beg (point) end (match-end 0))
+      (if (looking-at "[ \t]*\\(\n\\|\\'\\)")
+	  (setq beg (point) end beg)
 	(save-excursion
 	  (if (re-search-backward "^[ \t]*[^:]" nil 'move)
 	      (setq beg (point-at-bol 2))
@@ -5595,32 +5629,32 @@
 	  (if (re-search-forward "^[ \t]*[^:]" nil 'move)
 	      (setq end (1- (match-beginning 0)))
 	    (setq end (point))))
-	(goto-line line)
-	(if (get-buffer "*Org Edit Picture*")
-	    (kill-buffer "*Org Edit Picture*"))
-	(switch-to-buffer (make-indirect-buffer (current-buffer)
-						"*Org Edit Picture*"))
-	(narrow-to-region beg end)
-	(remove-text-properties beg end '(display nil invisible nil
-						  intangible nil))
-	(when (fboundp 'font-lock-unfontify-region)
-	  (font-lock-unfontify-region (point-min) (point-max)))
-	(cond
-	 ((eq org-edit-fixed-width-region-mode 'artist-mode)
-	  (fundamental-mode)
-	  (artist-mode 1))
-	 (t (funcall org-edit-fixed-width-region-mode)))
-	(set (make-local-variable 'org-edit-src-force-single-line) nil)
-	(set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
-	(set (make-local-variable 'org-edit-src-picture) t)
-	(goto-char (point-min))
-	(while (re-search-forward "^[ \t]*: " nil t)
-	  (replace-match ""))
-	(goto-line line)
-	(org-exit-edit-mode)
-	(org-set-local 'header-line-format msg)
-	(message "%s" msg)
-	t))))
+	(goto-line line))
+      (if (get-buffer "*Org Edit Picture*")
+	  (kill-buffer "*Org Edit Picture*"))
+      (switch-to-buffer (make-indirect-buffer (current-buffer)
+					      "*Org Edit Picture*"))
+      (narrow-to-region beg end)
+      (remove-text-properties beg end '(display nil invisible nil
+						intangible nil))
+      (when (fboundp 'font-lock-unfontify-region)
+	(font-lock-unfontify-region (point-min) (point-max)))
+      (cond
+       ((eq org-edit-fixed-width-region-mode 'artist-mode)
+	(fundamental-mode)
+	(artist-mode 1))
+       (t (funcall org-edit-fixed-width-region-mode)))
+      (set (make-local-variable 'org-edit-src-force-single-line) nil)
+      (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
+      (set (make-local-variable 'org-edit-src-picture) t)
+      (goto-char (point-min))
+      (while (re-search-forward "^[ \t]*: ?" nil t)
+	(replace-match ""))
+      (goto-line line)
+      (org-exit-edit-mode)
+      (org-set-local 'header-line-format msg)
+      (message "%s" msg)
+      t)))
 
 
 (defun org-edit-src-find-region-and-lang ()
@@ -5684,7 +5718,7 @@
 	   (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m))
       (match-string 1 m))
      (t "fundamental"))))
-      
+
 (defun org-edit-src-exit ()
   "Exit special edit and protect problematic lines."
   (interactive)
@@ -5711,6 +5745,7 @@
       (font-lock-unfontify-region (point-min) (point-max)))
     (put-text-property (point-min) (point-max) 'font-lock-fontified t))
   (when (org-bound-and-true-p org-edit-src-picture)
+    (untabify (point-min) (point-max))
     (goto-char (point-min))
     (while (re-search-forward "^" nil t)
       (replace-match ": "))
@@ -5819,6 +5854,8 @@
 	  '([(meta shift right)]  org-shiftmetaright)
 	  '([(shift up)]          org-shiftup)
 	  '([(shift down)]        org-shiftdown)
+	  '([(shift left)]        org-shiftleft)
+	  '([(shift right)]       org-shiftright)
 	  '("\C-c\C-c"            org-ctrl-c-ctrl-c)
 	  '("\M-q"                fill-paragraph)
 	  '("\C-c^"               org-sort)
@@ -5975,6 +6012,8 @@
 	  (cond
 	   ((symbolp rpl) (funcall rpl tag))
 	   ((string-match "%s" rpl) (replace-match (or tag "") t t rpl))
+	   ((string-match "%h" rpl)
+	    (replace-match (url-hexify-string (or tag "")) t t rpl))
 	   (t (concat rpl tag)))))
     link))
 
@@ -6049,7 +6088,7 @@
 into an org-buffer with \\[org-insert-link].
 
 For some link types, a prefix arg is interpreted:
-For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
+For links to usenet articles, arg negates `org-gnus-prefer-web-links'.
 For file links, arg negates `org-context-in-file-links'."
   (interactive "P")
   (org-load-modules-maybe)
@@ -6287,7 +6326,7 @@
 This is the list that is used before handing over to the browser.")
 
 (defun org-link-escape (text &optional table)
-  "Escape characters in TEXT that are problematic for links."
+  "Escape charaters in TEXT that are problematic for links."
   (setq table (or table org-link-escape-chars))
   (when text
     (let ((re (mapconcat (lambda (x) (regexp-quote
@@ -6485,7 +6524,7 @@
     ;; Check if we are linking to the current file with a search option
     ;; If yes, simplify the link by using only the search option.
     (when (and buffer-file-name
-	       (string-match "\\<file:\\(.+?\\)::\\([^>]+\\)" link))
+	       (string-match "^file:\\(.+?\\)::\\([^>]+\\)" link))
       (let* ((path (match-string 1 link))
 	     (case-fold-search nil)
 	     (search (match-string 2 link)))
@@ -6495,7 +6534,7 @@
 	      (setq link search)))))
 
     ;; Check if we can/should use a relative path.  If yes, simplify the link
-    (when (string-match "\\<file:\\(.*\\)" link)
+    (when (string-match "^file:\\(.*\\)" link)
       (let* ((path (match-string 1 link))
 	     (origpath path)
 	     (case-fold-search nil))
@@ -6534,6 +6573,15 @@
   (let ((minibuffer-local-completion-map
 	 (copy-keymap minibuffer-local-completion-map)))
     (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
+    (apply 'org-ido-completing-read args)))
+
+(defun org-ido-completing-read (&rest args)
+  "Completing-read using `ido-mode' speedups if available"
+  (if (and org-completion-use-ido
+	   (fboundp 'ido-completing-read)
+	   (boundp 'ido-mode) ido-mode
+	   (listp (second args)))
+      (apply 'ido-completing-read (concat (car args)) (cdr args))
     (apply 'completing-read args)))
 
 (defun org-extract-attributes (s)
@@ -6601,6 +6649,39 @@
       (setq org-link-search-failed t)
       (error "No further link found"))))
 
+(defun org-translate-link (s)
+  "Translate a link string if a translation function has been defined."
+  (if (and org-link-translation-function
+	   (fboundp org-link-translation-function)
+	   (string-match "\\([a-zA-Z0-9]+\\):\\(.*\\)" s))
+      (progn
+	(setq s (funcall org-link-translation-function
+			 (match-string 1) (match-string 2)))
+	(concat (car s) ":" (cdr s)))
+    s))
+
+(defun org-translate-link-from-planner (type path)
+  "Translate a link from Emacs Planner syntax so that Org can follow it.
+This is still an experimental function, your mileage may vary."
+ (cond
+  ((member type '("http" "https" "news" "ftp"))
+   ;; standard Internet links are the same.
+   nil)
+  ((and (equal type "irc") (string-match "^//" path))
+   ;; Planner has two / at the beginning of an irc link, we have 1.
+   ;; We should have zero, actually....
+   (setq path (substring path 1)))
+  ((and (equal type "lisp") (string-match "^/" path))
+   ;; Planner has a slash, we do not.
+   (setq type "elisp" path (substring path 1)))
+  ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path)
+   ;; A typical message link.  Planner has the id after the fina slash,
+   ;; we separate it with a hash mark
+   (setq path (concat (match-string 1 path) "#"
+		      (org-remove-angle-brackets (match-string 2 path)))))
+  )
+ (cons type path))
+
 (defun org-find-file-at-mouse (ev)
   "Open file link or URL at mouse."
   (interactive "e")
@@ -6611,6 +6692,8 @@
   "Open file link or URL at mouse."
   (interactive "e")
   (mouse-set-point ev)
+  (if (eq major-mode 'org-agenda-mode)
+      (org-agenda-copy-local-variable 'org-link-abbrev-alist-local))
   (org-open-at-point))
 
 (defvar org-window-config-before-follow-link nil
@@ -6668,7 +6751,7 @@
 	     ((or (file-name-absolute-p link)
 		  (string-match "^\\.\\.?/" link))
 	      (setq type "file" path link))
-	     ((string-match org-link-re-with-space2 link)
+	     ((string-match org-link-re-with-space3 link)
 	      (setq type (match-string 1 link) path (match-string 2 link)))
 	     (t (setq type "thisfile" path link)))
 	    (throw 'match t)))
@@ -6703,6 +6786,11 @@
       ;; Remove any trailing spaces in path
       (if (string-match " +\\'" path)
 	  (setq path (replace-match "" t t path)))
+      (if (and org-link-translation-function
+	       (fboundp org-link-translation-function))
+	  ;; Check if we need to translate the link
+	  (let ((tmp (funcall org-link-translation-function type path)))
+	    (setq type (car tmp) path (cdr tmp))))
 
       (cond
 
@@ -6787,7 +6875,10 @@
 			   (format "Execute \"%s\" as elisp? "
 				   (org-add-props cmd nil
 				     'face 'org-warning))))
-	      (message "%s => %s" cmd (eval (read cmd)))
+	      (message "%s => %s" cmd 
+		       (if (equal (string-to-char cmd) ?\()
+			   (eval (read cmd))
+			 (call-interactively (read cmd))))
 	    (error "Abort"))))
 
        (t
@@ -7311,7 +7402,7 @@
   (while (string-match "/" s)
     (setq s (replace-match "\\" t t s)))
   s)
-    
+
 (defun org-get-outline-path ()
   "Return the outline path to the current entry, as a list."
   (let (rtn)
@@ -7415,7 +7506,7 @@
   (let* ((cbuf (current-buffer))
 	 (cfunc (if org-refile-use-outline-path
 		    'org-olpath-completing-read
-		  'completing-read))
+		  'org-ido-completing-read))
 	 (extra (if org-refile-use-outline-path "/" ""))
 	 (filename (buffer-file-name (buffer-base-buffer cbuf)))
 	 (fname (and filename (file-truename filename)))
@@ -7434,8 +7525,8 @@
 (defun org-olpath-completing-read (prompt collection &rest args)
   "Read an outline path like a file name."
   (let ((thetable collection))
-    (apply 
-     'completing-read prompt
+    (apply
+     'org-ido-completing-read prompt
      (lambda (string predicate &optional flag)
        (let (rtn r s f (l (length string)))
 	 (cond
@@ -7591,7 +7682,7 @@
 
 (defcustom org-structure-template-alist
   '(
-    ("s" "#+begin_src ?\n\n#+end_src" 
+    ("s" "#+begin_src ?\n\n#+end_src"
          "<src lang=\"?\">\n\n</src>")
     ("e" "#+begin_example\n?\n#+end_example"
          "<example>\n?\n</example>")
@@ -7620,7 +7711,7 @@
 There are two templates for each key, the first uses the original Org syntax,
 the second uses Emacs Muse-like syntax tags.  These Muse-like tags become
 the default when the /org-mtags.el/ module has been loaded. See also the
-variable `org-mtags-prefere-muse-templates'.
+variable `org-mtags-prefer-muse-templates'.
 This is an experimental feature, it is undecided if it is going to stay in."
   :group 'org-completion
   :type '(repeat
@@ -7643,7 +7734,7 @@
 
 (defun org-complete-expand-structure-template (start cell)
   "Expand a structure template."
-  (let* ((musep (org-bound-and-true-p org-mtags-prefere-muse-templates))
+  (let* ((musep (org-bound-and-true-p org-mtags-prefer-muse-templates))
 	 (rpl (nth (if musep 2 1) cell)))
     (delete-region start (point))
     (when (string-match "\\`#\\+" rpl)
@@ -7654,7 +7745,7 @@
        (t (newline))))
     (setq start (point))
     (if (string-match "%file" rpl)
-	(setq rpl (replace-match 
+	(setq rpl (replace-match
 		   (concat
 		    "\""
 		    (save-match-data
@@ -7663,7 +7754,7 @@
 		   t t rpl)))
     (insert rpl)
     (if (re-search-backward "\\?" start t) (delete-char 1))))
-    
+
 
 (defun org-complete (&optional arg)
   "Perform completion on word at point.
@@ -7919,7 +8010,7 @@
 			   (or (not org-use-fast-todo-selection)
 			       (not org-todo-key-trigger)))
 		      ;; Read a state with completion
-		      (completing-read "State: " (mapcar (lambda(x) (list x))
+		      (org-ido-completing-read "State: " (mapcar (lambda(x) (list x))
 							 org-todo-keywords-1)
 				       nil t))
 		     ((eq arg 'right)
@@ -8069,7 +8160,7 @@
 	    (condition-case nil
 		(org-forward-same-level 1)
 	      (error (end-of-line 1)))))
-	(replace-match 
+	(replace-match
 	 (if is-percent
 	     (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
 	   (format "[%d/%d]" cnt-done cnt-all)))
@@ -8106,7 +8197,7 @@
       (setq changes (append changes (cdr (assoc 'done l)))))
     (dolist (c changes)
       (org-toggle-tag (car c) (if (cdr c) 'on 'off)))))
-	 
+
 (defun org-local-logging (value)
   "Get logging settings from a property VALUE."
   (let* (words w a)
@@ -8329,7 +8420,7 @@
 	(kwd-re
 	 (cond ((null arg) org-not-done-regexp)
 	       ((equal arg '(4))
-		(let ((kwd (completing-read "Keyword (or KWD1|KWD2|...): "
+		(let ((kwd (org-ido-completing-read "Keyword (or KWD1|KWD2|...): "
 					    (mapcar 'list org-todo-keywords-1))))
 		  (concat "\\("
 			  (mapconcat 'identity (org-split-string kwd "|") "\\|")
@@ -8507,7 +8598,7 @@
     (save-excursion
       (when findpos
 	(org-back-to-heading t)
-	(narrow-to-region (point) (save-excursion 
+	(narrow-to-region (point) (save-excursion
 				    (outline-next-heading) (point)))
 	(looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
 			    "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
@@ -8641,9 +8732,9 @@
      ((equal ans ?T)
       (call-interactively 'org-tags-sparse-tree))
      ((member ans '(?p ?P))
-      (setq kwd (completing-read "Property: "
+      (setq kwd (org-ido-completing-read "Property: "
 				 (mapcar 'list (org-buffer-property-keys))))
-      (setq value (completing-read "Value: "
+      (setq value (org-ido-completing-read "Value: "
 				   (mapcar 'list (org-property-values kwd))))
       (unless (string-match "\\`{.*}\\'" value)
 	(setq value (concat "\"" value "\"")))
@@ -8991,10 +9082,10 @@
 (defvar todo-only) ;; dynamically scoped
 
 (defun org-tags-sparse-tree (&optional todo-only match)
-  "Create a sparse tree according to tags string MATCH.
+  "Create a sparse tree according to tags  string MATCH.
 MATCH can contain positive and negative selection of tags, like
 \"+WORK+URGENT-WITHBOSS\".
-If optional argument TODO-ONLY is non-nil, only select lines that are
+If optional argument TODO_ONLY is non-nil, only select lines that are
 also TODO lines."
   (interactive "P")
   (org-prepare-agenda-buffers (list (current-buffer)))
@@ -9039,7 +9130,7 @@
     ;; Get a new match request, with completion
     (let ((org-last-tags-completion-table
 	   (org-global-tags-completion-table)))
-      (setq match (completing-read
+      (setq match (org-ido-completing-read
 		   "Match: " 'org-tags-completion-function nil nil nil
 		   'org-tags-history))))
 
@@ -9187,11 +9278,19 @@
       (error 0.)))
    (t 0.)))
 
+(defun org-time-today ()
+  "Time in seconds today at 0:00.
+Returns the float number of seconds since the beginning of the
+epoch to the beginning of today (00:00)."
+  (float-time (apply 'encode-time
+		     (append '(0 0 0) (nthcdr 3 (decode-time))))))
+
 (defun org-matcher-time (s)
   (cond
-   ((equal s "<now>") (float-time))
-   ((equal s "<today>")
-    (float-time (append '(0 0 0) (nthcdr 3 (decode-time)))))
+   ((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))))
 
 (defun org-match-any-p (re list)
@@ -9349,7 +9448,7 @@
 		  (let ((org-add-colon-after-tag-completion t))
 		    (org-trim
 		     (org-without-partial-completion
-		      (completing-read "Tags: " 'org-tags-completion-function
+		      (org-ido-completing-read "Tags: " 'org-tags-completion-function
 				       nil nil current 'org-tags-history)))))))
 	(while (string-match "[-+&]+" tags)
 	  ;; No boolean logic, just a list
@@ -9392,7 +9491,7 @@
 		(if (org-mode-p)
 		    (org-get-buffer-tags)
 		  (org-global-tags-completion-table))))
-	   (completing-read
+	   (org-ido-completing-read
 	    "Tag: " 'org-tags-completion-function nil nil nil
 	    'org-tags-history))
 	 (progn
@@ -9603,7 +9702,7 @@
 		  (if exit-after-next (setq exit-after-next 'now)))
 		 ((= c ?\t)
 		  (condition-case nil
-		      (setq tg (completing-read
+		      (setq tg (org-ido-completing-read
 				"Tag: "
 				(or buffer-tags
 				    (with-current-buffer buf
@@ -9738,12 +9837,12 @@
      ((eq match t)   (setq matcher t))
      ((eq match nil) (setq matcher t))
      (t (setq matcher (if match (org-make-tags-matcher match) t))))
-    
+
     (when (eq scope 'tree)
       (org-back-to-heading t)
       (org-narrow-to-subtree)
       (setq scope nil))
-    
+
     (if (not scope)
 	(progn
 	  (org-prepare-agenda-buffers
@@ -10078,7 +10177,7 @@
 	      (move-marker org-entry-property-inherited-from (point))
 	      (throw 'ex tmp))
 	    (or (org-up-heading-safe) (throw 'ex nil)))))
-      (or tmp 
+      (or tmp
 	  (cdr (assoc property org-file-properties))
 	  (cdr (assoc property org-global-properties))
 	  (cdr (assoc property org-global-properties-fixed))))))
@@ -10239,7 +10338,7 @@
   (interactive
    (let* ((completion-ignore-case t)
 	  (keys (org-buffer-property-keys nil t t))
-	  (prop0 (completing-read "Property: " (mapcar 'list keys)))
+	  (prop0 (org-ido-completing-read "Property: " (mapcar 'list keys)))
 	  (prop (if (member prop0 keys)
 		    prop0
 		  (or (cdr (assoc (downcase prop0)
@@ -10264,7 +10363,7 @@
   "In the current entry, delete PROPERTY."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (completing-read
+	  (prop (org-ido-completing-read
 		 "Property: " (org-entry-properties nil 'standard))))
      (list prop)))
   (message "Property %s %s" property
@@ -10276,7 +10375,7 @@
   "Remove PROPERTY globally, from all entries."
   (interactive
    (let* ((completion-ignore-case t)
-	  (prop (completing-read
+	  (prop (org-ido-completing-read
 		 "Globally remove property: "
 		 (mapcar 'list (org-buffer-property-keys)))))
      (list prop)))
@@ -11129,7 +11228,7 @@
   "Convert a time stamp to an absolute day number.
 If there is a specifyer for a cyclic time stamp, get the closest date to
 DAYNR.
-PREFER and SHOW-ALL are passed through to `org-closest-date'."
+PREFER and SHOW_ALL are passed through to `org-closest-date'."
   (cond
    ((and daynr (string-match "\\`%%\\((.*)\\)" s))
     (if (org-diary-sexp-entry (match-string 1 s) "" date)
@@ -11149,8 +11248,8 @@
 (defun org-small-year-to-year (year)
   "Convert 2-digit years into 4-digit years.
 38-99 are mapped into 1938-1999.  1-37 are mapped into 2001-2007.
-The year 2000 cannot be abbreviated.  Any year larger than 99
-is returned unchanged."
+The year 2000 cannot be abbreviated.  Any year lager than 99
+is retrned unchanged."
   (if (< year 38)
       (setq year (+ 2000 year))
     (if (< year 100)
@@ -11600,11 +11699,11 @@
 	    (lambda (b) (string-match "\*Org .*Export" (buffer-name b))))
 	   ((eq predicate 'agenda)
 	    (lambda (b)
-	      (with-current-buffer b 
+	      (with-current-buffer b
 		(and (eq major-mode 'org-mode)
 		     (setq bfn (buffer-file-name b))
 		     (member (file-truename bfn) agenda-files)))))
-	   (t (lambda (b) (with-current-buffer b 
+	   (t (lambda (b) (with-current-buffer b
 			    (or (eq major-mode 'org-mode)
 				(string-match "\*Org .*Export"
 					      (buffer-name b)))))))))
@@ -11822,7 +11921,7 @@
 		(append org-done-keywords-for-agenda org-done-keywords))
 	  (setq org-todo-keyword-alist-for-agenda
 		(append org-todo-keyword-alist-for-agenda org-todo-key-alist))
-	  (setq org-tag-alist-for-agenda 
+	  (setq org-tag-alist-for-agenda
 		(append org-tag-alist-for-agenda org-tag-alist))
 
 	  (save-excursion
@@ -12574,7 +12673,14 @@
    (t (call-interactively 'org-next-item))))
 
 (defun org-shiftright (&optional arg)
-  "Next TODO keyword or timestamp one day later, depending on context."
+  "Cycle the thing at point or in the current line, depending on context.
+Depending on context, this does one of the following:
+
+- switch a timestamp at point one day into the future
+- on a headline, switch to the next TODO keyword.
+- on an item, switch entire list to the next bullet type
+- on a property line, switch to the next allowed value
+- on a clocktable definition line, move time block into the future"
   (interactive "P")
   (cond
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
@@ -12585,7 +12691,14 @@
    (t (org-shiftcursor-error))))
 
 (defun org-shiftleft (&optional arg)
-  "Previous TODO keyword or timestamp one day earlier, depending on context."
+  "Cycle the thing at point or in the current line, depending on context.
+Depending on context, this does one of the following:
+
+- switch a timestamp at point one day into the past
+- on a headline, switch to the previous TODO keyword.
+- on an item, switch entire list to the previous bullet type
+- on a property line, switch to the previous allowed value
+- on a clocktable definition line, move time block into the past"
   (interactive "P")
   (cond
    ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
@@ -13845,7 +13958,7 @@
 	       (goto-char (+ (match-beginning 1) 5))
 	     (goto-char (match-end 0)))
 	   (make-string (current-column) ?\ )))
-	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] \\)?")
+	((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)]  ?\\)?")
 	 (save-excursion
 	   (goto-char (match-end 0))
 	   (make-string (current-column) ?\ )))
@@ -14011,13 +14124,14 @@
 \[1] Basically, the test checks if the first non-white line is a heading
     and if there are no other headings with fewer stars."
   (interactive "P")
+  (setq this-command 'yank)
   (if arg
       (call-interactively 'yank)
     (let ((subtreep ; is kill a subtree, and the yank position appropriate?
 	   (and (org-kill-is-subtree-p)
 		(or (bolp)
 		    (and (looking-at "[ \t]*$")
-			 (string-match 
+			 (string-match
 			  "\\`\\*+\\'"
 			  (buffer-substring (point-at-bol) (point)))))))
 	  swallowp)
@@ -14046,12 +14160,15 @@
 	     "Yanked text not folded because that would swallow text"))
 	  (goto-char end)
 	  (skip-chars-forward " \t\n\r")
-	  (beginning-of-line 1)))
+	  (beginning-of-line 1)
+	  (push-mark beg 'nomsg)))
        ((and subtreep org-yank-adjusted-subtrees)
-	(org-paste-subtree nil nil 'for-yank))
+	(let ((beg (point-at-bol)))
+	  (org-paste-subtree nil nil 'for-yank)
+	  (push-mark beg 'nomsg)))
        (t
 	(call-interactively 'yank))))))
-  
+
 (defun org-yank-folding-would-swallow-text (beg end)
   "Would hide-subtree at BEG swallow any text after END?"
   (let (level)
@@ -14086,7 +14203,13 @@
 	(outline-invisible-p)
       (get-char-property (point) 'invisible))))
 
-(defalias 'org-back-to-heading 'outline-back-to-heading)
+(defun org-back-to-heading (&optional invisible-ok)
+  "Call `outline-back-to-heading', but provide a better error message."
+  (condition-case nil
+      (outline-back-to-heading invisible-ok)
+    (error (error "Before first headline at position %d in buffer %s"
+		  (point) (current-buffer)))))
+
 (defalias 'org-on-heading-p 'outline-on-heading-p)
 (defalias 'org-at-heading-p 'outline-on-heading-p)
 (defun org-at-heading-or-item-p ()
@@ -14111,7 +14234,7 @@
   (let ((pos (point)) start-level level
 	(re (concat "^" outline-regexp)))
     (catch 'exit
-      (outline-back-to-heading t)
+      (org-back-to-heading t)
       (setq start-level (funcall outline-level))
       (if (equal start-level 1) (throw 'exit nil))
       (while (re-search-backward re nil t)
@@ -14187,7 +14310,7 @@
 Stop at the first and last subheadings of a superior heading.
 This is like outline-forward-same-level, but invisible headings are ok."
   (interactive "p")
-  (outline-back-to-heading t)
+  (org-back-to-heading t)
   (while (> arg 0)
     (let ((point-to-move-to (save-excursion
 			      (org-get-next-sibling))))