Forráskód Böngészése

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>
Nicolas Goaziou 8 éve
szülő
commit
d347d85a15
2 módosított fájl, 15 hozzáadás és 7 törlés
  1. 5 6
      lisp/org-element.el
  2. 10 1
      testing/lisp/test-ox.el

+ 5 - 6
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))

+ 10 - 1
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.