[R-sig-Debian] Open a text file with vi/vim in another Terminal

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Fri Dec 17 21:42:34 CET 2021


On 17 December 2021 at 21:13, Patrice Kiener wrote:
| Thank you for your suggestions. Let's give more details. The idea is to 
| insert the code in a function and then in a (private) package. We have 
| to rely on the default editors provided by the OS to R and cannot invent 
| a new editor, as R CMD check could fail on exotic platforms. We cannot 
| assume that Geany, even nano, is available everywhere.

But you can (and likely: should !!) test for their presence via
Sys.which(prog):

    > Sys.which("vi")
               vi 
    "/usr/bin/vi" 
    > Sys.which("notExisting")
    notExisting 
             "" 
    > 

In short, you have no guarantee that what is EDITOR is actually sane!

| The instruction for the text editor
| 
|   system2(getOption("editor"), fileREP, wait = FALSE)
| 
| works fine on Windows (it opens Notepad.exe, or Notepad++.exe in my 
| Rprofile.site) but not on Unix. I assumed there was something similar on 
| Unix (You have understood that I am not a Unix specialist). R includes a 

As Ivan was hinted this gets more complicated with apps being launched
synchronousy or asynchronously.

What you are after is actually a hard problem, portably, across OSs.

Dirk

-- 
https://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-SIG-Debian mailing list