diff options
Diffstat (limited to '')
-rwxr-xr-x | code.scm | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,7 +1,8 @@ (define-module (code) #:export (extract localize-date sort* drop-time! copy-date drop-time %date<=? date-today? color-if - for-each-in STR-YELLOW STR-RESET)) + for-each-in STR-YELLOW STR-RESET + print-vcomponent)) (use-modules (srfi srfi-19) (srfi srfi-19 setters) @@ -65,3 +66,20 @@ (define-syntax-rule (for-each-in lst proc) (for-each proc lst)) + +(define* (print-vcomponent comp #:optional (depth 0)) + (let ((kvs (map (lambda (key) (cons key (get-attr comp key))) + (attributes comp)))) + (format #t "~a <~a> :: ~:a~%" + (make-string depth #\:) + (type comp) comp) + (for-each-in kvs + (lambda (kv) + (let ((key (car kv)) + (value (cdr kv))) + (format #t "~a ~20@a: ~a~%" + (make-string depth #\:) + key value)))) + (for-each-in (children comp) + (cut print-vcomponent <> (1+ depth))))) + |