Argument names using r-autoyas

154 views Asked by At

I've recently been using r-autoyas (0.28) when working in R scripts (emacs 24.3.1, ESS 13.09-1, Windows 8.1) and have found it really helpful. It works out-of-box on loaded R libraries and user-defined functions after setting (setq r-autoyas-expand-package-functions-only nil).

However, I would like to tweak one small aspect of it: I would like to keep the argument names when explicitly entering their values. For instance, if I type 'rnorm' and then TAB to expand the snippet, I get:

rnorm(n= , mean=0, sd=1)

and type 10 TAB 100 TAB and then TAB again to leave sd=1 as default. What I end with is:

rnorm(10, 100)

and what I'd like to have is:

rnorm(n=10, mean=100)

which makes for code that I prefer. I know older versions of r-autoyas used to do this, since it shows up in the tutorial video on youtube, where he uses C-d to skip an argument, and TAB to cycle throw them. Further, if an argument is skipped (say mean), then all subsequent arguments are named. So for example if I instead typed 10 TAB TAB 50 C-g I get:

rnorm(10, sd=50)

Basically I'm wondering if it's possible to turn on leaving the argument name for all arguments, not just ones that follow a skipped argument. I can't seem to find anything on the github site which shows how to do this.

Thanks

1

There are 1 answers

1
Tobias On BEST ANSWER

Set r-autoyas-remove-explicit-assignments to nil. You can customize this variable M-x customize-option r-autoyas-remove-explicit-assignments. There, you also find a description of this variable.