[ESS] Indent for R's 'switch'
Marius Hofert
m@riu@@hofert @ending from uw@terloo@c@
Fri Jun 22 16:50:21 CEST 2018
Hi,
ESS (version 16.10-1 but also earlier) gives the following indentation
for switch statements in r:
f <- function(method = c("foo", "bar"))
{
switch(match.arg(method),
"foo" = { # (*)
cat("Will use 'method' = \"foo\".\n")
},
"bar" = {
cat("Will use 'method' = \"bar\".\n")
},
stop("Wrong 'method'"))
}
Line (*) is not ideal. Looking over the various cases (in longer
switch statements) along column 4 (containing the "s" of "switch()"),
one can easily overlook the case "foo". The following would be great
to have:
f <- function(method = c("foo", "bar"))
{
switch(match.arg(method),
"foo" = {
cat("Will use 'method' = \"foo\".\n")
},
"bar" = {
cat("Will use 'method' = \"bar\".\n")
},
stop("Wrong 'method'"))
}
Is that possible?
Cheers,
Marius
PS: There is a slight chance I already asked for this long time ago...
not sure anymore, though. Would be good to have.
More information about the ESS-help
mailing list