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/text/flow.scm | 4 ++-- module/text/markup.scm | 5 +++-- module/text/numbers/en.scm | 11 +++++++---- module/text/numbers/sv.scm | 11 +++++++---- module/text/util.scm | 24 ++++++++++++++---------- 5 files changed, 33 insertions(+), 22 deletions(-) (limited to 'module/text') diff --git a/module/text/flow.scm b/module/text/flow.scm index 3b958480..315bea06 100644 --- a/module/text/flow.scm +++ b/module/text/flow.scm @@ -8,11 +8,11 @@ :use-module (text util) :use-module (srfi srfi-1) :use-module (srfi srfi-71) - ) + :export (flow-text)) ;; str -> (str) -(define*-public (flow-text str #:key (width 70)) +(define* (flow-text str #:key (width 70)) (flatten (map (lambda (line) (justify-line line #:width width)) (lines str)))) diff --git a/module/text/markup.scm b/module/text/markup.scm index 53dab321..a7a905df 100644 --- a/module/text/markup.scm +++ b/module/text/markup.scm @@ -6,11 +6,12 @@ :use-module (ice-9 pretty-print) :use-module (text util) :use-module (text flow) - :use-module (texinfo string-utils)) + :use-module (texinfo string-utils) + :export (sxml->ansi-text)) ;; Takes an HTML-like sxml coded tree, and produces a string with ;; appropriate spacing and ANSI-escapes for different tags. -(define-public (sxml->ansi-text tree) +(define (sxml->ansi-text tree) ((parse-tree ontree onleaf) tree)) diff --git a/module/text/numbers/en.scm b/module/text/numbers/en.scm index 622decd5..6a5a636d 100644 --- a/module/text/numbers/en.scm +++ b/module/text/numbers/en.scm @@ -1,14 +1,17 @@ (define-module (text numbers en) - :use-module (ice-9 format)) + :use-module (ice-9 format) + :export (number->string-cardinal + number->string-ordinal + each-string)) -(define-public (number->string-cardinal n) +(define (number->string-cardinal n) (format #f "~r" n)) -(define-public (number->string-ordinal n) +(define (number->string-ordinal n) (format #f "~:r" n)) ;; Allows extra args to handle eventual local changes. -(define-public (each-string count . _) +(define (each-string count . _) (case count [(1) "each"] [(2) "every other"] diff --git a/module/text/numbers/sv.scm b/module/text/numbers/sv.scm index b70412fb..1760f622 100644 --- a/module/text/numbers/sv.scm +++ b/module/text/numbers/sv.scm @@ -1,6 +1,9 @@ (define-module (text numbers sv) :use-module (srfi srfi-71) - :use-module (hnh util)) + :use-module (hnh util) + :export (number->string-cardinal + number->string-ordinal + each-string)) ;; only used in number->string-cardinal (define (large-prefix e) @@ -17,7 +20,7 @@ [(<= 60 e 65) "dec"] )) -(define-public (number->string-cardinal n) +(define (number->string-cardinal n) (cond [(< n 0) (string-append "minus " (number->string-cardinal (- n)))] [(= n 0) "noll"] [(= n 1) "ett"] @@ -89,7 +92,7 @@ (string-append "det stora talet " (number->string n))])) -(define*-public (number->string-ordinal +(define* (number->string-ordinal n key: a-form?) (define a-string (if a-form? "a" "e")) (cond [(>= -3 n) (format #f "~a sista" (number->string-ordinal (- n)))] @@ -146,7 +149,7 @@ ;; (each-string 2) ; => "varannan" ;; (each-string 3) ; => "var tredje" ;; (each-string 3 #t) ; => "vart tredje" -(define*-public (each-string count optional: neutrum) +(define* (each-string count optional: neutrum) (string-flatten (cons "var" diff --git a/module/text/util.scm b/module/text/util.scm index 7144b032..5ade7144 100644 --- a/module/text/util.scm +++ b/module/text/util.scm @@ -3,18 +3,22 @@ ;;; Code: (define-module (text util) - :use-module ((hnh util) :select (define*-public intersperse) ) - ) + :use-module ((hnh util) :select (intersperse)) + :export (words unwords lines unlines + true-string-length + true-string-pad + trim-to-width + add-enumeration-punctuation)) -(define-public (words str) (string-split str #\space)) -(define-public (unwords list) (string-join list " " 'infix)) +(define (words str) (string-split str #\space)) +(define (unwords list) (string-join list " " 'infix)) -(define-public (lines str) (string-split str #\newline)) -(define-public (unlines list) (string-join list "\n" 'infix)) +(define (lines str) (string-split str #\newline)) +(define (unlines list) (string-join list "\n" 'infix)) ;; Alternative string-length whith counts ANSI escapes as 0-length. ;; NOTE Some way to opt in and out of different features would be nice. -(define-public (true-string-length word) +(define (true-string-length word) (let loop ((chars (string->list word))) (if (null? chars) 0 @@ -23,7 +27,7 @@ (loop (cdr (memv #\m chars))) (1+ (loop (cdr chars)))))))) -(define*-public (true-string-pad str len optional: (chr #\space)) +(define* (true-string-pad str len optional: (chr #\space)) (let ((strlen (true-string-length str))) (if (> strlen len) str @@ -31,7 +35,7 @@ str)))) -(define-public (trim-to-width str len) +(define (trim-to-width str len) (let ((trimmed (string-pad-right str len))) (if (< (string-length trimmed) (string-length str)) @@ -40,7 +44,7 @@ trimmed))) ;; TODO more options for infix strings -(define*-public (add-enumeration-punctuation +(define* (add-enumeration-punctuation list optional: (final-delim "&")) (cond [(null? list) ""] [(= 1 (length list)) (car list)] -- cgit v1.2.3