Subject: bug#63861: [PATCH] pp.el: New "pretty printing" code

From: Thierry Volpiatto <[email-masked]>
Date: Wed, 07 Jun 2023 14:10:22 +0000

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> Tags: patch
>
> 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?

I tried your code and it looks very slow (but looks nice once printed).
Testing on my bookmark-alist printed in some buffer.
Here with a slightly modified version of pp-buffer (not much faster than
the original one):

(benchmark-run-compiled 1 (pp-buffer))
=> (6.942135047 0 0.0)
And here with your version (using pp-region):
(benchmark-run-compiled 1 (pp-buffer))
=> (46.141411097 0 0.0)

For describe variable I use a modified version of `pp` which is very
fast (nearly instant to pretty print value above) but maybe unsafe with
some vars, didn't have any problems though, see
https://github.com/thierryvolpiatto/emacs-config/blob/main/describe-variable.el.

>
>         Stefan
>
>
>  In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
>  version 1.16.0, Xaw3d scroll bars) of 2023-05-24 built on pastel
> Repository revision: 41b6b907d4cf2f8c302647dc63c5d9c94f9f01d6
> Repository branch: work
> Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
> System Description: Debian GNU/Linux 11 (bullseye)
>
> Configured using:
>  'configure -C --enable-checking --enable-check-lisp-object-type --with-modules --with-cairo --with-tiff=ifavailable
>  'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign'
>  PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig'
>
>

-- 
Thierry