From 58b2524b89d4db614aadbd8497b6e791e0d999cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 8 Mar 2019 14:49:57 +0100 Subject: Move stuff between modules. --- main.scm | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'main.scm') diff --git a/main.scm b/main.scm index dd45d68b..7a33b06f 100755 --- a/main.scm +++ b/main.scm @@ -4,43 +4,33 @@ (add-to-load-path (dirname (current-filename))) -(use-modules (srfi srfi-1) - (srfi srfi-19) +(use-modules (srfi srfi-19) (srfi srfi-19 util) - (srfi srfi-26) (vcalendar) - (util) - (code)) + (vcalendar output) + (util)) -;;; ------------------------------------------------------------ - - -(define (search cal term) - (cdr (let ((events (filter (lambda (ev) (eq? 'VEVENT (type ev))) - (children cal)))) - (find (lambda (ev) (string-contains-ci (car ev) term)) - (map cons (map (cut get-attr <> "SUMMARY") - events) - events))))) +;;; This function borrowed from web-ics (calendar util) +(define* (sort* items comperator #:optional (get identity)) + "A sort function more in line with how python's sorted works" + (sort items (lambda (a b) + (comperator (get a) + (get b))))) +;;; ------------------------------------------------------------ (define (main args) - (define path - (if (null? (cdr (command-line))) - "testcal/repeating-event.ics" - (cadr (command-line)))) - + (define path (cadr (append args '("testcal/repeating-event.ics")))) (define cal (make-vcomponent path)) ;; Sort the events, and print a simple agenda. - (for-each-in (sort* (children cal 'VEVENT) timestring start "~1 ~H:~M"))) - (get-attr ev "SUMMARY"))))) + (attr ev "SUMMARY"))))) #; (define pizza-event (search cal "pizza")) -- cgit v1.2.3