doom//byte-compile: better error handling (revert on error)

This commit is contained in:
Henrik Lissner 2017-12-22 17:05:01 -05:00
parent 1873a48e71
commit 3bbb78f779
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -634,6 +634,8 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
(error "No targets to compile")) (error "No targets to compile"))
(let ((use-package-expand-minimally t)) (let ((use-package-expand-minimally t))
(push (expand-file-name "init.el" doom-emacs-dir) compile-targets) (push (expand-file-name "init.el" doom-emacs-dir) compile-targets)
(condition-case ex
(progn
(dolist (target compile-targets) (dolist (target compile-targets)
(when (or (not recompile-p) (when (or (not recompile-p)
(let ((elc-file (byte-compile-dest-file target))) (let ((elc-file (byte-compile-dest-file target)))
@ -660,7 +662,14 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
"%s %s file(s) %s" "%s %s file(s) %s"
(if recompile-p "Recompiled" "Compiled") (if recompile-p "Recompiled" "Compiled")
(format "%d/%d" total-ok (- (length compile-targets) total-noop)) (format "%d/%d" total-ok (- (length compile-targets) total-noop))
(format "(%s ignored)" total-noop))))))))) (format "(%s ignored)" total-noop)))))
(error
(message! (red "\n%%s\n\n%%s\n\n%%s")
"There were breaking errors."
(error-message-string ex)
"Reverting changes...")
(doom//clean-byte-compiled-files)
(message! (green "Finished (nothing was byte-compiled)")))))))))
(defun doom//byte-compile-core (&optional recompile-p) (defun doom//byte-compile-core (&optional recompile-p)
"Byte compile the core Doom files. "Byte compile the core Doom files.