Use dynamic byte-compilation for autoload files

Very experimental! This reduces the size and overhead of autoload files
slightly, but may have other reprecussions!
This commit is contained in:
Henrik Lissner 2018-06-05 14:06:30 +02:00
parent 43c65ab628
commit 3661462a7a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -46,8 +46,10 @@ init.el and config.el. Then runs `doom-reload-hook'."
everyone in the universe and their dog, causing errors that make babies cry. No everyone in the universe and their dog, causing errors that make babies cry. No
one wants that.") one wants that.")
(defun doom--byte-compile (file) (defun doom--byte-compile-file (file)
(let ((short-name (file-name-nondirectory file))) (let ((short-name (file-name-nondirectory file))
(byte-compile-dynamic t)
(byte-compile-dynamic-docstrings t))
(condition-case-unless-debug ex (condition-case-unless-debug ex
(when (byte-compile-file file) (when (byte-compile-file file)
(load (byte-compile-dest-file file) nil t) (load (byte-compile-dest-file file) nil t)
@ -179,7 +181,7 @@ modified."
(replace-match "" t t)) (replace-match "" t t))
;; Byte compile it to give the file a chance to reveal errors. ;; Byte compile it to give the file a chance to reveal errors.
(save-buffer) (save-buffer)
(doom--byte-compile doom-autoload-file) (doom--byte-compile-file doom-autoload-file)
(when (and noninteractive (not (daemonp))) (when (and noninteractive (not (daemonp)))
(doom--server-load doom-autoload-file)) (doom--server-load doom-autoload-file))
t) t)
@ -244,7 +246,7 @@ This should be run whenever your `doom!' block or update your packages."
(goto-char (match-beginning 1)) (goto-char (match-beginning 1))
(kill-sexp)) (kill-sexp))
(print! (green "✓ Removed load-path/auto-mode-alist entries"))) (print! (green "✓ Removed load-path/auto-mode-alist entries")))
(doom--byte-compile doom-package-autoload-file) (doom--byte-compile-file doom-package-autoload-file)
(when (and noninteractive (not (daemonp))) (when (and noninteractive (not (daemonp)))
(doom--server-load doom-package-autoload-file)) (doom--server-load doom-package-autoload-file))
t)) t))