我使用Latex, Emacs: automatically open *TeX Help* buffer on error and close it after correction of the error?中的以下函数通过latexmk
编译.tex文档:
(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")))))
如何将此函数“添加”到TeX-command-list
,以便.tex文件中的C-c C-c
执行此功能? [。C-c C-c
在.tex文件上执行时应使用run-latexmk
作为默认值]
我试过
(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")))
但它失败并显示消息:TeX-command-expand: Wrong type argument: stringp, (function run-latexmk)
(取自* Messages *)
答案 0 :(得分:4)
您不想使用TeX-run-command
,因为这是用于运行shell命令。您将需要运行TeX-run-function
,但它仍然将“函数”作为字符串,因此您应该说(未经测试):
(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")))