Skip to content
Prev 11681 / 15075 Next

UI suggestion: allow a tab with no more suggestions to fill in "$"

Hi all,
Simon send code that would essentially allow users to customise the behavior in a very R-ish way. Perhaps someone could even release a package R.app.options to contain functions like this.

Code copied below: I can?t get it to work as add.fn doesn?t exist for me: no doubt soluble, as Simon says it?s loaded as part of the GUI-tools.

While there are a good many things I?d like in the R.app, I realise this is all stuff to create and maintain, so not requesting new preference pane items. So having this as custom code in a package to be launched at  startup would suffice.

re what to do about foo?> when foo$part and foolish both exist. My request was that the tab only do something when the current behavior does nothing. Alternatively, a hierarchial menu would solve this also:

foo$part
     foolish
     tile

A bundle storing options and executing a custom add.fn("rcompgen.completion", function (x)  would allow flexibility over some of these choice.

cheers,
t

        
On 24 May 2016, at 10:08 pm, Simon Urbanek <simon.urbanek at r-project.org> wrote:
# add.fn is part of the GUI-tools which are automatically loaded when the R.app GUI starts
# and rcompgen.completion what the GUI uses to call the completion code.

add.fn("rcompgen.completion", function (x) {
 comp <- function(x) {
      utils:::.assignLinebuffer(x)
      utils:::.assignEnd(nchar(x))
      utils:::.guessTokenFromLine()
      utils:::.completeToken()
      utils:::.CompletionEnv[["comps"]]
 }
 res <- unique(comp(x))
 if (nzchar(x) && identical(res, x) && !identical(substr(x, nchar(x), nchar(x) + 1L), "$")) {
    rc <- comp(paste0(x, "$"))
    if (!identical(substr(rc, nchar(rc), nchar(rc) + 1L), "$")) res <- rc
 }
 res
})

# Obviously, you can eve spin that further and carry on with @ if $ doesn't work.