aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/load.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/vcomponent/load.scm')
-rw-r--r--module/vcomponent/load.scm38
1 files changed, 23 insertions, 15 deletions
diff --git a/module/vcomponent/load.scm b/module/vcomponent/load.scm
index fb25732d..2d339c64 100644
--- a/module/vcomponent/load.scm
+++ b/module/vcomponent/load.scm
@@ -1,5 +1,5 @@
(define-module (vcomponent load)
- :export (load-calendars)
+ :export (load-calendars load-calendars*)
:use-module (util)
:use-module (srfi srfi-1)
:use-module (srfi srfi-19)
@@ -13,12 +13,23 @@
:use-module ((vcomponent datetime) :select (ev-time<?)))
-;; Reads all calendar files from disk, and creates a list of "regular" events,
-;; and a stream of "repeating" events, which are passed in that order to the
-;; given procedure @var{proc}.
-;;
-;; Given as a sepparate function from main to ease debugging.
+;; Reads all calendar files from disk, generate recurence-sets for all repeating events,
+;; and returns a list of calendars, and a stream of all events "ready" for display.
(define* (load-calendars #:key (calendar-files (calendar-files)))
+ (let* ((calendars regular repeating (load-calendars* calendar-files: calendar-files)))
+ (values
+ calendars
+ (interleave-streams
+ ev-time<?
+ (cons (list->stream regular)
+ (map generate-recurrence-set repeating))))))
+
+;; Basic version, loads calendrs, sorts the events, and returns
+;; regular and repeating events separated from each other.
+;;
+;; (list string) → (list calendar), (list event), (list event)
+(define* (load-calendars* #:key (calendar-files (calendar-files)))
+
(define calendars (map parse-cal-path calendar-files))
(define events (concatenate
;; TODO does this drop events?
@@ -28,12 +39,9 @@
(let* ((repeating regular (partition repeating? events)))
- (set! repeating (sort*! repeating time<? (extract 'DTSTART))
- regular (sort*! regular time<? (extract 'DTSTART)))
-
- (values
- calendars
- (interleave-streams
- ev-time<?
- (cons (list->stream regular)
- (map generate-recurrence-set repeating))))))
+ ;; NOTE There might be instances where we don't care if the
+ ;; collection if sorted, but for the time beieng it's much
+ ;; easier to always sort it.
+ (values calendars
+ (sort*! regular time<? (extract 'DTSTART))
+ (sort*! repeating time<? (extract 'DTSTART)))))