Add queue helpers, with tests
[8sync.git] / eightsync / agenda.scm
index 2a431351af99b08ca06efed0c0afc03f28375f73..ede753fee409eb4a3f88b6728876fc77b079e74d 100644 (file)
@@ -30,6 +30,8 @@
             
             make-async-prompt-tag
 
+            list->q make-q*
+
             <time-segment>
             make-time-segment time-segment?
             time-segment-time time-segment-queue
@@ -146,6 +148,19 @@ Generally done automatically for the user through (make-agenda)."
          "Can't get current agenda prompt if there's no current agenda!")
         (agenda-prompt-tag current-agenda))))
 
+;; helper for making queues for an agenda
+(define (list->q lst)
+  "Makes a queue composed of LST items"
+  (let ((q (make-q)))
+    (for-each
+     (lambda (x)
+       (enq! q x))
+     lst)
+    q))
+
+(define (make-q* . args)
+  "Makes a queue and populates it with this invocation's ARGS"
+  (list->q args))
 
 \f
 ;;; Schedule
@@ -442,12 +457,6 @@ Will produce (0 . 0) instead of a negative number, if needed."
 ;;; Asynchronous escape to run things
 ;;; =================================
 
-(define (agenda-on-error agenda)
-  (const #f))
-
-(define (agenda-on-fail agenda)
-  (const #f))
-
 (define-syntax-rule (%8sync async-request)
   "Run BODY asynchronously at a prompt, passing args to make-future.