lisp/org-element-ast.el (org-element-copy): Fix altering source element
* testing/lisp/test-org-element.el (test-org-element/copy): Add new test case. Reported-by: gerard.vermeulen@posteo.net Link: https://orgmode.org/list/e0252d664af25728243734d67432ad64@posteo.net
This commit is contained in:
parent
d57d3bd9bb
commit
dfeff03c5a
|
@ -810,8 +810,8 @@ When DATUM is `plain-text', all the properties are removed."
|
|||
(org-element-put-property (car tail) :parent node-copy)
|
||||
(setq tail (cdr tail)))
|
||||
node-copy))
|
||||
(_
|
||||
(let ((node-copy (copy-sequence datum)))
|
||||
(type
|
||||
(let ((node-copy (append (list type (copy-sequence (cadr datum))) (copy-sequence (cddr datum)))))
|
||||
;; Copy `:standard-properties'
|
||||
(when-let ((parray (org-element-property-raw :standard-properties node-copy)))
|
||||
(org-element-put-property node-copy :standard-properties (copy-sequence parray)))
|
||||
|
|
|
@ -794,7 +794,13 @@ Some other text
|
|||
(should-not (org-element-copy nil))
|
||||
;; Return a copy secondary strings.
|
||||
(should (equal '("text") (org-element-copy '("text"))))
|
||||
(should-not (eq '("text") (org-element-copy '("text")))))
|
||||
(should-not (eq '("text") (org-element-copy '("text"))))
|
||||
;; Do not alter the source.
|
||||
(org-test-with-temp-text "*bold*"
|
||||
(let* ((source (org-element-context))
|
||||
(copy (org-element-copy source)))
|
||||
(should-not (org-element-parent copy))
|
||||
(should (org-element-parent source)))))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue