I am not really aware of a function that does this you could try digging into the implementation of raise-arguments-error,
usually I roll my own implementation depending on what I really want to output.
racket/format and its ~a, ~v, etc. have a lot of useful optional keyword arguments like #:align #:pad-string #:width etc.
This isn't totally what you want, but maybe it has something that is useful to you.
This or similar code is what I have used sometimes:
#lang racket
(define current-prefix-length (make-parameter 0))
(define (prefixln #:prefix [prefix ""]
#:align [align 'left]
. message)
(displayln (apply ~a (list* (~a prefix #:width (current-prefix-length) #:align align)
message))))
(define-syntax-rule (with-indent body ...)
(parameterize ([current-prefix-length (+ (current-prefix-length) 2)])
body ...))
(define (example-func1)
(prefixln "start of example func1")
(with-indent
(example-func2))
(prefixln "end of example func1"))
(define (example-func2)
(prefixln "start of example func2")
(prefixln "end of example func2"))
(module+ main
(displayln "Hello checkout these values:")
(define example-values
(hash 'foo 123
'this-is-a-long-key "some value"
'blabla #f
"cake" "is a lie"))
;; ugly oneliner to calculate prefix width
(current-prefix-length (+ 2 (foldl max 0 (map (compose1 string-length ~a) (hash-keys example-values)))))
(for ([(k v) (in-hash example-values)]) ;; probably sorting or assoc list would make sense too...
(prefixln #:prefix (~a k ": ") #:align 'right
v))
(current-prefix-length 0)
(displayln "")
(displayln "indentation through multiple nested calls:")
(with-indent
(example-func1)))
If you use a current-prefix-string parameter instead you can create other interesting things like lines indented with indentation level indicators, etc.:
indent0
| indent1
| | indent2
| indent1
indent0
But I am getting too off-topic...
Simon