aboutsummaryrefslogtreecommitdiff
path: root/main.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-08 14:49:57 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-08 14:49:57 +0100
commit58b2524b89d4db614aadbd8497b6e791e0d999cf (patch)
treeeba5a635e302b998751810920184fa4c72b25be7 /main.scm
parentFix error when looking at cloned events. (diff)
downloadcalp-58b2524b89d4db614aadbd8497b6e791e0d999cf.tar.gz
calp-58b2524b89d4db614aadbd8497b6e791e0d999cf.tar.xz
Move stuff between modules.
Diffstat (limited to 'main.scm')
-rwxr-xr-xmain.scm36
1 files changed, 13 insertions, 23 deletions
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)
time<? (extract "DTSTART"))
(lambda (ev) (format #t "~a | ~a~%"
- (let ((start (get-attr ev "DTSTART")))
+ (let ((start (attr ev "DTSTART")))
(color-if (today? start) STR-YELLOW
(time->string start "~1 ~H:~M")))
- (get-attr ev "SUMMARY")))))
+ (attr ev "SUMMARY")))))
#; (define pizza-event (search cal "pizza"))