aboutsummaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2023-11-17 13:55:07 +0000
committerArun Isaac2023-11-17 13:55:07 +0000
commitb1cff95e0360f7db8391763bba334aaac595dd41 (patch)
tree4a0bad34ba7e868311bbca8041a7b4e2468fdea4 /ccwl
parent19b9decada9b18b85e4197d0bc395389cba76fc3 (diff)
downloadccwl-b1cff95e0360f7db8391763bba334aaac595dd41.tar.gz
ccwl-b1cff95e0360f7db8391763bba334aaac595dd41.tar.lz
ccwl-b1cff95e0360f7db8391763bba334aaac595dd41.zip
ui: Colorize format specifiers not format arguments.
* ccwl/ui.scm (report-formatted-message): Colorize format specifiers not format arguments. * tests/ui.scm ("report-formatted-message must not fail on arguments that are not strings"): New test.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ui.scm15
1 files changed, 12 insertions, 3 deletions
diff --git a/ccwl/ui.scm b/ccwl/ui.scm
index 7f5c76a..3b46a23 100644
--- a/ccwl/ui.scm
+++ b/ccwl/ui.scm
@@ -20,6 +20,7 @@
#:use-module (rnrs io ports)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-28)
+ #:use-module (ice-9 string-fun)
#:use-module (term ansi-color)
#:use-module (ccwl conditions)
#:export (report-formatted-message
@@ -29,9 +30,17 @@
"Report @var{exception}, a @code{&formatted-message} condition to the
user."
(display (apply format
- (formatted-message-format exception)
- (map (cut colorize-string <> 'BOLD 'MAGENTA)
- (formatted-message-arguments exception)))
+ ;; We colorize the format specifiers instead of the
+ ;; arguments because we cannot always be sure that
+ ;; the arguments are strings.
+ (string-replace-substring
+ (string-replace-substring
+ (formatted-message-format exception)
+ "~a"
+ (colorize-string "~a" 'BOLD 'MAGENTA))
+ "~s"
+ (colorize-string "~s" 'BOLD 'MAGENTA))
+ (formatted-message-arguments exception))
(current-error-port))
(newline (current-error-port)))