From c2818bcfaa5dc1a0139d1deff7d77bf42a08eede Mon Sep 17 00:00:00 2001 From: Maoli Date: Fri, 24 Nov 2023 14:24:40 +0800 Subject: [PATCH] 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. --- modules/lang/latex/config.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 3bc13b18b..ed8e59fd5 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -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))