bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#56685: OBOE in string-truncate-left?


From: Stephen Berman
Subject: bug#56685: OBOE in string-truncate-left?
Date: Sat, 23 Jul 2022 10:51:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

On Sat, 23 Jul 2022 08:58:35 +0200 Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> But if the too-long string is
>> "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/";, then with the
>> current string-truncate-left gnus-shorten-url "shortens" it to
>> "cvs.savannah.gnu.org...ewv/emacs/emacs/1/".  AFAICS replacing the three
>> characters "/vi" by "..." here just loses information.
>
> What's the parameters when that happens?  I get:
>
> (gnus-shorten-url "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/"; 41)
> => "cvs.savannah.gnu.org/viewv/emacs/emacs/1/"
>
> (gnus-shorten-url "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/"; 40)
> => "cvs.savannah.gnu.org...wv/emacs/emacs/1/"

Same here; in my example, I used 40 since that's what
gnus-summary-browse-url (the caller of gnus-shorten-url) uses.

> Anyway, I think the examples show that this function isn't very useful
> if LENGTH is very small -- it really does want to add "..." to signal
> that some shortening has happened, and that may make the string longer.
> But just returning "d" for (string-truncate-left "and" 1) isn't correct
> either.

Yes.  My main motivation for proposing to omit truncation (and prefixing
with "...") of too-short lines was for using string-truncate-left in a
loop over differently sized input strings, but of course that can be
handled by suitable code in the loop.

> I've now fixed the originally reported off-by-one error when shortening,
> and documented the quirks of the function in Emacs 29.

Thanks, the doc string makes sense to me now.

Steve Berman





reply via email to

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