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/text/util.scm | |
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/text/util.scm | 24 |
1 files changed, 14 insertions, 10 deletions
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)] |