2018-07-18 12:12:04 +02:00
|
|
|
;;; lang/latex/+viewers.el -*- lexical-binding: t; -*-
|
|
|
|
|
2021-11-24 13:08:34 +01:00
|
|
|
;; Fall back PDF previewing to `latex-preview-pane-mode'.
|
2019-08-27 00:11:52 -04:00
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane") 'append)
|
|
|
|
(add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode))
|
|
|
|
|
2019-09-26 14:35:44 +02:00
|
|
|
(dolist (viewer (reverse +latex-viewers))
|
2019-08-27 00:11:52 -04:00
|
|
|
(pcase viewer
|
|
|
|
(`skim
|
2019-11-21 00:49:37 -05:00
|
|
|
(when-let
|
|
|
|
(app-path
|
|
|
|
(and IS-MAC
|
|
|
|
(file-exists-p! (or "/Applications/Skim.app"
|
|
|
|
"~/Applications/Skim.app"))))
|
2019-11-20 12:09:23 +01:00
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Skim"))
|
2019-11-21 00:49:37 -05:00
|
|
|
(add-to-list 'TeX-view-program-list
|
2022-08-03 02:42:39 +08:00
|
|
|
(list "Skim" (format "%s/Contents/SharedSupport/displayline -r -b %%n %%o %%b"
|
2019-11-21 14:04:55 -05:00
|
|
|
app-path)))))
|
2019-08-27 00:11:52 -04:00
|
|
|
|
|
|
|
(`sumatrapdf
|
|
|
|
(when (and IS-WINDOWS
|
|
|
|
(executable-find "SumatraPDF"))
|
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF"))))
|
|
|
|
|
|
|
|
(`okular
|
|
|
|
(when (executable-find "okular")
|
|
|
|
;; Configure Okular as viewer. Including a bug fix
|
2021-11-24 13:08:34 +01:00
|
|
|
;; (https://bugs.kde.org/show_bug.cgi?id=373855).
|
2021-05-02 21:33:20 +02:00
|
|
|
(add-to-list 'TeX-view-program-list '("Okular" ("okular --noraise --unique file:%o" (mode-io-correlate "#src:%n%a"))))
|
2019-08-27 00:11:52 -04:00
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Okular"))))
|
|
|
|
|
|
|
|
(`zathura
|
|
|
|
(when (executable-find "zathura")
|
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))))
|
|
|
|
|
|
|
|
(`evince
|
|
|
|
(when (executable-find "evince")
|
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Evince"))))
|
|
|
|
|
|
|
|
(`pdf-tools
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! :tools pdf)
|
2019-08-27 00:11:52 -04:00
|
|
|
(add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
|
|
|
|
(when IS-MAC
|
2021-11-24 13:08:34 +01:00
|
|
|
;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs.
|
2019-08-27 00:11:52 -04:00
|
|
|
(add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view)))
|
2021-11-24 13:08:34 +01:00
|
|
|
;; Update PDF buffers after successful LaTeX runs.
|
2019-09-26 14:35:44 +02:00
|
|
|
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)))))
|
2018-07-30 01:05:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
(after! latex-preview-pane
|
|
|
|
(setq latex-preview-pane-multifile-mode 'auctex)
|
|
|
|
|
2021-11-24 13:08:34 +01:00
|
|
|
;; TODO: PR this to maintained fork by arifer48. The original project appears abandoned.
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +latex--dont-reopen-preview-pane-a (fn &rest args)
|
2020-10-21 19:29:31 -04:00
|
|
|
"Once the preview pane has been closed it should not be reopened."
|
|
|
|
:around #'latex-preview-pane-update
|
|
|
|
(letf! (defun init-latex-preview-pane (&rest _)
|
|
|
|
;; HACK Avoid the function because it tries to delete the current
|
|
|
|
;; window, but it's already gone, so it ends up deleting the
|
|
|
|
;; wrong window.
|
|
|
|
(setq-local latex-preview-pane-mode nil))
|
2021-08-04 01:18:06 -04:00
|
|
|
(apply fn args)))
|
2020-10-21 19:29:31 -04:00
|
|
|
|
2018-07-30 01:05:56 +02:00
|
|
|
(define-key! doc-view-mode-map
|
2019-02-24 13:58:56 -05:00
|
|
|
"ESC" #'delete-window
|
|
|
|
"q" #'delete-window
|
2020-06-04 20:02:46 -04:00
|
|
|
"k" (cmd! (quit-window) (delete-window))))
|