[ESS] looking for definitions of R functions
Hello, what are people using (if anything) to find declarations of R functions within Emacs buffers? e.g. when point is on the name of a function, you hit a keybinding to look up the definiton of that function. I just had some success with using dumb-jump.el https://github.com/jacktasia/dumb-jump -- it has a notion of a project folder within which it will search for R function definitions dynamically using a grep variant. (It doesn't always work -- e.g. I can't yet get it to fund hidden functions that begin with a period, since I think it does not recognise the . as beginning of a word.) But I'm just wondering if others had success with other packages? We mention TAGS files in our ESS documentation, and rtags. Stephen __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [ESS] looking for definitions of R functions
The development version is integrated with xref based on function srcrefs. It should work with sourced scripts and local packages installed with srcrefs. We'll try to make it work with non-local packages as well. Lionel > On 22 juin 2018, at 11:15, Stephen Eglen via ESS-help > wrote: > > Hello, > > what are people using (if anything) to find declarations of R functions > within Emacs buffers? e.g. when point is on the name of a function, you > hit a keybinding to look up the definiton of that function. > > I just had some success with using dumb-jump.el > https://github.com/jacktasia/dumb-jump -- it has a notion of a project > folder within which it will search for R function definitions > dynamically using a grep variant. (It doesn't always work -- e.g. I > can't yet get it to fund hidden functions that begin with a period, > since I think it does not recognise the . as beginning of a word.) > > But I'm just wondering if others had success with other packages? We > mention TAGS files in our ESS documentation, and rtags. > > Stephen > > __ > ESS-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/ess-help __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [ESS] looking for definitions of R functions
Oh and it also works well with packages loaded with devtools::load_all(). Use C-c C-w i to install a package with srcrefs and C-c C-w l to load it with load_all(). Then M-x xref-find-definitions should work when cursor is on a function name. Lionel > On 22 juin 2018, at 11:15, Stephen Eglen via ESS-help > wrote: > > Hello, > > what are people using (if anything) to find declarations of R functions > within Emacs buffers? e.g. when point is on the name of a function, you > hit a keybinding to look up the definiton of that function. > > I just had some success with using dumb-jump.el > https://github.com/jacktasia/dumb-jump -- it has a notion of a project > folder within which it will search for R function definitions > dynamically using a grep variant. (It doesn't always work -- e.g. I > can't yet get it to fund hidden functions that begin with a period, > since I think it does not recognise the . as beginning of a word.) > > But I'm just wondering if others had success with other packages? We > mention TAGS files in our ESS documentation, and rtags. > > Stephen > > __ > ESS-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/ess-help __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [ESS] looking for definitions of R functions
In addition to xref and etags I use M-o for imenu-anywhere. It works within all buffers of the same mode and buffers within same project (if you have projectile installed). The benefit is that you don't need any fancy lockup functionality or TAGS. It will work straight away. The drawback is that you need to open the buffers first. Vitalie >> On Fri, Jun 22 2018 10:15, Stephen Eglen via ESS-help wrote: > Hello, > what are people using (if anything) to find declarations of R functions > within Emacs buffers? e.g. when point is on the name of a function, you > hit a keybinding to look up the definiton of that function. > I just had some success with using dumb-jump.el > https://github.com/jacktasia/dumb-jump -- it has a notion of a project > folder within which it will search for R function definitions > dynamically using a grep variant. (It doesn't always work -- e.g. I > can't yet get it to fund hidden functions that begin with a period, > since I think it does not recognise the . as beginning of a word.) > But I'm just wondering if others had success with other packages? We > mention TAGS files in our ESS documentation, and rtags. > Stephen > __ > ESS-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/ess-help __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
[ESS] Indent for R's 'switch'
Hi, ESS (version 16.10-1 but also earlier) gives the following indentation for switch statements in r: f <- function(method = c("foo", "bar")) { switch(match.arg(method), "foo" = { # (*) cat("Will use 'method' = \"foo\".\n") }, "bar" = { cat("Will use 'method' = \"bar\".\n") }, stop("Wrong 'method'")) } Line (*) is not ideal. Looking over the various cases (in longer switch statements) along column 4 (containing the "s" of "switch()"), one can easily overlook the case "foo". The following would be great to have: f <- function(method = c("foo", "bar")) { switch(match.arg(method), "foo" = { cat("Will use 'method' = \"foo\".\n") }, "bar" = { cat("Will use 'method' = \"bar\".\n") }, stop("Wrong 'method'")) } Is that possible? Cheers, Marius PS: There is a slight chance I already asked for this long time ago... not sure anymore, though. Would be good to have. __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [ESS] Indent for R's 'switch'
Hi Alex, thanks for your quick reply. You are right, I used "(setq ess-default-style 'C++)", so it's a problem of the C++ style. Thanks for pointing this out. I can confirm that the problem does not exist in the default style (although all cases are indented then, which is a bit of a waste of space since often one has constructions like "my_variable_value <- switch(...)" and so everything is indented quite a bit; would still find it elegant to have the cases aligned with 'switch') Cheers, Marius On Fri, Jun 22, 2018 at 10:54 AM Alex Branham wrote: > > > On Fri 22 Jun 2018 at 09:50, Marius Hofert via ESS-help > wrote: > > > Hi, > > > > ESS (version 16.10-1 but also earlier) gives the following indentation > > for switch statements in r: > > > > f <- function(method = c("foo", "bar")) > > { > > switch(match.arg(method), > >"foo" = { # (*) > > cat("Will use 'method' = \"foo\".\n") > > }, > > "bar" = { > > cat("Will use 'method' = \"bar\".\n") > > }, > > stop("Wrong 'method'")) > > } > > > > Line (*) is not ideal. Looking over the various cases (in longer > > switch statements) along column 4 (containing the "s" of "switch()"), > > one can easily overlook the case "foo". The following would be great > > to have: > > > > f <- function(method = c("foo", "bar")) > > { > > switch(match.arg(method), > > "foo" = { > > cat("Will use 'method' = \"foo\".\n") > > }, > > "bar" = { > > cat("Will use 'method' = \"bar\".\n") > > }, > > stop("Wrong 'method'")) > > } > > > > Is that possible? > > This is what I get when using the default style, FWIW. __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [ESS] Indent for R's 'switch'
On Fri 22 Jun 2018 at 09:50, Marius Hofert via ESS-help wrote: > Hi, > > ESS (version 16.10-1 but also earlier) gives the following indentation > for switch statements in r: > > f <- function(method = c("foo", "bar")) > { > switch(match.arg(method), >"foo" = { # (*) > cat("Will use 'method' = \"foo\".\n") > }, > "bar" = { > cat("Will use 'method' = \"bar\".\n") > }, > stop("Wrong 'method'")) > } > > Line (*) is not ideal. Looking over the various cases (in longer > switch statements) along column 4 (containing the "s" of "switch()"), > one can easily overlook the case "foo". The following would be great > to have: > > f <- function(method = c("foo", "bar")) > { > switch(match.arg(method), > "foo" = { > cat("Will use 'method' = \"foo\".\n") > }, > "bar" = { > cat("Will use 'method' = \"bar\".\n") > }, > stop("Wrong 'method'")) > } > > Is that possible? This is what I get when using the default style, FWIW. __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help