From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Truncated print Date: Tue, 05 Jan 2010 01:28:47 +0100 Message-ID: <878wcd9yyo.fsf@gnu.org> References: <87bphc9i9s.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1262665070 21684 80.91.229.12 (5 Jan 2010 04:17:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Jan 2010 04:17:50 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jan 05 05:17:43 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 1NS0rV-0001Rj-Bc for guile-devel@m.gmane.org; Tue, 05 Jan 2010 05:17:42 +0100 Original-Received: from localhost ([127.0.0.1]:40180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NS0jq-0004YJ-K7 for guile-devel@m.gmane.org; Mon, 04 Jan 2010 23:09:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NS0gq-0003K0-GR for guile-devel@gnu.org; Mon, 04 Jan 2010 23:06:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NS0gl-0003HX-Op for guile-devel@gnu.org; Mon, 04 Jan 2010 23:06:40 -0500 Original-Received: from [199.232.76.173] (port=52779 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NS0KT-0006yC-RX for guile-devel@gnu.org; Mon, 04 Jan 2010 22:43:34 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]:4131) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NRzA6-0001sN-Vt for guile-devel@gnu.org; Mon, 04 Jan 2010 21:28:48 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NRxMP-000884-8H for guile-devel@gnu.org; Mon, 04 Jan 2010 19:33:21 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1NRxIL-0004dS-C5 for guile-devel@gnu.org; Tue, 05 Jan 2010 01:29:09 +0100 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 05 Jan 2010 01:29:09 +0100 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 05 Jan 2010 01:29:09 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 16 =?iso-8859-1?Q?Niv=F4se?= an 218 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:0VyfPE/143bWYz+b143BcD+5O+w= X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:9821 Archived-At: Hi Andy! Andy Wingo writes: > On Sun 03 Jan 2010 00:52, ludo@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? > > Having it be a keyword parameter would complicate things somewhat, as > there are some hardcoded lengths in there. It could work. > > But perhaps a bigger problem is that if you're in a non-unicode > locale -- *as Guile is by default, without a call to setlocale* -- the > `…' will expand to `...', which uses up more characters, thus the > "truncated" part of things doesn't work as advertised. Once the string port patch I posted is applied, the following function comes in handy: --8<---------------cut here---------------start------------->8--- (define (ellipsis encoding) (define e "…") (with-fluids ((%default-port-encoding encoding)) (catch 'misc-error (lambda () (with-output-to-string (lambda () (display e)))) (lambda (key . args) "...")))) --8<---------------cut here---------------end--------------->8--- Another approach would be ‘string->encoding’ (a generalization of ‘string->utf8’), but we don’t have that yet. I guess we have to play tricks anyway to know whether a given character can be represented in a given encoding. What do you think? Thanks, Ludo’.