I am trying to get r-autoyas to work on Emacs 23.3.1
I have installed yasnippet and it works fine on its own. For eg: TAB after 'for' in c++ mode auto expands as it should. I then went on the get r-autoyas to work. I have followed the instructions given in the github repository but am unable to get the TAB to expand even inbuilt functions in an R buffer.
If I type, rnorm( and then press TAB, a minibuffer opens which shows me the various arguments to the functions. Is this the default behavior? Or should it fill in the input arguments as default and let me change them one by one?
I searched online to see if anyone else had come across this problem. In one forum, it was mentioned that it could be because of the auto-completion feature in Emacs.
I have the following lines in my init.el file which were given in the instructions:
(require 'r-autoyas)
(add-hook 'ess-mode-hook 'r-autoyas-ess-activate)
(add-hook 'ess-mode 'yas/minor-mode-on)
You need to add your own yasnippets for ESS/R for any yasnippet expansion to work. By default there are none.
The behavior you are seeing when you type
rnorm(<TAB>
has nothing to do with yasnippet, this is behavior that ESS provides to make your R-coding-life easier.So -- you will have to create your own snippets for R. You need to do this under the
text-mode/ess-mode
directory wherever your yasnippets are located (you'll have to create theess-mode
directory).Here are some of my R snippets. I thought I'd use them more, but I only really ever use the
setGeneric
andsetMethod
snippets ... and those aren't all that bullet proof, either.