I use the following function from Latex, Emacs: automatically open *TeX Help* buffer on error and close it after correction of the error? to compile .tex documents via latexmk
:
(defun run-latexmk ()
(interactive)
(let ((TeX-save-query nil)
(TeX-process-asynchronous nil)
(master-file (TeX-master-file)))
(TeX-save-document "")
(TeX-run-TeX "latexmk"
(TeX-command-expand "latexmk -pdf %s" 'TeX-master-file); adjusted
master-file)
(if (plist-get TeX-error-report-switches (intern master-file))
(TeX-next-error t)
(progn
(demolish-tex-help)
(minibuffer-message "latexmk: Done")))))
How can I "add" this function to TeX-command-list
so that C-c C-c
in .tex files executes this function? [C-c C-c
should use run-latexmk
as default when executed on .tex files]
I tried
(add-hook 'LaTeX-mode-hook
(lambda ()
(add-to-list 'TeX-command-list
'("latexmk" #'run-latexmk
TeX-run-command nil t :help "Run latexmk") t)
(setq TeX-command-default "latexmk")))
but it fails with message: TeX-command-expand: Wrong type argument: stringp, (function run-latexmk)
(taken from *Messages*)
You don't want to use TeX-run-command
since that is for running a shell command. You will want to run TeX-run-function
, but it still takes the "function" as a string so you should say (untested):
(add-hook 'LaTeX-mode-hook
(lambda ()
(add-to-list 'TeX-command-list
'("latexmk" "(run-latexmk)"
TeX-run-function nil t :help "Run latexmk") t)
(setq TeX-command-default "latexmk")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With