branch: externals/org
commit 4c0641837c8570dd8ad7f18c2482411bdc0cda16
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-babel-script-escape: Turn empty lists into nil
* lisp/ob-core.el: Translate (), {}, and [] to nil.
* testing/lisp/test-ob.el (test-ob/script-escape): Add tests.
Reported-by: Jonas Bernoulli <[email protected]>
Link: https://list.orgmode.org/[email protected]/T/#u
---
lisp/ob-core.el | 2 +-
testing/lisp/test-ob.el | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 3baa6347c3..f273fa92ec 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3124,7 +3124,7 @@ block but are passed literally to the \"example-block\"."
(error "`org-babel-script-escape' expects a string"))
(let ((escaped
(cond
- ((and (> (length str) 2)
+ ((and (>= (length str) 2)
(or (and (string-equal "[" (substring str 0 1))
(string-equal "]" (substring str -1)))
(and (string-equal "{" (substring str 0 1))
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 9051a642de..4ac278fafc 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -1962,6 +1962,11 @@ default-directory
(org-babel-execute-src-block)))))
(ert-deftest test-ob/script-escape ()
+ ;; Empty list.
+ (should (equal nil (org-babel-script-escape "[]")))
+ (should (equal nil (org-babel-script-escape "()")))
+ (should (equal nil (org-babel-script-escape "'()")))
+ (should (equal nil (org-babel-script-escape "{}")))
;; Delimited lists of numbers
(should (equal '(1 2 3)
(org-babel-script-escape "[1 2 3]")))