1

Q: how can I get to the source code of R packages using ESS?

When I'm working with elisp, I can access the source code for any package easily with find-library or by following the links in find-function or find-variable.

I'd like to be able to do the same thing with R via Emacs Speaks Statistics (ess). How can I get ess to send me to the source code of a given function/package?

1

I have had some decent success with ess-r-xref. (require 'ess-r-xref) and then M-. (xref-find-definitions) with point on some symbol. It should prompt you to save a TAGS file. Then M-. should do what you want.

Check out https://www.gnu.org/software/emacs/manual/html_node/emacs/Xref.html

Alternately:

I'm a big proponent of the Language Server Protocol. There's an R language server that should work with lsp-mode, but does not yet support find definition/reference requests AFAIK. I would recommend monitoring that project.

3
  • ess-build-tags-for-directory, bound to C-c C-e t and C-c C-e C-t is helpful for setting up xref.
    – Tyler
    Oct 25 '18 at 14:02
  • Did you have to enable xref-etags-mode to make it work with ess-r-xref ?
    – schatten
    Sep 18 '19 at 2:40
  • @schatten I did not.
    – ebpa
    Sep 18 '19 at 3:12
0

This is probably old, but I found out how to do it just looking at this question.

I installed ESS under Emacs 26.3 and I didn't do anything particular with this. It seems ess-r-xref works without doing any specific setting.

If do M-. or M-x xref-find-definitions and I am asked what I'm looking for ( auto-completion works nicely), than it opens a new buffer with the file containing the object I am looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.