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?


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


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.

| improve this answer | |
  • 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

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.