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:
parent
d00c5a0de5
commit
905ba1d23c
1 changed files with 7 additions and 5 deletions
|
@ -42,7 +42,7 @@ It also caches `load-path', `Info-directory-list', `doom-disabled-packages',
|
||||||
(ignore-errors (delete-file (byte-compile-dest-file file)))
|
(ignore-errors (delete-file (byte-compile-dest-file file)))
|
||||||
t))
|
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 "Restart or reload Doom Emacs for changes to take effect:\n")
|
||||||
(message " M-x doom/restart-and-restore")
|
(message " M-x doom/restart-and-restore")
|
||||||
(message " M-x doom/restart")
|
(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)
|
(defun doom--reload-files (&rest files)
|
||||||
(if noninteractive
|
(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)
|
(dolist (file files)
|
||||||
(load-file (byte-compile-dest-file file)))))
|
(load-file (byte-compile-dest-file file)))))
|
||||||
|
|
||||||
(defun doom--byte-compile-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
|
(condition-case e
|
||||||
(when (byte-compile-file file)
|
(when (byte-compile-file file)
|
||||||
;; Give autoloads file a chance to report error
|
;; 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))
|
nil t))
|
||||||
((debug error)
|
((debug error)
|
||||||
(let ((backup-file (concat file ".bk")))
|
(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))
|
(copy-file file backup-file 'overwrite))
|
||||||
(doom-delete-autoloads-file file)
|
(doom-delete-autoloads-file file)
|
||||||
(signal 'doom-autoload-error (list file e))))))
|
(signal 'doom-autoload-error (list file e))))))
|
||||||
|
@ -94,7 +96,7 @@ even if it doesn't need reloading!"
|
||||||
|
|
||||||
(defun doom--generate-header (func)
|
(defun doom--generate-header (func)
|
||||||
(goto-char (point-min))
|
(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"))
|
";; This file is autogenerated by `" (symbol-name func) "', DO NOT EDIT !!\n\n"))
|
||||||
|
|
||||||
(defun doom--generate-autoloads (targets)
|
(defun doom--generate-autoloads (targets)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue