make-run-request run-request?
run-request-proc run-request-when
- run wrap run-wrap run-wrap-at
+ run-it wrap run run-at delay
%current-agenda
start-agenda agenda-run-once))
;;; Request to run stuff
;;; ====================
-(define-record-type <run-request>
+(define-immutable-record-type <run-request>
(make-run-request proc when)
run-request?
(proc run-request-proc)
(when run-request-when))
-(define* (run proc #:optional when)
+(define* (run-it proc #:optional when)
+ "Make a request to run PROC (possibly at WHEN)"
(make-run-request proc when))
(define-syntax-rule (wrap body ...)
+ "Wrap contents in a procedure"
(lambda ()
body ...))
-(define-syntax-rule (run-wrap body ...)
- (run (wrap body ...)))
+(define-syntax-rule (run body ...)
+ "Run everything in BODY but wrap in a convenient procedure"
+ (make-run-request (wrap body ...) #f))
-(define-syntax-rule (run-wrap-at body ... when)
- (run (wrap body ...) when))
+(define-syntax-rule (run-at body ... when)
+ "Run BODY at WHEN"
+ (make-run-request (wrap body ...) when))
+
+(define-syntax-rule (run-delay body ... delay-time)
+ (make-run-request (wrap body ...) (tdelta delay-time)))
+
+(define (delay run-request delay-time)
+ "Delay a RUN-REQUEST by DELAY-TIME"
+ (set-field run-request
+ (run-request-when)
+ (tdelta delay-time)))
\f
;;; Execution of agenda, and current agenda
(test-assert (procedure? wrapped))
(test-equal (wrapped) 3))
-(let ((run-two-squared (run (lambda () (* 2 2)))))
+(let ((run-two-squared (run-it (lambda () (* 2 2)))))
(test-assert (run-request? run-two-squared))
(test-assert (procedure? (run-request-proc run-two-squared)))
(test-equal ((run-request-proc run-two-squared)) 4)
(test-eq (run-request-when run-two-squared) #f))
-(let ((run-two-squared (run (lambda () (* 2 2)) '(88 . 0))))
+(let ((run-two-squared (run-it (lambda () (* 2 2)) '(88 . 0))))
(test-assert (run-request? run-two-squared))
(test-assert (procedure? (run-request-proc run-two-squared)))
(test-equal ((run-request-proc run-two-squared)) 4)
(test-equal (run-request-when run-two-squared) '(88 . 0)))
-(let ((run-two-squared (run-wrap (* 2 2))))
+(let ((run-two-squared (run (* 2 2))))
(test-assert (run-request? run-two-squared))
(test-assert (procedure? (run-request-proc run-two-squared)))
(test-equal ((run-request-proc run-two-squared)) 4)
(test-eq (run-request-when run-two-squared) #f))
-(let ((run-two-squared (run-wrap-at (* 2 2) '(88 . 0))))
+(let ((run-two-squared (run-at (* 2 2) '(88 . 0))))
(test-assert (run-request? run-two-squared))
(test-assert (procedure? (run-request-proc run-two-squared)))
(test-equal ((run-request-proc run-two-squared)) 4)
(define (run-dummy)
(speaker "I bet I can make you say you're a dummy!\n")
- (run dummy-func))
+ (run-it dummy-func))
(let ((q (make-q)))
(set! speaker (speak-it)) ; reset the speaker