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

Manuel Jacob me at manueljacob.de
Wed Jun 10 19:17:27 UTC 2020


On 2020-06-08 15:43, PIERRE AUGIER wrote:
> ----- 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.

Technically, it’s not patching, but the Debian (and subsequently Ubuntu) 
package installs /etc/mercurial/hgrc.d/default-tools.rc, which sets the 
editor to `sensible-editor` and the pager to `sensible-pager`. Do you 
have this file? Which editor does `sensible-editor` open on your 
machine? `sensible-editor` falls back to nano before it falls back to 
vi.

> 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.

For the record, I agree that vi is a terrible default. People unfamiliar 
with it are lost. People familiar with it will probably use at least 
vim. I don’t know anyone who uses vi. For me as a vim user, vi is 
confusing because it’s a bit of vim, but it’s not vim.

Still, I don’t think that Mercurial should make this decision. I’m sure 
that someone could come up with reasons why nano is not a good default 
and the same for any other editor. If you start this kind of discussion, 
you end up with people discussing their favorite vi clone on this 
mailing list (this actually happened).

I would prefer if instead of falling back to vi, Mercurial shows a nice 
error message describing how to set an 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?
> 
> _______________________________________________
> Mercurial mailing list
> Mercurial at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial



More information about the Mercurial mailing list