From 49afa89eb2d5a59f66befa908d2a999456ce40df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 20 Apr 2019 21:41:44 +0200 Subject: Improve print-vcomponent. --- module/vcalendar/output.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'module/vcalendar/output.scm') diff --git a/module/vcalendar/output.scm b/module/vcalendar/output.scm index a15857f7..2abc1e08 100644 --- a/module/vcalendar/output.scm +++ b/module/vcalendar/output.scm @@ -20,20 +20,22 @@ (begin body ...) (if pred-value STR-RESET "")))) -(define* (print-vcomponent comp #:optional (depth 0)) - (let ((kvs (map (lambda (key) (cons key (attr comp key))) +(define* (print-vcomponent comp #:optional (port #t) #:key (depth 0)) + (let ((kvs (map (lambda (key) (cons key (attr* comp key))) (attributes comp)))) - (format #t "~a <~a> :: ~:a~%" + (format port "~a <~a> :: ~:a~%" (make-string depth #\:) (type comp) comp) (for-each-in kvs (lambda (kv) - (let* (((key . value) kv)) - (format #t "~a ~20@a: ~a~%" + (let* (((key . at) kv)) + (format port "~a ~15@a~{;~a=~{~a~^,~}~}: ~a~%" (make-string depth #\:) - key value)))) + key + (concat (hash-map->list list (cdr at))) + (v at))))) (for-each-in (children comp) - (cut print-vcomponent <> (1+ depth))))) + (lambda (e) (print-vcomponent e port #:depth (1+ depth)))))) -- cgit v1.2.3