Hi :) On Tue 05 Jan 2010 01:28, l...@gnu.org (Ludovic Courtès) writes:
>> On Sun 03 Jan 2010 00:52, l...@gnu.org (Ludovic Courtès) writes: > > [...] > >>>> +(truncated-print "The quick brown fox" #:width 10) (newline) >>>> +...@print{} "The quick brown..." >>> >>> I think it’d be nice to default to ‘HORIZONTAL ELLIPSIS’ (U+2026). >>> Perhaps the ellipsis string could be a keyword parameter? > > What do you think? I think that it sounds like you are interested in this :-) I would be happy with doing nothing, but happier still if someone fixed this for me. :) I'm attaching the patch I had, when I found out the issues I wrote in my mail. Happy hacking, Andy Modified module/ice-9/pretty-print.scm diff --git a/module/ice-9/pretty-print.scm b/module/ice-9/pretty-print.scm index 9a0edbd..1507b4d 100644 --- a/module/ice-9/pretty-print.scm +++ b/module/ice-9/pretty-print.scm @@ -1,6 +1,6 @@ -;;;; -*-scheme-*- +;;;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2001, 2004, 2006, 2009 Free Software Foundation, Inc. +;;;; Copyright (C) 2001, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -285,7 +285,7 @@ into @var{width} characters. By default, @var{x} will be printed using @var{display?} keyword argument. The default behaviour is to print depth-first, meaning that the entire -remaining width will be available to each sub-expressoin of @var{x} -- +remaining width will be available to each sub-expression of @var{x} -- e.g., if @var{x} is a vector, each member of @var{x}. One can attempt to \"ration\" the available width, trying to allocate it equally to each sub-expression, via the @var{breadth-first?} keyword argument." @@ -300,8 +300,8 @@ sub-expression, via the @var{breadth-first?} keyword argument." ((= i len)) ; catches 0-length case ((= i (1- len)) (print (ref x i) (if (zero? i) width (1- width)))) - ((<= width 4) - (display "...")) + ((<= width 2) + (display "…")) (else (let ((str (with-output-to-string (lambda () @@ -309,7 +309,7 @@ sub-expression, via the @var{breadth-first?} keyword argument." (if breadth-first? (max 1 (1- (floor (/ width (- len i))))) - (- width 4))))))) + (- width 2))))))) (display str) (lp (next x) (- width 1 (string-length str)) (1+ i))))))) @@ -348,8 +348,8 @@ sub-expression, via the @var{breadth-first?} keyword argument." width (+ (string-length (caar fixes)) (string-length (cdar fixes)) - 3))) - (format #f "~a~a...~a" + 1))) + (format #f "~a~a…~a" (caar fixes) (substring str (string-length (caar fixes)) (- width (string-length (cdar fixes)) 3)) @@ -363,7 +363,7 @@ sub-expression, via the @var{breadth-first?} keyword argument." (error "expected a positive width" width)) ((list? x) (cond - ((>= width 5) + ((>= width 3) (display "(") (print-sequence x (- width 2) (length x) (lambda (x i) (car x)) cdr) (display ")")) @@ -371,7 +371,7 @@ sub-expression, via the @var{breadth-first?} keyword argument." (display "#")))) ((vector? x) (cond - ((>= width 6) + ((>= width 4) (display "#(") (print-sequence x (- width 3) (vector-length x) vector-ref identity) (display ")")) @@ -379,7 +379,7 @@ sub-expression, via the @var{breadth-first?} keyword argument." (display "#")))) ((uniform-vector? x) (cond - ((>= width 9) + ((>= width 7) (format #t "#~a(" (uniform-vector-element-type x)) (print-sequence x (- width 6) (uniform-vector-length x) uniform-vector-ref identity) -- http://wingolog.org/