Search code examples
reditorr-usethis

R: `usethis::use_vignette`: how is the editor chosen?


[usethis 3.0.0 in R 4.4.1, called from shell on Ubuntu 20.04]

Calling usethis::use_vignette("my-vignette") I get the following error:

> usethis::use_vignette("my-vignette")
✔ Setting active project to [omitted].
✔ Writing vignettes/my-vignette.Rmd.
☐ Modify vignettes/my-vignette.Rmd.
sh: 1: emacsclient -a emacs: not found
Warning message:
error in running command 

There seems some misconfiguration in calling emacsclient, which would be my preferred editor indeed. However, I can invoke it without problems from any shell:

emacsclient [filenamehere] &

The usethis manual unfortunately does not say where and with which command the editor is invoked, so that I could customize it. Any ideas? Cheers!


Solution

  • Please see help(edit). R supports this via this function, which itself calls getOption("editor") allowing each user to override a default setting which otherwise comes from, if memory serves, a compile-time (fallback) choice.