From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
Date: Mon, 26 Jun 2023 10:27:40 -0400 [thread overview]
Message-ID: <jwvmt0ml2u5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwv4jmumiu7.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 26 Jun 2023 09:57:08 -0400")
>> 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))))
next prev parent reply other threads:[~2023-06-26 14:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
2023-06-26 14:52 ` Eli Zaretskii
2023-06-26 15:25 ` Stefan Monnier
2023-06-26 14:48 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvmt0ml2u5.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).