utils: Add unorg.

This commit is contained in:
Sergiu Ivanov 2020-02-22 19:48:39 +01:00
parent ea77374933
commit 576f204846
2 changed files with 9 additions and 3 deletions

View file

@ -51,8 +51,11 @@
(check-equal? (unstringify-pairs '(("a" . "1") ("b" . "(and a (not b))")))
'((a . 1) (b . (and a (not b)))))
(let ([m1 (read-org-variable-mapping "((\"a\" \"(and a b)\") (\"b\" \"(or b (not a))\"))")]
[m2 (read-org-variable-mapping "((\"a\" . \"(and a b)\") (\"b\" . \"(or b (not a))\"))")])
[m2 (read-org-variable-mapping "((\"a\" . \"(and a b)\") (\"b\" . \"(or b (not a))\"))")]
[m3 (unorg "((\"a\" . \"(and a b)\") (\"b\" . \"(or b (not a))\"))")])
(check-equal? (hash-ref m1 'a) '(and a b))
(check-equal? (hash-ref m2 'a) '(and a b))
(check-equal? (hash-ref m3 'a) '(and a b))
(check-equal? (hash-ref m1 'b) '(or b (not a)))
(check-equal? (hash-ref m2 'b) '(or b (not a)))))
(check-equal? (hash-ref m2 'b) '(or b (not a)))
(check-equal? (hash-ref m3 'b) '(or b (not a)))))

View file

@ -23,7 +23,7 @@
[string-variable-mapping? contract?]
[general-pair/c (-> contract? contract? contract?)])
;; Syntax
auto-hash-ref/explicit auto-hash-ref/: sgfy)
auto-hash-ref/explicit auto-hash-ref/: sgfy unorg)
;;; ===================
;;; HashTable Injection
@ -197,3 +197,6 @@
;;; Org-mode produces from tables.
(define (read-org-variable-mapping str)
(make-hash (unstringify-pairs (read-org-table str))))
;;; A synonym for read-org-variable-mapping.
(define-syntax-rule (unorg str) (read-org-variable-mapping str))