diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-11 17:38:03 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-11 17:38:03 +0200 |
commit | a18c7e898949ed53453d983e73d741395fb140ce (patch) | |
tree | 582486b6cb67ea4ac33e3204ae9255d24f28f94d /module/vcomponent/build.scm | |
parent | Add decimal_time_to_date. (diff) | |
download | calp-a18c7e898949ed53453d983e73d741395fb140ce.tar.gz calp-a18c7e898949ed53453d983e73d741395fb140ce.tar.xz |
Add (vcomponent build).
Diffstat (limited to 'module/vcomponent/build.scm')
-rw-r--r-- | module/vcomponent/build.scm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/module/vcomponent/build.scm b/module/vcomponent/build.scm new file mode 100644 index 00000000..dd3431c1 --- /dev/null +++ b/module/vcomponent/build.scm @@ -0,0 +1,38 @@ +;;; Commentary: +;; Module for quickly building new vcomponents from code. +;; @example +;; (vevent +;; summary: "This is a test event" +;; dtstart: #2020-01-01T13:37:00 +;; children: (list +;; (valarm ...))) +;;; Code: + +(define-module (vcomponent build) + :use-module (util) + :use-module (vcomponent base) + :use-module (srfi srfi-26) + :use-module ((srfi srfi-88) :select (keyword->string))) + +(define-public (vevent . body) (apply vcomponent 'VEVENT body)) +(define-public (vcalendar . body) (apply vcomponent 'VCALENDAR body)) +(define-public (valarm . body) (apply vcomponent 'VALARM body)) + +(define-public (vcomponent tag . rest) + (define v (make-vcomponent tag)) + + (let loop ((rem rest)) + (unless (null? rem) + (if (eq? children: (car rem)) + (for-each (cut add-child! v <>) (cadr rem)) + (let ((symb (-> (car rem) + keyword->string + string-upcase + string->symbol))) + (set! (prop v symb) (cadr rem)))) + (loop (cddr rem)))) + + ;; Return + v) + + |