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#63861: [PATCH] pp.el: New "pretty printing" code Date: Sat, 03 Jun 2023 14:18:36 -0400 Message-ID: References: <83fs799jmi.fsf@gnu.org> 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="29860"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63861@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 20:19:26 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 1q5VqX-0007YL-PP for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 20:19:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5VqG-0002dm-FC; Sat, 03 Jun 2023 14:19:08 -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 1q5VqC-0002d3-Mf for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 14:19:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q5VqA-0007Rf-Te for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 14:19:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5VqA-0001W5-9i for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 14:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Jun 2023 18:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63861 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 63861-submit@debbugs.gnu.org id=B63861.16858163285809 (code B ref 63861); Sat, 03 Jun 2023 18:19:02 +0000 Original-Received: (at 63861) by debbugs.gnu.org; 3 Jun 2023 18:18:48 +0000 Original-Received: from localhost ([127.0.0.1]:44270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Vpv-0001Vc-H5 for submit@debbugs.gnu.org; Sat, 03 Jun 2023 14:18:47 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Vps-0001VL-GX for 63861@debbugs.gnu.org; Sat, 03 Jun 2023 14:18:45 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DFDB880781; Sat, 3 Jun 2023 14:18:38 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 76BE080058; Sat, 3 Jun 2023 14:18:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1685816317; bh=1N2QNavXwWxHIke28SKjqrCeKuRWoXBOs6USGboMp+M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=aFuLSClDVvVkJqDtqCiclWH72i91Fy38eCpPJUlGjRi3CPFOPL+MXbsL2sWo2IUcm UROg+DQIEXaBrqTfFfecj69YK+s/cJhn2lFUGRMMk4btsj+uteamCGRiMNIXmCq1c4 v81z0ixnbhCoCSNiO041zio40IBKqgFfMt6dsz9rn49NkL7XHakmEJV5vhfkTxLq5r rcbFxLzTc7fCeDxtKRhPZAJgSZnfIU0eU44Oe7OU4uGrosaU+qvlukkau04R12Jnol 8JXSwnDhr6avxKlAChwaTtsJXmJcG3S8BlXtJTtpVyewADbIszF/chKK/H5tRZnPn5 aEqPru6liGUjg== Original-Received: from pastel (76-10-180-239.dsl.teksavvy.com [76.10.180.239]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 37EAD12031E; Sat, 3 Jun 2023 14:18:37 -0400 (EDT) In-Reply-To: <83fs799jmi.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 03 Jun 2023 08:53:41 +0300") 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:262878 Archived-At: >> I've often been annoyed by the way `ielm` "pretty prints" data, >> so I wrote my own pretty printer, which has evolved over the years. >> I believe it has finally reached a state which may be acceptable >> to more than just myself. >> >> The new code is in a new function `pp-region`. >> The old code redirects to the new code if `pp-buffer-use-pp-region` is >> non-nil, tho I'm not sure we want to bother users with such >> a config var. Hopefully, the new code should be good enough that users >> don't need to choose. Maybe I should make it a `defvar` and have it >> default to t, so new users will complain if it's not good enough? > > Thanks. I almost never use IELM, so I have no significant comments to > this, only minor ones. FWIW, the change affects other functionality that uses `pp`, such as `C-h v`. While working on (previous versions of) this code, I've had performance problems show up during the generation of `emoji-labels.el`. >> +(defun pp-region (beg end) >> + "Insert newlines in BEG..END to try and fit within `fill-column'. >> +Presumes the current buffer contains Lisp code and has indentation properly >> +configured for that. >> +Designed under the assumption that the region occupies a single line, >> +tho it should also work if that's not the case." > > The first line should say what this command does. How 'bout: Insert line-breaks in Lisp code so it fits within `fill-column`. ? > Also, I think this warrants a NEWS entry and should be documented in > the ELisp manual. Definitely for NEWS, yes. For the ELisp manual, currently we don't document `pp-buffer`, the closest I see is `indent-pp-sexp` (in `programs.texi`). I'm not sure what to put in there. nor where to put it. >> +(defcustom pp-buffer-use-pp-region nil >> + "If non-nil, `pp-buffer' uses the new `pp-region' code." >> + :type 'boolean) > Please add :version. Hmm... so you think it should stay as a `defcustom` and we should thus plan to keep both kinds of pretty-printing in the long term? I mostly intended it to be a temporary knob for people to be able to try the new code and easily compare with the old (or revert to the old when bumping into a problem with the new). If so, we should probably think of better names to distinguish the two pp styles than `pp-buffer` vs `pp-region`. Maybe `pp-fill` for the new code since arguably the main difference is that the new code pays attention to `fill-column`? I don't have a good idea for a name for the old code, OTOH (and I think it would make sense to keep `pp-buffer` as a dispatch between the two options, so it would be good to have a separate name for the old style). Another difference might be that the new style is maybe aimed more at pp'ing code than data, whereas the old style might be a bit more "agnostic" to the definition. Yet another difference is that the old code tends to use more lines (because it doesn't try to fill the line upto `fill-column`) and occasionally outputs very long lines because it only breaks lines near parentheses. Maybe that info can inspire someone to come up with a good name for this "old style"? > Also, "the new code" should be rephrased to not use "new" (which > doesn't stand the time test). :-) > And the new defcustom should probably be mentioned in the manual, > perhaps where we mention IELM. If it stays as a `defcustom`, agreed. Stefan