core-packages: add comprehensive byte-compile option

This commit is contained in:
Henrik Lissner 2017-02-02 21:56:40 -05:00
parent 3654e0face
commit 41bbd2730b

View file

@ -277,26 +277,31 @@ command line)."
(load generated-autoload-file nil t t) (load generated-autoload-file nil t t)
(message "Done!"))) (message "Done!")))
(defun doom/byte-compile () (defun doom/byte-compile (&optional comprehensive-p)
"Byte (re)compile the important files in your emacs configuration (i.e. "Byte (re)compile the important files in your emacs configuration (i.e.
init.el, core/*.el and modules/*/*/config.el) DOOM Emacs was designed to benefit init.el, core/*.el and modules/*/*/config.el) DOOM Emacs was designed to benefit
a lot from this." a lot from this.
If COMPREHENSIVE-P or the envar ALL is non-nil, also compile all autoload files.
The benefit from this is minimal and may take more time."
(interactive) (interactive)
(doom-initialize) (doom-initialize)
(doom-reload-modules) (doom-reload-modules)
(let ((targets (append (list (f-expand "init.el" doom-emacs-dir) (let* ((map-fn (lambda (file) (and (f-ext-p file "el")
(f-expand "core.el" doom-core-dir)) (if comprehensive-p
(reverse (f-glob "core-*.el" doom-core-dir)) (not (string= (f-base file) "packages"))
(-filter 'f-exists-p (string= (f-base file) "config")))))
(--map (doom-module-path (car it) (cdr it) "config.el") (targets (append
doom-enabled-modules)))) (list (f-expand "init.el" doom-emacs-dir)
(n 0) (f-expand "core.el" doom-core-dir))
results (f-glob "core-*.el" doom-core-dir)
use-package-always-ensure (-flatten (--map (f-entries (doom-module-path (car it) (cdr it)) map-fn t)
file-name-handler-alist) doom-enabled-modules))))
(n 0)
results)
(mapc (lambda (file) (mapc (lambda (file)
(push (cons (f-relative file doom-emacs-dir) (push (cons (f-relative file doom-emacs-dir)
(when (byte-compile-file file) (when (byte-recompile-file file nil 0)
(setq n (1+ n)) (setq n (1+ n))
t)) t))
results)) results))