diff --git a/undone/main.scm b/undone/main.scm index 8804bde..90db4b1 100644 --- a/undone/main.scm +++ b/undone/main.scm @@ -5,8 +5,8 @@ (define-syntax define-view (lambda (x) - (syntax-case x () - ((_ name doc fmt fields fields* ...) + (syntax-case x (where) + ((_ name doc fmt fields fields* ... where predicate) (with-syntax ((viewname (datum->syntax x (symbol-append (syntax->datum #'name) '-view)))) @@ -15,16 +15,22 @@ doc (map (lambda (item) (let (#,@(map (lambda (field) - #`(#,field (cdr (assq (quote #,field) item)))) - #'(fields fields* ...))) - (format #t fmt - #,@(map (lambda (field) - field) - #'(fields fields* ...))))) + #`(#,field (cdr (assq (quote #,field) item)))) + #'(fields fields* ...))) + (if predicate + (format #t fmt + #,@(map (lambda (field) + field) + #'(fields fields* ...)))))) todo-list)) (set! view-list (append view-list - (list (cons 'name viewname)))))))))) + (list (cons 'name viewname))))))) + ((_ name doc fmt fields fields* ...) + (with-syntax ((viewname + (datum->syntax + x (symbol-append (syntax->datum #'name) '-view)))) + #'(define-view name doc fmt fields fields* ... where #t)))))) (define todo-list-file "todo.scm")