How to add a function (latexmk variant) to TeX-command-list in AUCTeX?

I use the following function from Latex, Emacs: automatically open * TeX Help * clipboard on error and close it after fixing the error? to compile .tex documents through 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 this function is executed by Cc Cc in .tex files? [ Cc Cc should use run-latexmk by default when executed in .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 does not work with the message: TeX-command-expand: Wrong type argument: stringp, (function run-latexmk) (taken from * Messages *)

+6
source share
1 answer

You do not want to use TeX-run-command as this is to run a shell command. You want to run TeX-run-function , but it still accepts the "function" as a string, so you should say (unchecked):

 (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"))) 
+4
source

Source: https://habr.com/ru/post/909395/


All Articles