Browse Source

Use `org-element-copy'

* lisp/org.el (org-timestamp-split-range): Use `org-element-copy'.  Do
  not preserve :parent property anymore.

* lisp/ox.el (org-export-as): Use `org-element-copy'.

* testing/lisp/test-org.el (test-org/timestamp-split-range): Update test.
Nicolas Goaziou 10 years ago
parent
commit
16841306ed
3 changed files with 6 additions and 19 deletions
  1. 4 5
      lisp/org.el
  2. 1 6
      lisp/ox.el
  3. 1 8
      testing/lisp/test-org.el

+ 4 - 5
lisp/org.el

@@ -23427,11 +23427,10 @@ Universal Time."
 TIMESTAMP is a timestamp object. END, when non-nil, means extract
 TIMESTAMP is a timestamp object. END, when non-nil, means extract
 the end of the range.  Otherwise, extract its start.
 the end of the range.  Otherwise, extract its start.
 
 
-Return a new timestamp object sharing the same parent as
-TIMESTAMP."
+Return a new timestamp object."
   (let ((type (org-element-property :type timestamp)))
   (let ((type (org-element-property :type timestamp)))
     (if (memq type '(active inactive diary)) timestamp
     (if (memq type '(active inactive diary)) timestamp
-      (let ((split-ts (list 'timestamp (copy-sequence (nth 1 timestamp)))))
+      (let ((split-ts (org-element-copy timestamp)))
 	;; Set new type.
 	;; Set new type.
 	(org-element-put-property
 	(org-element-put-property
 	 split-ts :type (if (eq type 'active-range) 'active 'inactive))
 	 split-ts :type (if (eq type 'active-range) 'active 'inactive))
@@ -23445,9 +23444,9 @@ TIMESTAMP."
 	  (dolist (p-cell p-alist)
 	  (dolist (p-cell p-alist)
 	    (org-element-put-property
 	    (org-element-put-property
 	     split-ts
 	     split-ts
-	     (funcall (if end 'car 'cdr) p-cell)
+	     (funcall (if end #'car #'cdr) p-cell)
 	     (org-element-property
 	     (org-element-property
-	      (funcall (if end 'cdr 'car) p-cell) split-ts)))
+	      (funcall (if end #'cdr #'car) p-cell) split-ts)))
 	  ;; Eventually refresh `:raw-value'.
 	  ;; Eventually refresh `:raw-value'.
 	  (org-element-put-property split-ts :raw-value nil)
 	  (org-element-put-property split-ts :raw-value nil)
 	  (org-element-put-property
 	  (org-element-put-property

+ 1 - 6
lisp/ox.el

@@ -2878,12 +2878,7 @@ Return code as a string."
 				 (eq (org-element-type (car date)) 'timestamp))
 				 (eq (org-element-type (car date)) 'timestamp))
 			    (format "(eval (if (org-string-nw-p \"$1\") %s %S))"
 			    (format "(eval (if (org-string-nw-p \"$1\") %s %S))"
 				    (format "(org-timestamp-format '%S \"$1\")"
 				    (format "(org-timestamp-format '%S \"$1\")"
-					    ;; Remove parent to avoid
-					    ;; read error.
-					    `(timestamp
-					      ,(org-combine-plists
-						(nth 1 (car date))
-						'(:parent nil))))
+					    (org-element-copy (car date)))
 				    value)
 				    value)
 			  value)))
 			  value)))
 		;; EMAIL is not a parsed keyword: store it as-is.
 		;; EMAIL is not a parsed keyword: store it as-is.

+ 1 - 8
testing/lisp/test-org.el

@@ -3214,14 +3214,7 @@ Text.
    (org-test-with-temp-text "<%%(org-float t 4 2)>"
    (org-test-with-temp-text "<%%(org-float t 4 2)>"
      (let* ((ts-orig (org-element-context))
      (let* ((ts-orig (org-element-context))
 	    (ts-copy (org-timestamp-split-range ts-orig)))
 	    (ts-copy (org-timestamp-split-range ts-orig)))
-       (eq ts-orig ts-copy))))
-  ;; Check that parent is the same when a range was split.
-  (should
-   (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
-     (let* ((ts-orig (org-element-context))
-	    (ts-copy (org-timestamp-split-range ts-orig)))
-       (eq (org-element-property :parent ts-orig)
-	   (org-element-property :parent ts-copy))))))
+       (eq ts-orig ts-copy)))))
 
 
 (ert-deftest test-org/timestamp-translate ()
 (ert-deftest test-org/timestamp-translate ()
   "Test `org-timestamp-translate' specifications."
   "Test `org-timestamp-translate' specifications."