Better mechanism to choose the default editor (and avoid vi if possible)?

PIERRE AUGIER pierre.augier at univ-grenoble-alpes.fr
Mon Jun 8 13:43:40 UTC 2020


----- Mail original -----
> De: "Marcus Harnisch" <mh-mercurial at online.de>
> À: "mercurial" <mercurial at mercurial-scm.org>
> Envoyé: Dimanche 7 Juin 2020 13:35:06
> Objet: Re: Better mechanism to choose the default editor (and avoid vi if possible)?

> On 06/06/2020 23.24, Manuel Jacob wrote:
>> In my opinion, on a UNIX-style system, if a distribution targets an
>> audience that includes non-power users, it’s the responsibility of the
>> distribution to set $VISUAL or $EDITOR to a user-friendly default, or
>> patch Mercurial to choose a user-friendly default. We should refrain
>> from doing the distribution’s job. If every application had its own way
>> of choosing an editor, the result wouldn’t be very user-friendly.

I know at least one distribution targeting "non-power users" (Ubuntu) which does not set $VISUAL or $EDITOR by default and does not patch Mercurial.

Do you know a distribution that does something like that? Note also that most potential Mercurial users not very used to command-line tools (students, scientists, ...) on Unix-like OS use something close to Debian/Ubuntu, Fedora or macOS.

The default editor for Mercurial is used only if no editor has been defined by other standard methods. We are here considering only this special case (which is not so uncommon, especially for beginners). Trying not to open vi by default in this case does not prevent distributions / administrators to set a particular editor.

> Thanks, this was also my conclusion:
> 
> On 06/06/2020 12.29, Marcus Harnisch wrote:
> > As far as I see it, the lowest common denominator is in fact vi.
> > Anything else is up to the distribution package maintainers. They
> > would be responsible for selecting required or recommended packages,
> > sensible-editors and such.
> >
> > People installing Mercurial from source are in the same role as
> > packager maintainers and likewise responsible for their user
> > base. Perhaps the installation instructions should point out more
> > prominently that the system-wide config may need to be adapted with
> > respect to this important user-facing value.
> 
> On 06/06/2020 23.24, Manuel Jacob wrote:
>> Is there any standard demanding to open vi if neither $VISUAL nor
>> $EDITOR is defined?
> 
> Not explicitly, AFAIK, but there is SUS/POSIX[1] which define vi as the
> standard (full-screen) text editor. That's why I think that *if* a
> hardcoded fallback is to be implemented, vi is perhaps the best choice
> on Unixoid systems.
> 
> [1] https://pubs.opengroup.org/onlinepubs/9699919799/

It really depends on what you think is more important: 

- using as the default editor the standard text editor of SUS/POSIX,
- or taking care of users that are destabilized by vi.

I'm not sure that POSIX standard stands that applications should prioritize vi. I don't know but I understand it more like "vi must be there" than like "Your default editor has to be vi and the first thing beginners have to do is to learn enough vi to edit a file".

If we think it's a problem for some users to land in vi, it is much better to use nano **if it is available** and vi only as a fallback.

Nano is available by default on most Linux distributions targeting (among others) people not comfortable with vi. But most of the time, EDITOR is not set (see for example https://pagure.io/fedora-workstation/issue/103). Nano is available on most scientific computer clusters (with usually $EDITOR not set).

For many people, opening vi for them has really the effect of sending the message : "this tool is not for you". I also think many of these users would think : "Actually, Mercurial is not simpler/nicer than Git for beginners. I should rather use the standard tool.".

Finally, I didn't get what are the drawbacks of this setup (first environment variables + config files, then nano is available, finally vi as a fallback). Who is going to be disturbed by this? How? If few experimented users land in nano, won't they be able to set their preferred editor?




More information about the Mercurial mailing list