diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-03-02 23:11:36 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-03-02 23:11:36 +0100 |
commit | e3d628fba1652d2005d8856512e81a1f2c0698ff (patch) | |
tree | 546f63cce206d43cada287920b5c4a98845f9429 /code.scm | |
parent | Expose KEY(TRIE(content_line)) to scheme. (diff) | |
download | calp-e3d628fba1652d2005d8856512e81a1f2c0698ff.tar.gz calp-e3d628fba1652d2005d8856512e81a1f2c0698ff.tar.xz |
Add print-vcomponent procedure.
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))))) + |