<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">smokin’ - thanks Simon. Nice to learn a new trick too!<div class=""><br class=""></div><div class="">and I must say, felt great when "mtcars →” yielded this, without having to hit $ !</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><img apple-inline="yes" id="F7B339D7-BF98-4497-A555-148B058967B1" height="384" width="329" apple-width="yes" apple-height="yes" src="cid:F8CEA97F-5727-4E84-8035-E5976C7C09A7@ed.ac.uk" class=""></div><div class=""><br class=""><blockquote type="cite" class="">On 31 May 2016, at 2:01 pm, Simon Urbanek <<a href="mailto:simon.urbanek@r-project.org" class="">simon.urbanek@r-project.org</a>> wrote:<br class=""><br class="">If you don't see add.fn(), then use this instead which is equivalent:<br class=""><br class="">RGUI = as.environment("tools:RGUI")<br class="">RGUI$rcompgen.completion <- function (x) {<br class="">comp <- function(x) {<br class="">    utils:::.assignLinebuffer(x)<br class="">    utils:::.assignEnd(nchar(x))<br class="">    utils:::.guessTokenFromLine()<br class="">    utils:::.completeToken()<br class="">    utils:::.CompletionEnv[["comps"]]<br class="">}<br class="">res <- unique(comp(x))<br class="">if (nzchar(x) && identical(res, x) && !identical(substr(x, nchar(x), nchar(x) + 1L), "$")) {<br class="">  rc <- comp(paste0(x, "$"))<br class="">  if (!identical(substr(rc, nchar(rc), nchar(rc) + 1L), "$")) res <- rc<br class="">}<br class="">res<br class="">}<br class=""><br class="">Cheers,<br class="">Simon<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On May 31, 2016, at 4:12 AM, Timothy Bates <<a href="mailto:tim.bates@ed.ac.uk" class="">tim.bates@ed.ac.uk</a>> wrote:<br class=""><br class="">Hi all,<br class="">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.<br class=""><br class="">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.<br class=""><br class="">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.<br class=""><br class="">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:<br class=""><br class="">foo$part<br class="">   foolish<br class="">   tile<br class=""><br class="">A bundle storing options and executing a custom add.fn("rcompgen.completion", function (x)  would allow flexibility over some of these choice.<br class=""><br class="">cheers,<br class="">t<br class=""><br class=""><blockquote type="cite" class="">"foo"  and "foolish" in your workspace?<br class="">You want to write  "foo$bar" , but which gets precedence when you enter<br class="">a tab?  "foo$bar" or "foolish” ?<br class=""></blockquote><br class=""><blockquote type="cite" class="">On 25 May 2016, at 12:51 pm, <<a href="mailto:cgw@witthoft.com" class="">cgw@witthoft.com</a>> <<a href="mailto:cgw@witthoft.com" class="">cgw@witthoft.com</a>> wrote:<br class="">I have to agree with Simon here that "best guess" will only lead to pain<br class="">in many cases.  <br class=""><br class="">The best solution, albeit the most painful for Simon :-( , is to have a<br class="">Preferences pane where the user can specify what a tab does, i.e.<br class="">"nothing", " $", "@" , "$first_named_list_item", and so on.   But even<br class="">then, what if there are objects  "foo"  and "foolish" in your workspace?<br class="">You want to write  "foo$bar" , but which gets precedence when you enter<br class="">a tab?  "foo$bar" or "foolish" ?<br class=""><br class="">[Tim wrote...]<br class="">1. When a name is already complete, when the user pushes tab again, they<br class="">are expecting ?more? name completion, i.e.,  they want to access a $ or<br class="">@ sub-component. Currently, nothing happens, and the user feels<br class="">?thwarted?? like the typing ?Simon" but then having to type a space and<br class="">a tab to get "Urbanek" :-)<br class=""><br class="">2. Most object components are $ indexed rather than @ indexed), so $ is<br class="">the best guess.<br class=""></blockquote><br class="">On 24 May 2016, at 10:08 pm, Simon Urbanek <<a href="mailto:simon.urbanek@r-project.org" class="">simon.urbanek@r-project.org</a>> wrote:<br class=""><blockquote type="cite" class="">That seems like a very strong assumption and my point questioning that assumption. For a lot of objects $ makes no sense which is why I'm reluctant to add $ unconditionally. Really, it only makes sense for lists (and some subclasses) - anything else gets a bit dodgy (it works for some but not others).<br class=""><br class="">That said, I suppose one possible approach would be to catch any completion that yields just the items itself and if that happens attempt a completion with $ appended and see what it yields. If it yields anything additional, return that result instead. You can test whether you like that by using something like the following:<br class=""><br class=""></blockquote># add.fn is part of the GUI-tools which are automatically loaded when the R.app GUI starts<br class=""># and rcompgen.completion what the GUI uses to call the completion code.<br class=""><br class="">add.fn("rcompgen.completion", function (x) {<br class="">comp <- function(x) {<br class="">    utils:::.assignLinebuffer(x)<br class="">    utils:::.assignEnd(nchar(x))<br class="">    utils:::.guessTokenFromLine()<br class="">    utils:::.completeToken()<br class="">    utils:::.CompletionEnv[["comps"]]<br class="">}<br class="">res <- unique(comp(x))<br class="">if (nzchar(x) && identical(res, x) && !identical(substr(x, nchar(x), nchar(x) + 1L), "$")) {<br class="">  rc <- comp(paste0(x, "$"))<br class="">  if (!identical(substr(rc, nchar(rc), nchar(rc) + 1L), "$")) res <- rc<br class="">}<br class="">res<br class="">})<br class=""><br class=""># Obviously, you can eve spin that further and carry on with @ if $ doesn't work.<br class=""><br class=""><br class="">-- <br class="">The University of Edinburgh is a charitable body, registered in<br class="">Scotland, with registration number SC005336.<br class=""><br class="">_______________________________________________<br class="">R-SIG-Mac mailing list<br class=""><a href="mailto:R-SIG-Mac@r-project.org" class="">R-SIG-Mac@r-project.org</a><br class="">https://stat.ethz.ch/mailman/listinfo/r-sig-mac<br class=""></blockquote><br class="">_______________________________________________<br class="">R-SIG-Mac mailing list<br class=""><a href="mailto:R-SIG-Mac@r-project.org" class="">R-SIG-Mac@r-project.org</a><br class="">https://stat.ethz.ch/mailman/listinfo/r-sig-mac<br class=""></blockquote><br class=""></div></body></html>