From 0fefc43d391b5a13b956aee696fa80a93e4ee8c5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 19 Jun 2018 17:19:11 +0200 Subject: [PATCH] Refactor autoloads init & error handling Also reduces byte-compiled forms in the backtrace of a doom-autoload-error. --- core/core-dispatcher.el | 10 ++++++++-- core/core-modules.el | 9 --------- core/core.el | 9 +++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/core-dispatcher.el b/core/core-dispatcher.el index f4758ab1e..c086be793 100644 --- a/core/core-dispatcher.el +++ b/core/core-dispatcher.el @@ -345,11 +345,17 @@ it exists." (byte-compile-dynamic-docstrings t)) (condition-case e (when (byte-compile-file file) - (load (byte-compile-dest-file file) nil t) + ;; Give autoloads file a chance to report error + (load (if doom-debug-mode + file + (byte-compile-dest-file file)) + nil t) (unless noninteractive (message "Finished compiling %s" short-name))) ((debug error) - (copy-file file (concat file ".bk") 'overwrite) + (let ((backup-file (concat file ".bk"))) + (message "Copied backup to %s" backup-file) + (copy-file file backup-file 'overwrite)) (doom-delete-autoloads-file file) (signal 'doom-autoload-error (list short-name e)))))) diff --git a/core/core-modules.el b/core/core-modules.el index a5f09fc3a..7e09f8822 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -46,15 +46,6 @@ non-nil." ((debug error) (signal 'doom-private-error (list 'init e))))))) -(defun doom-initialize-autoloads (file) - "Tries to load FILE (an autoloads file). Return t on success, nil otherwise." - (condition-case e - (load (file-name-sans-extension file) 'noerror 'nomessage) - ((debug error) - (if noninteractive - (message "Autoload file warning: %s -> %s" (car e) (error-message-string e)) - (signal 'doom-autoload-error e))))) - ;; ;; Module API diff --git a/core/core.el b/core/core.el index e0478d49d..e2a06c867 100644 --- a/core/core.el +++ b/core/core.el @@ -373,6 +373,15 @@ to least)." (require 'core-projects) (require 'core-keybinds))) +(defun doom-initialize-autoloads (file) + "Tries to load FILE (an autoloads file). Return t on success, nil otherwise." + (condition-case e + (load (file-name-sans-extension file) 'noerror 'nomessage) + ((debug error) + (if noninteractive + (message "Autoload file warning: %s -> %s" (car e) (error-message-string e)) + (signal 'doom-autoload-error (list (file-name-nondirectory file) e)))))) + ;; ;; Bootstrap Doom