diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index cd17284c2..4d946c79c 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -51,9 +51,19 @@ (let ((wconf (current-window-configuration))) (pdf-tools-install) (message "Building epdfinfo, this will take a moment...") + ;; HACK We reset all `pdf-view-mode' buffers to fundamental mode so that + ;; `pdf-tools-install' has a change to reinitialize them as + ;; `pdf-view-mode' buffers. This is necessary because `pdf-tools-install' + ;; won't do this to buffers that are already in pdf-view-mode for some + ;; reason -- even though those are the buffers we need to reload! (dolist (buffer (doom-buffers-in-mode 'pdf-view-mode)) (with-current-buffer buffer (fundamental-mode))) (while compilation-in-progress + ;; Block until `pdf-tools-install' is done (sleep-for 1)) + ;; HACK If pdf-tools was loaded by you opening a pdf file, once + ;; `pdf-tools-install' completes, `pdf-view-mode' will throw an error + ;; because the compilation buffer is focused, not the pdf buffer. + ;; Therefore, it is imperative that the window config is restored. (when (file-executable-p pdf-info-epdfinfo-program) (set-window-configuration wconf)))))