More accurate timing in start-agenda... we have to update it twice
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 20 Nov 2015 04:26:08 +0000 (22:26 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 20 Nov 2015 04:26:08 +0000 (22:26 -0600)
Because of port selection is why ;p

loopy.scm

index 5477af677f65d7e8464eb3af686e1a1b591484c8..c78197a5c1c090f9132636b71ce5c69f3f9d4258 100644 (file)
--- a/loopy.scm
+++ b/loopy.scm
@@ -432,17 +432,20 @@ Will produce (0 . 0) instead of a negative number, if needed."
              (agenda-run-once agenda))))
       (if (and stop-condition (stop-condition agenda))
           'done
-          (let* ((new-time (get-time))
-                 (agenda
-                  (handle-ports
-                   ;; Adjust the agenda's time just in time
-                   ;; We do this here rather than in agenda-run-once to make
-                   ;; agenda-run-once's behavior fairly predictable
-                   (set-field agenda (agenda-time) new-time))))
+          (let* ((agenda
+                  ;; We have to update the time after ports handled, too
+                  ;; because it may have changed after a select
+                  (set-field
+                   (handle-ports
+                    ;; Adjust the agenda's time just in time
+                    ;; We do this here rather than in agenda-run-once to make
+                    ;; agenda-run-once's behavior fairly predictable
+                    (set-field agenda (agenda-time) (get-time)))
+                   (agenda-time) (get-time))))
             ;; Update the agenda's current queue based on
             ;; currently applicable time segments
             (add-segments-contents-to-queue!
-             (schedule-extract-until! (agenda-schedule agenda) new-time)
+             (schedule-extract-until! (agenda-schedule agenda) (agenda-time agenda))
              (agenda-queue agenda))
             (loop agenda))))))