Subject: Re: bug#73722: 30.0.91; error calling eshell/clear with no argument

From: Eli Zaretskii <[email-masked]>
Date: Tue, 15 Oct 2024 21:04:55 +0300

> Date: Tue, 15 Oct 2024 10:00:40 -0700
> From: Jim Porter <[email-masked]>
> 
> On 10/9/2024 10:33 AM, Christopher Howard wrote:
> > 
> > (same with or without emacs -Q)
> > 1. M-x eshell
> > 2. clear <return>
> > 
> > Gives error "wrong-type-argument listp progn".
> 
> I think this is probably the result of some improvements I've made to 
> Eshell's command evaluator that revealed a latent bug in 'eshell/clear' 
> (it actually runs a *second* Eshell command consisting only of newlines, 
> which shouldn't be necessary).
> 
> The actual error reported here is fixed in Emacs 31; in Emacs 30, 
> 'eshell-do-eval' mis-evaluates an empty '(progn)', but that generally 
> shouldn't occur except in odd cases like this. The "clear" command still 
> doesn't *work* correctly in Emacs 31 though.
> 
> Attached is the smallest fix I could come up with for this. This is made 
> somewhat more complex due to 'eshell/clear' also being used as an 
> interactive Emacs-level command. The two forms ("clear" at an Eshell 
> prompt and "M-x eshell/clear" in Emacs) should probably be separate 
> functions entirely since they behave differently regarding the current 
> prompt, but for the sake of compatibility, let's keep them fused 
> together for now...
> 
> Eli, does this look ok for the release branch? It fixes a regression 
> from Emacs 29 and adds a pair of regression tests to prevent future 
> breakage. (If and when this merges, I'll see about a more-thorough fix 
> for the master branch too.)

If the problem is with empty body of progn, why does the fix have to
be so much less self-evident?  Can you fix it by protecting against
empty body of progn instead, so that the fix is less likely to cause
unintended consequences?

In any case, please don't forget "Do not merge to master" in the
commit log message.

Thanks.