]> code.delx.au - gnu-emacs/commitdiff
2008-11-12 Carsten Dominik <carsten.dominik@gmail.com>
authorCarsten Dominik <dominik@science.uva.nl>
Wed, 12 Nov 2008 08:01:06 +0000 (08:01 +0000)
committerCarsten Dominik <dominik@science.uva.nl>
Wed, 12 Nov 2008 08:01:06 +0000 (08:01 +0000)
* org.el (org-yank): Make any prefix force normal yanking.
Suppress folding if text would be swallowed into a folded
subtree.
(org-yank-folded-subtrees, org-yank): Docstring updates.

* org-agenda.el (org-agenda-compare-effort): Treat no effort
defined as 0.

* org-exp.el (org-export-language-setup): Add Catalan and
Esperanto language entries.

2008-11-12  Carsten Dominik  <carsten.dominik@gmail.com>

* org.el (org-refile): Allow refiling of entire regions.

* org-clock.el (org-clock-time%): New function.

* org.el (org-entry-get, org-entry-delete): Use safer regexps to
retrieve property values.

2008-11-12  Carsten Dominik  <carsten.dominik@gmail.com>

* org-agenda.el (org-agenda-list): Handle the value `only' of
org-agenda-show-log'.
(org-agenda-log-mode): Interpret a double prefix arg.

2008-11-12  Carsten Dominik  <carsten.dominik@gmail.com>

* org-exp.el (org-export-html-footnotes-section): New variable.
(org-export-as-html): Use `org-export-html-footnotes-section' to
insert the footnotes.
(org-export-language-setup): Add "Footnotes" to language words.

2008-11-12  Carsten Dominik  <carsten.dominik@gmail.com>

* org.el (org-yank): Fix bug when not inserting a subtree.

2008-11-12  Carsten Dominik  <carsten.dominik@gmail.com>

* org-vm.el (org-vm-follow-link): Call `vm-preview-current-message'
instead of `vm-beginning-of-message'.

* org.el (org-make-link-regexps): Make sure that links to gnus can
contain brackets.

2008-11-12  Carsten Dominik  <carsten.dominik@gmail.com>

* org-attach.el (org-attach-dir): Remove duplicate ID creation
code.

* org-id.el (org-id-new): Use `org-trim' to extract the uuid from
shell output.

* org.el (org-link-abbrev-alist): Improve customization type.

* org-attach.el (org-attach-expand-link, org-attach-expand): New
functions.

* org-agenda.el (org-agenda-get-progress): Renamed from
`org-get-closed'.  Implement searching for state changes as well.
(org-agenda-log-mode-items): New option.
(org-agenda-log-mode): New option prefix argument, interpreted as
request to show all possible progress info.
(org-agenda-get-day-entries): Call `org-get-progress' instead of
`org-get-closed'.
(org-agenda-set-mode-name): Handle the more complex log mode
settings.
(org-get-closed): New alias, pointing to `org-get-progress'.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el (org-file-apps-defaults-gnu)
(org-file-apps-defaults-macosx)
(org-file-apps-defaults-windowsnt): Add an entry defining the
system command.
(org-file-apps): Allow `system' as key and value.
(org-open-at-point): Explain the effect of a double prefix arg.
(org-open-file): If the argument `in-emacs' is (16),
i.e. corresponding to a double prefix argument, try to open the
file externally.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el (org-insert-link): Abbreviate absolute files names in
links.  Also, fix a bug in which the double C-u prefix would not
be honored.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el (org-insert-heading): If buffer does not end with a
newline, add one if necessary to insert headline correctly.

* org-exp.el (org-export-as-html): Make sure that <hr/> is between
paragraphs, not inside.

* org.el (org-todo): Quote
`org-agenda-headline-snapshot-before-repeat'.

* org-exp.el (org-export-as-html): Fully process link descriptions.
(org-export-html-format-desc): New function.
(org-export-as-html): Collect footnotes into the correct basket.
(org-html-protect): No longer protect quotations marks here, this
goes wrong.

* org-agenda.el (org-agenda-remove-marked-text): Bind variable
BEG.

* org-compat.el (org-fit-window-to-buffer): New function (not
really, a preliminary and incomplete version was present earlier,
but not used).

* org.el (org-fast-todo-selection, org-fast-tag-selection): Use
`org-fit-window-to-buffer'.

* org-exp.el (org-export): Use `org-fit-window-to-buffer'.

* org-agenda.el (org-agenda-get-restriction-and-command)
(org-fit-agenda-window, org-agenda-convert-date): Use
`org-fit-window-to-buffer'.

* org-exp.el (org-export-as-html): Process href links through
`org-export-html-format-href'.
(org-export-html-format-href): New function.

* org-agenda.el (org-agenda-todo): Update only the current
headline if this is a repeated TODO, marked done for today.
(org-agenda-change-all-lines): New argument JUST-THIS, to change
only the current line.

* org.el (org-todo): Take a snapshot of the headline if the
repeater might change it.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org-publish.el (org-publish-find-title): Remove buffers visited
only for extracting the title.

* org-exp.el (org-export-html-style)
(org-export-html-style-default): Mark style definitions as
unparsed CDATA.

* org-publish.el (org-publish-validate-link): Function
re-introduced.

2008-11-12  Charles Sebold  <csebold@gmail.com>

* org-plot.el (org-plot/add-options-to-plist): Supports timefmt
property.
(org-plot-quote-timestamp-field): New function.
(org-plot-quote-tsv-field): Call timestamp field function when
necessary rather than just quoting as a string.
(org-plot/gnuplot-to-data): Pass in timefmt property.
(org-plot/gnuplot-script): Supports timefmt property.
(org-plot/gnuplot): Checks for timestamp column before checking
for text index column.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el (org-insert-heading): Improve behavior with hidden subtrees.

* org-publish.el (org-publish-org-index): Create a section in the
index file.
(org-publish-org-index): Stop linking to directories.

* org.el (org-emphasis-alist): Use span instead of <u> to
underline text.

* org-exp.el (org-export-as-html): Make sure <p> is closed before
<pre> sections.

2008-11-12  Sebastian Rose  <sebastian_rose@gmx.de>

* org-jsinfo.el (org-infojs-template): Remove language attribute
from script tag.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org-agenda.el (org-agenda-remove-marked-text): New function.
(org-agenda-mark-filtered-text)
(org-agenda-unmark-filtered-text): New functions.
(org-write-agenda): Remove fltered text.

* org.el (org-make-tags-matcher): Give access to TODO "property"
without speed penalty.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el (org-link-frame-setup): Add `org-gnus-no-new-news' as an
option.
(org-store-link-props): Make sure adding to the plist works
correctly.

* org-gnus.el (org-gnus-no-new-news): New function.
(org-gnus-follow-link): Allow the article ID to be a message-id,
in addition to allowing article numbers.  Message IDs make much
more roubust links.
(org-gnus-store-link): Use message-id to create link.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el (org-emphasize): Reverse the selection array.
(org-emphasis-alist): Set <code> tags for the verbatim
environment.

* org-remember.el (org-remember-handler): Fix bug with
prefix-related changing of the note storage target.

* org-exp.el (org-print-icalendar-entries): Make the exported
priorities compatible with RFC 2445.

* org-clock.el (org-clock-save): Insert time stamp without
dependence on time-stamp.el.

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org.el ("saveplace"): If saveplace puts point into an invisible
location, make it visible.
(org-make-tags-matcher): Allow inactive time stamps in time
comparisons.
(org-yank-adjusted-subtrees): New option.
(org-yank): Incorporate adjusting trees.
(org-paste-subtree): New argument FOR-YANK which will cause
insertion at point without backing up over white lines, and leave
point at the end of the inserted text.  Also if the cursor is
at the beginning of a headline, use the same level or the inserted
tree.

* org-publish.el (org-publish-get-base-files-1): Deal correctly
with broken symlinks

2008-11-12  Carsten Dominik  <dominik@science.uva.nl>

* org-exp.el (org-export-select-tags, org-get-current-options):
Fix typo.

30 files changed:
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

index eaa250584efbcd1c73f705322b7f7a3284378286..e538756cc105d004eed16372bc71b6fb9a94977e 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -389,7 +389,7 @@ or `C-c a #' to produce the list."
 
 (defcustom org-agenda-filter-effort-default-operator "<"
   "The default operator for effort estimate filtering.
-If you select an effort estimate limit with first pressing an operator,
+If you select an effort estimate limit without first pressing an operator,
 this one will be used."
   :group 'org-agenda-custom-commands
   :type '(choice (const :tag "less or equal" "<")
@@ -409,7 +409,7 @@ t, also all archive files associated with the current selection of agenda
 files will be included.")
 
 (defcustom org-agenda-skip-comment-trees t
-  "Non-nil means, skip trees that start with teh COMMENT keyword.
+  "Non-nil means, skip trees that start with the COMMENT keyword.
 When nil, these trees are also scand by agenda commands."
   :group 'org-agenda-skip
   :type 'boolean)
@@ -650,6 +650,16 @@ given here."
   :group 'org-agenda-daily/weekly
   :type 'number)
 
+(defcustom org-agenda-log-mode-items '(closed clock)
+  "List of items that should be shown in agenda log mode.
+This list may contain the following symbols:
+
+  closed    Show entries that have been closed on that day.
+  clock     Show entries that have received clocked time on that day.
+  state     Show all logged state changes."
+  :group 'org-agenda-daily/weekly
+  :type '(set :greedy t (const closed) (const clock) (const state)))
+
 (defcustom org-agenda-start-with-clockreport-mode nil
   "The initial value of clockreport-mode in a newly created agenda window."
   :group 'org-agenda-startup
@@ -1585,12 +1595,11 @@ s   Search for keywords                 C   Configure custom agenda commands
                                 "Prefix key"))))
                  prefixes))
          (goto-char (point-min))
-         (when (fboundp 'fit-window-to-buffer)
-           (if second-time
-               (if (not (pos-visible-in-window-p (point-max)))
-                   (fit-window-to-buffer))
-             (setq second-time t)
-             (fit-window-to-buffer)))
+         (if second-time
+             (if (not (pos-visible-in-window-p (point-max)))
+                 (org-fit-window-to-buffer))
+           (setq second-time t)
+           (org-fit-window-to-buffer))
          (message "Press key for agenda command%s:"
                   (if (or restrict-ok org-agenda-overriding-restriction)
                       (if org-agenda-overriding-restriction
@@ -1870,40 +1879,79 @@ higher priority settings."
   (org-let (if nosettings nil org-agenda-exporter-settings)
     '(save-excursion
        (save-window-excursion
-        (cond
-         ((string-match "\\.html?\\'" file)
-          (set-buffer (htmlize-buffer (current-buffer)))
-
-          (when (and org-agenda-export-html-style
-                     (string-match "<style>" org-agenda-export-html-style))
-            ;; replace <style> section with org-agenda-export-html-style
-            (goto-char (point-min))
-            (kill-region (- (search-forward "<style") 6)
-                         (search-forward "</style>"))
-            (insert org-agenda-export-html-style))
-          (write-file file)
-          (kill-buffer (current-buffer))
-          (message "HTML written to %s" file))
-         ((string-match "\\.ps\\'" file)
-          (ps-print-buffer-with-faces file)
-          (message "Postscript written to %s" file))
-         ((string-match "\\.ics\\'" file)
-          (let ((org-agenda-marker-table
-                 (org-create-marker-find-array
-                  (org-agenda-collect-markers)))
-                (org-icalendar-verify-function 'org-check-agenda-marker-table)
-                (org-combined-agenda-icalendar-file file))
-            (apply 'org-export-icalendar 'combine
-                   (org-agenda-files nil 'ifmode))))
-         (t
-          (let ((bs (buffer-string)))
-            (find-file file)
-            (erase-buffer)
+        (org-agenda-mark-filtered-text)
+        (let ((bs (copy-sequence (buffer-string))) beg)
+          (org-agenda-unmark-filtered-text)
+          (with-temp-buffer
             (insert bs)
-            (save-buffer 0)
-            (kill-buffer (current-buffer))
-            (message "Plain text written to %s" file))))))
+            (org-agenda-remove-marked-text 'org-filtered)
+            (while (setq beg (text-property-any (point-min) (point-max)
+                                                'org-filtered t))
+              (delete-region
+               beg (or (next-single-property-change beg 'org-filtered)
+                       (point-max))))
+            (cond
+             ((string-match "\\.html?\\'" file)
+              (set-buffer (htmlize-buffer (current-buffer)))
+              
+              (when (and org-agenda-export-html-style
+                         (string-match "<style>" org-agenda-export-html-style))
+                ;; replace <style> section with org-agenda-export-html-style
+                (goto-char (point-min))
+                (kill-region (- (search-forward "<style") 6)
+                             (search-forward "</style>"))
+                (insert org-agenda-export-html-style))
+              (write-file file)
+              (kill-buffer (current-buffer))
+              (message "HTML written to %s" file))
+             ((string-match "\\.ps\\'" file)
+              (ps-print-buffer-with-faces file)
+              (message "Postscript written to %s" file))
+             ((string-match "\\.ics\\'" file)
+              (let ((org-agenda-marker-table
+                     (org-create-marker-find-array
+                      (org-agenda-collect-markers)))
+                    (org-icalendar-verify-function 'org-check-agenda-marker-table)
+                    (org-combined-agenda-icalendar-file file))
+                (apply 'org-export-icalendar 'combine
+                       (org-agenda-files nil 'ifmode))))
+             (t
+              (let ((bs (buffer-string)))
+                (find-file file)
+                (erase-buffer)
+                (insert bs)
+                (save-buffer 0)
+                (kill-buffer (current-buffer))
+                (message "Plain text written to %s" file))))))))
     (set-buffer org-agenda-buffer-name)))
+(defvar org-agenda-filter-overlays nil)
+
+(defun org-agenda-mark-filtered-text ()
+  "Mark all text hidden by filtering with a text property."
+  (let ((inhibit-read-only t))
+    (mapc
+     (lambda (o)
+       (when (equal (org-overlay-buffer o) (current-buffer))
+        (put-text-property
+         (org-overlay-start o) (org-overlay-end o)
+         'org-filtered t)))
+     org-agenda-filter-overlays)))
+
+(defun org-agenda-unmark-filtered-text ()
+  "Remove the filtering text property."
+  (let ((inhibit-read-only t))
+    (remove-text-properties (point-min) (point-max) '(org-filtered t))))
+
+(defun org-agenda-remove-marked-text (property &optional value)
+  "Delete all text marked with VALUE of PROPERTY.
+VALUE defaults to t."
+  (let (beg)
+    (setq value (or value t))
+    (while (setq beg (text-property-any (point-min) (point-max)
+                                       property value))
+      (delete-region
+       beg (or (next-single-property-change beg 'org-filtered)
+              (point-max))))))
 
 (defun org-agenda-collect-markers ()
   "Collect the markers pointing to entries in the agenda buffer."
@@ -1952,7 +2000,7 @@ higher priority settings."
   "Fit the window to the buffer size."
   (and (memq org-agenda-window-setup '(reorganize-frame))
        (fboundp 'fit-window-to-buffer)
-       (fit-window-to-buffer
+       (org-fit-window-to-buffer
        nil
        (floor (* (frame-height) (cdr org-agenda-window-frame-fractions)))
        (floor (* (frame-height) (car org-agenda-window-frame-fractions))))))
@@ -2378,13 +2426,18 @@ given in `org-agenda-start-on-weekday'."
       (while (setq file (pop files))
        (catch 'nextfile
          (org-check-agenda-file file)
-         (if org-agenda-show-log
-             (setq rtn (org-agenda-get-day-entries
-                        file date
-                        :deadline :scheduled :timestamp :sexp :closed))
+         (cond
+          ((eq org-agenda-show-log 'only)
+           (setq rtn (org-agenda-get-day-entries
+                      file date :closed)))
+          (org-agenda-show-log
+           (setq rtn (org-agenda-get-day-entries
+                      file date
+                      :deadline :scheduled :timestamp :sexp :closed)))
+          (t
            (setq rtn (org-agenda-get-day-entries
                       file date
-                      :deadline :scheduled :sexp :timestamp)))
+                      :deadline :scheduled :sexp :timestamp))))
          (setq rtnall (append rtnall rtn))))
       (if org-agenda-include-diary
          (progn
@@ -3127,7 +3180,7 @@ the documentation of `org-diary'."
                  (setq rtn (org-agenda-get-scheduled))
                  (setq results (append results rtn)))
                 ((eq arg :closed)
-                 (setq rtn (org-agenda-get-closed))
+                 (setq rtn (org-agenda-get-progress))
                  (setq results (append results rtn)))
                 ((eq arg :deadline)
                  (setq rtn (org-agenda-get-deadlines))
@@ -3331,7 +3384,8 @@ the documentation of `org-diary'."
          (push txt ee))))
     (nreverse ee)))
 
-(defun org-agenda-get-closed ()
+(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
                      'org-not-done-regexp org-not-done-regexp
@@ -3341,8 +3395,20 @@ the documentation of `org-diary'."
                      'help-echo
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
+        (items (if (consp org-agenda-show-log)
+                   org-agenda-show-log
+                 org-agenda-log-mode-items))
+        (parts 
+         (delq nil
+               (list
+                (if (memq 'closed items) (concat "\\<" org-closed-string))
+                (if (memq 'clock items) (concat "\\<" org-clock-string))
+                (if (memq 'state items) "- State \"\\([a-zA-Z0-9]+\\)\""))))
+        (parts-re (if parts (mapconcat 'identity parts "\\|")
+                    (error "`org-agenda-log-mode-items' is empty")))
         (regexp (concat
-                 "\\<\\(" org-closed-string "\\|" org-clock-string "\\) *\\["
+                 "\\(" parts-re "\\)"
+                 " *\\["
                  (regexp-quote
                   (substring
                    (format-time-string
@@ -3350,7 +3416,7 @@ the documentation of `org-diary'."
                     (apply 'encode-time  ; DATE bound by calendar
                            (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
                    1 11))))
-        marker hdmarker priority category tags closedp
+        marker hdmarker priority category tags closedp statep state
         ee txt timestr rest clocked)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
@@ -3358,6 +3424,8 @@ the documentation of `org-diary'."
        (org-agenda-skip)
        (setq marker (org-agenda-new-marker (match-beginning 0))
              closedp (equal (match-string 1) org-closed-string)
+             statep (equal (string-to-char (match-string 1)) ?-)
+             state (and statep (match-string 2))
              category (org-get-category (match-beginning 0))
              timestr (buffer-substring (match-beginning 0) (point-at-eol))
              ;; donep (org-entry-is-done-p)
@@ -3366,7 +3434,7 @@ the documentation of `org-diary'."
          ;; substring should only run to end of time stamp
          (setq rest (substring timestr (match-end 0))
                timestr (substring timestr 0 (match-end 0)))
-         (if (and (not closedp)
+         (if (and (not closedp) (not statep)
                   (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)" rest))
              (progn (setq timestr (concat (substring timestr 0 -1)
                                           "-" (match-string 1 rest) "]"))
@@ -3380,8 +3448,10 @@ the documentation of `org-diary'."
                      tags (org-get-tags-at))
                (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
                (setq txt (org-format-agenda-item
-                          (if closedp "Closed:    "
-                            (concat "Clocked:   (" clocked  ")"))
+                          (cond
+                           (closedp "Closed:    ")
+                           (statep (concat "State:     (" state ")"))
+                           (t (concat "Clocked:   (" clocked  ")")))
                           (match-string 1) category tags timestr)))
            (setq txt org-agenda-no-heading-message))
          (setq priority 100000)
@@ -4238,7 +4308,7 @@ E looks line \"+<2:25\"."
 If the line does not have an effort defined, return nil."
   (let ((eff (get-text-property (point) 'effort-minutes)))
     (if (not eff)
-       nil ; we don't have an effort defined
+       0 ; we don't have an effort defined, treat as 0
       (funcall op eff value))))
 
 (defun org-agenda-filter-apply (filter)
@@ -4258,8 +4328,6 @@ If the line does not have an effort defined, return nil."
              (beginning-of-line 2))
          (beginning-of-line 2))))))
 
-(defvar org-agenda-filter-overlays nil)
-
 (defun org-agenda-filter-by-tag-hide-line ()
   (let (ov)
     (setq ov (org-make-overlay (max (point-min) (1- (point-at-bol)))
@@ -4565,11 +4633,18 @@ so that the date SD will be in that range."
   (message "Clocktable mode is %s"
           (if org-agenda-clockreport-mode "on" "off")))
 
-(defun org-agenda-log-mode ()
-  "Toggle log mode in an agenda buffer."
-  (interactive)
+(defun org-agenda-log-mode (&optional special)
+  "Toggle log mode in an agenda buffer.
+With argument SPECIAL, show all possible log items, not only the ones
+configured in `org-agenda-log-mode-items'.
+With a double `C-u' prefix arg, show *only* log items, nothing else."
+  (interactive "P")
   (org-agenda-check-type t 'agenda 'timeline)
-  (setq org-agenda-show-log (not org-agenda-show-log))
+  (setq org-agenda-show-log
+       (if (equal special '(16))
+           'only
+         (if special '(closed clock state)
+           (not org-agenda-show-log))))
   (org-agenda-set-mode-name)
   (org-agenda-redo)
   (message "Log mode is %s"
@@ -4622,7 +4697,8 @@ so that the date SD will be in that range."
                (if org-agenda-follow-mode     " Follow" "")
                (if org-agenda-include-diary   " Diary"  "")
                (if org-agenda-use-time-grid   " Grid"   "")
-               (if org-agenda-show-log        " Log"    "")
+               (if (consp org-agenda-show-log) " LogAll"
+                   (if org-agenda-show-log " Log" ""))
                (if org-agenda-filter
                    (concat " {" (mapconcat 'identity org-agenda-filter "") "}")
                  "")
@@ -4890,8 +4966,10 @@ the same tree node, and the headline of the tree node in the Org-mode file."
         (buffer (marker-buffer marker))
         (pos (marker-position marker))
         (hdmarker (get-text-property (point) 'org-hd-marker))
+        (todayp (equal (get-text-property (point) 'day)
+                       (time-to-days (current-time))))
         (inhibit-read-only t)
-        newhead)
+        org-agenda-headline-snapshot-before-repeat newhead just-one)
     (org-with-remote-undo buffer
       (with-current-buffer buffer
        (widen)
@@ -4903,12 +4981,19 @@ the same tree node, and the headline of the tree node in the Org-mode file."
        (org-todo arg)
        (and (bolp) (forward-char 1))
        (setq newhead (org-get-heading))
+       (when (and (org-bound-and-true-p
+                   org-agenda-headline-snapshot-before-repeat)
+                  (not (equal org-agenda-headline-snapshot-before-repeat
+                              newhead))
+                  todayp)
+         (setq newhead org-agenda-headline-snapshot-before-repeat
+               just-one t))
        (save-excursion
          (org-back-to-heading)
          (move-marker org-last-heading-marker (point))))
       (beginning-of-line 1)
       (save-excursion
-       (org-agenda-change-all-lines newhead hdmarker 'fixface))
+       (org-agenda-change-all-lines newhead hdmarker 'fixface just-one))
       (org-move-to-column col))))
 
 (defun org-agenda-add-note (&optional arg)
@@ -4930,7 +5015,7 @@ the same tree node, and the headline of the tree node in the Org-mode file."
             (org-flag-heading nil)))   ; show the next heading
       (org-add-note))))
 
-(defun org-agenda-change-all-lines (newhead hdmarker &optional fixface)
+(defun org-agenda-change-all-lines (newhead hdmarker &optional fixface just-this)
   "Change all lines in the agenda buffer which match HDMARKER.
 The new content of the line will be NEWHEAD (as modified by
 `org-format-agenda-item').  HDMARKER is checked with
@@ -4938,6 +5023,7 @@ The new content of the line will be NEWHEAD (as modified by
 If FIXFACE is non-nil, the face of each item is modified acording to
 the new TODO state."
   (let* ((inhibit-read-only t)
+        (line (org-current-line))
         props m pl undone-face done-face finish new dotime cat tags)
     (save-excursion
       (goto-char (point-max))
@@ -4945,6 +5031,7 @@ the new TODO state."
       (while (not finish)
        (setq finish (bobp))
        (when (and (setq m (get-text-property (point) 'org-hd-marker))
+                  (or (not just-this) (= (org-current-line) line))
                   (equal m hdmarker))
          (setq props (text-properties-at (point))
                dotime (get-text-property (point) 'dotime)
@@ -5450,8 +5537,7 @@ This is a command that has to be installed in `calendar-mode-map'."
             "Chinese:    " (calendar-chinese-date-string date) "\n"))
     (with-output-to-temp-buffer "*Dates*"
       (princ s))
-    (if (fboundp 'fit-window-to-buffer)
-       (fit-window-to-buffer (get-buffer-window "*Dates*")))))
+    (org-fit-window-to-buffer (get-buffer-window "*Dates*"))))
 
 ;;; Appointment reminders
 
index 75acc8e89ec613e9a6829e049535aa8db8e8dd46..d580db989fed1ab51ea1a04d88ed9823c65165e3 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 08b4a5997e627139039f04547d7e6cf7147e316a..feeb5f66a4d9211c1b63a109f083b714ae0f19a6 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: John Wiegley <johnw@newartisans.com>
 ;; Keywords: org data task
-;; Version: 6.10c
+;; Version: 6.12a
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -125,7 +125,7 @@ F       Like \"f\", but force using dired in Emacs.
 d       Delete one attachment, you will be prompted for a file name.
 D       Delete all of a task's attachments.  A safer way is
         to open the directory in dired and delete from there.")))
-         (shrink-window-if-larger-than-buffer (get-buffer-window "*Org Attach*"))
+         (org-fit-window-to-buffer (get-buffer-window "*Org Attach*"))
          (message "Select command: [acmlzoOfFdD]")
          (setq c (read-char-exclusive))
          (and (get-buffer "*Org Attach*") (kill-buffer "*Org Attach*"))))
@@ -156,11 +156,7 @@ the directory and the corresponding ID will be created."
   (let ((uuid (org-id-get (point) create-if-not-exists-p)))
     (when (or uuid create-if-not-exists-p)
       (unless uuid
-       (let ((uuid-string (shell-command-to-string "uuidgen")))
-         (setf uuid-string
-               (substring uuid-string 0 (1- (length uuid-string))))
-         (org-entry-put (point) "ID" uuid-string)
-         (setf uuid uuid-string)))
+       (error "ID retrieval/creation failed"))
       (let ((attach-dir (expand-file-name
                         (format "%s/%s"
                                 (substring uuid 0 2)
@@ -334,6 +330,17 @@ See `org-attach-open'."
   (interactive)
   (org-attach-open 'in-emacs))
 
+(defun org-attach-expand (file)
+  "Return the full path to the current entry's attachment file FILE.
+Basically, this adds the path to the attachment directory."
+  (expand-file-name file (org-attach-dir)))
+
+(defun org-attach-expand-link (file)
+  "Return a file link pointing to the current entry's attachment file FILE.
+Basically, this adds the path to the attachment directory, and a \"file:\"
+prefix."
+  (concat "file:" (org-attach-expand file)))
+
 (provide 'org-attach)
 
 ;; arch-tag: fce93c2e-fe07-4fa3-a905-e10dcc7a6248
index ca68a20f684c769aee3da4918da65cddda00dde8..13b3ff047dfd1306cfb19246ee2ae47f96767e1a 100644 (file)
@@ -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.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 94224afb100ae37915c6a0a81b6df96abeba239f..b457121e44667026c4bc4de9d78e836e1eb92c7d 100644 (file)
@@ -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.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index d5bfbf4690617568b9d49332ed4d2b045e6822d2..d54a490047669410244e7ce983981510f492012e 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -33,6 +33,7 @@
   (require 'calendar))
 
 (declare-function calendar-absolute-from-iso    "cal-iso"    (&optional date))
+(defvar org-time-stamp-formats)
 
 (defgroup org-clock nil
   "Options concerning clocking working time in Org-mode."
@@ -95,6 +96,34 @@ The function is called with point at the beginning of the headline."
   :group 'org-clock
   :type 'integer)
 
+(defcustom org-clock-in-resume nil
+  "If non-nil, when clocking into a task with a clock entry which
+has not been closed, resume the clock from that point"
+  :group 'org-clock
+  :type 'boolean)
+
+(defcustom org-clock-persist nil
+  "When non-nil, save the running clock when emacs is closed, and
+  resume it next time emacs is started."
+  :group 'org-clock
+  :type 'boolean)
+
+(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el"
+  "File to save clock data to"
+  :group 'org-clock
+  :type 'string)
+
+(defcustom org-clock-persist-query-save nil
+  "When non-nil, ask before saving the current clock on exit"
+  :group 'org-clock
+  :type 'boolean)
+
+(defcustom org-clock-persist-query-resume t
+  "When non-nil, ask before resuming any stored clock during
+load."
+  :group 'org-clock
+  :type 'boolean)
+
 ;;; The clock for measuring work time.
 
 (defvar org-mode-line-string "")
@@ -175,9 +204,7 @@ of a different task.")
                      (+ i (- ?A 10))) m))
           (push s sel-list)))
        org-clock-history)
-      (if (fboundp 'fit-window-to-buffer)
-         (fit-window-to-buffer)
-       (shrink-window-if-larger-than-buffer))
+      (org-fit-window-to-buffer)
       (message (or prompt "Select task for clocking:"))
       (setq rpl (read-char-exclusive))
       (cond
@@ -291,12 +318,21 @@ the clocking selection, associated with the letter `d'."
                      (t "???")))
          (setq org-clock-heading (org-propertize org-clock-heading 'face nil))
          (org-clock-find-position)
-
-         (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 (current-time) 'with-hm 'inactive))
+         (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
+             (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)
@@ -783,7 +819,7 @@ the currently selected interval size."
           (te (plist-get params :tend))
           (block (plist-get params :block))
           (link (plist-get params :link))
-          ipos time p level hlc hdl
+          ipos time p level hlc hdl content recalc formula pcol
           cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list)
       (setq org-clock-file-total-minutes nil)
       (when step
@@ -923,9 +959,37 @@ the currently selected interval size."
                                  'identity (delq nil tbl)
                                  (if scope-is-list "\n|-\n" "\n")))
          (backward-delete-char 1)
+         (if (setq formula (plist-get params :formula))
+             (cond
+              ((eq formula '%)
+               (setq pcol (+ (if scope-is-list 1 0) maxlevel 3))
+               (insert 
+                (format 
+                 "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f"
+                 pcol
+                 2
+                 (+ 3 (if scope-is-list 1 0))
+                 (+ (if scope-is-list 1 0) 3)
+                 (1- pcol)))
+               (setq recalc t))
+              ((stringp formula)
+               (insert "\n#+TBLFM: " formula)
+               (setq recalc t))
+              (t (error "invalid formula in clocktable")))
+           ;; Should we rescue an old formula?
+           (when (stringp (setq content (plist-get params :content)))
+             (when (string-match "^\\(#\\+TBLFM:.*\\)" content)
+               (setq recalc t)
+               (insert "\n" (match-string 1 (plist-get params :content)))
+               (beginning-of-line 0))))
          (goto-char ipos)
          (skip-chars-forward "^|")
          (org-table-align)
+         (when recalc
+           (if (eq formula '%)
+               (save-excursion (org-table-goto-column pcol nil 'force)
+                               (insert "%")))
+           (org-table-recalculate 'all))
          (when rm-file-column
            (forward-char 1)
            (org-table-delete-column)))))))
@@ -962,7 +1026,6 @@ the currently selected interval size."
       (re-search-forward "#\\+END:")
       (end-of-line 0))))
 
-
 (defun org-clocktable-add-file (file table)
   (if table
       (let ((lines (org-split-string table "\n"))
@@ -975,6 +1038,102 @@ the currently selected interval size."
                           lines)
                   "\n"))))
 
+(defun org-clock-time% (total &rest strings)
+  "Compute a time fraction in percent.
+TOTAL s a time string like 10:21 specifying the total times.
+STRINGS is a list of strings that should be checked for a time.
+The first string that does have a time will be used.
+This function is made for clock tables."
+  (let ((re "\\([0-9]+\\):\\([0-9]+\\)")
+       tot s)
+    (save-match-data
+      (catch 'exit
+       (if (not (string-match re total))
+           (throw 'exit 0.)
+         (setq tot (+ (string-to-number (match-string 2 total))
+                      (* 60 (string-to-number (match-string 1 total)))))
+         (if (= tot 0.) (throw 'exit 0.)))
+       (while (setq s (pop strings))
+         (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
+             (throw 'exit
+                    (/ (* 100.0 (+ (string-to-number (match-string 2 s))
+                                   (* 60 (string-to-number (match-string 1 s)))))
+                       tot))))
+       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)))))
+
+(defvar org-clock-loaded nil)
+
+(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)))))
+         (message "Not restoring clock data; %s not found"
+                  org-clock-persist-file)))))
+
+;;;###autoload
+(defun org-clock-persistence-insinuate ()
+  "Set up hooks for clock persistence"
+  (add-hook 'org-mode-hook 'org-clock-load)
+  (add-hook 'kill-emacs-hook 'org-clock-save))
+
 (provide 'org-clock)
 
 ;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
index 6580def46e2a24de17a8378b69222ef4ee8f1a08..b3be9f281619fef5403f8a189ba698f22e441003 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 075fbac46e966b32a2e389646f20271242539bc2..df0b187f472ff7cfd1d0a87b11e9c7a252e1b6e9 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -150,6 +150,22 @@ that will be added to PLIST.  Returns the string that was modified."
   string)
 (put 'org-add-props 'lisp-indent-function 2)
 
+(defun org-fit-window-to-buffer (&optional window max-height min-height
+                                          shrink-only)
+  "Fit WINDOW to the buffer, but only if it is not a side-by-side window.
+WINDOW defaults to the selected window.  MAX-HEIGHT and MIN-HEIGHT are
+passed through to `fit-window-to-buffer'.  If SHRINK-ONLY is set, call
+`shrink-window-if-larger-than-buffer' instead, the hight limit are
+ignored in this case."
+  (cond ((> (frame-width) (window-width window))
+        ;; do nothing if another window would suffer
+        )
+       ((and (fboundp 'fit-window-to-buffer) (not shrink-only))
+        (fit-window-to-buffer window max-height min-height))
+       ((fboundp 'shrink-window-if-larger-than-buffer)
+        (shrink-window-if-larger-than-buffer window)))
+  (or window (selected-window)))
+
 ;; Region compatibility
 
 (defvar org-ignore-region nil
index c5c0bb30d4710064d1cd776895ae01f5228665ae..87023e74c07115fdaf4b79e90ec6f2bda28520c4 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -70,7 +70,7 @@ force an export command into the current process."
 If any such tag is found in a buffer, all trees that do not carry one
 of these tags will be deleted before export.
 Inside trees that are selected like this, you can still deselect a
-subtree by tagging it with one of the `org-export-excude-tags'."
+subtree by tagging it with one of the `org-export-exclude-tags'."
   :group 'org-export-general
   :type '(repeat (string :tag "Tag")))
 
@@ -98,18 +98,24 @@ This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
   :type 'boolean)
 
 (defcustom org-export-language-setup
-  '(("en"  "Author"          "Date"  "Table of Contents")
-    ("cs"  "Autor"           "Datum" "Obsah")
-    ("da"  "Ophavsmand"      "Dato"  "Indhold")
-    ("de"  "Autor"           "Datum" "Inhaltsverzeichnis")
-    ("es"  "Autor"           "Fecha" "\xcdndice")
-    ("fr"  "Auteur"          "Date"  "Table des mati\xe8res")
-    ("it"  "Autore"          "Data"  "Indice")
-    ("nl"  "Auteur"          "Datum" "Inhoudsopgave")
-    ("no"  "Forfatter"       "Dato"  "Innhold")
-    ("nb"  "Forfatter"       "Dato"  "Innhold")  ;; nb = Norsk (bokm.l)
-    ("nn"  "Forfattar"       "Dato"  "Innhald")  ;; nn = Norsk (nynorsk)
-    ("sv"  "F\xf6rfattarens" "Datum" "Inneh\xe5ll"))
+  '(("en" "Author"     "Date"  "Table of Contents" "Footnotes")
+    ("ca"  "Autor"      "Data" "&Iacute;ndex" "Peus de p&agrave;gina")
+    ("cs" "Autor"      "Datum" "Obsah" "Pozn\xe1mky pod carou")
+    ("da" "Ophavsmand" "Dato"  "Indhold" "Fodnoter")
+    ("de" "Autor"      "Datum" "Inhaltsverzeichnis" "Fu&szlig;noten")
+    ("eo"  "A&#365;toro"      "Dato" "Enhavo" "Piednotoj")
+    ("es" "Autor"      "Fecha" "&Iacute;ndice" "Pies de p&aacute;gina")
+    ("fi" "Tekij&auml;"     "P&auml;iv&auml;m&auml;&auml;r&auml;"   "Sis&auml;llysluettelo"  "Alaviitteet")
+    ("fr" "Auteur"     "Date"  "Table des mati&egrave;res" "Notes de bas de page")
+    ("hu" "Szerz&otilde;" "D&aacute;tum" "Tartalomjegyz&eacute;k" "L&aacute;bjegyzet")
+    ("is" "H&ouml;fundur" "Dagsetning" "Efnisyfirlit" "Aftanm&aacute;lsgreinar")
+    ("it" "Autore"     "Data"  "Indice" "Note a pi&egrave; di pagina")
+    ("nl" "Auteur"     "Datum" "Inhoudsopgave" "Voetnoten")
+    ("no" "Forfatter"  "Dato"  "Innhold" "Fotnoter")
+    ("nb" "Forfatter"  "Dato"  "Innhold" "Fotnoter")  ;; nb = Norsk (bokm.l)
+    ("nn" "Forfattar"  "Dato"  "Innhald" "Fotnotar")  ;; nn = Norsk (nynorsk)
+    ("pl" "Autor"      "Data" "Spis tre&sacute;ci"  "Przypis")
+    ("sv" "F&ouml;rfattare" "Datum" "Inneh&aring;ll" "Fotnoter"))
   "Terms used in export text, translated to different languages.
 Use the variable `org-export-default-language' to set the language,
 or use the +OPTION lines for a per-file setting."
@@ -119,7 +125,8 @@ or use the +OPTION lines for a per-file setting."
           (string :tag "HTML language tag")
           (string :tag "Author")
           (string :tag "Date")
-          (string :tag "Table of Contents"))))
+          (string :tag "Table of Contents")
+          (string :tag "Footnotes"))))
 
 (defcustom org-export-default-language "en"
   "The default language of HTML export, as a string.
@@ -303,6 +310,19 @@ This option can also be set with the +OPTIONS line, e.g. \"f:nil\"."
   :group 'org-export-translation
   :type 'boolean)
 
+(defcustom org-export-html-footnotes-section "<div id=\"footnotes\">
+<h2 class=\"footnotes\">%s: </h2>
+<div id=\"footnotes-text\">
+%s
+</div> 
+</div>"
+  "Format for the footnotes section.
+Should contain a two instances of %s.  The first will be replaced with the
+language-specific word for \"Footnotes\", the second one will be replaced
+by the footnotes themselves."
+  :group 'org-export-html
+  :type 'string)
+
 (defcustom org-export-with-sub-superscripts t
   "Non-nil means, interpret \"_\" and \"^\" for export.
 When this option is turned on, you can use TeX-like syntax for sub- and
@@ -492,6 +512,7 @@ Org-mode file."
 
 (defconst org-export-html-style-default
 "<style type=\"text/css\">
+ <![CDATA[
   html { font-family: Times, serif; font-size: 12pt; }
   .title  { text-align: center; }
   .todo   { color: red; }
@@ -518,11 +539,23 @@ Org-mode file."
                                white-space:nowrap; }
   .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
                                  font-weight:bold; }
-
+ ]]>
 </style>"
   "The default style specification for exported HTML files.
 Please use the variables `org-export-html-style' and
-`org-export-html-style-extra' to add to this style.")
+`org-export-html-style-extra' to add to this style.  If you wish to not
+have the default style included, customize the variable
+`org-export-html-style-include-default'.")
+
+(defcustom org-export-html-style-include-default t
+  "Non-nil means, include the default style in exported HTML files.
+The actualy style is defined in `org-export-html-style-default' and should
+not be modified.  Use the variables `org-export-html-style' to add
+your own style information."
+  :group 'org-export-html
+  :type 'boolean)
+;;;###autoload
+(put 'org-export-html-style 'safe-local-variable 'booleanp)
 
 (defcustom org-export-html-style ""
   "Org-wide style definitions for exported HTML files.
@@ -535,11 +568,13 @@ you should consider to include definitions for the following classes:
 For example, a valid value would be:
 
    <style type=\"text/css\">
+    <![CDATA[
        p { font-weight: normal; color: gray; }
        h1 { color: black; }
       .title { text-align: center; }
       .todo, .timestamp-kwd { color: red; }
       .done { color: green; }
+    ]]>
    </style>
 
 If you'd like to refer to en external style file, use something like
@@ -812,6 +847,7 @@ or if they are only using it locally."
     (:time-stamp-file      . org-export-time-stamp-file)
     (:tables               . org-export-with-tables)
     (:table-auto-headline  . org-export-highlight-first-table-line)
+    (:style-include-default . org-export-html-style-include-default)
     (:style                . org-export-html-style)
     (:style-extra          . org-export-html-style-extra)
     (:agenda-style         . org-agenda-export-html-style)
@@ -1046,9 +1082,8 @@ value of `org-export-run-in-background'."
       (delete-other-windows)
       (with-output-to-temp-buffer "*Org Export/Publishing Help*"
        (princ help))
-      (if (fboundp 'fit-window-to-buffer)
-         (fit-window-to-buffer (get-buffer-window
-                                "*Org Export/Publishing Help*")))
+      (org-fit-window-to-buffer (get-buffer-window
+                                "*Org Export/Publishing Help*"))
       (message "Select command: ")
       (setq r1 (read-char-exclusive)))
     (setq r2 (if (< r1 27) (+ r1 96) r1))
@@ -2597,7 +2632,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
 #+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s
 %s
 #+EXPORT_SELECT_TAGS: %s
-#+EXPORT_EXCUDE_TAGS: %s
+#+EXPORT_EXCLUDE_TAGS: %s
 #+LINK_UP:   %s
 #+LINK_HOME: %s
 #+CATEGORY:  %s
@@ -2764,6 +2799,7 @@ in a window.  A non-interactive call will only return the buffer."
       rtn)))
 
 (defvar html-table-tag nil) ; dynamically scoped into this.
+(defvar org-par-open nil)
 ;;;###autoload
 (defun org-export-as-html (arg &optional hidden ext-plist
                               to-buffer body-only pub-dir)
@@ -2802,8 +2838,8 @@ PUB-DIR is set, use this as the publishing directory."
           (org-combine-plists (org-default-export-plist)
                               ext-plist
                               (org-infile-export-plist))))
-
-        (style (concat org-export-html-style-default
+        (style (concat (if (plist-get opt-plist :style-include-default)
+                           org-export-html-style-default)
                        (plist-get opt-plist :style)
                        (plist-get opt-plist :style-extra)))
         (html-extension (plist-get opt-plist :html-extension))
@@ -2915,6 +2951,7 @@ PUB-DIR is set, use this as the publishing directory."
         ind item-type starter didclose
         rpl path attr desc descp desc1 desc2 link
         snumber fnc item-tag
+        footnotes
         )
 
     (let ((inhibit-read-only t))
@@ -3085,6 +3122,7 @@ lang=\"%s\" xml:lang=\"%s\">
                     (string-match "^[ \t]*:\\(.*\\)" line))
            (when (not infixed)
              (setq infixed t)
+             (org-close-par-maybe)
              (insert "<pre class=\"example\">\n"))
            (insert (org-html-protect (match-string 1 line)) "\n")
            (when (or (not lines)
@@ -3112,7 +3150,9 @@ lang=\"%s\" xml:lang=\"%s\">
 
          ;; Horizontal line
          (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
-           (insert "\n<hr/>\n")
+           (if org-par-open
+               (insert "\n</p>\n<hr/>\n<p>\n")
+             (insert "\n<hr/>\n"))
            (throw 'nextline nil))
 
          ;; Blockquotes and verse
@@ -3202,7 +3242,9 @@ lang=\"%s\" xml:lang=\"%s\">
                     "<a href=\"#"
                     (org-solidify-link-text
                      (save-match-data (org-link-unescape path)) nil)
-                    "\"" attr ">" desc "</a>")))
+                    "\"" attr ">" 
+                    (org-export-html-format-desc desc)
+                    "</a>")))
             ((member type '("http" "https"))
              ;; standard URL, just check if we need to inline an image
              (if (and (or (eq t org-export-html-inline-images)
@@ -3210,12 +3252,19 @@ lang=\"%s\" xml:lang=\"%s\">
                       (org-file-image-p path))
                  (setq rpl (concat "<img src=\"" type ":" path "\"" attr "/>"))
                (setq link (concat type ":" path))
-               (setq rpl (concat "<a href=\"" link "\"" attr ">"
-                                 desc "</a>"))))
+               (setq rpl (concat "<a href=\"" 
+                                 (org-export-html-format-href link)
+                                 "\"" attr ">"
+                                 (org-export-html-format-desc desc)
+                                 "</a>"))))
             ((member type '("ftp" "mailto" "news"))
              ;; standard URL
              (setq link (concat type ":" path))
-             (setq rpl (concat "<a href=\"" link "\"" attr ">" desc "</a>")))
+             (setq rpl (concat "<a href=\""
+                               (org-export-html-format-href link)
+                               "\"" attr ">" 
+                               (org-export-html-format-desc desc)
+                               "</a>")))
 
             ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
              ;; The link protocol has a function for format the link
@@ -3261,7 +3310,8 @@ lang=\"%s\" xml:lang=\"%s\">
                                            (not descp))))
                              (concat "<img src=\"" thefile "\"" attr "/>")
                            (concat "<a href=\"" thefile "\"" attr ">"
-                                   desc "</a>")))
+                                   (org-export-html-format-desc desc)
+                                   "</a>")))
                (if (not valid) (setq rpl desc))))
 
             (t
@@ -3322,6 +3372,7 @@ lang=\"%s\" xml:lang=\"%s\">
                                  head-count)
            ;; QUOTES
            (when (string-match quote-re line)
+             (org-close-par-maybe)
              (insert "<pre>")
              (setq inquote t)))
 
@@ -3415,12 +3466,17 @@ lang=\"%s\" xml:lang=\"%s\">
 
            ;; Is this the start of a footnote?
            (when org-export-with-footnotes
+             (when (and (boundp 'footnote-section-tag-regexp)
+                        (string-match (concat "^" footnote-section-tag-regexp)
+                                      line))
+               ;; ignore this line
+               (throw 'nextline nil))
              (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
                (org-close-par-maybe)
                (let ((n (match-string 1 line)))
-                 (setq line (replace-match
-                             (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line))
-                 (setq line (concat line "</p>")))))
+                 (setq org-par-open t
+                       line (replace-match
+                             (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line)))))
 
            ;; Check if the line break needs to be conserved
            (cond
@@ -3432,7 +3488,9 @@ lang=\"%s\" xml:lang=\"%s\">
            (insert line "\n")))))
 
       ;; Properly close all local lists and other lists
-      (when inquote (insert "</pre>\n"))
+      (when inquote
+       (insert "</pre>\n")
+       (org-open-par))
       (when in-local-list
        ;; Close any local lists before inserting a new header line
        (while local-list-type
@@ -3447,6 +3505,16 @@ lang=\"%s\" xml:lang=\"%s\">
       ;; the </div> to close the last text-... div.
       (insert "</div>\n")
 
+      (save-excursion
+       (goto-char (point-min))
+       (while (re-search-forward "<p class=\"footnote\">[^\000]*?\\(</p>\\|\\'\\)" nil t)
+         (push (match-string 0) footnotes)
+         (replace-match "" t t)))
+      (when footnotes
+       (insert (format org-export-html-footnotes-section
+                       (or (nth 4 lang-words) "Footnotes")
+                       (mapconcat 'identity (nreverse footnotes) "\n"))
+               "\n"))
       (unless body-only
        (when (plist-get opt-plist :auto-postamble)
          (insert "<div id=\"postamble\">")
@@ -3525,6 +3593,21 @@ lang=\"%s\" xml:lang=\"%s\">
            (kill-buffer (current-buffer)))
        (current-buffer)))))
 
+(defun org-export-html-format-href (s)
+  "Make sure the S is valid as a href reference in an XHTML document."
+  (save-match-data
+    (let ((start 0))
+      (while (string-match "&" s start)
+       (setq start (+ (match-beginning 0) 3)
+             s (replace-match "&amp;" t t s)))))
+  s)
+
+(defun org-export-html-format-desc (s)
+  "Make sure the S is valid as a description in a link."
+  (if s
+      (save-match-data
+       (org-html-do-expand s))
+    s))
 
 (defvar org-table-colgroup-info nil)
 (defun org-format-table-ascii (lines)
@@ -3882,7 +3965,10 @@ that uses these same face definitions."
     (while (string-match "<" s)
       (setq s (replace-match "&lt;" t t s)))
     (while (string-match ">" s)
-      (setq s (replace-match "&gt;" t t s))))
+      (setq s (replace-match "&gt;" t t s)))
+;    (while (string-match "\"" s)
+;      (setq s (replace-match "&quot;" t t s)))
+    )
   s)
 
 (defun org-export-cleanup-toc-line (s)
@@ -4037,7 +4123,6 @@ stacked delimiters is N.  Escaping delimiters is not possible."
        (setq s (1+ s))))
     string))
 
-(defvar org-par-open nil)
 (defun org-open-par ()
   "Insert <p>, but first close previous paragraph if any."
   (org-close-par-maybe)
@@ -4384,9 +4469,9 @@ END:VEVENT\n"
                        hd (concat (substring hd 0 (match-beginning 1))
                                   (substring hd (match-end 1))))
                (setq pri org-default-priority))
-             (setq pri (floor (1+ (* 8. (/ (float (- org-lowest-priority pri))
-                                           (- org-lowest-priority org-highest-priority))))))
-
+             (setq pri (floor (- 9 (* 8. (/ (float (- org-lowest-priority pri))
+                                            (- org-lowest-priority org-highest-priority))))))
+             
              (princ (format "BEGIN:VTODO
 UID: %s
 %s
index 7a6cc8e3c980b3fff3185166619aa0473d663865..cf80dffa2200cfe77f6b02fffa5f3e31d8b759bf 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-export-latex.el
-;; Version: 6.10c
+;; Version: 6.12a
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: org, wp, tex
index 8244283be49a6df8f1b4505ce7ec514c6b408352..e24441135fae1b139353e13c8a2128e072bda93b 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index d31f9a7826ced3137d92ea9d4405a2bdd55d93b6..3f2781bbf365cff5f379648cab8dddd4a48f2971 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -96,12 +96,11 @@ negates this setting for the duration of the command."
       (setq desc (org-email-link-description))
       (if (org-xor current-prefix-arg org-usenet-links-prefer-google)
          (setq link
-               (concat
-                desc "\n  "
-                (format "http://groups.google.com/groups?as_umsgid=%s"
-                        (org-fixup-message-id-for-http message-id))))
-       (setq link (org-make-link "gnus:" group
-                                 "#" (number-to-string article))))
+               (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)))))
       (org-add-link-props :link link :description desc)
       link))))
 
@@ -121,9 +120,17 @@ negates this setting for the duration of the command."
   (if gnus-other-frame-object (select-frame gnus-other-frame-object))
   (cond ((and group article)
         (gnus-group-read-group 1 nil group)
-        (gnus-summary-goto-article (string-to-number article) nil t))
+        (gnus-summary-goto-article
+         (if (string-match "[^0-9]" article)
+             article
+           (string-to-number article))
+         nil t))
        (group (gnus-group-jump-to-group group))))
 
+(defun org-gnus-no-new-news ()
+  "Like `M-x gnus' but doesn't check for new news."
+  (if (not (gnus-alive-p)) (gnus)))
+
 (provide 'org-gnus)
 
 ;; arch-tag: 512e0840-58fa-45b3-b456-71e10fa2376d
index 5ba0c419a8a302d893d98bd9641f79c0006be31e..764c0254e75352ef0bcf029bd97840e13cabcee1 100644 (file)
@@ -4,7 +4,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -251,7 +251,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
     (if (equal prefix ":") (setq prefix ""))
     (cond
      ((eq org-id-method 'uuidgen)
-      (setq unique (substring (shell-command-to-string "uuidgen") 1 -1)))
+      (setq unique (org-trim (shell-command-to-string "uuidgen"))))
      ((eq org-id-method 'org)
       (let* ((etime (org-id-reverse-string (org-id-time-to-b36)))
             (postfix (if org-id-include-domain
index b664d61f6e7ca1402095e7245f5bed830e4381c8..20127e4aca7703decbe3962b9de8b303fa5e5f55 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index ed8e2fa68d2669f7a57839ea63c76c7f4e07e102..acc991858222d100cafa2198416c5401b2f1aa61 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Philip Jackson <emacs@shellarchive.co.uk>
 ;; Keywords: erc, irc, link, org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 17a029dfc93824a5cf57f5627674dfaa687a1516..93a57de618535076fa01f45af2d358a2c8ce0bcd 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -104,8 +104,8 @@ means to use the maximum value consistent with other options."
           org-infojs-opts-table)))
 
 (defcustom org-infojs-template
-  "<script type=\"text/javascript\" language=\"JavaScript\" src=\"%SCRIPT_PATH\"></script>
-<script type=\"text/javascript\" language=\"JavaScript\">
+  "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\"></script>
+<script type=\"text/javascript\" >
 /* <![CDATA[ */
 %MANAGER_OPTIONS
 org_html_manager.setup();  // activate after the parameterd are set
index 583042ed5f1394622da8dd81ecf2508913b37b92..0b3dd3d36012cdb5f0c4f0859550b29cda7bfa5b 100644 (file)
@@ -6,7 +6,7 @@
 ;;         Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index bd8e5d308b0ff8833ea29e3bb38b838f49ec5463..13fa6ddd7598e9d8eb4c27730513f5ef7511eb08 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2008 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Version: 6.10c
+;; Version: 6.12a
 ;; Keywords: outlines, hypermedia, calendar, wp
 
 ;; This file is part of GNU Emacs.
index 7cb39b76cf7cc41e177777cfc946f955e8608832..7f4f3d106fcf425c5c943c8c6f98d3bec13b6814 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index f056d27a9a5e067f24a479450ae862af4c47b612..f8c7f3f9167816767abce7102e72428bdd63f729 100644 (file)
@@ -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.10c
+;; Version: 6.12a
 
 ;; This file is part of GNU Emacs.
 
index 9fa6c6c54a2a58a26abcd8e1f529f34959d76740..19c7f5b1d30218f1d43de083e4400760366430dc 100644 (file)
@@ -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.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 07d12091796e61c66d3c544388fe04e9f327a2bb..8d203211e41380488000ef502a414e6c6ee2e954 100644 (file)
@@ -4,7 +4,7 @@
 ;;
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index db67257e51335748e76d7b1dffcbbf9dc702feaa..a469cf6168cffb29220e114905deb164812e766a 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
     (:ind . 0))
   "Default options to gnuplot used by `org-plot/gnuplot'")
 
+(defvar org-plot-timestamp-fmt nil)
+
 (defun org-plot/add-options-to-plist (p options)
   "Parse an OPTIONS line and set values in the property list P.
 Returns the resulting property list."
   (let (o)
     (when options
-      (let ((op '(("type"   . :plot-type)
-                 ("script" . :script)
-                 ("line"   . :line)
-                 ("set"    . :set)
-                 ("title"  . :title)
-                 ("ind"    . :ind)
-                 ("deps"   . :deps)
-                 ("with"   . :with)
-                 ("file"   . :file)
-                 ("labels" . :labels)
-                 ("map"    . :map)))
+      (let ((op '(("type"    . :plot-type)
+                 ("script"  . :script)
+                 ("line"    . :line)
+                 ("set"     . :set)
+                 ("title"   . :title)
+                 ("ind"     . :ind)
+                 ("deps"    . :deps)
+                 ("with"    . :with)
+                 ("file"    . :file)
+                 ("labels"  . :labels)
+                 ("map"     . :map)
+                  ("timefmt" . :timefmt)))
            (multiples '("set" "line"))
            (regexp ":\\([\"][^\"]+?[\"]\\|[(][^)]+?[)]\\|[^ \t\n\r;,.]*\\)")
            (start 0)
@@ -101,20 +104,31 @@ will be added.  Returns the resulting property list."
        (org-plot/add-options-to-plist params (match-string 1 line))
       params)))
 
+(defun org-plot-quote-timestamp-field (s)
+  "Convert field S from timestamp to Unix time and export to gnuplot."
+  (format-time-string org-plot-timestamp-fmt (org-time-string-to-time s)))
+
 (defun org-plot-quote-tsv-field (s)
   "Quote field S for export to gnuplot."
   (if (string-match org-table-number-regexp s) s
-    (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")))
+    (if (string-match org-ts-regexp3 s)
+        (org-plot-quote-timestamp-field s)
+      (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\""))))
 
 (defun org-plot/gnuplot-to-data (table data-file params)
   "Export TABLE to DATA-FILE in a format readable by gnuplot.
 Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
   (with-temp-file
-      data-file (insert (orgtbl-to-generic
-                        table
-                        (org-combine-plists
-                         '(:sep "\t" :fmt org-plot-quote-tsv-field)
-                         params))))
+      data-file 
+    (make-local-variable 'org-plot-timestamp-fmt)
+    (setq org-plot-timestamp-fmt (or
+                                  (plist-get params :timefmt)
+                                  "%Y-%m-%d-%H:%M:%S"))
+    (insert (orgtbl-to-generic
+             table
+             (org-combine-plists
+              '(:sep "\t" :fmt org-plot-quote-tsv-field)
+              params))))
   nil)
 
 (defun org-plot/gnuplot-to-grid-data (table data-file params)
@@ -180,6 +194,8 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
         (title (plist-get params :title))
         (file (plist-get params :file))
         (ind (plist-get params :ind))
+         (time-ind (plist-get params :timeind))
+         (timefmt (plist-get params :timefmt))
         (text-ind (plist-get params :textind))
         (deps (if (plist-member params :deps) (plist-get params :deps)))
         (col-labels (plist-get params :labels))
@@ -217,6 +233,11 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
                 (mapconcat (lambda (pair)
                              (format "\"%s\" %d" (cdr pair) (car pair)))
                            y-labels ", "))))
+      (when time-ind ;; timestamp index
+        (add-to-script "set xdata time")
+        (add-to-script (concat "set timefmt \""
+                               (or timefmt ;; timefmt passed to gnuplot
+                                   "%Y-%m-%d-%H:%M:%S") "\"")))
       (case type ;; plot command
        ('2d (dotimes (col num-cols)
               (unless (and (equal type '2d)
@@ -284,16 +305,24 @@ line directly before or after the table."
        ('grid (let ((y-labels (org-plot/gnuplot-to-grid-data
                                table data-file params)))
                 (when y-labels (plist-put params :ylabels y-labels)))))
-      ;; check for text ind column
+      ;; check for timestamp ind column
       (let ((ind (- (plist-get params :ind) 1)))
-       (when (and (>= ind 0) (equal '2d (plist-get params :plot-type)))
-         (if (> (length
-                 (delq 0 (mapcar
+        (when (and (>= ind 0) (equal '2d (plist-get params :plot-type)))
+          (if (= (length
+                  (delq 0 (mapcar
                           (lambda (el)
-                            (if (string-match org-table-number-regexp el)
+                            (if (string-match org-ts-regexp3 el)
                                 0 1))
                           (mapcar (lambda (row) (nth ind row)) table)))) 0)
-             (plist-put params :textind t))))
+             (plist-put params :timeind t)
+            ;; check for text ind column
+            (if (> (length
+                    (delq 0 (mapcar
+                             (lambda (el)
+                               (if (string-match org-table-number-regexp el)
+                                   0 1))
+                             (mapcar (lambda (row) (nth ind row)) table)))) 0)
+                (plist-put params :textind t)))))
       ;; write script
       (with-temp-buffer
        (if (plist-get params :script) ;; user script
@@ -307,7 +336,8 @@ line directly before or after the table."
        (gnuplot-mode)
        (gnuplot-send-buffer-to-gnuplot))
       ;; cleanup
-      (bury-buffer (get-buffer "*gnuplot*"))(delete-file data-file))))
+      (bury-buffer (get-buffer "*gnuplot*"))
+      (delete-file data-file))))
 
 (provide 'org-plot)
 
index 41d72878969ee1f306c251df3c77b7e5ab125215..aa8c495b732fa2d6f245f85794764992c823c765 100644 (file)
@@ -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.10c
+;; Version: 6.12a
 
 ;; This file is part of GNU Emacs.
 ;;
@@ -75,7 +75,7 @@
 ;;                   :with-section-numbers nil
 ;;                  :table-of-contents nil
 ;;                   :recursive t
-;;                  :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">")))
+;;                  :style "<link rel="stylesheet" href=\"../other/mystyle.css\" type=\"text/css\">")))
 
 ;;;; More complex example configuration:
 
 ;;                    :headline-levels 3
 ;;                     :with-section-numbers nil
 ;;                    :table-of-contents nil
-;;                    :style "<link rel=stylesheet href=\"../other/mystyle.css\" type=\"text/css\">"
+;;                    :style "<link rel="stylesheet" href=\"../other/mystyle.css\" type=\"text/css\">"
 ;;                    :auto-preamble t
 ;;                    :auto-postamble nil)
 ;;         ("images" :base-directory "~/images/"
@@ -364,6 +364,10 @@ Also set it if the optional argument REFRESH is non-nil."
     (setq org-publish-files-alist
          (org-publish-get-files org-publish-project-alist))))
 
+(defun org-publish-validate-link (link &optional directory)
+  "Check if LINK points to a file in the current project."
+  (assoc (expand-file-name link directory) org-publish-files-alist))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Compatibility aliases
 
@@ -427,7 +431,7 @@ MATCH.  If SKIP-FILE is non-nil, skip file matching the regexp
 SKIP-FILE.  If SKIP-DIR is non-nil, don't check directories
 matching the regexp SKIP-DIR when recursiing through BASE-DIR."
   (mapc (lambda (f)
-         (let ((fd-p (car (file-attributes f)))
+         (let ((fd-p (file-directory-p f))
                (fnd (file-name-nondirectory f)))
            (if (and fd-p recurse
                     (not (string-match "^\\.+$" fnd))
@@ -435,6 +439,7 @@ matching the regexp SKIP-DIR when recursiing through BASE-DIR."
                (org-publish-get-base-files-1 f recurse match skip-file skip-dir)
              (unless (or fd-p ;; this is a directory
                          (and skip-file (string-match skip-file fnd))
+                         (not (file-exists-p (file-truename f)))
                          (not (string-match match fnd)))
                (pushnew f org-publish-temp-files)))))
        (directory-files base-dir t (unless recurse match))))
@@ -529,6 +534,7 @@ See `org-publish-org-to' to the list of arguments."
 (defun org-publish-attachment (plist filename pub-dir)
   "Publish a file with no transformation of any kind.
 See `org-publish-org-to' to the list of arguments."
+  ;; make sure eshell/cp code is loaded
   (unless (file-directory-p pub-dir)
     (make-directory pub-dir t))
   (copy-file filename pub-dir))
@@ -620,7 +626,7 @@ Default for INDEX-FILENAME is 'index.org'."
     (if index-buffer
        (kill-buffer index-buffer))
     (with-temp-buffer
-      (insert (concat index-title "\n\n"))
+      (insert (concat "* " index-title "\n\n"))
       (while (setq file (pop files))
        (let ((fn (file-name-nondirectory file))
              (link (file-relative-name file dir))
@@ -640,13 +646,18 @@ Default for INDEX-FILENAME is 'index.org'."
                          (directory-file-name
                           (file-name-directory
                            (file-relative-name localdir dir))) "/"))
-                       (subdir ""))
+                       (subdir "")
+                       (old-subdirs (split-string
+                                     (file-relative-name oldlocal dir) "/")))
                    (setq indent-str (make-string 2 ?\ ))
+                   (while (string= (car old-subdirs) (car subdirs))
+                     (setq indent-str (concat indent-str (make-string 2 ?\ )))
+                     (pop old-subdirs)
+                     (pop subdirs))
                    (dolist (d subdirs)
                      (setq subdir (concat subdir d "/"))
-                     (insert (concat indent-str " + [[file:" 
-                                     subdir "][" d "/]]\n"))
-                     (setq indent-str (make-string 
+                     (insert (concat indent-str " + " d "\n"))
+                     (setq indent-str (make-string
                                        (+ (length indent-str) 2) ?\ )))))))
            ;; This is common to 'flat and 'tree
            (insert (concat indent-str " + [[file:" link "]["
@@ -658,16 +669,22 @@ Default for INDEX-FILENAME is 'index.org'."
 
 (defun org-publish-find-title (file)
   "Find the title of file in project."
-  (save-excursion
-    (set-buffer (find-file-noselect file))
-    (let* ((opt-plist (org-combine-plists (org-default-export-plist)
-                                         (org-infile-export-plist))))
-      (or (plist-get opt-plist :title)
-         (and (not
-               (plist-get opt-plist :skip-before-1st-heading))
-              (org-export-grab-title-from-buffer))
-         (file-name-nondirectory (file-name-sans-extension file))))))
-
+  (let* ((visiting (find-buffer-visiting file))
+        (buffer (or visiting (find-file-noselect file)))
+        title)
+    (save-excursion
+      (set-buffer buffer)
+      (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+                                           (org-infile-export-plist))))
+       (setq title
+             (or (plist-get opt-plist :title)
+                 (and (not
+                       (plist-get opt-plist :skip-before-1st-heading))
+                      (org-export-grab-title-from-buffer))
+                 (file-name-nondirectory (file-name-sans-extension file))))))
+    (unless visiting
+      (kill-buffer buffer))
+    title))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Interactive publishing functions
index 5424e007d8c8617e812bed965ff3e47d3c1bf696..7968f0a89455366b6b763a0c935b995bab0f5f6c 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -694,7 +694,7 @@ also indented so that it starts in the same column as the headline
 See also the variable `org-reverse-note-order'."
   (when (and (equal current-prefix-arg 2)
             (not (marker-buffer org-clock-marker)))
-    (error "No runing clock"))
+    (error "No running clock"))
   (when (org-bound-and-true-p org-jump-to-target-location)
     (let* ((end (min (point-max) (1+ (point))))
           (beg (point)))
@@ -733,10 +733,12 @@ See also the variable `org-reverse-note-order'."
        (setq visitp t))
       (when previousp
        (setq file (car org-remember-previous-location)
+             visiting (and file (org-find-base-buffer-visiting file))
              heading (cdr org-remember-previous-location)
              fastp t))
       (when clockp
        (setq file (buffer-file-name (marker-buffer org-clock-marker))
+             visiting (and file (org-find-base-buffer-visiting file))
              heading org-clock-heading-for-remember
              fastp t))
       (setq current-prefix-arg nil)
index 5d59cce887b7af6f6c448af8f99a13923cfb128c..8754f2a8c6ef1477c08e11b0fede43d90c65b51f 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index 08893a8d8f24bf897b071878b635f8d2f3c9975c..5394241654610ec663c4b75be00b01eabf044e74 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -2172,7 +2172,7 @@ $1->    %s\n" orig formula form0 form))
                             ev (or fmt "NONE")
                             (if fmt (format fmt (string-to-number ev)) ev)))))
          (setq bw (get-buffer-window "*Substitution History*"))
-         (shrink-window-if-larger-than-buffer bw)
+         (org-fit-window-to-buffer bw)
          (unless (and (interactive-p) (not ndown))
            (unless (let (inhibit-redisplay)
                      (y-or-n-p "Debugging Formula. Continue to next? "))
@@ -3490,7 +3490,7 @@ overwritten, and the table is not marked as requiring realignment."
        (self-insert-command N))
     (setq org-table-may-need-update t)
     (let (orgtbl-mode a)
-      (call-interactively
+      (call-interactively 
        (key-binding
        (or (and (listp function-key-map)
                 (setq a (assoc last-input-event function-key-map))
@@ -3569,7 +3569,7 @@ The table is taken from the parameter TXT, or from the buffer at point."
   (unless txt
     (unless (org-at-table-p)
       (error "No table at point")))
-  (let* ((txt (or txt
+  (let* ((txt (or txt 
                  (buffer-substring-no-properties (org-table-begin)
                                                  (org-table-end))))
         (lines (org-split-string txt "[ \t]*\n[ \t]*")))
index 053fcb5146cfcb493f18fb94ace335aab13a80fe..1195e1192f658852d4018e37b510994ba58ee5eb 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -33,7 +33,7 @@
 (require 'org)
 
 ;; Declare external functions and variables
-(declare-function vm-beginning-of-message "ext:vm-page" ())
+(declare-function vm-preview-current-message "ext:vm-page" ())
 (declare-function vm-follow-summary-cursor "ext:vm-motion" ())
 (declare-function vm-get-header-contents "ext:vm-summary"
                  (message header-name-regexp &optional clump-sep))
            (error "Could not find the specified message in this folder"))
        (vm-isearch-update)
        (vm-isearch-narrow)
-       (vm-beginning-of-message)
+       (vm-preview-current-message)
        (vm-summarize)))))
 
 (provide 'org-vm)
index 354f21f381c875b5cbb86226c0777c3b5564381c..ac2be1f409263fef9fad2ddc61ad9f09ebeb99e6 100644 (file)
@@ -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.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
index b9ee2fc098da189c2f719e547d33ba30c16e7db5..e0b0821195338c1c811a0fc3449dcb44bde0a9f7 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.10c
+;; Version: 6.12a
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -92,7 +92,7 @@
 
 ;;; Version
 
-(defconst org-version "6.10c"
+(defconst org-version "6.12a"
   "The version number of the file org.el.")
 
 (defun org-version (&optional here)
@@ -637,7 +637,15 @@ When t, the following will happen while the cursor is in the headline:
   "Non-nil means, when yanking subtrees, fold them.
 If the kill is a single subtree, or a sequence of subtrees, i.e. if
 it starts with a heading and all other headings in it are either children
-or siblings, then fold all the subtrees."
+or siblings, then fold all the subtrees.  However, do this only if no
+text after the yank would be swallowed into a folded tree by this action."
+  :group 'org-edit-structure
+  :type 'boolean)
+
+(defcustom org-yank-adjusted-subtrees t
+  "Non-nil means, when yanking subtrees, adjust the level.
+With this setting, `org-paste-subtree' is used to insert the subtree, see
+this function for details."
   :group 'org-edit-structure
   :type 'boolean)
 
@@ -842,7 +850,12 @@ only argument to create the link, which should be returned as a string.
 
 See the manual for examples."
   :group 'org-link
-  :type 'alist)
+  :type '(repeat
+         (cons
+          (string :tag "Protocol")
+          (choice
+           (string :tag "Format")
+           (function)))))
 
 (defcustom org-descriptive-links t
   "Non-nil means, hide link part and only show description of bracket links.
@@ -1011,6 +1024,7 @@ For VM, use any of
 For Gnus, use any of
     `gnus'
     `gnus-other-frame'
+    `org-gnus-no-new-news'
 For FILE, use any of
     `find-file'
     `find-file-other-window'
@@ -1028,7 +1042,8 @@ another window."
          (cons (const gnus)
                (choice
                 (const gnus)
-                (const gnus-other-frame)))
+                (const gnus-other-frame)
+                (const org-gnus-no-new-news)))
          (cons (const file)
                (choice
                 (const find-file)
@@ -1108,6 +1123,7 @@ single keystroke rather than having to type \"yes\"."
 
 (defconst org-file-apps-defaults-gnu
   '((remote . emacs)
+    (system . mailcap)
     (t . mailcap))
   "Default file applications on a UNIX or GNU/Linux system.
 See `org-file-apps'.")
@@ -1115,6 +1131,7 @@ See `org-file-apps'.")
 (defconst org-file-apps-defaults-macosx
   '((remote . emacs)
     (t . "open %s")
+    (system . "open %s")
     ("ps.gz"  . "gv %s")
     ("eps.gz" . "gv %s")
     ("dvi"    . "xdvi %s")
@@ -1128,6 +1145,11 @@ See `org-file-apps'.")
   (list
    '(remote . emacs)
    (cons t
+        (list (if (featurep 'xemacs)
+                  'mswindows-shell-execute
+                'w32-shell-execute)
+              "open" 'file))
+   (cons 'system
         (list (if (featurep 'xemacs)
                   'mswindows-shell-execute
                 'w32-shell-execute)
@@ -1156,11 +1178,15 @@ file identifier are
                Remote files most likely should be visited through Emacs
                because external applications cannot handle such paths.
 `auto-mode'    Matches files that are mached by any entry in `auto-mode-alist',
-               so all files Emacs knows how to handle.  Useing this with
+               so all files Emacs knows how to handle.  Using this with
                command `emacs' will open most files in Emacs.  Beware that this
                will also open html files insite Emacs, unless you add
                (\"html\" . default) to the list as well.
  t             Default for files not matched by any of the other options.
+ `system'      The system command to open files, like `open' on Windows
+               and Mac OS X, and mailcap under GNU/Linux.  This is the command
+               that will be selected if you call `C-c C-o' with a double
+               `C-u C-u' prefix.
 
 Possible values for the command are:
  `emacs'       The file will be visited by the current Emacs process.
@@ -1169,6 +1195,11 @@ Possible values for the command are:
                part.
                This can be used to overrule an unwanted seting in the
                system-specific variable.
+ `system'      Use the system command for opening files, like \"open\".
+               This command is specified by the entry whose car is `system'.
+               Most likely, the system-specific version of this variable
+               does define this command, but you can overrule/replace it
+               here.
  string        A command to be executed by a shell; %s will be replaced
               by the path to the file.
  sexp          A Lisp form which will be evaluated.  The file path will
@@ -1181,6 +1212,7 @@ For more examples, see the system specific constants
   :type '(repeat
          (cons (choice :value ""
                        (string :tag "Extension")
+                       (const :tag "System command to open files" system)
                        (const :tag "Default for unrecognized files" t)
                        (const :tag "Remote file" remote)
                        (const :tag "Links to a directory" directory)
@@ -1188,7 +1220,8 @@ For more examples, see the system specific constants
                               auto-mode))
                (choice :value ""
                        (const :tag "Visit with Emacs" emacs)
-                       (const :tag "Use system default" default)
+                       (const :tag "Use default" default)
+                       (const :tag "Use the system command" system)
                        (string :tag "Command")
                        (sexp :tag "Lisp form")))))
 
@@ -1262,7 +1295,7 @@ This is list of cons cells.  Each cell contains:
   - a cons cell (:maxlevel . N). Any headline with level <= N is a target.
 
 When this variable is nil, all top-level headlines in the current buffer
-are used, equivalent to the vlaue `((nil . (:level . 1))'."
+are used, equivalent to the value `((nil . (:level . 1))'."
   :group 'org-remember
   :type '(repeat
          (cons
@@ -1666,7 +1699,7 @@ end of the second format."
 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.
@@ -2255,9 +2288,9 @@ Use customize to modify this, or restart Emacs after changing it."
 (defcustom org-emphasis-alist
   `(("*" bold "<b>" "</b>")
     ("/" italic "<i>" "</i>")
-    ("_" underline "<u>" "</u>")
+    ("_" underline "<span style=\"text-decoration:underline;\">" "</span>")
     ("=" org-code "<code>" "</code>" verbatim)
-    ("~" org-verbatim "" "" verbatim)
+    ("~" org-verbatim "<code>" "</code>" verbatim)
     ("+" ,(if (featurep 'xemacs) 'org-table '(:strike-through t))
      "<del>" "</del>")
     )
@@ -2532,7 +2565,7 @@ Otherwise, return nil."
                     (<= 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
@@ -2705,8 +2738,8 @@ collapsed state."
 ;; 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,7 +3430,7 @@ This should be called after the variable `org-link-types' has changed."
        (concat
         "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
         "\\([^" org-non-link-chars " ]"
-        "[^]\t\n\r]*"
+        "[^\t\n\r]*"
         "[^" org-non-link-chars " ]\\)>?")
        org-angle-link-re
        (concat
@@ -3503,6 +3536,7 @@ will be prompted for."
       (push (cons c (string-to-char (car e))) det)
       (setq prompt (concat prompt (format " [%s%c]%s" (car e) c
                                          (substring tag 1)))))
+    (setq det (nreverse det))
     (unless char
       (message "%s" (concat "Emphasis marker or tag:" prompt))
       (setq char (read-char-exclusive)))
@@ -4419,7 +4453,7 @@ or nil."
           (error (make-indirect-buffer (current-buffer) "*org-goto*"))))
        (with-output-to-temp-buffer "*Help*"
          (princ help))
-       (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*"))
+       (org-fit-window-to-buffer (get-buffer-window "*Help*"))
        (setq buffer-read-only nil)
        (let ((org-startup-truncated t)
              (org-startup-folded nil)
@@ -4595,7 +4629,7 @@ frame is not changed."
 If point is in a plain list and FORCE-HEADING is nil, create a new list item.
 If point is at the beginning of a headline, insert a sibling before the
 current headline.  If point is not at the beginning, do not split the line,
-but create the new hedline after the current line."
+but create the new headline after the current line."
   (interactive "P")
   (if (= (buffer-size) 0)
       (insert "\n* ")
@@ -4607,7 +4641,7 @@ but create the new hedline after the current line."
                           (match-string 0))
                       (error "*"))))
             (blank (cdr (assq 'heading org-blank-before-new-entry)))
-            pos hide-previous)
+            pos hide-previous previous-pos)
        (cond
         ((and (org-on-heading-p) (bolp)
               (or (bobp)
@@ -4621,19 +4655,29 @@ but create the new hedline after the current line."
          ;; insert right here
          nil)
         (t
-         ;; in the middle of the line
+         ;; somewhere in the line
           (save-excursion
+           (setq previous-pos (point-at-bol))
             (end-of-line)
             (setq hide-previous (org-invisible-p)))
-         (org-show-entry)
+         (and org-insert-heading-respect-content (org-show-subtree))
          (let ((split
-                (org-get-alist-option org-M-RET-may-split-line 'headline))
+                (and (org-get-alist-option org-M-RET-may-split-line 'headline)
+                     (save-excursion
+                       (let ((p (point)))
+                         (goto-char (point-at-bol))
+                         (and (looking-at org-complex-heading-regexp)
+                              (> p (match-beginning 4)))))))
                tags pos)
            (cond
             (org-insert-heading-respect-content
              (org-end-of-subtree nil t)
+             (or (bolp) (newline))
              (open-line 1))
             ((org-on-heading-p)
+             (when hide-previous
+               (show-children)
+               (org-show-entry))
              (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
              (setq tags (and (match-end 2) (match-string 2)))
              (and (match-end 1)
@@ -4657,8 +4701,8 @@ but create the new hedline after the current line."
        (unless (= (point) pos) (just-one-space) (backward-delete-char 1))
         (when (and org-insert-heading-respect-content hide-previous)
          (save-excursion
-           (outline-previous-visible-heading 1)
-           (hide-entry)))
+           (goto-char previous-pos)
+           (hide-subtree)))
        (run-hooks 'org-insert-heading-hook)))))
 
 (defun org-get-heading (&optional no-tags)
@@ -5047,10 +5091,15 @@ useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
               (if cut "Cut" "Copied")
               (length org-subtree-clip)))))
 
-(defun org-paste-subtree (&optional level tree)
+(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.  By default, the new level is derived from the visible headings
+level.  
+
+If the cursor is at the beginning of a headline, the same level as
+that headline is used to paste the tree
+
+If not, the new level is derived from the *visible* headings
 before and after the insertion point, and taken to be the inferior headline
 level of the two.  So if the previous visible heading is level 3 and the
 next is level 4 (or vice versa), level 4 will be used for insertion.
@@ -5061,9 +5110,11 @@ You can also force a different level, either by using a numeric prefix
 argument, or by inserting the heading marker by hand.  For example, if the
 cursor is after \"*****\", then the tree will be shifted to level 5.
 
-If you want to insert the tree as is, just use \\[yank].
+If optional TREE is given, use this text instead of the kill ring.
 
-If optional TREE is given, use this text instead of the kill ring."
+When FOR-YANK is set, this is called by `org-yank'.  In this case, do not
+move back over whitespace before inserting, and move point to the end of
+the inserted text when done."
   (interactive "P")
   (unless (org-kill-is-subtree-p tree)
     (error "%s"
@@ -5079,9 +5130,14 @@ If optional TREE is given, use this text instead of the kill ring."
                        (- (match-end 0) (match-beginning 0) 1)
                      -1))
         (force-level (cond (level (prefix-numeric-value level))
-                           ((string-match
-                             ^re_ (buffer-substring (point-at-bol) (point)))
+                           ((and (looking-at "[ \t]*$")
+                                 (string-match
+                                  ^re_ (buffer-substring
+                                        (point-at-bol) (point))))
                             (- (match-end 1) (match-beginning 1)))
+                           ((and (bolp)
+                                 (looking-at org-outline-regexp))
+                            (- (match-end 0) (point) 1))
                            (t nil)))
         (previous-level (save-excursion
                           (condition-case nil
@@ -5109,16 +5165,17 @@ If optional TREE is given, use this text instead of the kill ring."
         (delta (if (> shift 0) -1 1))
         (func (if (> shift 0) 'org-demote 'org-promote))
         (org-odd-levels-only nil)
-        beg end)
+        beg end newend)
     ;; Remove the forced level indicator
     (if force-level
        (delete-region (point-at-bol) (point)))
     ;; Paste
     (beginning-of-line 1)
-    (org-back-over-empty-lines)
+    (unless for-yank (org-back-over-empty-lines))
     (setq beg (point))
     (insert-before-markers txt)
     (unless (string-match "\n\\'" txt) (insert "\n"))
+    (setq newend (point))
     (org-reinstall-markers-in-region beg)
     (setq end (point))
     (goto-char beg)
@@ -5133,14 +5190,17 @@ If optional TREE is given, use this text instead of the kill ring."
        (while (not (= shift 0))
          (org-map-region func (point-min) (point-max))
          (setq shift (+ delta shift)))
-       (goto-char (point-min))))
-    (when (interactive-p)
+       (goto-char (point-min))
+       (setq newend (point-max))))
+    (when (or (interactive-p) for-yank)
       (message "Clipboard pasted as level %d subtree" new-level))
-    (if (and kill-ring
+    (if (and (not for-yank) ; in this case, org-yank will decide about folding
+            kill-ring
             (eq org-subtree-clip (current-kill 0))
             org-subtree-clip-folded)
        ;; The tree was folded before it was killed/copied
-       (hide-subtree))))
+       (hide-subtree))
+    (and for-yank (goto-char newend))))
 
 (defun org-kill-is-subtree-p (&optional txt)
   "Check if the current kill is an outline subtree, or a set of trees.
@@ -5624,7 +5684,7 @@ the language, a switch telling of the content should be in a single line."
           (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)
@@ -6105,19 +6165,20 @@ For file links, arg negates `org-context-in-file-links'."
   (let (x adr)
     (when (setq x (plist-get plist :from))
       (setq adr (mail-extract-address-components x))
-      (plist-put plist :fromname (car adr))
-      (plist-put plist :fromaddress (nth 1 adr)))
+      (setq plist (plist-put plist :fromname (car adr)))
+      (setq plist (plist-put plist :fromaddress (nth 1 adr))))
     (when (setq x (plist-get plist :to))
       (setq adr (mail-extract-address-components x))
-      (plist-put plist :toname (car adr))
-      (plist-put plist :toaddress (nth 1 adr))))
+      (setq plist (plist-put plist :toname (car adr)))
+      (setq plist (plist-put plist :toaddress (nth 1 adr)))))
   (let ((from (plist-get plist :from))
        (to (plist-get plist :to)))
     (when (and from to org-from-is-user-regexp)
-      (plist-put plist :fromto
-                (if (string-match org-from-is-user-regexp from)
-                    (concat "to %t")
-                  (concat "from %f")))))
+      (setq plist
+           (plist-put plist :fromto
+                      (if (string-match org-from-is-user-regexp from)
+                          (concat "to %t")
+                        (concat "from %f"))))))
   (setq org-store-link-plist plist))
 
 (defun org-add-link-props (&rest plist)
@@ -6302,7 +6363,10 @@ This command can be called in any mode to insert a link in Org-mode syntax."
 (defun org-insert-link (&optional complete-file link-location)
   "Insert a link.  At the prompt, enter the link.
 
-Completion can be used to select a link previously stored with
+Completion can be used to insert any of the link protocol prefixes like
+http or ftp in use.
+
+The history can be used to select a link previously stored with
 `org-store-link'.  When the empty string is entered (i.e. if you just
 press RET at the prompt), the link defaults to the most recently
 stored link.  As SPC triggers completion in the minibuffer, you need to
@@ -6318,11 +6382,14 @@ With a \\[universal-argument] prefix, prompts for a file to link to. The file na
 be selected using completion. The path to the file will be relative to the
 current directory if the file is in the current directory or a subdirectory.
 Otherwise, the link will be the absolute path as completed in the minibuffer
-\(i.e. normally ~/path/to/file).
+\(i.e. normally ~/path/to/file).  You can configure this behavior using the
+option `org-link-file-path-type'.
 
 With two \\[universal-argument] prefixes, enforce an absolute path even if the file is in
-the current directory or below. With three \\[universal-argument] prefixes, negate the meaning
-of `org-keep-stored-link-after-insertion'.
+the current directory or below.
+
+With three \\[universal-argument] prefixes, negate the meaning of
+`org-keep-stored-link-after-insertion'.
 
 If `org-make-link-description-function' is non-nil, this function will be
 called with the link target, and the result will be the default
@@ -6354,7 +6421,7 @@ used as the link location instead of reading one interactively."
       (setq remove (list (match-beginning 0) (match-end 0))
            link (read-string "Link: "
                              (org-remove-angle-brackets (match-string 0)))))
-     ((equal complete-file '(4))
+     ((member complete-file '((4) (16)))
       ;; Completing read for file names.
       (setq file (read-file-name "File: "))
       (let ((pwd (file-name-as-directory (expand-file-name ".")))
@@ -6384,7 +6451,7 @@ used as the link location instead of reading one interactively."
                  (reverse org-stored-links) "\n"))))
       (let ((cw (selected-window)))
        (select-window (get-buffer-window "*Org Links*"))
-       (shrink-window-if-larger-than-buffer)
+       (org-fit-window-to-buffer)
        (setq truncate-lines t)
        (select-window cw))
       ;; Fake a link history, containing the stored links.
@@ -6433,7 +6500,8 @@ used as the link location instead of reading one interactively."
             (origpath path)
             (case-fold-search nil))
        (cond
-        ((eq org-link-file-path-type 'absolute)
+        ((or (eq org-link-file-path-type 'absolute)
+             (equal complete-file '(16)))
          (setq path (abbreviate-file-name (expand-file-name path))))
         ((eq org-link-file-path-type 'noabbrev)
          (setq path (expand-file-name path)))
@@ -6447,7 +6515,8 @@ used as the link location instead of reading one interactively."
                              (expand-file-name path))
                ;; We are linking a file with relative path name.
                (setq path (substring (expand-file-name path)
-                                     (match-end 0)))))))
+                                     (match-end 0)))
+             (setq path (abbreviate-file-name (expand-file-name path)))))))
        (setq link (concat "file:" path))
        (if (equal desc origpath)
            (setq desc path))))
@@ -6461,6 +6530,7 @@ used as the link location instead of reading one interactively."
     (insert (org-make-link-string link desc))))
 
 (defun org-completing-read (&rest args)
+  "Completing-read with SPACE being a normal character."
   (let ((minibuffer-local-completion-map
         (copy-keymap minibuffer-local-completion-map)))
     (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
@@ -6574,7 +6644,9 @@ Org-mode syntax."
 If there is no link at point, this function will search forward up to
 the end of the current subtree.
 Normally, files will be opened by an appropriate application.  If the
-optional argument IN-EMACS is non-nil, Emacs will visit the file."
+optional argument IN-EMACS is non-nil, Emacs will visit the file.
+With a double prefix argument, try to open outside of Emacs, in the
+application the system uses for this file type."
   (interactive "P")
   (org-load-modules-maybe)
   (move-marker org-open-link-marker (point))
@@ -7003,8 +7075,13 @@ onto the ring."
 First, this expands any special file name abbreviations.  Then the
 configuration variable `org-file-apps' is checked if it contains an
 entry for this file type, and if yes, the corresponding command is launched.
+
 If no application is found, Emacs simply visits the file.
-With optional argument IN-EMACS, Emacs will visit the file.
+
+With optional prefix argument IN-EMACS, Emacs will visit the file.
+With a double C-c C-u prefix arg, Org tries to avoid opening in Emacs
+and o use an external application to visit the file.
+
 Optional LINE specifies a line to go to, optional SEARCH a string to
 search for.  If LINE or SEARCH is given, the file will always be
 opened in Emacs.
@@ -7029,14 +7106,19 @@ If the file does not exist, an error is thrown."
        (setq ext (match-string 1 dfile))
       (if (string-match "^.*\\.\\([a-zA-Z0-9]+\\)$" dfile)
          (setq ext (match-string 1 dfile))))
-    (if in-emacs
-       (setq cmd 'emacs)
+    (cond
+     ((equal in-emacs '(16))
+      (setq cmd (cdr (assoc 'system apps))))
+     (in-emacs (setq cmd 'emacs))
+     (t
       (setq cmd (or (and remp (cdr (assoc 'remote apps)))
                    (and dirp (cdr (assoc 'directory apps)))
                    (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p)
                                   'string-match)
                    (cdr (assoc ext apps))
-                   (cdr (assoc t apps)))))
+                   (cdr (assoc t apps))))))
+    (when (eq cmd 'system)
+      (setq cmd (cdr (assoc 'system apps))))
     (when (eq cmd 'default)
       (setq cmd (cdr (assoc t apps))))
     (when (eq cmd 'mailcap)
@@ -7229,7 +7311,7 @@ on the system \"/user@host:\"."
   (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)
@@ -7252,14 +7334,27 @@ At the target location, the entry is filed as a subitem of the target heading.
 Depending on `org-reverse-note-order', the new subitem will either be the
 first or the last subitem.
 
+If there is an active region, all entries in that region will be moved.
+However, the region must fulfil the requirement that the first heading
+is the first one sets the top-level of the moved text - at most siblings
+below it are allowed.
+
 With prefix arg GOTO, the command will only visit the target location,
 not actually move anything.
 With a double prefix `C-u C-u', go to the location where the last refiling
 operation has put the subtree."
   (interactive "P")
   (let* ((cbuf (current-buffer))
+        (regionp (org-region-active-p))
+        (region-start (and regionp (region-beginning)))
+        (region-end (and regionp (region-end)))
+        (region-length (and regionp (- region-end region-start)))
         (filename (buffer-file-name (buffer-base-buffer cbuf)))
         pos it nbuf file re level reversed)
+    (when regionp (goto-char region-start)
+         (unless (org-kill-is-subtree-p
+                  (buffer-substring region-start region-end))
+           (error "The region is not a (sequence of) subtree(s)")))
     (if (equal goto '(16))
        (org-refile-goto-last-stored)
       (when (setq it (org-refile-get-location
@@ -7274,7 +7369,11 @@ operation has put the subtree."
              (switch-to-buffer nbuf)
              (goto-char pos)
              (org-show-context 'org-goto))
-         (org-copy-subtree 1 nil t)
+         (if regionp
+             (progn
+               (kill-new (buffer-substring region-start region-end))
+               (org-save-markers-in-region region-start region-end))
+           (org-copy-subtree 1 nil t))
          (save-excursion
            (set-buffer (setq nbuf (or (find-buffer-visiting file)
                                       (find-file-noselect file))))
@@ -7294,9 +7393,11 @@ operation has put the subtree."
                (if (not (bolp)) (newline))
                (bookmark-set "org-refile-last-stored")
                (org-paste-subtree level))))
-         (org-cut-subtree)
+         (if regionp
+             (delete-region (point) (+ (point) region-length))
+           (org-cut-subtree))
          (setq org-markers-to-move nil)
-         (message "Entry refiled to \"%s\"" (car it)))))))
+         (message "Refiled to \"%s\"" (car it)))))))
 
 (defun org-refile-goto-last-stored ()
   "Go to the location where the last refile was stored."
@@ -7333,7 +7434,7 @@ operation has put the subtree."
 (defun org-olpath-completing-read (prompt collection &rest args)
   "Read an outline path like a file name."
   (let ((thetable collection))
-    (apply
+    (apply 
      'completing-read prompt
      (lambda (string predicate &optional flag)
        (let (rtn r s f (l (length string)))
@@ -7490,7 +7591,7 @@ This function can be used in a hook."
 
 (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>")
@@ -7553,7 +7654,7 @@ expands them."
        (t (newline))))
     (setq start (point))
     (if (string-match "%file" rpl)
-       (setq rpl (replace-match
+       (setq rpl (replace-match 
                   (concat
                    "\""
                    (save-match-data
@@ -7562,7 +7663,7 @@ expands them."
                   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.
@@ -7758,7 +7859,7 @@ TODO state changes
 :from  previous state (keyword as a string), or nil
 :to    new state (keyword as a string), or nil")
 
-
+(defvar org-agenda-headline-snapshot-before-repeat)
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
 The state of an item is given by a keyword at the start of the heading,
@@ -7926,7 +8027,13 @@ For calling through lisp, arg is also interpreted in the following way:
            (setq head (org-get-todo-sequence-head state)))
        (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head)
        ;; Do we need to trigger a repeat?
-       (when now-done-p (org-auto-repeat-maybe state))
+       (when now-done-p
+         (when (boundp 'org-agenda-headline-snapshot-before-repeat)
+           ;; This is for the agenda, take a snapshot of the headline.
+           (save-match-data
+             (setq org-agenda-headline-snapshot-before-repeat
+                   (org-get-heading))))
+         (org-auto-repeat-maybe state))
        ;; Fixup cursor location if close to the keyword
        (if (and (outline-on-heading-p)
                 (not (bolp))
@@ -7962,7 +8069,7 @@ For calling through lisp, arg is also interpreted in the following way:
            (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)))
@@ -7999,7 +8106,7 @@ when there is a statistics cookie in the headline!
       (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)
@@ -8079,8 +8186,7 @@ Returns the new TODO keyword, or nil if no state change should occur."
            (setq cnt 0)))))
       (insert "\n")
       (goto-char (point-min))
-      (if (and (not expert) (fboundp 'fit-window-to-buffer))
-         (fit-window-to-buffer))
+      (if (not expert) (org-fit-window-to-buffer))
       (message "[a-z..]:Set [SPC]:clear")
       (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
       (cond
@@ -8401,7 +8507,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
     (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
@@ -8943,7 +9049,7 @@ also TODO lines."
        minus tag mm
        tagsmatch todomatch tagsmatcher todomatcher kwd matcher
        orterms term orlist re-p str-p level-p level-op time-p
-       prop-p pn pv po cat-p gv)
+       prop-p pn pv po cat-p gv rest)
     (if (string-match "/+" match)
        ;; match contains also a todo-matching request
        (progn
@@ -8964,7 +9070,8 @@ also TODO lines."
        (while (and (equal (substring term -1) "\\") orterms)
          (setq term (concat term "|" (pop orterms)))) ; repair bad split
        (while (string-match re term)
-         (setq minus (and (match-end 1)
+         (setq rest (substring term (match-end 0))
+               minus (and (match-end 1)
                           (equal (match-string 1 term) "-"))
                tag (match-string 2 term)
                re-p (equal (string-to-char tag) ?{)
@@ -8983,13 +9090,18 @@ also TODO lines."
                           cat-p (equal pn "CATEGORY")
                           re-p (equal (string-to-char pv) ?{)
                           str-p (equal (string-to-char pv) ?\")
-                          time-p (save-match-data (string-match "^\"<.*>\"$" pv))
+                          time-p (save-match-data
+                                   (string-match "^\"[[<].*[]>]\"$" pv))
                           pv (if (or re-p str-p) (substring pv 1 -1) pv))
                     (if time-p (setq pv (org-matcher-time pv)))
                     (setq po (org-op-to-function po (if time-p 'time str-p)))
-                    (if (equal pn "CATEGORY")
-                        (setq gv '(get-text-property (point) 'org-category))
-                      (setq gv `(org-cached-entry-get nil ,pn)))
+                    (cond
+                     ((equal pn "CATEGORY")
+                      (setq gv '(get-text-property (point) 'org-category)))
+                     ((equal pn "TODO")
+                      (setq gv 'todo))
+                     (t
+                      (setq gv `(org-cached-entry-get nil ,pn))))
                     (if re-p
                         (if (eq po 'org<>)
                             `(not (string-match ,pv (or ,gv "")))
@@ -9000,7 +9112,7 @@ also TODO lines."
                               ,(string-to-number pv) ))))
                    (t `(member ,(downcase tag) tags-list)))
                mm (if minus (list 'not mm) mm)
-               term (substring term (match-end 0)))
+               term rest)
          (push mm tagsmatcher))
        (push (if (> (length tagsmatcher) 1)
                  (cons 'and tagsmatcher)
@@ -9459,8 +9571,7 @@ Returns the new tags string, or nil to not change the current settings."
       (setq ntable (nreverse ntable))
       (insert "\n")
       (goto-char (point-min))
-      (if (and (not expert) (fboundp 'fit-window-to-buffer))
-         (fit-window-to-buffer))
+      (if (not expert) (org-fit-window-to-buffer))
       (setq rtn
            (catch 'exit
              (while t
@@ -9482,8 +9593,7 @@ Returns the new tags string, or nil to not change the current settings."
                    (delete-other-windows)
                    (split-window-vertically)
                    (org-switch-to-buffer-other-window " *Org tags*")
-                   (and (fboundp 'fit-window-to-buffer)
-                        (fit-window-to-buffer))))
+                   (org-fit-window-to-buffer)))
                 ((or (= c ?\C-g)
                      (and (= c ?q) (not (rassoc c ntable))))
                  (org-detach-overlay org-tags-overlay)
@@ -9628,12 +9738,12 @@ the scanner.  The following items can be given here:
      ((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
@@ -9667,7 +9777,7 @@ the scanner.  The following items can be given here:
 ;;; Setting and retrieving properties
 
 (defconst org-special-properties
-  '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "PRIORITY"
+  '("TODO" "TAGS" "ALLTAGS" "DEADLINE" "SCHEDULED" "CLOCK" "CLOSED" "PRIORITY"
     "TIMESTAMP" "TIMESTAMP_IA")
   "The special properties valid in Org-mode.
 
@@ -9855,7 +9965,7 @@ If the property is not present at all, nil is returned."
          (if (and range
                   (goto-char (car range))
                   (re-search-forward
-                   (concat "^[ \t]*:" property ":[ \t]*\\(.*\\S-\\)?")
+                   (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)?")
                    (cdr range) t))
              ;; Found the property, return it.
              (if (match-end 1)
@@ -9879,7 +9989,7 @@ If yes, return this value.  If not, return the current value of the variable."
        (if (and range
                 (goto-char (car range))
                 (re-search-forward
-                 (concat "^[ \t]*:" property ":[ \t]*\\(.*\\S-\\)")
+                 (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)")
                  (cdr range) t))
            (progn
              (delete-region (match-beginning 0) (1+ (point-at-eol)))
@@ -9968,7 +10078,7 @@ is set.")
              (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))))))
@@ -11267,13 +11377,15 @@ With prefix ARG, change that many days."
   "Toggle the type (<active> or [inactive]) of a time stamp."
   (interactive)
   (when (org-at-timestamp-p t)
-    (save-excursion
-      (goto-char (match-beginning 0))
-      (insert (if (equal (char-after) ?<) "[" "<")) (delete-char 1)
-      (goto-char (1- (match-end 0)))
-      (insert (if (equal (char-after) ?>) "]" ">")) (delete-char 1))
-    (message "Timestamp is now %sactive"
-            (if (equal (char-before) ?>) "in" ""))))
+    (let ((beg (match-beginning 0)) (end (match-end 0))
+         (map '((?\[ . "<") (?\] . ">") (?< . "[") (?> . "]"))))
+      (save-excursion
+       (goto-char beg)
+       (while (re-search-forward "[][<>]" end t)
+         (replace-match (cdr (assoc (char-after (match-beginning 0)) map))
+                        t t)))
+      (message "Timestamp is now %sactive"
+              (if (equal (char-after beg) ?<) "" "in")))))
 
 (defun org-timestamp-change (n &optional what)
   "Change the date in the time stamp at point.
@@ -11488,11 +11600,11 @@ If EXCLUDE-TMP is non-nil, ignore temporary buffers."
            (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)))))))))
@@ -11710,7 +11822,7 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
                (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
@@ -12572,9 +12684,10 @@ This command does many different things, depending on context:
 - If the cursor is inside a table created by the table.el package,
   activate that table.
 
-- If the current buffer is a remember buffer, close note and file it.
-  with a prefix argument, file it without further interaction to the default
-  location.
+- If the current buffer is a remember buffer, close note and file
+  it.  A prefix argument of 1 files to the default location
+  without further interaction.  A prefix argument of 2 files to
+  the currently clocking task.
 
 - If the cursor is on a <<<target>>>, update radio targets and corresponding
   links in this buffer.
@@ -13871,31 +13984,89 @@ beyond the end of the headline."
     (org-set-tags nil t))
    (t (kill-region (point) (point-at-eol)))))
 
-
 (define-key org-mode-map "\C-k" 'org-kill-line)
 
-(defun org-yank ()
-  "Yank, and if the yanked text is a single subtree, fold it.
-In fact, if the yanked text is a sequence of subtrees, fold all of them."
-  (interactive)
-  (if org-yank-folded-subtrees
-      (let ((beg (point)) end)
-       (call-interactively 'yank)
-       (setq end (point))
-       (goto-char beg)
-       (when (and (bolp)
-                  (org-kill-is-subtree-p))
-         (or (looking-at outline-regexp)
-             (re-search-forward (concat "^" outline-regexp) end t))
-         (while (and (< (point) end) (looking-at outline-regexp))
-           (hide-subtree)
-           (org-cycle-show-empty-lines 'folded)
-           (condition-case nil
-               (outline-forward-same-level 1)
-             (error (goto-char end)))))
-       (goto-char end)
-       (skip-chars-forward " \t\n\r"))
-    (call-interactively 'yank)))
+(defun org-yank (&optional arg)
+  "Yank.  If the kill is a subtree, treat it specially.
+This command will look at the current kill and check if is a single
+subtree, or a series of subtrees[1].  If it passes the test, and if the
+cursor is at the beginning of a line or after the stars of a currently
+empty headline, then the yank is handeled specially.  How exactly depends
+on the value of the following variables, both set by default.
+
+org-yank-folded-subtrees
+    When set, the subree(s) will be folded after insertion, but only
+    if doing so would now swallow text after the yanked text.
+
+org-yank-adjusted-subtrees
+    When set, the subtree will be promoted or demoted in order to
+    fit into the local outline tree structure, which means that the level
+    will be adjusted so that it becomes the smaller one of the two
+    *visible* surrounding headings.
+
+Any prefix to this command will cause `yank' to be called directly with
+no special treatment.  In particular, a simple `C-u' prefix will just
+plainly yank the text as it is.
+
+\[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")
+  (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 
+                         "\\`\\*+\\'"
+                         (buffer-substring (point-at-bol) (point)))))))
+         swallowp)
+      (cond
+       ((and subtreep org-yank-folded-subtrees)
+       (let ((beg (point))
+             end)
+         (if (and subtreep org-yank-adjusted-subtrees)
+             (org-paste-subtree nil nil 'for-yank)
+           (call-interactively 'yank))
+         (setq end (point))
+         (goto-char beg)
+         (when (and (bolp) subtreep
+                    (not (setq swallowp
+                               (org-yank-folding-would-swallow-text beg end))))
+           (or (looking-at outline-regexp)
+               (re-search-forward (concat "^" outline-regexp) end t))
+           (while (and (< (point) end) (looking-at outline-regexp))
+             (hide-subtree)
+             (org-cycle-show-empty-lines 'folded)
+             (condition-case nil
+                 (outline-forward-same-level 1)
+               (error (goto-char end)))))
+         (when swallowp
+           (message
+            "Yanked text not folded because that would swallow text"))
+         (goto-char end)
+         (skip-chars-forward " \t\n\r")
+         (beginning-of-line 1)))
+       ((and subtreep org-yank-adjusted-subtrees)
+       (org-paste-subtree nil nil 'for-yank))
+       (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)
+    (save-excursion
+      (goto-char beg)
+      (when (or (looking-at outline-regexp)
+               (re-search-forward (concat "^" outline-regexp) end t))
+       (setq level (org-outline-level)))
+      (goto-char end)
+      (skip-chars-forward " \t\r\n\v\f")
+      (if (or (eobp)
+             (and (bolp) (looking-at org-outline-regexp)
+                  (<= (org-outline-level) level)))
+         nil ; Nothing would be swallowed
+       t)))) ; something would swallow
 
 (define-key org-mode-map "\C-y" 'org-yank)
 
@@ -14256,6 +14427,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
        "Make the position visible."
        (org-bookmark-jump-unhide))))
 
+;; Make sure saveplace show the location if it was hidden
+(eval-after-load "saveplace"
+  '(defadvice save-place-find-file-hook (after org-make-visible activate)
+     "Make the position visible."
+     (org-bookmark-jump-unhide)))
+
 (defun org-bookmark-jump-unhide ()
   "Unhide the current position, to show the bookmark location."
   (and (org-mode-p)