From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" 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 13:51:14 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35337"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65680@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 21 19:52:17 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 1qjNqa-0008wB-Iz for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Sep 2023 19:52:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjNqE-0007LV-1B; Thu, 21 Sep 2023 13:51:54 -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 1qjNqC-0007LH-9A for bug-gnu-emacs@gnu.org; Thu, 21 Sep 2023 13:51: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 1qjNqC-0002Vw-04 for bug-gnu-emacs@gnu.org; Thu, 21 Sep 2023 13:51:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjNqL-00048h-NV for bug-gnu-emacs@gnu.org; Thu, 21 Sep 2023 13:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Sep 2023 17:52:01 +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.169531869815878 (code B ref 65680); Thu, 21 Sep 2023 17:52:01 +0000 Original-Received: (at 65680) by debbugs.gnu.org; 21 Sep 2023 17:51:38 +0000 Original-Received: from localhost ([127.0.0.1]:34778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjNpx-000482-VC for submit@debbugs.gnu.org; Thu, 21 Sep 2023 13:51:38 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47303) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjNps-00047k-Op for 65680@debbugs.gnu.org; Thu, 21 Sep 2023 13:51:36 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C3811801BE; Thu, 21 Sep 2023 13:51:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1695318675; bh=C5dDXdEdNFLTkx6trS1Fngc1qbKpBTu3wwwDfRWUiJw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=d0ahxttVzQQhloDXfyU0k0QGqKc5c1LHApDS8d1QLNoYYmyPCttICKBZSgq2XDNx5 GKhnWvmb3l6uXo8IJchP40Fy9m/IjSG2clcdFPdxizIpzID6tfJSFAWShJVl08rVM4 63HOWInDFG6Puy710HtoiY/fKaXyP8YFYU9+xoFxJtbgiAC8QfgYUs1tPAAaiFLs8l XSWV3rJga9vwVyBTf3yHzZvAxgKWJ9NVYCYuUVCv/auTLLdplltt1d+cI1PLBqcBun tTYu+CGQAlQYFgAYmOVzzEXJWm3KNjmOEi+8psf1nGrxyrv5cV2lOr+g9FdnynFkMC z8Okivbamufjg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 40F0A8014C; Thu, 21 Sep 2023 13:51:15 -0400 (EDT) Original-Received: from pastel (unknown [45.72.220.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1BAC2120255; Thu, 21 Sep 2023 13:51:15 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Thu, 21 Sep 2023 17:07:58 +0000") 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:271012 Archived-At: >> > .. 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