[R] Can't get Sweave syntax highlighting with Emacs
A.J. Rossini
rossini at blindglobe.net
Fri Nov 14 02:16:11 CET 2003
"Waichler, Scott R" <Scott.Waichler at pnl.gov> writes:
> I can't get Emacs to automatically do syntax highlighting of
> Sweave files. I have followed Friedrich's suggestion for code
> to insert into my .emacs file. The complete section from my .emacs
> file is given below. When I load a *.Snw file, font is white until I press
> M-x, then the first code and document chunks get highlighted, but not
> the rest of the file. Latex and Noweb menus are active, but not ESS,
> and there is no switching of modes as I move the pointer to different
> types of chunks.
This is a contradiction. You should at least switch from LaTeX to
fundamental mode within chunks, or Noweb isn't working.
You might try:
M-x noweb-set-code-mode <ret> R-mode <ret>
(where <ret> is the enter or return key).
I've had problems like that before -- and havn't had time to fix them
yet.
(as always, will be fixed with the new version of ESS, which is only
1+ years delayed).
best,
-tony
> ; -------------------------------------------------------------
> ; Emacs Speaks Statistics
> ; mode for R
> ; -------------------------------------------------------------
> (load "/home/waichler/emacs/ess-5.1.19/lisp/ess-site")
>
> ; ESS "emacs speaks statistics" SRW 2-19-01
> (autoload 'ess-mode "ess" "ess major mode" t)
> (autoload 'ess-noweb-mode "ess" "ess noweb mode" t)
> (autoload 'ess-noweb-make-buffer "ess" "open a buffer in R mode" t)
> (autoload 'ess-make-buffer "ess" "open a buffer in R mode" t)
> (setq auto-mode-alist (append '(("\\.R$" . ess-mode)) auto-mode-alist))
> (setq auto-mode-alist (append '(("\\.S$" . ess-mode)) auto-mode-alist))
> (setq auto-mode-alist (append '(("\\.sp$" . ess-mode)) auto-mode-alist))
> (global-set-key [(f10)] 'ess-make-buffer)
> (add-hook 'ess-mode-hook 'turn-on-font-lock)
>
> ; Sweave mode
> (defun Rnw-mode ()
> (require 'ess-noweb)
> (noweb-mode)
> (if (fboundp 'R-mode)
> (setq noweb-default-code-mode 'R-mode)))
> (add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
> (add-to-list 'auto-mode-alist '("\\.Snw\\'" . Rnw-mode))
> (setq reftex-file-extensions
> '(("Snw" "Rnw" "nw" "tex" ".tex" ".ltx") ("bib" ".bib")))
> (setq TeX-file-extensions
> '("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
>
>
> Scott
>
> Scott Waichler, Senior Research Scientist
> Pacific Northwest National Laboratory
> MSIN K9-36
> P.O. Box 999
> Richland, WA 99352 USA
> 509-372-4423 (voice)
> 509-372-6089 (fax)
> scott.waichler at pnl.gov
> http://hydrology.pnl.gov
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
rossini at u.washington.edu http://www.analytics.washington.edu/
Biomedical and Health Informatics University of Washington
Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email
CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}
More information about the R-help
mailing list