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

From: Visuwesh <[email-masked]>
Date: Fri, 09 Jun 2023 08:51:39 +0530

[புதன் ஜூன் 07, 2023] Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

>> BTW, how does this compare to the newly added `pp-emacs-lisp-code`?
>
> Very good question.  I had completely missed that (and its `pp-use-max-width`).
> This points to a host of integration issues between my code and the
> existing code.  I'll have to take a deeper look.

>From what I remember, pp simply switches to use pp-emacs-lisp-code when
the relevant user option is set.  The poor performance of
pp-emacs-lisp-code made me wish pp-use-max-width was only obeyed by user
facing commands like pp-eval-expression & friends.

>> It was still rough around the edges the last time I set
>> `pp-use-max-width' non-nil.  It is also quite a lot slower than the
>> old path.
>
> My new code is expected to be slower than the "normal" pretty-printer,
> but barring performance bugs in `lisp-indent-line` (such as the one
> fixed by the patch I just sent to Thierry) it should be approximately
> a constant factor slower.
>
> AFAICT the performance of `pp-emacs-lisp-code` can be more problematic.

Hopefully, the constant factor is quite small.  pp-emacs-lisp-code took
a lot of time to print my modest bookmark alist (28 entries) and for the
longest time I thought some other code in Emacs has gone awry.

> Beside performance, I guess the behavior of the two should be
> somewhat similar, tho I also see that `pp-emacs-lisp-code` pays
> attention to the Edebug and `doc-string-elt` info, so it may give
> slightly more refined info.

I haven't tested your pretty printer but pp-emacs-lisp-code could give
some really bizarre results for lisp data.  Unfortunately, I don't have
any examples handy to illustrate what I mean by bizarre though. 

> Another difference is that `pp-emacs-lisp-code` starts with an S-exp
> object, whereas my code starts with a region (i.e. an sexp that's
> already been printed).
>
>
>         Stefan