utils: Make read-org-sexp recursively apply string->any.
This commit is contained in:
parent
502e564fc7
commit
036b9b7973
2 changed files with 8 additions and 4 deletions
|
@ -45,9 +45,9 @@
|
||||||
(check-equal? (string->any "14") 14)
|
(check-equal? (string->any "14") 14)
|
||||||
(check-equal? (map-sexp add1 '(1 2 (4 10) 3)) '(2 3 (5 11) 4))
|
(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))\"))")
|
(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\"))")
|
(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))")))
|
(check-equal? (unstringify-pairs '(("a" . "1") ("b" . "(and a (not b))")))
|
||||||
'((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))")))
|
(check-equal? (unstringify-pairs '(("a" . 1) ("b" . "(and a (not b))")))
|
||||||
|
|
|
@ -224,7 +224,11 @@
|
||||||
|
|
||||||
;;; Reads a sexp from a string produced by Org-mode for a named table.
|
;;; Reads a sexp from a string produced by Org-mode for a named table.
|
||||||
;;; See example.org for examples.
|
;;; 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.
|
;;; A shortcut for read-org-sexp.
|
||||||
(define unorg read-org-sexp)
|
(define unorg read-org-sexp)
|
||||||
|
@ -253,7 +257,7 @@
|
||||||
;;; Reads a variable mapping from a string, such as the one which
|
;;; Reads a variable mapping from a string, such as the one which
|
||||||
;;; Org-mode produces from tables.
|
;;; Org-mode produces from tables.
|
||||||
(define read-org-variable-mapping
|
(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.
|
;;; A synonym for read-org-variable-mapping.
|
||||||
(define unorgv read-org-variable-mapping)
|
(define unorgv read-org-variable-mapping)
|
||||||
|
|
Loading…
Reference in a new issue