diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-02-13 16:29:54 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-02-13 16:29:54 +0100 |
commit | d347d85a15750641552b15436b7e86bb0b9d1fa8 (patch) | |
tree | 2ee53327f0930989a933b1ad468286bebdd29374 | |
parent | fe97948e89b17a430d993cb732c240b3b7785ae7 (diff) | |
download | org-mode-d347d85a15750641552b15436b7e86bb0b9d1fa8.tar.gz |
org-element: Fix `org-element-insert-before'
* lisp/org-element.el (org-element-insert-before): Do not call
`reverse' as contents might use `eq' objects.
* testing/lisp/test-ox.el (test-org-export/uninterpreted): Add test
Reported-by: Justin Kirby <justinkirby@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/112065>
-rw-r--r-- | lisp/org-element.el | 11 | ||||
-rw-r--r-- | testing/lisp/test-ox.el | 11 |
2 files changed, 15 insertions, 7 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index 9d7e435..1920625 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -593,16 +593,15 @@ Parse tree is modified by side effect." (specialp (and (not property) (eq siblings parent) (eq (car parent) location)))) - ;; Install ELEMENT at the appropriate POSITION within SIBLINGS. + ;; Install ELEMENT at the appropriate LOCATION within SIBLINGS. (cond (specialp) ((or (null siblings) (eq (car siblings) location)) (push element siblings)) ((null location) (nconc siblings (list element))) - (t (let ((previous (cadr (memq location (reverse siblings))))) - (if (not previous) - (error "No location found to insert element") - (let ((next (memq previous siblings))) - (setcdr next (cons element (cdr next)))))))) + (t + (let ((index (cl-position location siblings))) + (unless index (error "No location found to insert element")) + (push element (cdr (nthcdr (1- index) siblings)))))) ;; Store SIBLINGS at appropriate place in parse tree. (cond (specialp (setcdr parent (copy-sequence parent)) (setcar parent element)) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 4854490..7a23b1d 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -747,6 +747,15 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (paragraph . (lambda (p c i) c)) (section . (lambda (s c i) c)))) nil nil nil '(:with-emphasize nil))))) + (should + (equal "/simple/ /example/\n" + (org-test-with-temp-text "/simple/ /example/" + (org-export-as + (org-export-create-backend + :transcoders '((bold . (lambda (b c i) "dummy")) + (paragraph . (lambda (p c i) c)) + (section . (lambda (s c i) c)))) + nil nil nil '(:with-emphasize nil))))) ;; LaTeX environment. (should (equal "dummy\n" @@ -839,7 +848,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :transcoders '((subscript . (lambda (s c i) "dummy")) (template . (lambda (c i) (org-export-data - (plist-get i :title) i))) + (plist-get i :title) i))) (section . (lambda (s c i) c)))) nil nil nil '(:with-sub-superscript nil))))) ;; Handle uninterpreted objects in captions. |