Add warning prompt to byte-compile

Byte-compiling should be a considered an advanced workflow. Warn users
of the dangers. The prompt can be suppressed with the -y option. e.g.

  bin/doom -y compile

You won't get the prompt for byte-compiling :core or :plugins however.
This commit is contained in:
Henrik Lissner 2018-06-03 22:00:40 +02:00
parent 48fdc8a5b5
commit 7acfcf907a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -270,10 +270,8 @@ these files.
If RECOMPILE-P is non-nil, only recompile out-of-date files."
(interactive
(list nil current-prefix-arg))
(let ((default-directory doom-emacs-dir))
(unless recompile-p
(doom//clean-byte-compiled-files))
(let ((total-ok 0)
(let ((default-directory doom-emacs-dir)
(total-ok 0)
(total-fail 0)
(total-noop 0)
compile-plugins-p
@ -296,17 +294,34 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
(intern (match-string 2 module)))
targets))))
(cl-block 'byte-compile
(unless (or (equal modules '(":core"))
recompile-p)
(unless (and (not doom-auto-accept)
(y-or-n-p
(concat "Warning: byte compiling is for advanced users. It will interfere with your\n"
"efforts to debug issues. It is not recommended you do it if you frequently\n"
"tinker with your Emacs config.\n\n"
"Alternatively, use `bin/doom compile :core` instead to byte-compile only the\n"
"Doom core files, as these don't change often.\n\n"
"If you have issues, please make sure byte-compilation isn't the cause by using\n"
"`bin/doom clean` to clear out your *.elc files.\n\n"
"Byte-compile anyway?")))
(message "Aborting.")
(cl-return-from 'byte-compile)))
;; If we're just here to byte-compile our plugins, we're done!
(and (not modules)
compile-plugins-p
(cl-return-from 'byte-compile t))
(unless recompile-p
(doom//clean-byte-compiled-files))
(unless targets
(message "Regenerating autoloads files (if necessary)")
(let ((inhibit-message t)
noninteractive)
;; But first we must be sure that Doom and your private config have
;; been fully loaded. Which usually aren't so in an noninteractive
;; session.
(doom//reload-autoloads)
(quiet! (doom//reload-autoloads))
(doom-initialize t)))
;; If no targets were supplied, then we use your module list.
(unless modules
@ -364,7 +379,7 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
(error-message-string ex)
"Reverting changes...")
(quiet! (doom//clean-byte-compiled-files))
(print! (yellow "Finished (nothing was byte-compiled)")))))))))
(print! (yellow "Finished (nothing was byte-compiled)"))))))))
;;;###autoload
(defun doom//clean-byte-compiled-files ()