aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-11-20 22:52:16 +0100
committerLudovic Courtès <ludo@gnu.org>2022-11-20 23:20:31 +0100
commit82bde985f47a84b9b05a2adc26c2f2cee278b1f5 (patch)
tree3f4b07213d45b40de5a75e4012f6966a7b732226
parent238d983b4e95b7c8bfd25e86d3c5a3d7df7e01ef (diff)
downloadguix-82bde985f47a84b9b05a2adc26c2f2cee278b1f5.tar
guix-82bde985f47a84b9b05a2adc26c2f2cee278b1f5.tar.gz
style: '-f' reads input files as UTF-8 by default.
Reported by mirai on #guix. * guix/scripts/style.scm (format-whole-file): Wrap body in 'with-fluids'. Pass #:guess-encoding to 'call-with-input-file'.
-rw-r--r--guix/scripts/style.scm16
1 files changed, 9 insertions, 7 deletions
diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index c0b9ea1a28..fa7175fb16 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -335,13 +335,15 @@ PACKAGE."
(define* (format-whole-file file #:rest rest)
"Reformat all of FILE."
- (let ((lst (call-with-input-file file read-with-comments/sequence)))
- (with-atomic-file-output file
- (lambda (port)
- (apply pretty-print-with-comments/splice port lst
- #:format-comment canonicalize-comment
- #:format-vertical-space canonicalize-vertical-space
- rest)))))
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (let ((lst (call-with-input-file file read-with-comments/sequence
+ #:guess-encoding #t)))
+ (with-atomic-file-output file
+ (lambda (port)
+ (apply pretty-print-with-comments/splice port lst
+ #:format-comment canonicalize-comment
+ #:format-vertical-space canonicalize-vertical-space
+ rest))))))
;;;