aboutsummaryrefslogtreecommitdiff
path: root/code.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-03-02 23:11:36 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-03-02 23:11:36 +0100
commite3d628fba1652d2005d8856512e81a1f2c0698ff (patch)
tree546f63cce206d43cada287920b5c4a98845f9429 /code.scm
parentExpose KEY(TRIE(content_line)) to scheme. (diff)
downloadcalp-e3d628fba1652d2005d8856512e81a1f2c0698ff.tar.gz
calp-e3d628fba1652d2005d8856512e81a1f2c0698ff.tar.xz
Add print-vcomponent procedure.
Diffstat (limited to 'code.scm')
-rwxr-xr-xcode.scm20
1 files changed, 19 insertions, 1 deletions
diff --git a/code.scm b/code.scm
index eba732bc..14581c90 100755
--- a/code.scm
+++ b/code.scm
@@ -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)))))
+