From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Truncated print Date: Tue, 05 Jan 2010 10:01:00 +0100 Message-ID: References: <87bphc9i9s.fsf@gnu.org> <878wcd9yyo.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1262694474 31404 80.91.229.12 (5 Jan 2010 12:27:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Jan 2010 12:27:54 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jan 05 13:27:46 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from terminus-est.gnu.org ([66.92.78.210] helo=lists.gnu.org) by lo.gmane.org with esmtp (Exim 4.50) id 1NS8Vm-00075l-59 for guile-devel@m.gmane.org; Tue, 05 Jan 2010 13:27:46 +0100 Original-Received: from localhost ([127.0.0.1]:39500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NS8Vm-0006RG-CT for guile-devel@m.gmane.org; Tue, 05 Jan 2010 07:27:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NS8Vi-0006OK-MO for guile-devel@gnu.org; Tue, 05 Jan 2010 07:27:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NS8Ve-0006HF-Q8 for guile-devel@gnu.org; Tue, 05 Jan 2010 07:27:42 -0500 Original-Received: from [199.232.76.173] (port=36984 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NS8Ve-0006H1-Lp for guile-devel@gnu.org; Tue, 05 Jan 2010 07:27:38 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:44509 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NS8VZ-0007ND-LP; Tue, 05 Jan 2010 07:27:33 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 2E1F1ACA5A; Tue, 5 Jan 2010 07:27:32 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=KofA68wUocPF dfjN2EEnK6Bi+xI=; b=J/7z0sqECLZ9KJ09hmDq7yP2wJps4klEvJhZcBGFn6Rd S01z5DrS+YdcsNwI4zIecl424EnrySBoGaXw5vNM475EeohUCy47jwDYEFz1DaBm kJ4nCEP5muALB+tzjrh2KJL3YmJqtZDiqAaT8gfK6/wDWRJneE43rrzO9nhB7wc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=NyKbBy PUOZWTydNb4txYI82hax0C9n3uNYVQybCqz3UAqOBC96Xw7HpgkGPVAk8wGFMUK7 WLeRpc/K1OtXTvlwpyhqOB2/rvdfCIHZufeVxPS02X/0PvR1Pwgjewaq/KWw5+Pz ghQJK8wxJLg1U3krIQB8uyayThcInYC5iyyek= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 1AE96ACA59; Tue, 5 Jan 2010 07:27:31 -0500 (EST) Original-Received: from unquote (unknown [83.202.29.76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 4C2A6ACA57; Tue, 5 Jan 2010 07:27:28 -0500 (EST) In-Reply-To: <878wcd9yyo.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 05 Jan 2010 01:28:47 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: B1A99878-F9F5-11DE-A722-465EBBB5EC2E-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:9826 Archived-At: Hi :) On Tue 05 Jan 2010 01:28, ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> On Sun 03 Jan 2010 00:52, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > > [...] > >>>> +(truncated-print "The quick brown fox" #:width 10) (newline) >>>> +@print{} "The quick brown..." >>> >>> I think it=E2=80=99d be nice to default to =E2=80=98HORIZONTAL ELLIPSIS= =E2=80=99 (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. ;;;;=20 ;;;; 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 b= e printed using @var{display?} keyword argument. =20 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 ar= gument." ((=3D i len)) ; catches 0-length case ((=3D i (1- len)) (print (ref x i) (if (zero? i) width (1- width)))) - ((<=3D width 4) - (display "...")) + ((<=3D width 2) + (display "=E2=80=A6")) (else (let ((str (with-output-to-string (lambda () @@ -309,7 +309,7 @@ sub-expression, via the @var{breadth-first?} keyword ar= gument." (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))))))) =20 @@ -348,8 +348,8 @@ sub-expression, via the @var{breadth-first?} keyword ar= gument." width (+ (string-length (caar fixes)) (string-length (cdar fixes)) - 3))) - (format #f "~a~a...~a" + 1))) + (format #f "~a~a=E2=80=A6~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 ar= gument." (error "expected a positive width" width)) ((list? x) (cond - ((>=3D width 5) + ((>=3D width 3) (display "(") (print-sequence x (- width 2) (length x) (lambda (x i) (car x)) cd= r) (display ")")) @@ -371,7 +371,7 @@ sub-expression, via the @var{breadth-first?} keyword ar= gument." (display "#")))) ((vector? x) (cond - ((>=3D width 6) + ((>=3D width 4) (display "#(") (print-sequence x (- width 3) (vector-length x) vector-ref identit= y) (display ")")) @@ -379,7 +379,7 @@ sub-expression, via the @var{breadth-first?} keyword ar= gument." (display "#")))) ((uniform-vector? x) (cond - ((>=3D width 9) + ((>=3D width 7) (format #t "#~a(" (uniform-vector-element-type x)) (print-sequence x (- width 6) (uniform-vector-length x) uniform-vector-ref identity) --=20 http://wingolog.org/