From 9664f68c5fabc4e3198314fce983aedc8ad5834a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 17 Dec 2019 18:10:16 -0500 Subject: [PATCH] tools/pdf: minor refactor & reformat --- modules/tools/pdf/config.el | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index b04753da2..91f600e0e 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -3,9 +3,7 @@ (use-package! pdf-tools :mode ("\\.[pP][dD][fF]\\'" . pdf-view-mode) :magic ("%PDF" . pdf-view-mode) - :config - (map! :map pdf-view-mode-map :gn "q" #'kill-current-buffer) - + :init (after! pdf-annot (defun +pdf-cleanup-windows-h () "Kill left-over annotation buffers when the document is killed." @@ -19,6 +17,9 @@ (add-hook! 'pdf-view-mode-hook (add-hook 'kill-buffer-hook #'+pdf-cleanup-windows-h nil t))) + :config + (map! :map pdf-view-mode-map :gn "q" #'kill-current-buffer) + (setq-default pdf-view-display-size 'fit-page pdf-view-use-scaling t pdf-view-use-imagemagick nil) @@ -41,11 +42,16 @@ ;; Turn off cua so copy works (add-hook! 'pdf-view-mode-hook (cua-mode 0)) + ;; Handle PDF-tools related popups better - (set-popup-rule! "^\\*Outline*" :side 'right :size 40 :select nil) - (set-popup-rule! "\\(?:^\\*Contents\\|'s annots\\*$\\)" :ignore t) + (set-popup-rules! + '(("^\\*Outline*" :side 'right :size 40 :select nil) + ("\\(?:^\\*Contents\\|'s annots\\*$\\)" :ignore t))) + + ;; The mode-line does serve any useful purpose is annotation windows (add-hook 'pdf-annot-list-mode-hook #'hide-mode-line-mode) - ;; Fix #1107: flickering pdfs when evil-mode is enabled + + ;; HACK Fix #1107: flickering pdfs when evil-mode is enabled (setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil)) ;; Install epdfinfo binary if needed, blocking until it is finished @@ -54,18 +60,19 @@ (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 chance 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. + ;; `pdf-tools-install' has a chance 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. (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. + ;; `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))))