[ESS] ESS, AUCTeX, S/Rweave (noweb) and mode switching
Berwin A Turlach
statba at nus.edu.sg
Sat Mar 8 20:46:04 CET 2008
G'day Brett,
On Sat, 08 Mar 2008 12:30:27 -0500
Brett Presnell <presnell at stat.ufl.edu> wrote:
> (Side question: shouldn't TeX-PDF-mode be picked up from the master
> file?)
Would be nice, but is, apparently, not in the design. :)
> The problem is that once I move into a code chunk in a .Rnw file
> (automatically switching from AUCTeX to ESS mode) and then back out of
> the code chunch (automatically switching back to AUCTeX mode),
> TeX-master and TeX-PDF-mode both get set to nil. Worse, this also
> causes the invaluable reftex to lose all its reference information.
>
> Typing C-cC-n (i.e., running TeX-normal-mode) causes all the
> auctex/reftex information to be reset properly. However, the Noweb
> menu disappears when I do this and when I move back into a code chunk
> the buffer remains in PDFLaTeX/M mode instead of ESS[S] mode. Typing
> C-cC-n again seems to toggle this behavior, but then TeX-master and
> TeX-PDF-mode get set to nil again. Obviously this whole process
> becomes especially annoying when editing a complicated document.
> [...]
> Any ideas? Am I the only one having this problem?
Long time that I edited .Rnw file extensively, but when I did (under
emacs 21) I remember that I also had problems with being in the correct
mode when moving in and out of code-chunks. At that time, I decided to
put the following into my .emacs:
(global-set-key (quote [f3]) (quote normal-mode))
and put the following at the end of each .Rnw file:
%%% eval: (local-set-key (quote [f4]) (quote Rnw-mode))
then hitting F3 & F4 would always reset everything.
> [...] Briefly my current set up is ess-mode 5.3.6, auctex 11.85,
> both in emacs 22.1.1 running on ubuntu gutsy.
I have emacs 22.1.1 on ubuntu gutsy with ess-mode 5.3.0 and auctex
11.83.
> I've also attached a trivial pair of test files for anyone who wants
> to try this (only "slave.Rnw" is actually needed).
>
> Thanks for any guidance that anyone can provide.
I see the same behaviour as you. After moving out of the code chunk,
TeX-master and TeX-PDF-mode are unset. Hitting C-cC-n loses the Noweb
menu but sets these two variables again and, since noweb was lost,
moving back into a code chunk does not change out of PDFLatex/M mode.
But when I add the above "%%% eval: " line to slave.Rnw, then hitting
the F4 key makes the Noweb menu return and when moving into a code
chunk the mode switches to ESS[S]. Unfortunately, you immediately
lose again the information on TeX-PDF-mode and TeX-master.
But then, I am a bit puzzled why the correct setting of these variables
are of importance in a .Rnw file. You cannot run a .Rnw file through
pdflatex, so after any editing, you would first have to call Sweave.sh
to create the corresponding .tex file and then pdflatex could be run on
the master file. Except if you have some way of doing the .Rnw -> .tex
step automatically, I do not see any point of hitting C-cC-c in an .Rnw
buffer. And if you have automated that step then presumably via a
makefile? So why not make the makefile also run pdflatex on the master
file? Then you just have to hit C-xC-c in any buffer. Much easier to
remember. ;-)
If you are not using a make file for this, you could start of with the
attached makefile. Also, in that case, I would put into each .Rnw file
the line:
%%% eval: (set 'compile-command "make all")
and just leave the lines defining TeX-master and TeX-PDF-mode out.
HTH.
Cheers,
Berwin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile
URL: <https://stat.ethz.ch/pipermail/ess-help/attachments/20080309/e57505ca/attachment.pl>
More information about the ESS-help
mailing list