From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: 65680@debbugs.gnu.org
Subject: bug#65680: cl-print-to-string-with-limit erroneously imposes a maximum print-length of 50
Date: Thu, 21 Sep 2023 13:51:14 -0400 [thread overview]
Message-ID: <jwvjzsjh1lr.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <ZQx4bskZ7fWGOwRL@ACM> (Alan Mackenzie's message of "Thu, 21 Sep 2023 17:07:58 +0000")
>> > .. 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
next prev parent reply other threads:[~2023-09-21 17:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 14:17 bug#65680: cl-print-to-string-with-limit erroneously imposes a maximum print-length of 50 Alan Mackenzie
2023-09-19 10:32 ` Alan Mackenzie
2023-09-21 16:16 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-21 16:36 ` Eli Zaretskii
2023-09-21 17:07 ` Alan Mackenzie
2023-09-21 17:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-21 19:22 ` Drew Adams
2023-09-21 20:00 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-21 18:33 ` Eli Zaretskii
[not found] ` <ZQ1m766tulSqvuC6@ACM>
[not found] ` <83msxe779i.fsf@gnu.org>
[not found] ` <ZQ2JVhy-e8NpCJqq@ACM>
[not found] ` <837coi74ia.fsf@gnu.org>
[not found] ` <jwva5tefif5.fsf-monnier+emacs@gnu.org>
[not found] ` <ZRRGZaRf3WU9z6m_@ACM>
[not found] ` <83v8btywz3.fsf@gnu.org>
2023-09-29 16:49 ` Alan Mackenzie
2023-09-29 16:53 ` Eli Zaretskii
2023-10-03 2:11 ` Michael Heerdegen
2023-10-03 9:18 ` Alan Mackenzie
2023-10-03 10:26 ` Alan Mackenzie
2023-10-03 23:35 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvjzsjh1lr.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=65680@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).