Browse Source

org-list: Fix sending empty lists

* lisp/org-list.el (org-list--to-generic-item): Fix sending empty lists.

* testing/lisp/test-org-list.el (test-org-list/to-generic): Add test.

Reported-by: Eric Abrahamsen <eric@ericabrahamsen.net>
<http://permalink.gmane.org/gmane.emacs.orgmode/103462>
Nicolas Goaziou 9 years ago
parent
commit
64aee4692a
2 changed files with 5 additions and 2 deletions
  1. 1 1
      lisp/org-list.el
  2. 4 1
      testing/lisp/test-org-list.el

+ 1 - 1
lisp/org-list.el

@@ -3349,7 +3349,7 @@ PARAMS is a plist used to tweak the behavior of the transcoder."
 				    (org-element-interpret-data tag))
 				  dtend))
 		     (and tag ddstart)
-		     (if (equal contents "") "" (substring contents 0 -1))
+		     (if (= (length contents) 0) "" (substring contents 0 -1))
 		     (and tag ddend))
 		  (org-export-with-backend backend item contents info))))
 	   ;; Remove final newline.

+ 4 - 1
testing/lisp/test-org-list.el

@@ -1104,7 +1104,10 @@
     "a"
     (org-test-with-temp-text "- a"
       (org-list-to-generic (org-list-to-lisp)
-			   '(:ustart "begin" :uend "end" :splice t))))))
+			   '(:ustart "begin" :uend "end" :splice t)))))
+  ;; No error on empty lists.
+  (should
+   (org-test-with-temp-text "-" (org-list-to-generic (org-list-to-lisp) nil))))
 
 (ert-deftest test-org-list/to-html ()
   "Test `org-list-to-html' specifications."