diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-23 03:23:44 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-23 03:48:22 +0200 |
commit | 1976980d4a272fb7fc3694c734bfc6825edfc721 (patch) | |
tree | 8460db1176c64895e9968447588953fac85fe7d6 /module/vcomponent/util | |
parent | Remove all inline use-modules. (diff) | |
download | calp-1976980d4a272fb7fc3694c734bfc6825edfc721.tar.gz calp-1976980d4a272fb7fc3694c734bfc6825edfc721.tar.xz |
Centralize (almost) all exports to :export in define-module.
Diffstat (limited to '')
-rw-r--r-- | module/vcomponent/util/describe.scm | 6 | ||||
-rw-r--r-- | module/vcomponent/util/group.scm | 6 | ||||
-rw-r--r-- | module/vcomponent/util/instance.scm | 4 | ||||
-rw-r--r-- | module/vcomponent/util/instance/methods.scm | 6 | ||||
-rw-r--r-- | module/vcomponent/util/parse-cal-path.scm | 5 | ||||
-rw-r--r-- | module/vcomponent/util/search.scm | 39 |
6 files changed, 41 insertions, 25 deletions
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) → <paginator> -(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 ;; <paginator>, 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. ;; <paginator>, int → (list event) throws ('max-page <int>) -(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) |