aboutsummaryrefslogtreecommitdiff
path: root/modules/latex-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-16 03:55:49 -0500
committerCraig Jennings <c@cjennings.net>2026-05-16 03:55:49 -0500
commitd84aa4374af5e3447445377a836c66cc07d7a223 (patch)
tree0d438568f866feef0a036de7a59192b469e231bc /modules/latex-config.el
parenta005c7636f30b710e27a6812ca989506d5df7531 (diff)
downloaddotemacs-d84aa4374af5e3447445377a836c66cc07d7a223.tar.gz
dotemacs-d84aa4374af5e3447445377a836c66cc07d7a223.zip
refactor(prog): six programming-track hygiene fixes from re-review
- prog-lsp.el: rename `cj/lsp--remove-eldoc-provider' → `cj/lsp--remove-eldoc-provider-global' and call it once from the lsp-mode `:config' block instead of attaching it per-buffer via `lsp-managed-mode-hook'. The previous per-buffer remove with the buffer-local flag raced lsp-mode's own population of the local hook; removing the provider from the global default before any LSP buffer attaches makes the absence stick. Two existing tests updated to the new contract (remove-from-default + idempotent re-run). - prog-webdev.el / prog-python.el: warn at load time when `prettier' or `pyright' is missing on PATH via `cj/executable-find-or-warn'. Both modules now `(require 'system-lib)' to expose the helper. Missing dependencies surface up front instead of mid-edit at first format/LSP attach. - keyboard-compat.el: document existing idempotence. The hook install uses a named function so `add-hook' deduplicates, and the hook body only calls `define-key' (latest binding wins, same value) -- adding a comment so future readers don't re-question. - dev-fkeys.el: add a `typescript' clause to `cj/--f6-test-runner-cmd-for'. F6 now runs `npx --no-install vitest <path>' when vitest is on PATH, otherwise `npx --no-install jest <path>'. Updates the matching test from "returns nil" to cover both code paths; the impl-level test now asserts the routed command instead of expecting a user-error. - flycheck-config.el: build the LanguageTool wrapper path with `(expand-file-name "scripts/languagetool-flycheck" user-emacs-directory)' instead of a hardcoded `~/.emacs.d/...'. Survives a non-standard `user-emacs-directory'. - latex-config.el: replace the hardcoded Zathura viewer with `cj/--latex-select-pdf-viewer', which walks `cj/--latex-pdf-viewer-candidates' (zathura → evince → okular → SumatraPDF → xdg-open) and falls back to "PDF Tools" when nothing is on PATH. Each entry maps an executable to the matching TeX-view-program-list name so AUCTeX's defaults handle the actual viewer invocation.
Diffstat (limited to 'modules/latex-config.el')
-rw-r--r--modules/latex-config.el33
1 files changed, 32 insertions, 1 deletions
diff --git a/modules/latex-config.el b/modules/latex-config.el
index bb4cf510..a0af2a1a 100644
--- a/modules/latex-config.el
+++ b/modules/latex-config.el
@@ -15,6 +15,37 @@
;;
;;; Code:
+;; ----------------------------- PDF Viewer Selection --------------------------
+;;
+;; Pick whichever PDF viewer is available rather than hard-coding Zathura.
+;; The selected viewer is pushed onto `TeX-view-program-selection' for
+;; output-pdf so `C-c C-v' opens the compiled PDF.
+
+(defconst cj/--latex-pdf-viewer-candidates
+ ;; (PROGRAM . TeX-VIEWER-NAME) in preference order. TeX-view-program-list
+ ;; has built-in entries for "Zathura", "Evince", "Okular", "Skim",
+ ;; "PDF Tools", and platform openers; we match against those names.
+ '(("zathura" . "Zathura")
+ ("evince" . "Evince")
+ ("okular" . "Okular")
+ ("SumatraPDF" . "Sumatra PDF")
+ ("xdg-open" . "xdg-open"))
+ "Ordered (EXECUTABLE . TEX-VIEWER-NAME) pairs for PDF preview selection.")
+
+(defvar TeX-view-program-selection)
+(declare-function pdf-view-mode "pdf-view")
+
+(defun cj/--latex-select-pdf-viewer ()
+ "Push the first available external PDF viewer onto `TeX-view-program-selection'.
+Falls back to PDF Tools when no external viewer is on PATH. The new
+selection is consed onto the head of the alist so it wins over any
+default. Idempotent: re-running picks the same viewer."
+ (let* ((found (cl-find-if (lambda (entry)
+ (executable-find (car entry)))
+ cj/--latex-pdf-viewer-candidates))
+ (viewer-name (if found (cdr found) "PDF Tools")))
+ (push (list 'output-pdf viewer-name) TeX-view-program-selection)))
+
;; ----------------------------- Auctex And Related ----------------------------
(use-package tex
@@ -25,7 +56,7 @@
(LaTeX-mode . (lambda () (TeX-fold-mode 1))) ; automatically activate TeX-fold-mode.
(LaTeX-mode . flyspell-mode) ; turn on flyspell-mode by default
(LaTeX-mode . TeX-PDF-mode)
- (LaTeX-mode . (lambda () (push (list 'output-pdf "Zathura") TeX-view-program-selection)))
+ (LaTeX-mode . cj/--latex-select-pdf-viewer)
:mode
("\\.tex\\'" . latex-mode)
:config