[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Truncated print

From: Ludovic Courtès
Subject: Re: Truncated print
Date: Tue, 05 Jan 2010 01:28:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi Andy!

Andy Wingo <address@hidden> writes:

> On Sun 03 Jan 2010 00:52, address@hidden (Ludovic Courtès) writes:


>>> +(truncated-print "The quick brown fox" #:width 10) (newline)
>>> address@hidden "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 ()
          (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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]