Refactor autoloads byte-compilation

- Let-bind byte-compile-* vars instead of using file-local vars.
- Fix duplicate bullet point in "Copied backup..." message.
- Only display refresh message if cli command was successful.
This commit is contained in:
Henrik Lissner 2019-07-25 17:23:49 +02:00
parent d00c5a0de5
commit 905ba1d23c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -42,7 +42,7 @@ It also caches `load-path', `Info-directory-list', `doom-disabled-packages',
(ignore-errors (delete-file (byte-compile-dest-file file)))
t))
(defun doom--warn-refresh-session ()
(defun doom--warn-refresh-session-h ()
(message "Restart or reload Doom Emacs for changes to take effect:\n")
(message " M-x doom/restart-and-restore")
(message " M-x doom/restart")
@ -50,12 +50,14 @@ It also caches `load-path', `Info-directory-list', `doom-disabled-packages',
(defun doom--reload-files (&rest files)
(if noninteractive
(add-hook 'doom-cli-post-execute-hook #'doom--warn-refresh-session)
(add-hook 'doom-cli-post-success-execute-hook #'doom--warn-refresh-session-h)
(dolist (file files)
(load-file (byte-compile-dest-file file)))))
(defun doom--byte-compile-file (file)
(let ((byte-compile-warnings (if doom-debug-mode byte-compile-warnings)))
(let ((byte-compile-warnings (if doom-debug-mode byte-compile-warnings))
(byte-compile-dynamic t)
(byte-compile-dynamic-docstrings t))
(condition-case e
(when (byte-compile-file file)
;; Give autoloads file a chance to report error
@ -65,7 +67,7 @@ It also caches `load-path', `Info-directory-list', `doom-disabled-packages',
nil t))
((debug error)
(let ((backup-file (concat file ".bk")))
(print! (warn "- Copied backup to %s") (relpath backup-file))
(print! (warn "Copied backup to %s") (relpath backup-file))
(copy-file file backup-file 'overwrite))
(doom-delete-autoloads-file file)
(signal 'doom-autoload-error (list file e))))))
@ -94,7 +96,7 @@ even if it doesn't need reloading!"
(defun doom--generate-header (func)
(goto-char (point-min))
(insert ";; -*- lexical-binding:t; byte-compile-dynamic-docstrings: t; -*-\n"
(insert ";; -*- lexical-binding:t; -*-\n"
";; This file is autogenerated by `" (symbol-name func) "', DO NOT EDIT !!\n\n"))
(defun doom--generate-autoloads (targets)