From dcc7d643e2b8cbe05bb97a0185f8ea16ebdf8c03 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 26 Apr 2021 15:24:31 -0500 Subject: Enhance `refresh-emacs' - Enable `debug-on-error' - Save all init files before sourcing them --- lisp/acdw.el | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index f1c1a8d..9426117 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -57,19 +57,26 @@ each hook in HOOKS." (defun refresh-emacs () "Reload Emacs's configuration files." (interactive) - (dolist (file (append - ;; Load lisp libraries first, in case their functionality is - ;; used by {early-,}init.el - (let* ((dir (expand-file-name "lisp/" user-emacs-directory)) - (full-name (lambda (f) - (concat (file-name-as-directory dir) f)))) - (mapcar full-name (directory-files dir nil "\\.el\\'"))) - ;; Load regular init files - (list (locate-user-emacs-file "early-init.el") - (locate-user-emacs-file "init.el" ".emacs")))) - (with-message (format "Loading %s" file) - (when (file-exists-p file) - (load-file file))))) + (let ((init-files (append + ;; Load lisp libraries first, in case their functionality + ;; is used by {early-,}init.el + (let* ((dir (expand-file-name "lisp/" + user-emacs-directory)) + (full-name (lambda (f) + (concat + (file-name-as-directory dir) f)))) + (mapcar full-name (directory-files dir nil "\\.el\\'"))) + ;; Load regular init files + (list (locate-user-emacs-file "early-init.el") + (locate-user-emacs-file "init.el" ".emacs")))) + (debug-on-error t)) + (with-message "Saving init files" + (save-some-buffers :no-confirm (lambda () (member (buffer-file-name) + init-files)))) + (dolist (file init-files) + (with-message (format "Loading %s" file) + (when (file-exists-p file) + (load-file file)))))) (defun expand-file-name-exists-p (&rest expand-file-name-args) "Call `expand-file-name' on EXPAND-FILE-NAME-ARGS, returning -- cgit 1.4.1-21-gabe81