[ESS] fill-column in Rnw files

Kasper Daniel Hansen kasperdanielhansen at gmail.com
Thu Jul 14 17:57:03 CEST 2011


On Thu, Jul 14, 2011 at 11:22 AM, Stephen Eglen
<S.J.Eglen at damtp.cam.ac.uk> wrote:
>
>> % 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?
>
> another hack might be to condition setting the variable upon the name of
> the buffer (or the value of some other unique variable which you also
> set in the local variables).  Alternatively, try making the mode-hook
> buffer local in some way?

Based on the Emacs manual 57.3.4.1 "If mode is used to set a major
mode, it should be the first “variable” in the list. Otherwise, the
entries that precede it will usually have no effect, since most major
modes kill all local variables as part of their initialization." I
conclude that anything using local variables will not work (and indeed
this is why the fill-column setting at first did not work).

My Rnw file is called minfi.Rnw.  The following seems to work:

% Local Variables:
% eval: (add-hook 'LaTeX-mode-hook '(lambda () (if (string=
(buffer-name) "minfi.Rnw") (setq fill-column 100))))
% End:

Thanks for the idea.

Kasper



More information about the ESS-help mailing list