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.
This commit is contained in:
Nicolas Goaziou 2015-02-09 10:13:50 +01:00
parent 70933a3dd6
commit 16841306ed
3 changed files with 6 additions and 19 deletions

View File

@ -23427,11 +23427,10 @@ Universal Time."
TIMESTAMP is a timestamp object. END, when non-nil, means extract
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)))
(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.
(org-element-put-property
split-ts :type (if (eq type 'active-range) 'active 'inactive))
@ -23445,9 +23444,9 @@ TIMESTAMP."
(dolist (p-cell p-alist)
(org-element-put-property
split-ts
(funcall (if end 'car 'cdr) p-cell)
(funcall (if end #'car #'cdr) p-cell)
(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'.
(org-element-put-property split-ts :raw-value nil)
(org-element-put-property

View File

@ -2878,12 +2878,7 @@ Return code as a string."
(eq (org-element-type (car date)) 'timestamp))
(format "(eval (if (org-string-nw-p \"$1\") %s %S))"
(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)))
;; EMAIL is not a parsed keyword: store it as-is.

View File

@ -3214,14 +3214,7 @@ Text.
(org-test-with-temp-text "<%%(org-float t 4 2)>"
(let* ((ts-orig (org-element-context))
(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 ()
"Test `org-timestamp-translate' specifications."