This is an automated email from the git hooks/post-receive script.

wingo pushed a commit to branch main
in repository guile.

The following commit(s) were added to refs/heads/main by this push:
     new 437e5ac43 Fix pretty-print with a per-line prefix
437e5ac43 is described below

commit 437e5ac43d89fbab902003dfce4e6982f350ffb5
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Wed Nov 15 09:35:23 2023 +0100

    Fix pretty-print with a per-line prefix
    
    * module/ice-9/pretty-print.scm (pretty-print): Include the per-line
    prefix in the indent.
    * test-suite/tests/print.test ("pretty-print"): Add test.
---
 module/ice-9/pretty-print.scm |  2 +-
 test-suite/tests/print.test   | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/module/ice-9/pretty-print.scm b/module/ice-9/pretty-print.scm
index 7a649a4f0..fa0402a18 100644
--- a/module/ice-9/pretty-print.scm
+++ b/module/ice-9/pretty-print.scm
@@ -114,7 +114,7 @@ port directly after OBJ, like (pretty-print OBJ PORT)."
        ((< to col)
         (put-string port "\n")
         (put-string port per-line-prefix)
-        (spaces to))
+        (spaces (- to (string-length per-line-prefix))))
        (else
         (spaces (- to col))))))
 
diff --git a/test-suite/tests/print.test b/test-suite/tests/print.test
index 729a5342b..4c6bedd43 100644
--- a/test-suite/tests/print.test
+++ b/test-suite/tests/print.test
@@ -127,7 +127,24 @@
               "        (1\n"
               "         (0\n"
               "          0))))))))))\n")
-             #:width 10)))
+             #:width 10))
+
+  (pass-if "prefix"
+    (prints? (9 (8 (7 (6 (5 (4 (3 (2 (1 (0 0))))))))))
+             (string-append
+              "> (9\n"
+              ">  (8\n"
+              ">   (7\n"
+              ">    (6\n"
+              ">     (5\n"
+              ">      (4\n"
+              ">       (3\n"
+              ">        (2\n"
+              ">         (1\n"
+              ">          (0\n"
+              ">           0))))))))))\n")
+             #:width 10
+             #:per-line-prefix "> ")))
 
 
 (with-test-prefix "truncated-print"

Reply via email to