Subject: bug#65267: 30.0.50; modifying debug-ignored-errors during startup with --debug-init is broken

From: Eli Zaretskii <[email-masked]>
Date: Sun, 13 Aug 2023 20:52:53 +0300

> From: Štěpán Němec <[email-masked]>
> Date: Sun, 13 Aug 2023 19:08:26 +0200
> 
> On Sun, 13 Aug 2023 12:19:31 -0400
> Stefan Monnier via wrote:
> 
> > Yeah, it's wrong, but I'm not sure how to fix it:
> > `--debug-init` needs to change the value of `debug-ignored-errors` while
> > `init.el` is executed,
> 
> FWIW, I'm sure I'm missing something, but the above is far from obvious
> to me.  Why does --debug-init need to muck with debug-ignored-errors at
> all?  debug-ignored-errors usually/mostly contains errors unlikely to
> occur during startup, and even if they do occur during startup, why
> should Emacs not respect debug-ignored-errors and ignore them?

If debug-ignored-errors were by default nil, then this would have made
sense.  But that's not the case: we set debug-ignored-errors to a
non-nil value by default, and that gets in the way of --debug-init.
See bug#64163.  How's that for user surprise?

> (I also couldn't find this exception (i.e., --debug-init causing
> debug-ignored-errors to be ignored) documented anywhere, BTW.)

The value set by the init file was not supposed to be ignored, only
our own self-imposed default was.  So there was nothing to document:
those are Emacs internals, and we tweak them to make --debug-init work
as expected, which is to catch every error.

> > We could document that modifying debug-ignored-errors only works
> > reliably if done from after-init-hook.  WDYT?
> 
> Pushing the breakage downstream... would mean packages like yasnippet
> would have to adapt, among other things.

Why on earth does yasnippet modify the value of a user variable?

> Not the end of the world, I guess, but I still don't understand why
> the breakage (or "change in behavior", if you prefer) is necessary
> or desired.

See above: it was the result of fixing a bug.

Another possibility, I guess, would be to set debug-ignored-errors to
its current default only after loading the user init file, and do that
in a way that _adds_ the ignored-by-default errors to the list it has
after loading init files.  Before loading the init files, the value
could would be nil.