[Rd] Is it advisable/possible to default on Linux to an EDITOR that actually exists?

Michael Chirico m|ch@e|ch|r|co4 @end|ng |rom gm@||@com
Tue Dec 10 18:02:33 CET 2024


> As for the conjecture

To quickly clarify, I mean "it is much more common to write code from
lightweight environments [now as compared to the year 2000 when the
EDITOR default was set to 'vi']". We agree about where most code is
written still today.

And yes, we can set VISUAL/EDITOR (as my personal .Rprofile does), but
doing something at run time still seems prudent. If I don't own the
Docker image, it's easy to forget this until we trip over file.edit()
much later. Onn the Docker image I use most often (for GitHub
Codespaces), there is no (command-line) editor by default -- VSCode
does the bulk of the work & I only install 'nano' to do things outside
the "current" repo. In short, there are very many ways EDITOR can wind
up un-set/incorrect.

On Wed, Dec 11, 2024 at 12:46 AM Dirk Eddelbuettel <edd using debian.org> wrote:
>
>
> Michael,
>
> This looks rather like a 'compile-time versus run-time' question to me. If
> you look at etc/Renviron.in in the R sources you see a number of choices,
> some of them with configure-time determined values (which I tend to override
> with values for the Debian package).
>
> For 'EDIT' it is
>
>    ## Default editor
>    EDITOR=${EDITOR-${VISUAL-vi}}
>
> giving us two env vars to override eg in 'degenerate' situations such as the
> forcefully minimized docker setup without other commands.
>
> Otherwise, a generalization that would be possible might be to do something
> similar to 'R CMD javareconf' to allow a later run-time call to affect the
> encoded values---which would then be read at startup.  On the other hand,
> environment variables already give customization so ...
>
> Linux distributions can also have their mechanism. For example, Debian has
> /etc/alternatives which for 'editor' defaults to nano even when vi, emacs,
> mg, atom, code, ... are installed.  So you could also have the environment
> variable EDITOR point to a script you control which then runs over possible
> alternatives.
>
> As for the conjecture 'it is much more common to write code from ...'  I
> would love to see some empirics across a properly surveyed R user base. The
> love of some power users for codespaces / devcontainers notwithstanding, 'the
> most common' environment for writing R code is likely still what it always
> was, a single windows desktop.
>
> Anyway, thanks for raising this. I can look into making the Debian (and hence
> Ubuntu) package switch to 'editor' over the vi fallback.
>
> Dirk
>
> --
> dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-devel mailing list