emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [PATCH] Maybe create ID property in cloned subtrees.


From: David Maus
Subject: [Orgmode] [PATCH] Maybe create ID property in cloned subtrees.
Date: Wed, 19 May 2010 20:14:24 +0200

---
 lisp/ChangeLog |    2 ++
 lisp/org.el    |   18 ++++++++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 01672a0..ec2fa36 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -2,6 +2,8 @@
 
        * org.el (org-refile-cache-get): Return empty list of targets
        when cache was cleared.
+       (org-clone-subtree-with-time-shift): Maybe create ID property
+       in cloned subtrees.
 
 2010-05-17  Carsten Dominik  <address@hidden>
 
diff --git a/lisp/org.el b/lisp/org.el
index 4ede91f..64da60a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7170,7 +7170,7 @@ the following will happen:
 I this way you can spell out a number of instances of a repeating task,
 and still retain the repeater to cover future instances of the task."
   (interactive "nNumber of clones to produce: \nsDate shift per clone (e.g. 
+1w, empty to copy unchanged): ")
-  (let (beg end template task
+  (let (beg end template task idprop
            shift-n shift-what doshift nmin nmax (n-no-remove -1))
     (if (not (and (integerp n) (> n 0)))
        (error "Invalid number of replications %s" n))
@@ -7187,15 +7187,11 @@ and still retain the repeater to cover future instances 
of the task."
     (setq nmin 1 nmax n)
     (org-back-to-heading t)
     (setq beg (point))
+    (setq idprop (org-entry-get nil "ID"))
     (org-end-of-subtree t t)
     (or (bolp) (insert "\n"))
     (setq end (point))
-    (setq template (let ((tmpl (buffer-substring beg end)))
-                    (with-temp-buffer
-                      (insert tmpl)
-                      (org-mode)
-                      (org-entry-delete nil "ID")
-                      (buffer-string))))
+    (setq template (buffer-substring beg end))
     (when (and doshift
               (string-match "<[^<>\n]+ \\+[0-9]+[dwmy][^<>\n]*>" template))
       (delete-region beg end)
@@ -7204,11 +7200,17 @@ and still retain the repeater to cover future instances 
of the task."
     (goto-char end)
     (loop for n from nmin to nmax do
          (if (not doshift)
-             (setq task template)
+             (setq task (if (not idprop) template
+                          (with-temp-buffer
+                            (insert template)
+                            (org-mode)
+                            (org-id-get-create t)
+                            (buffer-string))))
            (with-temp-buffer
              (insert template)
              (org-mode)
              (goto-char (point-min))
+             (if idprop (org-id-get-create t))
              (while (re-search-forward org-ts-regexp-both nil t)
                (org-timestamp-change (* n shift-n) shift-what))
              (unless (= n n-no-remove)
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]