5

I would like to study the autocomplete code of R, when R is run in a terminal. For example, if you run R from the terminal and type lm( and then tab, R will give you the arguments of lm.

Dirk's answer here suggests that autocompletion of R is supported by the codetools package which is in base R:

Is it possible to get code completion for R in Emacs ESS similar to what is available in Rstudio?

However, I can't find where in that package it adds support for autocomplete. I grepped for 'completion' and came up empty.

Community
  • 1
  • 1
Xu Wang
  • 10,199
  • 6
  • 44
  • 78
  • 1
    I *think* Dirk had the **rcompgen** package in mind not **codetools**. **rcompgen** is now subsumed within R as part of the **utils** package. – Gavin Simpson Nov 10 '12 at 09:40

1 Answers1

6

The completion code is actually in the base instalation in the utils package. You can view everything associated with it (for the devel version) on R's SVN server:

http://svn.r-project.org/R/trunk/src/library/utils/R/completion.R

This code should be read in conjunction with ?completion.

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
  • 1
    Or in prettier format from github: https://github.com/wch/r-source/blob/trunk/src/library/utils/R/completion.R – Spacedman Nov 10 '12 at 11:41
  • @Spacedman That is nicer indeed. I wish R-core would move to github but everyone has different preferences I guess. – Xu Wang Nov 11 '12 at 01:24