r-devel / r-project-sprint-2023

Material for the R project sprint
https://contributor.r-project.org/r-project-sprint-2023/
17 stars 3 forks source link

Code completion #52

Open hturner opened 1 year ago

hturner commented 1 year ago

Discussed in https://github.com/r-devel/r-project-sprint-2023/discussions/49

Originally posted by **deepayan** August 23, 2023 R has a built-in code completion mechanism (see `?utils::rc.settings`) which is not used by RStudio (making it of limited general interest) but is used by several other front-ends, including the Windows / Mac GUIs, ESS, and Jupyter (via the [IRkernel](https://cran.r-project.org/package=IRkernel) package). The current state of affairs could be improved in many small ways: - Rgui on Windows does not currently support "fuzzy" completion. This is a backend problem which is conceptually easy to fix but needs some low-level GraphApp coding. - Completion inside quotes and backquotes could be improved, as can completion involving non-syntactic names; for example, see [PR#18479](https://bugs.r-project.org/show_bug.cgi?id=18479). A solution that works perfectly for all backends may not be feasible, but it would help to at least make a list of what kinds of behaviour would be useful in different contexts, and have settings to activate them. - There is scope to extend the currently available types of completions, e.g., to support pipeline operators and some kinds of non-standard evaluation (here is a very prelimiary [prototype](https://github.com/deepayan/misc/blob/master/experiments/custom-completions.R)). It is perhaps best to implement this (mostly) as an add-on package, but it would be useful to at least understand what kind of API at the R level will be most useful.
lionel- commented 1 year ago

is not used by RStudio (making it of limited general interest) but is used by several other front-ends, including the Windows / Mac GUIs, ESS, and Jupyter (via the IRkernel package).

I believe it's also used in CLI. More recently web-based REPLs using webR have also started using this facility for completions. It definitely continues to be relevant and it's nice to be able to rely on a built-in completion mechanism for special setups or environments.