From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#65680: cl-print-to-string-with-limit erroneously imposes a maximum print-length of 50 Date: Thu, 21 Sep 2023 17:07:58 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38301"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 65680@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 21 19:09:07 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qjNAo-0009kj-Vc for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Sep 2023 19:09:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjNAe-0001A2-L8; Thu, 21 Sep 2023 13:08:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjNAa-00019o-Je for bug-gnu-emacs@gnu.org; Thu, 21 Sep 2023 13:08:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjNAa-0002Lr-Bf for bug-gnu-emacs@gnu.org; Thu, 21 Sep 2023 13:08:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjNAk-0002sc-DR for bug-gnu-emacs@gnu.org; Thu, 21 Sep 2023 13:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Sep 2023 17:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65680 X-GNU-PR-Package: emacs Original-Received: via spool by 65680-submit@debbugs.gnu.org id=B65680.169531610311012 (code B ref 65680); Thu, 21 Sep 2023 17:09:02 +0000 Original-Received: (at 65680) by debbugs.gnu.org; 21 Sep 2023 17:08:23 +0000 Original-Received: from localhost ([127.0.0.1]:34752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjNA6-0002rW-NP for submit@debbugs.gnu.org; Thu, 21 Sep 2023 13:08:23 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:16078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjNA2-0002rD-3u for 65680@debbugs.gnu.org; Thu, 21 Sep 2023 13:08:21 -0400 Original-Received: (qmail 9173 invoked by uid 3782); 21 Sep 2023 19:08:01 +0200 Original-Received: from acm.muc.de (p4fe15e82.dip0.t-ipconnect.de [79.225.94.130]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 21 Sep 2023 19:08:00 +0200 Original-Received: (qmail 11046 invoked by uid 1000); 21 Sep 2023 17:07:58 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271008 Archived-At: Hello, Stefan. On Thu, Sep 21, 2023 at 12:16:57 -0400, Stefan Monnier wrote: > Alan Mackenzie [2023-09-01 14:17:12] wrote: > > Hello, Emacs. > > In cl-print-to-string-with-limit appears the following binding: > > (print-length (cond > > ((null limit) nil) > > ((eq limit t) print-length) > > (t (min limit 50)))) > > ^^^^^^^^^^^^ > > .. This has the effect of ignoring the parameter LIMIT (unless it is > > very small) and instead truncating the printed size to 50. There is a > > similar mechanism to limit print-level to 8. > > Although the doc string doesn't explicitly say it won't truncate like > > this, it kind of implies that LIMIT is the size it will truncate to. > > This excessive truncation is a bug. > See also bug#34183. > > .. 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. > [ 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 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 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. If somebody doesn't want a string longer that 50 to get printed, then she shouldn't call cl-prin1 with it. The mistake in Emacs before my patch was a category error: wrongly believing that print-length applies to a string length too. It doesn't. String lengths are a completely different kettle of fish from list lengths. 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). A sensible value for this variable in printing backtraces might be, say, 500. > Stefan -- Alan Mackenzie (Nuremberg, Germany).