aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-31 00:12:00 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-31 00:12:00 +0100
commit49ffe09b4290ee3c1189660332fca51583c3916a (patch)
tree80fc507b6c231fd820092752086b9400788d2d3e
parentAdd cval field to LLIST. (diff)
downloadcalp-49ffe09b4290ee3c1189660332fca51583c3916a.tar.gz
calp-49ffe09b4290ee3c1189660332fca51583c3916a.tar.xz
Add as-{string,symb}.
-rw-r--r--module/util.scm6
-rw-r--r--module/vcalendar.scm9
2 files changed, 10 insertions, 5 deletions
diff --git a/module/util.scm b/module/util.scm
index 82c2ddc0..2302f671 100644
--- a/module/util.scm
+++ b/module/util.scm
@@ -168,3 +168,9 @@
"Like @var{take}, but might lists shorter than length."
(if (> i (length lst))
lst (take lst i)))
+
+(define-public (as-string s)
+ (if (symbol? s) (symbol->string s) s))
+
+(define-public (as-symb s)
+ (if (string? s) (string->symbol s) s))
diff --git a/module/vcalendar.scm b/module/vcalendar.scm
index bea9c0dc..51c4f8e3 100644
--- a/module/vcalendar.scm
+++ b/module/vcalendar.scm
@@ -31,13 +31,13 @@
(define (set-attr! component attr value)
(%vcomponent-set-attribute!
component
- (if (symbol? attr) (symbol->string attr) attr)
+ (as-string attr)
value))
(define (get-attr component attr)
(%vcomponent-get-attribute
component
- (if (symbol? attr) (symbol->string attr) attr)))
+ (as-string attr)))
;; Enables symmetric get and set:
;; (set! (attr ev "KEY") 10)
@@ -67,9 +67,8 @@
(cut get-attr <> field))
(define-public (key=? k1 k2)
- (eq?
- (if (string? k1) (string->symbol k1) k1)
- (if (string? k2) (string->symbol k2) k2)))
+ (eq? (as-symb k1)
+ (as-symb k2)))
(define* (make-vcomponent #:optional path)
(if (not path)