Simplify call to define-view

This commit is contained in:
Tom Willemsen 2012-08-14 22:24:34 +02:00
parent b026bf9fcc
commit 17d9c17d9f

View file

@ -5,15 +5,21 @@
(define-syntax define-view
(lambda (x)
(syntax-case x ()
((_ name doc exps exps* ...)
(syntax-case x (with)
((_ name doc fmt fields fields* ...)
(with-syntax ((viewname
(datum->syntax
x (symbol-append (syntax->datum #'name) '-view))))
#'(begin
#`(begin
(define (viewname)
doc
exps exps* ...)
(map (lambda (item)
(format #t fmt
#,@(map
(lambda (field)
#`(cdr (assq (quote #,field) item)))
#'(fields fields* ...))))
todo-list))
(set! view-list
(append view-list
(list (cons 'name viewname))))))))))
@ -77,13 +83,7 @@
(define-view default
"Default todo-list view, show only the title."
(map (lambda (todo)
(display (cdr (assq 'content todo))))
todo-list))
(define-view raw
"Just a test view, see everything in todo-list."
(format #t "~y" todo-list))
"~a" content)
(define (view args)
"Show a list of todo items."