[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH 2/3] ob-table: Fix org-sbe's handling of list arguments
From: |
Vladimir Panteleev |
Subject: |
[O] [PATCH 2/3] ob-table: Fix org-sbe's handling of list arguments |
Date: |
Wed, 7 Mar 2018 22:58:46 +0000 |
* ob-table.el (org-sbe): Add an explicit case for handling list
arguments. This avoids doing the wrong thing (%s-formatting a list,
thus losing syntax like double-quotes). This enables passing org-table
ranges through org-sbe in a simple and correct manner.
* test-ob-table.el: Add test.
---
lisp/ob-table.el | 17 +++++++++++------
testing/lisp/test-ob-table.el | 20 ++++++++++++++++++++
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/lisp/ob-table.el b/lisp/ob-table.el
index 105aca5e2..17810dd74 100644
--- a/lisp/ob-table.el
+++ b/lisp/ob-table.el
@@ -132,12 +132,17 @@ as shown in the example below.
"("
(mapconcat
(lambda (var-spec)
- (if (> (length (cdr var-spec)) 1)
- (format "%S='%S"
- (car var-spec)
- (mapcar #'read (cdr var-spec)))
- (format "%S=%s"
- (car var-spec) (cadr var-spec))))
+ (cond
+ ((> (length (cdr var-spec)) 1)
+ (format "%S='%S"
+ (car var-spec)
+ (mapcar #'read (cdr var-spec))))
+ ((stringp (cadr var-spec))
+ (format "%S=%s"
+ (car var-spec) (cadr var-spec)))
+ (t
+ (format "%S=%S"
+ (car var-spec) (cadr
var-spec)))))
',variables ", ")
")")))))
(org-babel-execute-src-block
diff --git a/testing/lisp/test-ob-table.el b/testing/lisp/test-ob-table.el
index 725cf6bdd..40cc877d8 100644
--- a/testing/lisp/test-ob-table.el
+++ b/testing/lisp/test-ob-table.el
@@ -40,6 +40,26 @@
(should (equal "a\"b\"c"
(eval '(org-sbe identity (x $ "a\"b\"c")))))))
+(ert-deftest test-ob-table/sbe-list ()
+ "Test that `org-sbe' can correctly handle list arguments."
+ (org-test-with-temp-text-in-file "
+#+name: concat
+#+begin_src emacs-lisp :eval yes
+ (mapconcat #'identity x \"\")
+#+end_src"
+ (should (equal "foobar"
+ (eval '(org-sbe concat (x '("foo" "bar"))))))))
+
+(ert-deftest test-ob-table/sbe-$-list ()
+ "Test that `org-sbe' can correctly handle $-prefixed list arguments."
+ (org-test-with-temp-text-in-file "
+#+name: concat
+#+begin_src emacs-lisp :eval yes
+ (mapconcat #'identity x \"\")
+#+end_src"
+ (should (equal "foobar"
+ (eval '(org-sbe concat (x $ '("foo" "bar"))))))))
+
(provide 'test-ob-table)
;;; test-ob-table.el ends here
--
2.16.2
- Re: [O] [PATCH v2 0/3] org-sbe fixes, (continued)
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Vladimir Panteleev, 2018/03/25
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Nicolas Goaziou, 2018/03/26
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Vladimir Panteleev, 2018/03/26
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Nicolas Goaziou, 2018/03/26
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Vladimir Panteleev, 2018/03/26
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Nicolas Goaziou, 2018/03/27
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Alan Schmitt, 2018/03/26
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Nicolas Goaziou, 2018/03/26
- Re: [O] [PATCH v2 0/3] org-sbe fixes, Bastien, 2018/03/26
[O] [PATCH 3/3] ob-table: Mention passing ranges as lists in org-sbe's documentation, Vladimir Panteleev, 2018/03/08
[O] [PATCH 2/3] ob-table: Fix org-sbe's handling of list arguments,
Vladimir Panteleev <=