fix(latex): reorder viewers wrt +latex-viewers
If a viewer already exists in `TeX-view-program-selection`, loading `+viewer.el` does not change its order because `add-to-list` does nothing when the item is already in the list. Close: #8046 Fix: #5275 Co-authored-by: cartoonist <cartoonist@users.noreply.github.com>
This commit is contained in:
parent
1fa1eba5ac
commit
03e5f1333c
1 changed files with 39 additions and 36 deletions
|
@ -4,47 +4,50 @@
|
|||
(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))
|
||||
|
||||
(dolist (viewer (reverse +latex-viewers))
|
||||
(pcase viewer
|
||||
(`skim
|
||||
(when-let
|
||||
(app-path
|
||||
(and (featurep :system 'macos)
|
||||
(file-exists-p! (or "/Applications/Skim.app"
|
||||
"~/Applications/Skim.app"))))
|
||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Skim"))
|
||||
(add-to-list 'TeX-view-program-list
|
||||
(list "Skim" (format "%s/Contents/SharedSupport/displayline -r -b %%n %%o %%b"
|
||||
app-path)))))
|
||||
(letf! (defun prepend-to-list (list-var value &optional append)
|
||||
(set list-var (delete value (symbol-value list-var)))
|
||||
(add-to-list list-var value append))
|
||||
(dolist (viewer (reverse +latex-viewers))
|
||||
(pcase viewer
|
||||
(`skim
|
||||
(when-let
|
||||
(app-path
|
||||
(and (featurep :system 'macos)
|
||||
(file-exists-p! (or "/Applications/Skim.app"
|
||||
"~/Applications/Skim.app"))))
|
||||
(prepend-to-list 'TeX-view-program-selection '(output-pdf "Skim"))
|
||||
(add-to-list 'TeX-view-program-list
|
||||
(list "Skim" (format "%s/Contents/SharedSupport/displayline -r -b %%n %%o %%b"
|
||||
app-path)))))
|
||||
|
||||
(`sumatrapdf
|
||||
(when (and (featurep :system 'windows)
|
||||
(executable-find "SumatraPDF"))
|
||||
(add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF"))))
|
||||
(`sumatrapdf
|
||||
(when (and (featurep :system 'windows)
|
||||
(executable-find "SumatraPDF"))
|
||||
(prepend-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF"))))
|
||||
|
||||
(`okular
|
||||
(when (executable-find "okular")
|
||||
;; Configure Okular as viewer. Including a bug fix
|
||||
;; (https://bugs.kde.org/show_bug.cgi?id=373855).
|
||||
(add-to-list 'TeX-view-program-list '("Okular" ("okular --noraise --unique file:%o" (mode-io-correlate "#src:%n%a"))))
|
||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Okular"))))
|
||||
(`okular
|
||||
(when (executable-find "okular")
|
||||
;; Configure Okular as viewer. Including a bug fix
|
||||
;; (https://bugs.kde.org/show_bug.cgi?id=373855).
|
||||
(add-to-list 'TeX-view-program-list '("Okular" ("okular --noraise --unique file:%o" (mode-io-correlate "#src:%n%a"))))
|
||||
(prepend-to-list 'TeX-view-program-selection '(output-pdf "Okular"))))
|
||||
|
||||
(`zathura
|
||||
(when (executable-find "zathura")
|
||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))))
|
||||
(`zathura
|
||||
(when (executable-find "zathura")
|
||||
(prepend-to-list 'TeX-view-program-selection '(output-pdf "Zathura"))))
|
||||
|
||||
(`evince
|
||||
(when (executable-find "evince")
|
||||
(add-to-list 'TeX-view-program-selection '(output-pdf "Evince"))))
|
||||
(`evince
|
||||
(when (executable-find "evince")
|
||||
(prepend-to-list 'TeX-view-program-selection '(output-pdf "Evince"))))
|
||||
|
||||
(`pdf-tools
|
||||
(when (modulep! :tools pdf)
|
||||
(add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
|
||||
(when (featurep :system 'macos)
|
||||
;; 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-functions #'TeX-revert-document-buffer)))))
|
||||
(`pdf-tools
|
||||
(when (modulep! :tools pdf)
|
||||
(prepend-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
|
||||
(when (featurep :system 'macos)
|
||||
;; 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-functions #'TeX-revert-document-buffer))))))
|
||||
|
||||
|
||||
(after! latex-preview-pane
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue