"ESS is a GNU Emacs and XEmacs mode for interactive statistical programming and data analysis" (ESS)
Currently my configuration is as follows:
- GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600) of 2009-07-30 on SOFT-MJSAON
- AucTeX 11.84
- ESS 5.5
- Miktex 2.7
- latest version of R
One of the things I was missing from ESS & AucTeX is in relation to Sweaving. In particular, what I wanted to do was to be able to press C-c C-c inside a documentation chunk in a .Rnw file and be able to run Sweave, followed by LaTeX etc. While there is some support for sweaving etc in ESS I wanted some integration with AucTeX (and its options). As a result I came up with the following code (put it into your .emacs file). It works in AucTeX 11.84 - see below for a version that works with 11.83).
(setq TeX-file-extensions
'("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-to-list 'auto-mode-alist '("\\.Snw\\'" . Snw-mode))
(add-hook 'Rnw-mode-hook
(lambda ()
(add-to-list 'TeX-command-list
'("Sweave" "R CMD Sweave %s"
TeX-run-command nil (latex-mode) :help "Run Sweave") t)
(add-to-list 'TeX-command-list
'("LatexSweave" "%l %(mode) %s"
TeX-run-TeX nil (latex-mode) :help "Run Latex after Sweave") t)
(setq TeX-command-default "Sweave")))
For AucTeX 11.83 the above code may work (I haven't tested it), but I know that the following code snippet will). Simply replace the third last line above with the following line.
'("LatexSweave" "%l \"%(mode) \\input{%s}\""
The reason for this is explained in this short thread on the AucTeX mailing list. There was some further discussion about problems with the use of \\input{%s} (which is what I had originally) versus %s, which can be accessed here.