I would like the default compile command for .tex files to be different than the default for .Rnw (knitr) files.
Here is a minimal example to illustrate my current .emacs file:
(defvar TeX-command-list)
(add-hook 'LaTeX-mode-hook
(lambda()
(add-to-list 'TeX-command-list '("LaTeXmk -- run continuously" "latexmk -pdf -pvc -new-viewer- -e \"$pdf_previewer='start C:/SumatraPDF-TeX/SumatraPDF-TeX.exe';$pdflatex='pdflatex -interaction=nonstopmode -synctex=1 %%O %%S'\" %s" TeX-run-TeX nil t))
(setq TeX-command-default "LaTeXmk -- run continuously")
(setq TeX-save-query nil)))
So far so good. When I press C-c C-c, my .tex files default to this command.
Here is what I have for .Rnw files:
(setq TeX-file-extensions
'("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-hook 'Rnw-mode-hook
(lambda()
(add-to-list 'TeX-command-list '("Knitr via latexmk" "latexmk -pdf -pvc -new-viewer- -f -r \"%UserProfile%\\.emacs.d\\Knitrlatexmk.rc\" %t" TeX-run-TeX nil t))
(setq TeX-command-default "Knitr via latexmk")
(setq TeX-save-query nil)))
But when I try to compile my .Rnw files (with C-c C-c), the default is the "Sweave" command. What am I missing? I've searched high and low, trying everything I can think of, but the above command is never offered to me as the default for .Rnw files.