Subject: bug#54537: 29.0.50; Last sexp notion is different for eval-last-sexp and pp-eval-last-sexp

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 23 Mar 2022 15:06:31 +0100

Visuwesh <[email-masked]> writes:

> The notion of "last sexp" is different for eval-last-sexp and
> pp-eval-last-sexp as seen by the following,
>
>     ,(list 1 2 3)
>
> eval-last-sexp echoes (1 2 3) in the echo area but pp-eval-last-sexp
> signals an error.  I am not sure which one is more correct, but
> eval-last-sexp behaviour is more convenient (and backward-sexp when
> after the closing parenthesis places the point after , too...).

The pp function uses (forward-sexp -1) to determine where the preceding
expression begins, which seems natural.  (And it skips to before the
comma.)

The non-pp function uses (elisp--preceding-sexp), which basically does
the same, but then explicitly skips past the comma.

I think the non-pp function has the most convenient behaviour, so I'd be
in favour of changing it to just use (elisp--preceding-sexp).  Any opinions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no