From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#63861: [PATCH] pp.el: New "pretty printing" code Date: Sat, 03 Jun 2023 21:58:03 +0300 Message-ID: <83r0qs74qs.fsf@gnu.org> References: <83fs799jmi.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12261"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63861@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 20:58:19 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 1q5WSA-0002y3-Cz for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 20:58:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5WRy-0007sk-S4; Sat, 03 Jun 2023 14:58:06 -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 1q5WRu-0007sB-Js for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 14:58:03 -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 1q5WRu-0007qo-BX for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 14:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5WRu-0002XO-73 for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 14:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Jun 2023 18:58: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.16858186419702 (code B ref 63861); Sat, 03 Jun 2023 18:58:02 +0000 Original-Received: (at 63861) by debbugs.gnu.org; 3 Jun 2023 18:57:21 +0000 Original-Received: from localhost ([127.0.0.1]:44311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5WRE-0002WQ-R5 for submit@debbugs.gnu.org; Sat, 03 Jun 2023 14:57:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:32950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5WRB-0002W9-M7 for 63861@debbugs.gnu.org; Sat, 03 Jun 2023 14:57:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5WR5-0007kP-Q4; Sat, 03 Jun 2023 14:57:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5Vrb6KWJfP8kxRRXPwnZlMhzyS5w52nNMGSExoMc1x8=; b=MtkDUAGCN73E /5aw/lSc9ZdGRv8+lYDRZW9DAWXWDmRsxRNl7gShrcEOrj9SMBI9ItRTVAFrKyn2kcYMxbNyehFOv vGmc33Ufy/L+/g3xsUjIQs+xzKAv4tfdoM7xcSQV7PVROR4ZJKXr+SjJNw/sgw6TvKl+CGaFw0/Pz XHtHNFT1F825CM4jWgE84IYzxkAKdK1zGxFvgTb1Ep/L/kEBa0aLxVum6Ki55vxbG6L6SrFrD90jZ LWXzucVPlePvAGroSTwJfT25mZw+xdU4Ko7vu8m8Q1owIxflGBluygA0W3bT2e+khLexNbyavKBkp cLKKLCnLlsINZesycOmYYg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5WR5-0007Os-9T; Sat, 03 Jun 2023 14:57:11 -0400 In-Reply-To: (message from Stefan Monnier on Sat, 03 Jun 2023 14:18:36 -0400) 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:262880 Archived-At: > From: Stefan Monnier > Cc: 63861@debbugs.gnu.org > Date: Sat, 03 Jun 2023 14:18:36 -0400 > > >> +(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`. > > ? Yes, but let's also mention BEG and END: Break lines in Lisp code between BEG and END 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. We document "pp" in "Output Functions". Maybe there? > >> +(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? No, I just said that _if_ we keep it as a defcustom, _then_ it should have a :version tag. I have no idea how many users will want to customize this. > 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"? Maybe we should leave it as a variable for now, and see if there's enough demand for both flavors.