Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Emacs mode for Rscript?

Tags:

emacs

r

ess

Is there any usable emacs mode for Rscript?

(Rscript is the script front-end for the R language.)

If I type this:

#!/usr/bin/Rscript
print(commandArgs(TRUE))

and do indent in the ESS R-mode it indents the first line like crazy, since it sees it as a comment:

                          #!/usr/bin/Rscript
print(commandArgs(TRUE))
like image 733
Frank Avatar asked Jul 10 '09 03:07

Frank


2 Answers

As of version 5.9, ESS will recognize scripts using the Rscript or litter interpreter; see http://ess.r-project.org/Manual/ess.html#New-features.

For reference, to assign a mode to an interpreter, use the interpreter-mode-alist variable. For example,

(add-to-list 'interpreter-mode-alist '("Rscript" . r-mode))

Any file with a first line like "#!/usr/bin/Rscript" will be recognized as r-mode.

like image 124
jrnold Avatar answered Sep 20 '22 16:09

jrnold


There isn't, but you can force your Rscript into R editing mode by making the second line of the file look like this:

# -*- mode: R -*-

(More information here.)

like image 26
David Smith Avatar answered Sep 21 '22 16:09

David Smith