[ESS] Sweave (Rnw): text displays differently when cursor is in latex code or in R code

Joseph Mingrone jrm at ftfl.ca
Thu Dec 15 17:13:22 CET 2011

> On Wed, Dec 14, 2011 at 5:34 PM, Joseph Mingrone <jrm at ftfl.ca> wrote:
>> When I scroll through an Sweave document (Rnw) with latex code and R
>> code, the text jumps around when the mode changes between Latex and
>> ESS.  The two modes disagree how text should be wrapped when it can't
>> fit within the window.  Moreover, I've noticed that when I do
>> 1) M-x toggle-truncate-lines to enable truncate long lines while the
>> cursor is within latex code
>> 2) move the cursor to R code
>> 3) return to the latex code
>> truncate long lines is no longer on.
>> Has anyone noticed this?  Has anyone solved this problem?

On Wed, Dec 14, 2011 at 20:21, Kasper Daniel Hansen
<kasperdanielhansen at gmail.com> wrote:
> This is because buffer-local variables get reset when you move between
> R and Latex.  You need to be smart about it. I had the same question
> about fill-column on this email list within the last 6 months and got
> some great hints.

Thanks for the reference.  I modified your solution slightly:

(add-hook 'LaTeX-mode-hook '(lambda () (if (string-match "\\.Rnw\\'"
buffer-file-name) (setq fill-column 80))))

More information about the ESS-help mailing list