fix(latex): avoid stealing focus after compilation

Current LaTeX module uses `TeX-command-run-all` for compilation, which
by default opens the compiled document in a viewer. This behavior causes
a loss of focus from the Emacs window. We address this by adding a
custom compilation function.
This commit is contained in:
Maoli 2023-11-24 14:24:40 +08:00 committed by Henrik Lissner
parent 3cdf67ccce
commit c2818bcfaa

View file

@ -102,16 +102,23 @@ If no viewer is found, `latex-preview-pane-mode' is used.")
(add-hook! '(tex-mode-local-vars-hook
latex-mode-local-vars-hook)
:append #'lsp!))
;; Define a function to compile the project.
(defun +latex/compile ()
(interactive)
(TeX-save-document (TeX-master-file))
(TeX-command TeX-command-default 'TeX-master-file -1))
(map! :localleader
:map latex-mode-map
:desc "View" "v" #'TeX-view
:desc "Compile" "c" #'TeX-command-run-all
:desc "Compile" "c" #'+latex/compile
:desc "Run all" "a" #'TeX-command-run-all
:desc "Run a command" "m" #'TeX-command-master)
(map! :after latex
:localleader
:map LaTeX-mode-map
:desc "View" "v" #'TeX-view
:desc "Compile" "c" #'TeX-command-run-all
:desc "Compile" "c" #'+latex/compile
:desc "Run all" "a" #'TeX-command-run-all
:desc "Run a command" "m" #'TeX-command-master))