tools/pdf: document pdf-tools-install hackery

This commit is contained in:
Henrik Lissner 2019-09-22 20:15:20 -04:00
parent 89242f83d2
commit ece174d9ed
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -51,9 +51,19 @@
(let ((wconf (current-window-configuration))) (let ((wconf (current-window-configuration)))
(pdf-tools-install) (pdf-tools-install)
(message "Building epdfinfo, this will take a moment...") (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)) (dolist (buffer (doom-buffers-in-mode 'pdf-view-mode))
(with-current-buffer buffer (fundamental-mode))) (with-current-buffer buffer (fundamental-mode)))
(while compilation-in-progress (while compilation-in-progress
;; Block until `pdf-tools-install' is done
(sleep-for 1)) (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) (when (file-executable-p pdf-info-epdfinfo-program)
(set-window-configuration wconf))))) (set-window-configuration wconf)))))