[ESS] fill-column in Rnw files

Kasper Daniel Hansen kasperdanielhansen at gmail.com
Thu Jul 14 17:12:19 CEST 2011

On Thu, Jul 14, 2011 at 10:29 AM, Stephen Eglen
<S.J.Eglen at damtp.cam.ac.uk> wrote:
>> If I set the fill-column in an Rnw file to a non-standard value (say
>> 100, standard is 70) inside a Latex chunk and I move around and pass
>> an R chunk, the fill-column value gets reset.  This looks like a bug
>> to me.
> How did you change the value of the variable?  Every time you switch
> from R to latex, it will re-run e.g. latex-mode, so that any variables
> set temporarily will be lost.  If you set it through a hook, you may
> have better luck.  e.g.
>  (add-hook 'LaTeX-mode-hook '(lambda() (setq ...)))
> as the hooks will be rerun each time you switch mode.
> This is a limitation of the current .Rnw setup.

Thanks for the pointer.  During experiments I have been setting it
using C-x f (ie. interactively), but my real use case is to use a file
local variable like

% Local Variables:
% fill-column: 100
% End:

at the end of my .Rnw file (because several people edits this file).
I have now "solved" this by having

% Local Variables:
% eval: (add-hook 'LaTeX-mode-hook '(lambda () (setq fill-column 100)))
% End:

I have put "solved" in quotes because not only does this piece of code
affect other latex buffers I will be editing (this might not be so
bad, I like fill-column 100), but it also affect other buffers of
other users who edits this file in Emacs.  Nevertheless, it seems like
the only solution right now?


More information about the ESS-help mailing list