From d74deac624de47c672e81c33db5fc39f244ec0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 17 Jul 2020 23:58:20 +0200 Subject: Properties now return alist instead of hashmap. --- module/output/ical.scm | 10 ++++------ module/output/xcal.scm | 46 ++++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 30 deletions(-) (limited to 'module/output') diff --git a/module/output/ical.scm b/module/output/ical.scm index d0dcd98c..9e147316 100644 --- a/module/output/ical.scm +++ b/module/output/ical.scm @@ -133,21 +133,19 @@ (define-public (component->ical-string component) (format #t "BEGIN:~a\r\n" (type component)) - ;; TODO this leaks internal information, - ;; write a better API for vcomponent. - (hash-for-each + (for-each ;; Special cases depending on key. ;; Value formatting is handled in @code{value-format}. - (match-lambda* + (match-lambda [(? (compose internal-field? car)) 'noop] - [(key (vlines ...)) + [(key vlines ...) (for vline in vlines (display (vline->string vline)) (display "\r\n"))] - [(key vline) + [(key . vline) (display (vline->string vline)) (display "\r\n")]) (properties component)) diff --git a/module/output/xcal.scm b/module/output/xcal.scm index b4fee9b7..b2c3f899 100644 --- a/module/output/xcal.scm +++ b/module/output/xcal.scm @@ -101,30 +101,28 @@ (remove null? `(,tagsymb - ;; TODO only have when it's non-empty. - ;; This becomes MUCH easier once properties stop returning - ;; a hash-map... - (properties - ,@(filter - identity - (hash-map->list - (match-lambda* - [(? (compose internal-field? car)) #f] - - [(key (vlines ...)) - (remove null? - `(,(downcase-symbol key) - ,(parameters-tag (reduce assq-merge - '() (map parameters vlines))) - ,@(for vline in vlines - (vline->value-tag vline))))] - - [(key vline) - (remove null? - `(,(downcase-symbol key) - ,(parameters-tag (parameters vline)) - ,(vline->value-tag vline)))]) - (properties component)))) + ;; only have when it's non-empty. + ,(let ((props + (filter-map + (match-lambda + [(? (compose internal-field? car)) #f] + + [(key vlines ...) + (remove null? + `(,(downcase-symbol key) + ,(parameters-tag (reduce assq-merge + '() (map parameters vlines))) + ,@(for vline in vlines + (vline->value-tag vline))))] + + [(key . vline) + (remove null? + `(,(downcase-symbol key) + ,(parameters-tag (parameters vline)) + ,(vline->value-tag vline)))]) + (properties component)))) + (unless (null? props) + `(properties ,@props))) ,(unless (null? (children component)) `(components ,@(map vcomponent->sxcal (children component))))))) -- cgit v1.2.3