Frank
Frank

Reputation: 66164

Is there an Emacs mode for Rscript?

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))

Upvotes: 6

Views: 1440

Answers (4)

path
path

Reputation: 1

If you just want to comment out a line, use "##" instead of "#". Double # will put the line at the right position.

Upvotes: 0

jrnold
jrnold

Reputation: 126

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.

Upvotes: 2

David Smith
David Smith

Reputation: 2166

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.)

Upvotes: 1

Michael Paulukonis
Michael Paulukonis

Reputation: 9100

Try shell-script-mode - with some notes on customized indentation

It indented your code just fine, for me.

Upvotes: 0

Related Questions