lang/latex: refactor default viewer resolution
And add evince to list of auto-detected viewers. This should fix an issue where preview-pane was used regardless of what viewer(s) were available.
This commit is contained in:
parent
a9b5640d1f
commit
3fae411918
2 changed files with 36 additions and 34 deletions
|
@ -1,43 +1,45 @@
|
||||||
;;; lang/latex/+viewers.el -*- lexical-binding: t; -*-
|
;;; lang/latex/+viewers.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(catch 'found-viewer
|
;; fall back pdf previewing to latex-preview-pane
|
||||||
(dolist (viewer +latex-viewers)
|
(add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane") 'append)
|
||||||
(if (pcase viewer
|
(add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode))
|
||||||
(`skim
|
|
||||||
(when (and IS-MAC
|
|
||||||
(file-exists-p! (or "/Applications/Skim.app"
|
|
||||||
"~/Applications/Skim.app")))
|
|
||||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Skim"))))
|
|
||||||
(`sumatrapdf
|
|
||||||
(when (and IS-WINDOWS
|
|
||||||
(executable-find "SumatraPDF"))
|
|
||||||
(add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF"))))
|
|
||||||
|
|
||||||
(`okular
|
(dolist (viewer +latex-viewers)
|
||||||
(when (executable-find "okular")
|
(pcase viewer
|
||||||
;; Configure Okular as viewer. Including a bug fix
|
(`skim
|
||||||
;; (https://bugs.kde.org/show_bug.cgi?id=373855)
|
(when (and IS-MAC
|
||||||
(add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a"))))
|
(file-exists-p! (or "/Applications/Skim.app"
|
||||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Okular"))))
|
"~/Applications/Skim.app")))
|
||||||
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Skim"))))
|
||||||
|
|
||||||
(`zathura
|
(`sumatrapdf
|
||||||
(when (executable-find "zathura")
|
(when (and IS-WINDOWS
|
||||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))))
|
(executable-find "SumatraPDF"))
|
||||||
|
(add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF"))))
|
||||||
|
|
||||||
(`pdf-tools
|
(`okular
|
||||||
(when (featurep! :tools pdf)
|
(when (executable-find "okular")
|
||||||
(add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
|
;; Configure Okular as viewer. Including a bug fix
|
||||||
(when IS-MAC
|
;; (https://bugs.kde.org/show_bug.cgi?id=373855)
|
||||||
;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs
|
(add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a"))))
|
||||||
(add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view)))
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Okular"))))
|
||||||
;; Update PDF buffers after successful LaTeX runs
|
|
||||||
(add-hook 'TeX-after-compilation-finished-function #'TeX-revert-document-buffer))))
|
|
||||||
|
|
||||||
(throw 'found-viewer t)))
|
(`zathura
|
||||||
|
(when (executable-find "zathura")
|
||||||
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))))
|
||||||
|
|
||||||
;; fall back to latex-preview-pane
|
(`evince
|
||||||
(add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode))
|
(when (executable-find "evince")
|
||||||
(add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane")))
|
(add-to-list 'TeX-view-program-selection '(output-pdf "Evince"))))
|
||||||
|
|
||||||
|
(`pdf-tools
|
||||||
|
(when (featurep! :tools pdf)
|
||||||
|
(add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
|
||||||
|
(when IS-MAC
|
||||||
|
;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs
|
||||||
|
(add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view)))
|
||||||
|
;; Update PDF buffers after successful LaTeX runs
|
||||||
|
(add-hook 'TeX-after-compilation-finished-function #'TeX-revert-document-buffer)))))
|
||||||
|
|
||||||
|
|
||||||
(after! latex-preview-pane
|
(after! latex-preview-pane
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
enabling unicode symbols in math regions. This requires the unicode-math latex
|
enabling unicode symbols in math regions. This requires the unicode-math latex
|
||||||
package to be installed.")
|
package to be installed.")
|
||||||
|
|
||||||
(defvar +latex-viewers `(skim sumatrapdf zathura okular pdf-tools)
|
(defvar +latex-viewers '(skim evince sumatrapdf zathura okular pdf-tools)
|
||||||
"A list of enabled latex viewers to use, in this order. If they don't exist,
|
"A list of enabled latex viewers to use, in this order. If they don't exist,
|
||||||
they will be ignored. Recognized viewers are skim, zathura, okular and
|
they will be ignored. Recognized viewers are skim, zathura, okular and
|
||||||
pdf-tools.
|
pdf-tools.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue