* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
[not found] ` <20230621132823.6C945C06C79@vcs2.savannah.gnu.org>
@ 2023-06-25 23:26 ` Stefan Monnier
2023-06-26 11:07 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2023-06-25 23:26 UTC (permalink / raw)
To: emacs-devel; +Cc: Eli Zaretskii
Hi Eli,
> Allow --debug-init to debug all errors in init files
>
> * lisp/startup.el (startup--load-user-init-file): Ignore the value
> of 'debug-ignored-errors' when loading init files if we were
> invoked interactively with --debug-init. (Bug#64163)
I understand you didn't like my patch because of the cosmetic renaming
it included, but you threw away some of the baby with the bathwater:
> - (load (if (equal (file-name-extension init-file-name)
> - "el")
> - (file-name-sans-extension init-file-name)
> - init-file-name)
> - 'noerror 'nomessage))
> + ;; If they specified --debug-init, enter the debugger
> + ;; on any error whatsoever.
> + (let ((debug-ignored-errors
> + (if (and init-file-debug (not noninteractive))
> + nil
> + debug-ignored-errors)))
> + (load (if (equal (file-name-extension init-file-name)
> + "el")
> + (file-name-sans-extension init-file-name)
> + init-file-name)
> + 'noerror 'nomessage)))
Now the changes I make to `debug-ignored-errors` in my `init.el` are
thrown away :-(
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
2023-06-25 23:26 ` master 4302bc9b0f1: Allow --debug-init to debug all errors in init files Stefan Monnier
@ 2023-06-26 11:07 ` Eli Zaretskii
2023-06-26 13:57 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-26 11:07 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Eli Zaretskii <eliz@gnu.org>
> Date: Sun, 25 Jun 2023 19:26:27 -0400
>
> > - (load (if (equal (file-name-extension init-file-name)
> > - "el")
> > - (file-name-sans-extension init-file-name)
> > - init-file-name)
> > - 'noerror 'nomessage))
> > + ;; If they specified --debug-init, enter the debugger
> > + ;; on any error whatsoever.
> > + (let ((debug-ignored-errors
> > + (if (and init-file-debug (not noninteractive))
> > + nil
> > + debug-ignored-errors)))
> > + (load (if (equal (file-name-extension init-file-name)
> > + "el")
> > + (file-name-sans-extension init-file-name)
> > + init-file-name)
> > + 'noerror 'nomessage)))
>
> Now the changes I make to `debug-ignored-errors` in my `init.el` are
> thrown away :-(
They are? AFAIU, the code only overrides the value of
debug-ignored-errors if Emacs was invoked with --debug-init, and
otherwise honors whatever value you set in your init files. Or what
am I missing?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
2023-06-26 11:07 ` Eli Zaretskii
@ 2023-06-26 13:57 ` Stefan Monnier
2023-06-26 14:27 ` Stefan Monnier
2023-06-26 14:48 ` Eli Zaretskii
0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2023-06-26 13:57 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> > - (load (if (equal (file-name-extension init-file-name)
>> > - "el")
>> > - (file-name-sans-extension init-file-name)
>> > - init-file-name)
>> > - 'noerror 'nomessage))
>> > + ;; If they specified --debug-init, enter the debugger
>> > + ;; on any error whatsoever.
>> > + (let ((debug-ignored-errors
>> > + (if (and init-file-debug (not noninteractive))
>> > + nil
>> > + debug-ignored-errors)))
>> > + (load (if (equal (file-name-extension init-file-name)
>> > + "el")
>> > + (file-name-sans-extension init-file-name)
>> > + init-file-name)
>> > + 'noerror 'nomessage)))
>>
>> Now the changes I make to `debug-ignored-errors` in my `init.el` are
>> thrown away :-(
>
> They are? AFAIU, the code only overrides the value of
> debug-ignored-errors if Emacs was invoked with --debug-init, and
> otherwise honors whatever value you set in your init files. Or what
> am I missing?
There's a let-binding of `debug-ignored-errors` around the `load`, so
the old value is restored when we finish `load` :-(
That's what the `startup` value in `debug-on-error` is about (which
I changed to `startup--witness` in my patch to try and make it more
clear): to detect when init files changed the value and then be careful
to preserve this new value when we exit the `let`.
BTW, another difference is that you seem to have that offending code in
3 places whereas the setting of `debug-on-error` happens only once
(which is why I put my code alongside that setting rather than around
each and every `load`).
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
2023-06-26 13:57 ` Stefan Monnier
@ 2023-06-26 14:27 ` Stefan Monnier
2023-06-26 14:52 ` Eli Zaretskii
2023-06-26 14:48 ` Eli Zaretskii
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2023-06-26 14:27 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> They are? AFAIU, the code only overrides the value of
>> debug-ignored-errors if Emacs was invoked with --debug-init, and
>> otherwise honors whatever value you set in your init files. Or what
>> am I missing?
>
> There's a let-binding of `debug-ignored-errors` around the `load`, so
> the old value is restored when we finish `load` :-(
>
> That's what the `startup` value in `debug-on-error` is about (which
> I changed to `startup--witness` in my patch to try and make it more
> clear): to detect when init files changed the value and then be careful
> to preserve this new value when we exit the `let`.
>
> BTW, another difference is that you seem to have that offending code in
> 3 places whereas the setting of `debug-on-error` happens only once
> (which is why I put my code alongside that setting rather than around
> each and every `load`).
For reference, find below my initial suggestion stripped of its
gratuitous renaming.
Stefan
diff --git a/lisp/startup.el b/lisp/startup.el
index 484c8f57a9f..7baacba0af6 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1027,6 +1027,11 @@ startup--load-user-init-file
(if (eq init-file-debug t)
'startup
init-file-debug))
+ (d-i-e-from-init-file nil)
+ (d-i-e-initial
+ ;; Use (startup--witness) instead of nil, so we can detect when the
+ ;; init files set `debug-ignored-errors' to nil.
+ (if init-file-debug '(startup--witness) debug-ignored-errors))
;; The init file might contain byte-code with embedded NULs,
;; which can cause problems when read back, so disable nul
;; byte detection. (Bug#52554)
@@ -1126,10 +1131,14 @@ startup--load-user-init-file
;; If we can tell that the init file altered debug-on-error,
;; arrange to preserve the value that it set up.
+ (or (eq debug-ignored-errors d-i-e-initial)
+ (setq d-i-e-from-init-file (list debug-ignored-errors)))
(or (eq debug-on-error debug-on-error-initial)
(setq debug-on-error-should-be-set t
debug-on-error-from-init-file debug-on-error)))
+ (when d-i-e-from-init-file
+ (setq debug-ignored-errors (car d-i-e-from-init-file)))))
(when debug-on-error-should-be-set
(setq debug-on-error debug-on-error-from-init-file))))
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
2023-06-26 13:57 ` Stefan Monnier
2023-06-26 14:27 ` Stefan Monnier
@ 2023-06-26 14:48 ` Eli Zaretskii
1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-26 14:48 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 26 Jun 2023 09:57:08 -0400
>
> >> Now the changes I make to `debug-ignored-errors` in my `init.el` are
> >> thrown away :-(
> >
> > They are? AFAIU, the code only overrides the value of
> > debug-ignored-errors if Emacs was invoked with --debug-init, and
> > otherwise honors whatever value you set in your init files. Or what
> > am I missing?
>
> There's a let-binding of `debug-ignored-errors` around the `load`, so
> the old value is restored when we finish `load` :-(
Feel free to fix that, but please don't rename the variables.
> BTW, another difference is that you seem to have that offending code in
> 3 places whereas the setting of `debug-on-error` happens only once
That's because you explicitly asked this to be in effect only during
loading the init files. My original suggestion used just one
let-binding.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
2023-06-26 14:27 ` Stefan Monnier
@ 2023-06-26 14:52 ` Eli Zaretskii
2023-06-26 15:25 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-06-26 14:52 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 26 Jun 2023 10:27:40 -0400
>
> For reference, find below my initial suggestion stripped of its
> gratuitous renaming.
Doesn't this need to be protected from quitting?
But anyway, feel free to install any fixes you think are necessary.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
2023-06-26 14:52 ` Eli Zaretskii
@ 2023-06-26 15:25 ` Stefan Monnier
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2023-06-26 15:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> For reference, find below my initial suggestion stripped of its
>> gratuitous renaming.
> Doesn't this need to be protected from quitting?
As you can see in the patch, my code just does the same that is done for
`debug-on-error`, so if we think it's not good enough for
`debug-ignored-errors` we should also fix it for `debug-on-error` but
I think that's orthogonal to the issue at hand.
Installed,
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-06-26 15:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <168735410313.21082.15347717294570895563@vcs2.savannah.gnu.org>
[not found] ` <20230621132823.6C945C06C79@vcs2.savannah.gnu.org>
2023-06-25 23:26 ` master 4302bc9b0f1: Allow --debug-init to debug all errors in init files Stefan Monnier
2023-06-26 11:07 ` Eli Zaretskii
2023-06-26 13:57 ` Stefan Monnier
2023-06-26 14:27 ` Stefan Monnier
2023-06-26 14:52 ` Eli Zaretskii
2023-06-26 15:25 ` Stefan Monnier
2023-06-26 14:48 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).