From 036b9b7973effcb34dbe1fe27007155bb57a6e68 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Wed, 6 May 2020 23:03:15 +0200 Subject: [PATCH] utils: Make read-org-sexp recursively apply string->any. --- utils-tests.rkt | 4 ++-- utils.rkt | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/utils-tests.rkt b/utils-tests.rkt index dae0132..30882ef 100644 --- a/utils-tests.rkt +++ b/utils-tests.rkt @@ -45,9 +45,9 @@ (check-equal? (string->any "14") 14) (check-equal? (map-sexp add1 '(1 2 (4 10) 3)) '(2 3 (5 11) 4)) (check-equal? (read-org-sexp "((\"a\" \"(and a b)\") (\"b\" \"(or b (not a))\"))") - '(("a" "(and a b)") ("b" "(or b (not a))"))) + '((a (and a b)) (b (or b (not a))))) (check-equal? (read-org-sexp "(#t \"#t\" \"#t \" '(1 2 \"#f\"))") - '(#t #t "#t " '(1 2 #f))) + '(#t #t #t '(1 2 #f))) (check-equal? (unstringify-pairs '(("a" . "1") ("b" . "(and a (not b))"))) '((a . 1) (b . (and a (not b))))) (check-equal? (unstringify-pairs '(("a" . 1) ("b" . "(and a (not b))"))) diff --git a/utils.rkt b/utils.rkt index 3c27d61..304fe35 100644 --- a/utils.rkt +++ b/utils.rkt @@ -224,7 +224,11 @@ ;;; Reads a sexp from a string produced by Org-mode for a named table. ;;; See example.org for examples. -(define read-org-sexp (compose handle-org-booleans string->any)) +(define read-org-sexp + (compose ((curry map-sexp) (match-lambda + [(and (? string?) str) (string->any str)] + [x x])) + string->any)) ;;; A shortcut for read-org-sexp. (define unorg read-org-sexp) @@ -253,7 +257,7 @@ ;;; Reads a variable mapping from a string, such as the one which ;;; Org-mode produces from tables. (define read-org-variable-mapping - (compose make-immutable-hash unstringify-pairs read-org-sexp)) + (compose make-immutable-hash unstringify-pairs string->any)) ;;; A synonym for read-org-variable-mapping. (define unorgv read-org-variable-mapping)