Subject: Re: bug#76949: 30.1; --debug-init and condition-case-unless-debug

From: Aaron Zeng <[email-masked]>
Date: Wed, 12 Mar 2025 22:24:07 -0400

With apologies to the maintainers, I accidentally replied directly 
to
Stefan rather than reply-all.  Copying in some context from our
exchange below (hand-edited from the most recent email I received 
from
Stefan):

> Aaron Zeng <[email-masked]> writes:
>
> > Stefan Monnier <[email-masked]> writes:
> >
> > >> It seems cumbersome to fix this without re-introducing the 
> > >> problem that
> > >> `handler-bind` addresses, so I'm in favor of fixing the doc 
> > >> rather than
> > >> the code.
> > >
> > > I understand this to mean that we should fix the doc to 
> > > reflect that
> > > `debug-on-error` is no longer explicitly non-nil when 
> > > --debug-init is
> > > passed.
> >
> > Yes.
> >
> > > But for the other issue, I think we should still make it so 
> > > that
> > > condition-case-unless-debug works with --debug-init as 
> > > advertised (and
> > > as it did in Emacs 29).  Do you agree?
> >
> > No, for the same reason: `condition-case-unless-debug` depends 
> > on the
> > value of `debug-on-error`, not on whether the user has asked 
> > some variant of
> > "show the debugger when there's an error".
>
> condition-case-unless-debug's docstring says "it does not 
> prevent
> debugging".  It also alludes to the value of debug-on-error, but 
> this
> doc could change as well :)

Yes, but it would bring us back to the problem of how to 
implementing it
without re-introducing the problem.

> I would argue, the intention of the programmer who used
> condition-case-unless-debug likely doesn't depend on the exact 
> value
> of debug-on-error, but rather, whether or not the user "wants" 
> to
> invoke the debugger when an error is signaled inside the body.
>
> > Another way to look at it:
> >
> > `--debug-init` is there so you can debug an error that breaks 
> > your init.
> > In the case of `condition-case-unless-debug`, the error 
> > presumably
> > doesn't break your init, since it is properly caught and 
> > handled.
>
> In my experience, condition-case-unless-debug seems to be often 
> used
> to "ignore" an error but not properly catch and handle it.  For
> example in the macroexpansion of `with-demoted-errors`, or in 
> the
> original place where I found this: Spacemacs, where it is used 
> to log
> an error message somewhere and proceed with installing the rest 
> of the
> packages that are needed even if one installation fails.
>
> For me, the major concern is, code which was intended to be 
> called
> during init and used condition-case-unless-debug to make its 
> errors
> non-fatal but debuggable, has broken in a backwards-incompatible 
> way,
> and also doesn't seem to have an obvious way forwards.

There's a simple way forward: set `debug-on-error`.