GNU bug report logs -
#65680
cl-print-to-string-with-limit erroneously imposes a maximum print-length of 50
Previous Next
Reported by: Alan Mackenzie <acm <at> muc.de>
Date: Fri, 1 Sep 2023 14:18:02 UTC
Severity: normal
Done: Alan Mackenzie <acm <at> muc.de>
Bug is archived. No further changes may be made.
Full log
Message #22 received at 65680 <at> debbugs.gnu.org (full text, mbox):
>> > .. I propose fixing this bug by removing these limits on print-length and
>> > print-level in cl-print-to-string-with-limit.
>
>> Sounds a bit drastic. Strings can be obnoxiously long, so it's
>> important for cl-print to be able to truncate them.
>
> There is clearly no human-sized bound on string lengths, so they can
> indeed be very long. Most of the time they're not. But they are very
> frequently longer than 50 characters.
Agreed.
>> [ IOW, I'm not happy with commit
>> 761f8901fffdb155cbcc7f3b5a2329161c2c1826. ]
>
> Well I did post about it to emacs-devel on Sunday and Monday, asking if
> anybody had any objection. Nobody, not even you, responded.
I'm not on `emacs-devel` nowadays :-)
> I still believe that not truncating strings is better than truncating
> them to the minute length of 50. In fact, why truncate strings at all in
> cl-prin1? They're not truncated in prin1, etc.
The main purpose of `prin1` is to print Sexp in a way that can be
read back. I.e. for machine-consumption.
The main purpose of `cl-prin1` OTOH is for human consumption.
For this reason it started truncating strings while `prin1` doesn't
bother doing so.
> The reason for truncating lists and vectors is to prevent infinite
> printing when there's a circular list or vector, something which
> cannot happen with a string.
Not really, no. It's rather for things like keeping the length of
backtrace lines under control.
> If somebody doesn't want a string longer that 50 to get printed, then she
> shouldn't call cl-prin1 with it.
You're arguing against the wrong guy: I filed bug#34183 because I found the
(current implementation of) string truncation annoying. That doesn't
mean it's always annoying.
> The mistake in Emacs before my patch was a category error: wrongly
> believing that print-length applies to a string length too.
That's bug#34183, indeed.
> It doesn't. String lengths are a completely different kettle of fish
> from list lengths.
Not completely: they're all concerned with truncating the output so the
human gets to see what comes afterwards, and to a large extent their
optimal value for any given string/list/vector is probably one that
corresponds more or less to the same output string length.
> To solve this problem properly, we need, as Eli has suggested, a separate
> variable called something like print-string-length, to be set
> independently of print-length (and print-level).
Sounds good.
> A sensible value for this variable in printing backtraces might be,
> say, 500.
500 is "damn long" for a line in a backtrace, IMO. If I need to see
that much of the string, I won't mind having to click the "..." to
reveal it. I'd vote for a default limit somewhere between "one or two
lines of 80 columns".
FWIW, after filing bug#34183 I hacked my local Emacs to use (*
8 print-length) for max string length (leading to 96 chars by default,
IIRC), thinking I'd tweak it later based on experience.
I never felt like tweaking it, tho, so it looks like it's a good
approximation of my ideal choice.
We could make its default value dynamically computed from
`print-length`, so things like `cl-print-to-string-with-limit` don't
need to be adjusted.
Stefan
This bug report was last modified 1 year and 292 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.