After reading a similar question on the ess-help@r-project.org mailing list, I found out about it. When we view the noweb file, we switch the main modes from ESS to LaTeX. Most basic modes kill all local variables as part of their initialization, so when we simply set the variable locally, it is overwritten. To solve this problem, I changed the found hook:
(add-hook 'LaTeX-mode-hook '(lambda () (if (string-match "\\.Rnw\\'" buffer-file-name) (setq fill-column 80))))
You can set a similar hook for longline or skew-truncation-lines, etc., to suit your needs. The disadvantage of this solution is that you are stuck with a single value for the variable set in the hook.
source share