Sfoglia il codice sorgente

org-element: Fix interpretation of empty items

* lisp/org-element.el (org-element-item-interpreter): This patch fixes
  "(wrong-type-argument arrayp nil)" error when trying to interpret
  empty items.
* testing/lisp/test-org-element.el: Add test.
Nicolas Goaziou 11 anni fa
parent
commit
0aa0fdd971
2 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 5 4
      lisp/org-element.el
  2. 3 1
      testing/lisp/test-org-element.el

+ 5 - 4
lisp/org-element.el

@@ -1142,10 +1142,11 @@ CONTENTS is the contents of the element."
        (off "[ ] ")
        (trans "[-] "))
      (and tag (format "%s :: " tag))
-     (let ((contents (replace-regexp-in-string
-		      "\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
-       (if item-starts-with-par-p (org-trim contents)
-	 (concat "\n" contents))))))
+     (when contents
+       (let ((contents (replace-regexp-in-string
+			"\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
+	 (if item-starts-with-par-p (org-trim contents)
+	   (concat "\n" contents)))))))
 
 
 ;;;; Plain List

+ 3 - 1
testing/lisp/test-org-element.el

@@ -2168,7 +2168,9 @@ Outside list"
      (equal (org-test-parse-and-interpret "-\n  | a | b |")
 	    "- \n  | a | b |\n"))
     ;; Special case: correctly handle "*" bullets.
-    (should (org-test-parse-and-interpret " * item"))))
+    (should (org-test-parse-and-interpret " * item"))
+    ;; Special case: correctly handle empty items.
+    (should (org-test-parse-and-interpret "-"))))
 
 (ert-deftest test-org-element/quote-block-interpreter ()
   "Test quote block interpreter."