From 92b2f429a06ed9b052baff5e27f012397b338f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 23 Dec 2019 23:40:14 +0100 Subject: Rework program initialization. Old init setup had the fancy idea to parse all files before anything could be done with them. This however led to problems when a part of the program which didn't care for the calendar files (such as text formatting). It also made testing performance almost impossible since to much code was run before I had a chance to init statprof. --- module/output/ical.scm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'module/output/ical.scm') diff --git a/module/output/ical.scm b/module/output/ical.scm index fcb75526..3dbc74b8 100644 --- a/module/output/ical.scm +++ b/module/output/ical.scm @@ -1,5 +1,4 @@ (define-module (output ical) - :use-module (ice-9 getopt-long) :use-module (ice-9 format) :use-module (ice-9 match) :use-module (util) @@ -11,14 +10,11 @@ :use-module (srfi srfi-41 util) ) -(define opt-spec - '((from (value #t) (single-char #\f)) - (to (value #t) (single-char #\t)))) ;; Format value depending on key type. ;; Should NOT emit the key. (define (value-format key vline) - (catch 'wrong-type-arg + (with-throw-handler 'wrong-type-arg (lambda () (case key ((DTSTART DTEND) @@ -38,7 +34,7 @@ (else (escape-chars (value vline))))) (lambda (err caller fmt args call-args) (format (current-error-port) - "WARNING: ~k~%" fmt args) + "WARNING: key = ~a, caller = ~s, call-args = ~s~%~k~%" key caller call-args fmt args) (with-output-to-string (lambda () (display (value vline)))) ))) @@ -101,14 +97,7 @@ CALSCALE:GREGORIAN\r (define (print-footer) (format #t "END:VCALENDAR\r\n")) -(define-public (ical-main calendars events args) - (define opts (getopt-long args opt-spec)) - - (define start (cond [(option-ref opts 'from #f) => parse-freeform-date] - [else (start-of-month (current-date))])) - (define end (cond [(option-ref opts 'to #f) => parse-freeform-date] - [else (normalize-date* (set (date-month start) = (+ 1)))])) - +(define-public (ical-main calendars events start end) (print-header) (let ((tzs (make-hash-table))) -- cgit v1.2.3