6

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))
Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Frank
  • 64,140
  • 93
  • 237
  • 324

4 Answers4

2

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.

jrnold
  • 126
  • 1
  • 6
1

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

David Smith
  • 2,114
  • 3
  • 18
  • 17
  • 2
    Also, if you end them .R (my choice for normal R files) or .r (my choice for littler or Rscript 'scripts') the mode tends get assigned automatically to. – Dirk Eddelbuettel Aug 12 '09 at 16:23
0

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

It indented your code just fine, for me.

Michael Paulukonis
  • 9,020
  • 5
  • 48
  • 68
  • Any reason for the drive-by down-vote? As I said, what I linked to corrected the bad indentation the OP complained about; if this is not helpful, please ignore. If wrong or harmful, downvote -- but do everybody the courtesy of explaining WHY it is wrong. – Michael Paulukonis Sep 07 '10 at 14:57
0

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

path
  • 1