Defer server reloading of autoloads

Occasionally, bin/doom commands hang when generating autoloads. It
blocks endlessly after sending a message to an active Emacs server, but
never receives a proper reply.

This commit makes it less likely that this hanging will leave Doom in a
broken state (and also informs the user it is safe to abort the
process).
This commit is contained in:
Henrik Lissner 2018-07-03 00:53:06 +02:00
parent 1530cdbdb6
commit 9648aa4093
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -337,10 +337,22 @@ it exists."
(when (funcall fn doom-auto-accept)
(doom-reload-package-autoloads)))
(defun doom--server-load (file)
(require 'server)
(when (server-running-p)
(server-eval-at server-name `(load-file ,(byte-compile-dest-file file)))))
(defun doom--server-reload-autoloads ()
(message "Reloading your current Emacs session\n")
(message "If this hangs, it is safe to abort the process here")
(server-eval-at
server-name
`(dolist (file '(,doom-autoload-file ,doom-package-autoload-file))
(load-file (byte-compile-dest-file file)))))
(defun doom--server-load (&rest files)
(if (and noninteractive (not (daemonp)))
(progn
(require 'server)
(when (server-running-p)
(add-hook 'kill-emacs-hook #'doom--server-reload-autoloads)))
(dolist (file files)
(load-file (byte-compile-dest-file file)))))
(defun doom--byte-compile-file (file)
(let ((short-name (file-name-nondirectory file))