Browse Source

Maybe create ID property in cloned subtrees.

David Maus 15 years ago
parent
commit
9f9d129a00
2 changed files with 12 additions and 8 deletions
  1. 2 0
      lisp/ChangeLog
  2. 10 8
      lisp/org.el

+ 2 - 0
lisp/ChangeLog

@@ -10,6 +10,8 @@
 
 
 	* org.el (org-refile-cache-get): Return empty list of targets
 	* org.el (org-refile-cache-get): Return empty list of targets
 	when cache was cleared.
 	when cache was cleared.
+	(org-clone-subtree-with-time-shift): Maybe create ID property
+	in cloned subtrees.
 
 
 2010-05-17  Carsten Dominik  <carsten.dominik@gmail.com>
 2010-05-17  Carsten Dominik  <carsten.dominik@gmail.com>
 
 

+ 10 - 8
lisp/org.el

@@ -7171,7 +7171,7 @@ the following will happen:
 I this way you can spell out a number of instances of a repeating task,
 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."
 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): ")
   (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))
 	    shift-n shift-what doshift nmin nmax (n-no-remove -1))
     (if (not (and (integerp n) (> n 0)))
     (if (not (and (integerp n) (> n 0)))
 	(error "Invalid number of replications %s" n))
 	(error "Invalid number of replications %s" n))
@@ -7188,15 +7188,11 @@ and still retain the repeater to cover future instances of the task."
     (setq nmin 1 nmax n)
     (setq nmin 1 nmax n)
     (org-back-to-heading t)
     (org-back-to-heading t)
     (setq beg (point))
     (setq beg (point))
+    (setq idprop (org-entry-get nil "ID"))
     (org-end-of-subtree t t)
     (org-end-of-subtree t t)
     (or (bolp) (insert "\n"))
     (or (bolp) (insert "\n"))
     (setq end (point))
     (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
     (when (and doshift
 	       (string-match "<[^<>\n]+ \\+[0-9]+[dwmy][^<>\n]*>" template))
 	       (string-match "<[^<>\n]+ \\+[0-9]+[dwmy][^<>\n]*>" template))
       (delete-region beg end)
       (delete-region beg end)
@@ -7205,11 +7201,17 @@ and still retain the repeater to cover future instances of the task."
     (goto-char end)
     (goto-char end)
     (loop for n from nmin to nmax do
     (loop for n from nmin to nmax do
 	  (if (not doshift)
 	  (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
 	    (with-temp-buffer
 	      (insert template)
 	      (insert template)
 	      (org-mode)
 	      (org-mode)
 	      (goto-char (point-min))
 	      (goto-char (point-min))
+	      (if idprop (org-id-get-create t))
 	      (while (re-search-forward org-ts-regexp-both nil t)
 	      (while (re-search-forward org-ts-regexp-both nil t)
 		(org-timestamp-change (* n shift-n) shift-what))
 		(org-timestamp-change (* n shift-n) shift-what))
 	      (unless (= n n-no-remove)
 	      (unless (= n n-no-remove)