diff options
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index b9ba8c0f7a..a469494d78 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -104,6 +104,7 @@ read/eval read/eval-package-expression check-available-space + indented-string fill-paragraph %text-width texi->plain-text @@ -1206,6 +1207,23 @@ replacement if PORT is not Unicode-capable." (lambda () body ...))))) +(define* (indented-string str indent + #:key (initial-indent? #t)) + "Return STR with each newline preceded by IDENT spaces. When +INITIAL-INDENT? is true, the first line is also indented." + (define indent-string + (make-list indent #\space)) + + (list->string + (string-fold-right (lambda (chr result) + (if (eqv? chr #\newline) + (cons chr (append indent-string result)) + (cons chr result))) + '() + (if initial-indent? + (string-append (list->string indent-string) str) + str)))) + (define* (fill-paragraph str width #:optional (column 0)) "Fill STR such that each line contains at most WIDTH characters, assuming that the first character is at COLUMN. |