emacs R mode ESS

3

I can run the R interpreter through emacs. However, I am looking for the R mode for writing scripts that would perform syntax highlighting, autocompletion and so forth (let me know if there are other features you would recommend as well).

For example, I have opened up an R script (with file extension .R) but the mode says fundamental, how would I get an R mode to be used when I open R scripts?

I use Ubuntu 12.04 LTS and emacs 24.3, let me know if you need any more information and thanks in advance!

CodeKingPlusPlus

Posted 2013-08-12T17:08:56.800

Reputation: 261

In your .emacs file do you have the line (setq-default ess-dialect "R")? – SlowLearner – 2013-08-12T19:10:01.053

Answers

4

As I understand it from this primer, the mode in question is R-mode. You can confirm this by visiting a file of R code and doing M-x R-mode; if your buffer is fontified (i.e., syntax-highlighted), you know this is the mode you want to use for your R files.

To automatically set this major mode when visiting files of R code, add the following to your Emacs init file (~/.emacs, /.emacs.el, ~/.emacs.d/init.el, &c.):

(add-to-list 'auto-mode-alist '("\\.R$" . R-mode))

Please note that I haven't actually had cause to use ESS myself, so may be mistaken in the mode name for R source. That said, the pattern will hold true for whatever mode you need to invoke; if you can find out the name of the mode you need, substituting it for R-mode in the (add-to-list) call will produce the desired effect.

Aaron Miller

Posted 2013-08-12T17:08:56.800

Reputation: 8 849