emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init f


From: Stefan Monnier
Subject: Re: master 4302bc9b0f1: Allow --debug-init to debug all errors in init files
Date: Mon, 26 Jun 2023 10:27:40 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> 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))))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]