From ea9f1314041c83ef60fd293bea01d5fb025c72e3 Mon Sep 17 00:00:00 2001 From: Jared Finder Date: Tue, 12 Dec 2023 09:12:18 -0800 Subject: [PATCH] Switching from debugger hook to just condition-case. The motivation for using debugger was to get a backtrace, but this is more complicated than originally thought. * `signal-hook-function' does not not work because it gets every signal, even ones that would be handled by `condition-case'. * `debugger' and `debug-on-error' because the debugger will only be invoked once per event. --- init-dir.el | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/init-dir.el b/init-dir.el index c8379be..7368c7d 100644 --- a/init-dir.el +++ b/init-dir.el @@ -147,17 +147,15 @@ FILE: File path to a file to load. Unlike `load', this must be an absolute path with an extension. ROOT-DIR: Directory root being loaded from." (let ((prev-time (time-convert nil 'list)) - (debug-ignored-errors '()) - (debug-on-error t) - (debugger #'init-dir--debugger) ;; Dynamic binding intended to be modified by clients. (init-dir--long-load-time-warning init-dir--long-load-time-warning)) (let* (;; This line actually loads the file as a side effect. - (load-error (catch 'init-dir--load-error - (load file nil nil t t) - nil)) - + (load-error + (condition-case err + (load file nil nil t t) + (:success nil) + ((debug t) err))) (cur-time (time-convert nil 'list)) (delta-time (float-time (time-subtract cur-time prev-time)))) (when load-error @@ -195,16 +193,6 @@ ROOT-DIR: Directory root that file is in." (throw 'return file-with-suffix)))) nil)) -(defun init-dir--debugger (&rest args) - "Replacement debugger function while running `init-dir--load-single-file'. - -ARGS: See `debugger' for the meaning of ARGS." - (if (eq (car-safe args) 'error) - ;; This entered the debugger due to an error -- the exact case - ;; we want to handle specially. - (throw 'init-dir--load-error (car-safe (cdr-safe args))) - (apply #'debug args))) - (provide 'init-dir) ;;; init-dir.el ends here