On Fri, 17 Dec 2021 21:13:12 +0100 Patrice Kiener <patrice.kie...@inmodelia.com> wrote:
> 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. "A file.edit() but with the editor running in parallel with the R session" is a hard problem. Suppose that the user is running an R session on a server without a graphical display over remote command line. The user is probably running a graphical session with different windows, but R is unaware of it; it's only got one text terminal. What should our hypothetical file.edit.in.background() do in this case? It's fair to stopifnot(interactive()), but this counts as an interactive session. In theory, R could bundle a terminal multiplexer like tmux, split the terminal window in half and emulate a smaller terminal for the editor to run in, but there's no such functionality (or plans to implement it). On Debian, there's the /usr/bin/x-terminal-emulator symlink (typically present, but not 100% guaranteed to exist) pointing to _a_ graphical terminal emulator (if you can assume a running graphical session), but different terminal emulators take subtly different options to run command lines inside them. For example, xterm runs the rest of the command line after -e, while xfce4-terminal takes only one argument to -e but the rest of the command line after -x. The result is that you can't reliably pass arguments to the command you intend to launch. This *could* be worked around by writing a temporary shell script in /tmp, but the resulting solution accumulates too many moving parts to inspire any confidence and doesn't work on other distros or macOS. Besides, the user could plausibly prefer a text editor with a GUI when running a graphical session. Can you ask your users to specify an editor to run in the background? They could say it's 'emacs', c('xterm', '-e', 'joe'), c('xfce4-terminal', '-x', 'ed') or anything else. What do you intend to do with the file being edited by the user? Perhaps there's some other way to achieve the goal. (Not sure whether it's a better question for R-help or R-pkg-devel.) -- Best regards, Ivan _______________________________________________ R-SIG-Debian mailing list R-SIG-Debian@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-debian