From 1976980d4a272fb7fc3694c734bfc6825edfc721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 23 Jun 2022 03:23:44 +0200 Subject: Centralize (almost) all exports to :export in define-module. --- module/vcomponent/base.scm | 70 +++++++++++++++++--------- module/vcomponent/datetime.scm | 34 +++++++++---- module/vcomponent/datetime/output.scm | 14 ++++-- module/vcomponent/duration.scm | 7 ++- module/vcomponent/formats/common/types.scm | 4 +- module/vcomponent/formats/ical/output.scm | 14 ++++-- module/vcomponent/formats/ical/parse.scm | 4 +- module/vcomponent/formats/ical/types.scm | 6 +-- module/vcomponent/formats/vdir/parse.scm | 5 +- module/vcomponent/formats/vdir/save-delete.scm | 5 +- module/vcomponent/formats/xcal/output.scm | 6 +-- module/vcomponent/formats/xcal/parse.scm | 3 +- module/vcomponent/formats/xcal/types.scm | 4 +- module/vcomponent/geo.scm | 5 +- module/vcomponent/recurrence.scm | 2 +- module/vcomponent/recurrence/display/en.scm | 5 +- module/vcomponent/recurrence/display/sv.scm | 5 +- module/vcomponent/recurrence/generate.scm | 13 +++-- module/vcomponent/recurrence/internal.scm | 52 ++++++++++--------- module/vcomponent/recurrence/parse.scm | 9 ++-- module/vcomponent/util/describe.scm | 6 +-- module/vcomponent/util/group.scm | 6 ++- module/vcomponent/util/instance.scm | 4 +- module/vcomponent/util/instance/methods.scm | 6 ++- module/vcomponent/util/parse-cal-path.scm | 5 +- module/vcomponent/util/search.scm | 39 ++++++++------ 26 files changed, 203 insertions(+), 130 deletions(-) (limited to 'module/vcomponent') diff --git a/module/vcomponent/base.scm b/module/vcomponent/base.scm index 3d40ef9c..e79a4d5c 100644 --- a/module/vcomponent/base.scm +++ b/module/vcomponent/base.scm @@ -5,7 +5,34 @@ :use-module (srfi srfi-9 gnu) :use-module (srfi srfi-17) :use-module (ice-9 hash-table) - :use-module ((ice-9 optargs) :select (define*-public)) + :export (make-vline + vline? + vline-key + vline-source + + make-vcomponent + vcomponent? + children type parent + + add-child! remove-child! + + delete-property! + prop* prop + extract extract* + + delete-parameter! + value + param + + parameters + properties + + copy-vcomponent + x-property? + internal-field? + + + ) ) @@ -31,8 +58,6 @@ (source get-source set-source!) ) -(export vline? vline-key) - (set-record-type-printer! (lambda (v p) @@ -41,11 +66,11 @@ (get-vline-value v) (hash-map->list list (get-vline-parameters v))))) -(define-public vline-source +(define vline-source (make-procedure-with-setter get-source set-source!)) -(define*-public (make-vline key value #:optional (ht (make-hash-table))) +(define* (make-vline key value #:optional (ht (make-hash-table))) (make-vline% key value ht)) (define-record-type @@ -55,7 +80,6 @@ (children children set-component-children!) (parent get-component-parent set-component-parent!) (properties get-component-properties)) -(export vcomponent? children type) ((@ (srfi srfi-9 gnu) set-record-type-printer!) @@ -66,18 +90,18 @@ (and=> (get-component-parent c) type)))) ;; TODO should this also update the parent -(define-public parent +(define parent (make-procedure-with-setter get-component-parent set-component-parent!)) -(define*-public (make-vcomponent #:optional (type 'VIRTUAL)) +(define* (make-vcomponent #:optional (type 'VIRTUAL)) (make-vcomponent% type '() #f (make-hash-table))) -(define-public (add-child! parent child) +(define (add-child! parent child) (set-component-children! parent (cons child (children parent))) (set-component-parent! child parent)) -(define-public (remove-child! parent-component child) +(define (remove-child! parent-component child) (unless (eq? parent-component (parent child)) (scm-error 'wrong-type-arg "remove-child!" "Child doesn't belong to parent" @@ -97,7 +121,7 @@ ;; vline → value -(define-public value +(define value (make-procedure-with-setter get-vline-value set-vline-value!)) @@ -110,12 +134,12 @@ (hashq-set! (get-component-properties component) (as-symb key) value)) -(define-public prop* +(define prop* (make-procedure-with-setter get-prop* set-prop*!)) -(define-public (delete-property! component key) +(define (delete-property! component key) (hashq-remove! (get-component-properties component) (as-symb key))) @@ -131,13 +155,13 @@ (define (set-prop! component key value) (set-property! component (as-symb key) value)) -(define-public prop +(define prop (make-procedure-with-setter get-prop set-prop!)) -(define-public param +(define param (make-procedure-with-setter (lambda (vline parameter-key) ;; TODO `list' is a hack since a bit to much code depends @@ -150,17 +174,17 @@ (as-symb parameter-key) val)))) -(define-public (delete-parameter! vline parameter-key) +(define (delete-parameter! vline parameter-key) (hashq-remove! (get-vline-parameters vline) (as-symb parameter-key))) ;; Returns the parameters of a property as an assoc list. ;; @code{(map car <>)} leads to available parameters. -(define-public (parameters vline) +(define (parameters vline) (hash-map->list list (get-vline-parameters vline))) -(define-public (properties component) +(define (properties component) (hash-map->list cons (get-component-properties component))) (define (copy-vline vline) @@ -169,7 +193,7 @@ ;; TODO deep-copy on parameters? (get-vline-parameters vline))) -(define-public (copy-vcomponent component) +(define (copy-vcomponent component) (make-vcomponent% (type component) ;; TODO deep copy? @@ -183,16 +207,16 @@ (copy-vline value)))) (get-component-properties component))))) -(define-public (extract field) +(define (extract field) (lambda (e) (prop e field))) -(define-public (extract* field) +(define (extract* field) (lambda (e) (prop* e field))) -(define-public (x-property? symb) +(define (x-property? symb) (string=? "X-" (string-take (symbol->string symb) 2))) -(define*-public (internal-field? symbol optional: (prefix "-")) +(define* (internal-field? symbol optional: (prefix "-")) (string=? prefix (string-take-to (symbol->string symbol) (string-length prefix)))) diff --git a/module/vcomponent/datetime.scm b/module/vcomponent/datetime.scm index bb4fe50e..5fb1148c 100644 --- a/module/vcomponent/datetime.scm +++ b/module/vcomponent/datetime.scm @@ -12,8 +12,20 @@ event-overlaps? overlapping? event-contains? - ev-timevtimezone + )) ;;; date time pointer #; @@ -50,16 +62,16 @@ Event must have the DTSTART and DTEND protperty set." (end (add-day start))) (event-overlaps? ev start end))) -(define-public (event-zero-length? ev) +(define (event-zero-length? ev) (and (datetime? (prop ev 'DTSTART)) (not (prop ev 'DTEND)))) -(define-public (ev-timevtimezone zoneinfo zone-name event) +(define (zoneinfo->vtimezone zoneinfo zone-name event) (define vtimezone (make-vcomponent 'VTIMEZONE)) (define last-until (datetime date: (date month: 1 day: 1))) (define last-offset (timespec-zero)) diff --git a/module/vcomponent/datetime/output.scm b/module/vcomponent/datetime/output.scm index b75fd564..614438da 100644 --- a/module/vcomponent/datetime/output.scm +++ b/module/vcomponent/datetime/output.scm @@ -5,11 +5,15 @@ :use-module (text util) :use-module (calp translation) :use-module ((hnh util exceptions) :select (warning)) - ) + :export (format-recurrence-rule + format-summary + format-description + fmt-time-span + )) ;; ev → sxml ;; TODO translation -(define-public (format-recurrence-rule ev) +(define (format-recurrence-rule ev) ;; [FRR] ;; Part of the sentance "Repeated [every two weeks], except on ~a, ~a & ~a" ;; See everything tagged [FRR] @@ -37,11 +41,11 @@ (map value it))))) ".")) -(define-public (format-summary ev str) +(define (format-summary ev str) ((@ (calp html filter) summary-filter) ev str)) ;; NOTE this should have information about context (html/term/...) -(define-public (format-description ev str) +(define (format-description ev str) (catch #t (lambda () ((@ (calp html filter) description-filter) ev str)) (lambda (err . args) @@ -53,7 +57,7 @@ ;; Takes an event, and returns a pretty string for the time interval ;; the event occupies. -(define-public (fmt-time-span ev) +(define (fmt-time-span ev) (cond [(prop ev 'DTSTART) date? => (lambda (s) (cond [(prop ev 'DTEND) diff --git a/module/vcomponent/duration.scm b/module/vcomponent/duration.scm index 637d7db4..449645fc 100644 --- a/module/vcomponent/duration.scm +++ b/module/vcomponent/duration.scm @@ -6,7 +6,10 @@ :use-module (ice-9 match) :use-module (srfi srfi-9 gnu) :use-module (srfi srfi-1) - :export (duration parse-duration)) + :export (duration + parse-duration + format-duration + )) (define-immutable-record-type (make-duration sign week day dur-time) @@ -26,7 +29,7 @@ (make-duration sign week day time)) -(define-public (format-duration duration) +(define (format-duration duration) (with-output-to-string (lambda () (unless (eq? '+ (duration-sign duration)) diff --git a/module/vcomponent/formats/common/types.scm b/module/vcomponent/formats/common/types.scm index 1a7ec0da..a8a923da 100644 --- a/module/vcomponent/formats/common/types.scm +++ b/module/vcomponent/formats/common/types.scm @@ -7,7 +7,7 @@ :use-module (srfi srfi-71) :use-module (datetime timespec) :use-module (calp translation) - ) + :export (get-parser)) ;; BINARY (define (parse-binary props value) @@ -136,7 +136,7 @@ (hashq-set! type-parsers 'URI parse-uri) (hashq-set! type-parsers 'UTC-OFFSET parse-utc-offset) -(define-public (get-parser type) +(define (get-parser type) (or (hashq-ref type-parsers type #f) (scm-error 'misc-error "get-parser" (_ "No parser for type ~a") (list type) #f))) diff --git a/module/vcomponent/formats/ical/output.scm b/module/vcomponent/formats/ical/output.scm index 489cdc00..fbb9c862 100644 --- a/module/vcomponent/formats/ical/output.scm +++ b/module/vcomponent/formats/ical/output.scm @@ -17,7 +17,11 @@ :use-module (vcomponent recurrence) :use-module (calp translation) :autoload (vcomponent util instance) (global-event-object) - ) + :export (component->ical-string + print-components-with-fake-parent + print-all-events + print-events-in-interval + )) (define (prodid) (format #f "-//hugo//calp ~a//EN" @@ -140,7 +144,7 @@ (parameters vline))) ":" (value-format key vline)))) -(define-public (component->ical-string component) +(define (component->ical-string component) (format #t "BEGIN:~a\r\n" (type component)) (for-each ;; Special cases depending on key. @@ -192,7 +196,7 @@ CALSCALE:GREGORIAN\r '("dummy" "local"))) -(define-public (print-components-with-fake-parent events) +(define (print-components-with-fake-parent events) ;; The events are probably sorted before, but until I can guarantee ;; that we sort them again here. We need them sorted from earliest @@ -216,7 +220,7 @@ CALSCALE:GREGORIAN\r (print-footer)) -(define-public (print-all-events) +(define (print-all-events) (print-components-with-fake-parent (append (get-fixed-events global-event-object) ;; TODO RECCURENCE-ID exceptions @@ -225,7 +229,7 @@ CALSCALE:GREGORIAN\r ;; the given date range. (get-repeating-events global-event-object)))) -(define-public (print-events-in-interval start end) +(define (print-events-in-interval start end) (print-components-with-fake-parent (append (fixed-events-in-range start end) ;; TODO RECCURENCE-ID exceptions diff --git a/module/vcomponent/formats/ical/parse.scm b/module/vcomponent/formats/ical/parse.scm index cca306c5..49f8f101 100644 --- a/module/vcomponent/formats/ical/parse.scm +++ b/module/vcomponent/formats/ical/parse.scm @@ -12,7 +12,7 @@ :use-module (vcomponent geo) :use-module (vcomponent formats common types) :use-module (calp translation) - ) + :export (parse-calendar)) (define string->symbol (let ((ht (make-hash-table 1000))) @@ -23,7 +23,7 @@ symb))))) ;; TODO rename to parse-vcomponent, or parse-ical (?). -(define-public (parse-calendar port) +(define (parse-calendar port) (parse (map tokenize (read-file port)))) (define-immutable-record-type diff --git a/module/vcomponent/formats/ical/types.scm b/module/vcomponent/formats/ical/types.scm index 67f9f633..7b6aad2e 100644 --- a/module/vcomponent/formats/ical/types.scm +++ b/module/vcomponent/formats/ical/types.scm @@ -6,7 +6,7 @@ :use-module (datetime) :use-module (datetime timespec) :use-module (calp translation) - ) + :export (escape-chars get-writer)) ;; TODO shouldn't these really take vline:s? @@ -45,7 +45,7 @@ ((@ (vcomponent recurrence internal) recur-rule->rrule-string) value)) -(define-public (escape-chars str) +(define (escape-chars str) (define (escape char) (string #\\ char)) (string-concatenate @@ -92,6 +92,6 @@ (hashq-set! type-writers 'URI write-uri) (hashq-set! type-writers 'UTC-OFFSET write-utc-offset) -(define-public (get-writer type) +(define (get-writer type) (or (hashq-ref type-writers type #f) (error (_ "No writer for type") type))) diff --git a/module/vcomponent/formats/vdir/parse.scm b/module/vcomponent/formats/vdir/parse.scm index b21a5f2b..46626402 100644 --- a/module/vcomponent/formats/vdir/parse.scm +++ b/module/vcomponent/formats/vdir/parse.scm @@ -18,7 +18,8 @@ :use-module (calp translation) :use-module (vcomponent formats ical parse) - ) + + :export (parse-vdir)) @@ -26,7 +27,7 @@ ;; All VTIMEZONE's seem to be in "local" time in relation to ;; themselves. Therefore, a simple comparison should work, ;; and then the TZOFFSETTO properties can be subtd. -(define-public (parse-vdir path) +(define (parse-vdir path) ;; TODO empty files here cause "#" to appear in the output XML, which is *really* bad. (let ((color (catch 'system-error diff --git a/module/vcomponent/formats/vdir/save-delete.scm b/module/vcomponent/formats/vdir/save-delete.scm index fb84d59c..ac520463 100644 --- a/module/vcomponent/formats/vdir/save-delete.scm +++ b/module/vcomponent/formats/vdir/save-delete.scm @@ -17,10 +17,11 @@ :use-module (vcomponent) :use-module (calp translation) :use-module ((hnh util io) :select (with-atomic-output-to-file)) + :export (save-event remove-event) ) -(define-public (save-event event) +(define (save-event event) (define calendar (parent event)) (unless calendar @@ -50,7 +51,7 @@ uid)) -(define-public (remove-event event) +(define (remove-event event) (define calendar (parent event)) (unless (eq? 'vdir (prop calendar '-X-HNH-SOURCETYPE)) (scm-error 'wrong-type-arg "remove-event" diff --git a/module/vcomponent/formats/xcal/output.scm b/module/vcomponent/formats/xcal/output.scm index 26018d92..87ebd32b 100644 --- a/module/vcomponent/formats/xcal/output.scm +++ b/module/vcomponent/formats/xcal/output.scm @@ -8,7 +8,7 @@ :use-module (datetime) :use-module (srfi srfi-1) :use-module (calp translation) - ) + :export (vcomponent->sxcal ns-wrap)) (define (vline->value-tag vline) @@ -94,7 +94,7 @@ (unless (null? outparams) `(parameters ,@outparams))) -(define-public (vcomponent->sxcal component) +(define (vcomponent->sxcal component) (define tagsymb (downcase-symbol (type component))) @@ -129,6 +129,6 @@ ,(unless (null? (children component)) `(components ,@(map vcomponent->sxcal (children component))))))) -(define-public (ns-wrap sxml) +(define (ns-wrap sxml) `(icalendar (@ (xmlns "urn:ietf:params:xml:ns:icalendar-2.0")) ,sxml)) diff --git a/module/vcomponent/formats/xcal/parse.scm b/module/vcomponent/formats/xcal/parse.scm index d9020858..8537956a 100644 --- a/module/vcomponent/formats/xcal/parse.scm +++ b/module/vcomponent/formats/xcal/parse.scm @@ -10,6 +10,7 @@ :use-module (datetime) :use-module (srfi srfi-1) :use-module (calp translation) + :export (sxcal->vcomponent) ) ;; symbol, ht, (list a) -> non-list @@ -179,7 +180,7 @@ ;; are possibilities, which other parts of the code will crash on. ;; TODO ;; since we are feeding user input into this it really should be fixed. -(define-public (sxcal->vcomponent sxcal) +(define (sxcal->vcomponent sxcal) (define type (symbol-upcase (car sxcal))) (define component (make-vcomponent type)) diff --git a/module/vcomponent/formats/xcal/types.scm b/module/vcomponent/formats/xcal/types.scm index 8f13d3d1..a88b6b04 100644 --- a/module/vcomponent/formats/xcal/types.scm +++ b/module/vcomponent/formats/xcal/types.scm @@ -3,7 +3,7 @@ :use-module (vcomponent formats ical types) :use-module (datetime) :use-module (calp translation) - ) + :export (get-writer)) (define (write-boolean _ v) `(boolean ,(if v "true" "false"))) @@ -50,6 +50,6 @@ (hashq-set! sxml-writers 'RECUR write-recur) (hashq-set! sxml-writers 'TEXT write-text) -(define-public (get-writer type) +(define (get-writer type) (or (hashq-ref sxml-writers type #f) (error (_ "No writer for type") type))) diff --git a/module/vcomponent/geo.scm b/module/vcomponent/geo.scm index 27b2cbae..9261076f 100644 --- a/module/vcomponent/geo.scm +++ b/module/vcomponent/geo.scm @@ -1,11 +1,10 @@ (define-module (vcomponent geo) :use-module (hnh util) - :use-module (srfi srfi-9 gnu)) + :use-module (srfi srfi-9 gnu) + :export (make-geo geo-pos? geo-latitude geo-longitude)) (define-immutable-record-type (make-geo latitude longitude) geo-pos? (latitude geo-latitude) (longitude geo-longitude)) - -(export make-geo geo-pos? geo-latitude geo-longitude) diff --git a/module/vcomponent/recurrence.scm b/module/vcomponent/recurrence.scm index 12f901d2..29cbbc64 100644 --- a/module/vcomponent/recurrence.scm +++ b/module/vcomponent/recurrence.scm @@ -4,4 +4,4 @@ #:use-module (vcomponent recurrence internal) #:re-export (generate-recurrence-set parse-recurrence-rule - repeating? format-recur-rule make-recur-rule)) + repeating? make-recur-rule)) diff --git a/module/vcomponent/recurrence/display/en.scm b/module/vcomponent/recurrence/display/en.scm index 68d435af..c711a75c 100644 --- a/module/vcomponent/recurrence/display/en.scm +++ b/module/vcomponent/recurrence/display/en.scm @@ -6,7 +6,8 @@ :use-module (vcomponent recurrence display common) :use-module ((datetime) :select (time time->string datetime->string - week-day-name))) + week-day-name)) + :export (format-recurrence-rule)) @@ -41,7 +42,7 @@ (map number->string-ordinal lst)))) -(define-public (format-recurrence-rule rrule) +(define (format-recurrence-rule rrule) (string-trim (string-flatten (list diff --git a/module/vcomponent/recurrence/display/sv.scm b/module/vcomponent/recurrence/display/sv.scm index 35b3569b..2bd70657 100644 --- a/module/vcomponent/recurrence/display/sv.scm +++ b/module/vcomponent/recurrence/display/sv.scm @@ -13,7 +13,8 @@ :use-module (vcomponent recurrence display common) :use-module ((datetime) :select (time time->string datetime->string - week-day-name))) + week-day-name)) + :export (format-recurrence-rule)) ;; TODO this currently only groups on offsets, but not on days. ;; So 1MO, 1TU becomes "första måndagen och tisdagen", which is good @@ -49,7 +50,7 @@ (map number->string-ordinal lst) final-delim))) -(define-public (format-recurrence-rule rrule) +(define (format-recurrence-rule rrule) (string-trim (string-flatten (list diff --git a/module/vcomponent/recurrence/generate.scm b/module/vcomponent/recurrence/generate.scm index 83ef4274..07305647 100644 --- a/module/vcomponent/recurrence/generate.scm +++ b/module/vcomponent/recurrence/generate.scm @@ -10,15 +10,16 @@ :use-module (vcomponent recurrence parse) :use-module (datetime) - :use-module (ice-9 curried-definitions) ) - + :use-module (ice-9 curried-definitions) + :export (rrule-instances + final-event-occurence + generate-recurrence-set)) - ;; Returns #t if any of the predicates return true when applied to object. (define (any-predicate object predicates) ((@ (srfi srfi-1) any) @@ -354,10 +355,8 @@ (stream-remove (lambda (dt) (member dt exdates)) items) items)))) -(export rrule-instances) - -(define-public (final-event-occurence event) +(define (final-event-occurence event) (define rrule (prop event 'RRULE)) (if (or (count rrule) (until rrule)) @@ -390,7 +389,7 @@ ;; -> (stream ) ;; TODO memoize this? -(define-public (generate-recurrence-set base-event) +(define (generate-recurrence-set base-event) (define duration (event-duration base-event)) diff --git a/module/vcomponent/recurrence/internal.scm b/module/vcomponent/recurrence/internal.scm index 2e04dd64..9cb6b115 100644 --- a/module/vcomponent/recurrence/internal.scm +++ b/module/vcomponent/recurrence/internal.scm @@ -1,6 +1,4 @@ (define-module (vcomponent recurrence internal) - #:export (repeating? format-recur-rule make-recur-rule) - #:use-module (srfi srfi-1) #:use-module (srfi srfi-71) #:use-module (srfi srfi-88) ; better keywords @@ -11,7 +9,27 @@ #:use-module (ice-9 format) #:use-module (hnh util) #:use-module (datetime) - ) + + :replace (count) + :export (repeating? + + make-recur-rule + freq until interval bysecond byminute byhour + byday bymonthday byyearday byweekno bymonth bysetpos + wkst + + recur-rule->rrule-string + recur-rule->rrule-sxml + + weekdays + intervals + )) + +(define weekdays + (weekday-list sun)) + +(define intervals + '(SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY)) ;; EXDATE is also a property linked to recurense rules @@ -47,19 +65,16 @@ (wkst wkst) ; weekday ) -(export freq until interval bysecond byminute byhour - byday bymonthday byyearday byweekno bymonth bysetpos - wkst) -(export! count) + ;; Interval and wkst have default values, since those are assumed ;; anyways, and having them set frees us from having to check them at ;; the use site. -(define*-public (make-recur-rule - key: - freq until count (interval 1) bysecond byminute byhour - byday bymonthday byyearday byweekno bymonth bysetpos - (wkst monday)) +(define* (make-recur-rule + key: + freq until count (interval 1) bysecond byminute byhour + byday bymonthday byyearday byweekno bymonth bysetpos + (wkst monday)) ;; TODO possibly validate fields here ;; to prevent creation of invalid rules. ;; This was made apparent when wkst was (incorrectly) set to MO, @@ -117,7 +132,7 @@ #f (proc field (get field)))) (record-type-fields ))) -(define-public (recur-rule->rrule-string rrule) +(define (recur-rule->rrule-string rrule) (string-join (map-fields (lambda (field value) @@ -127,7 +142,7 @@ rrule) ";")) -(define-public (recur-rule->rrule-sxml rrule) +(define (recur-rule->rrule-sxml rrule) (map-fields (lambda (field value) (cond [(string-ci=? "UNTIL" (symbol->string field)) @@ -152,12 +167,3 @@ `(,(downcase-symbol field) ,(field->string field value))])) rrule)) - - - - -(define-public weekdays - (weekday-list sun)) - -(define-public intervals - '(SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY)) diff --git a/module/vcomponent/recurrence/parse.scm b/module/vcomponent/recurrence/parse.scm index a64cf4a7..91209dc7 100644 --- a/module/vcomponent/recurrence/parse.scm +++ b/module/vcomponent/recurrence/parse.scm @@ -1,8 +1,6 @@ (define-module (vcomponent recurrence parse) #:duplicates (last) ; Replace @var{count} - #:export (parse-recurrence-rule) - #:use-module (srfi srfi-1) #:use-module (srfi srfi-71) #:use-module (datetime) @@ -10,11 +8,14 @@ #:use-module (vcomponent recurrence internal) #:use-module (hnh util) #:use-module (hnh util exceptions) - #:use-module (ice-9 match)) + #:use-module (ice-9 match) + + #:export (rfc->datetime-weekday + parse-recurrence-rule)) ;; transform into weekday objects from -(define-public (rfc->datetime-weekday symbol) +(define (rfc->datetime-weekday symbol) (case symbol [(SU) sun] [(MO) mon] diff --git a/module/vcomponent/util/describe.scm b/module/vcomponent/util/describe.scm index 703ac73a..36a3f998 100644 --- a/module/vcomponent/util/describe.scm +++ b/module/vcomponent/util/describe.scm @@ -2,9 +2,10 @@ :use-module (hnh util) :use-module (srfi srfi-71) :use-module (vcomponent base) - :use-module (text util)) + :use-module (text util) + :export (describe)) -(define*-public (describe vcomponent optional: (indent 0)) +(define* (describe vcomponent optional: (indent 0)) (define ii (make-string indent #\space)) (define iii (make-string (1+ indent) #\space)) @@ -39,7 +40,6 @@ (compose symbol->string car))) (for child in (children vcomponent) - (describe child (+ indent 2))) (format #t "~aEND ~a~%" ii (type vcomponent))) diff --git a/module/vcomponent/util/group.scm b/module/vcomponent/util/group.scm index b8852975..89ec47a1 100644 --- a/module/vcomponent/util/group.scm +++ b/module/vcomponent/util/group.scm @@ -4,7 +4,9 @@ #:use-module (datetime) #:use-module (srfi srfi-41) #:use-module (srfi srfi-41 util) - #:export (group-stream get-groups-between)) + #:export (group-stream + get-groups-between + group->event-list)) ;; TODO templetize this (define-stream (group-stream in-stream) @@ -67,5 +69,5 @@ [else good-part])) -(define-public (group->event-list group) +(define (group->event-list group) (stream->list (cdr group))) diff --git a/module/vcomponent/util/instance.scm b/module/vcomponent/util/instance.scm index 2004f13e..a18085eb 100644 --- a/module/vcomponent/util/instance.scm +++ b/module/vcomponent/util/instance.scm @@ -2,7 +2,7 @@ :use-module (hnh util) :use-module (calp translation) :use-module ((vcomponent util instance methods) :select (make-instance)) - :export (global-event-object) + :export (global-event-object reload) ) @@ -14,6 +14,6 @@ (define-once global-event-object (make-instance ((@ (vcomponent config) calendar-files)))) -(define-public (reload) +(define (reload) (begin (set! global-event-object (make-instance ((@ (vcomponent config) calendar-files)))) (format (current-error-port) (_ "Reload done~%")))) diff --git a/module/vcomponent/util/instance/methods.scm b/module/vcomponent/util/instance/methods.scm index 7a1d2fc8..193a0304 100644 --- a/module/vcomponent/util/instance/methods.scm +++ b/module/vcomponent/util/instance/methods.scm @@ -15,7 +15,9 @@ :use-module (calp translation) - :export (add-event + :export (load-calendars + + add-event remove-event make-instance @@ -33,7 +35,7 @@ add-calendars )) -(define-public (load-calendars calendar-files) +(define (load-calendars calendar-files) (map parse-cal-path calendar-files)) diff --git a/module/vcomponent/util/parse-cal-path.scm b/module/vcomponent/util/parse-cal-path.scm index 4baa647e..cf03db88 100644 --- a/module/vcomponent/util/parse-cal-path.scm +++ b/module/vcomponent/util/parse-cal-path.scm @@ -6,11 +6,12 @@ :use-module ((vcomponent formats ical parse) :select (parse-calendar)) :use-module ((vcomponent formats vdir parse) - :select (parse-vdir))) + :select (parse-vdir)) + :export (parse-cal-path)) ;; Parse a vdir or ics file at the given path. -(define-public (parse-cal-path path) +(define (parse-cal-path path) ;; TODO check (access? path R_OK) ? (define st (stat path)) (define cal diff --git a/module/vcomponent/util/search.scm b/module/vcomponent/util/search.scm index 61e81eb5..e2057e9e 100644 --- a/module/vcomponent/util/search.scm +++ b/module/vcomponent/util/search.scm @@ -32,7 +32,20 @@ :use-module (srfi srfi-41 util) :use-module ((ice-9 sandbox) :select (make-sandbox-module - all-pure-bindings))) + all-pure-bindings)) + :export (prepare-string + build-query-proc + execute-query + prepare-query + + paginator? + get-query get-max-page true-max-page? + + next-page + paginator->list + paginator->sub-list + + get-page)) ;; Takes a string and appends closing parenthese until all parenthese are @@ -49,7 +62,7 @@ ;; Prepares a string to be sent to build-query-proc ;; sexp-like string -> sexp -(define-public (prepare-string str) +(define (prepare-string str) (call-with-input-string (close-parenthese str) read)) ;; TODO place this in a proper module @@ -64,7 +77,7 @@ ;; eval-in-sandbox is possibly slow, and that would prevent easy caching by the ;; caller. ;; sexp -> (event → bool) -(define-public (build-query-proc . expressions) +(define (build-query-proc . expressions) ;; TODO does this eval help? Or will the body of the procedure ;; be evalutade later? (eval `(lambda (event) ,@expressions) @@ -80,7 +93,7 @@ ;; Returns a new stream which is the result of filtering the input set with the ;; query procedure. ;; (a → bool), (stream a) → (stream a) -(define-public (execute-query query-proc event-set) +(define (execute-query query-proc event-set) (stream-timeslice-limit (stream-filter query-proc event-set) ;; .5s, tested on my laptop. .1s sometimes doesn't get to events on @@ -89,7 +102,7 @@ ;; Creates a prepared query wrappend in a paginator. ;; (event → bool), (stream event) → -(define*-public (prepare-query query-proc event-set optional: (page-size 10)) +(define* (prepare-query query-proc event-set optional: (page-size 10)) (make-paginator (stream-paginate (execute-query query-proc event-set) page-size))) @@ -106,29 +119,27 @@ (define (unset-true-max-page! paginator) (%set-true-max-page! paginator #f)) -(export paginator? get-query get-max-page true-max-page?) - (define (make-paginator query) (make-paginator% query 0 #f)) ;; a fancy version of 1+ which caps at max page ;; , int → int -(define*-public (next-page paginator optional: (page (get-max-page paginator))) +(define* (next-page paginator optional: (page (get-max-page paginator))) (if (true-max-page? paginator) (min (1+ page) (get-max-page paginator)) (1+ page))) -(define-public (paginator->list paginator proc tail-proc) +(define (paginator->list paginator proc tail-proc) (if (true-max-page? paginator) (map proc (iota (1+ (get-max-page paginator)))) (append (map proc (iota (1+ (get-max-page paginator)))) (list (tail-proc (next-page paginator)))))) -(define*-public (paginator->sub-list paginator current-page proc - key: head-proc tail-proc - (ahead 5) (behind 5) - ) +(define* (paginator->sub-list paginator current-page proc + key: head-proc tail-proc + (ahead 5) (behind 5) + ) (let ((start (max 0 (- current-page behind))) (end (min (+ current-page ahead) @@ -143,7 +154,7 @@ ;; returns the contents of the requested page, or throws 'max-page with the ;; highest known available page. ;; , int → (list event) throws ('max-page ) -(define-public (get-page paginator page) +(define (get-page paginator page) (catch 'wrong-type-arg (lambda () (let ((q (get-query paginator))) (if (stream-null? q) -- cgit v1.2.3