Better mechanism to choose the default editor (and avoid vi if possible)?
Manuel Jacob
me at manueljacob.de
Sat Jun 6 21:24:32 UTC 2020
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.
Is there any standard demanding to open vi if neither $VISUAL nor
$EDITOR is defined? If not, I think we should print a helpful message
and abort instead of opening vi as a fallback. I think that most people
who know how to use vi are able to set environment variables (we could
even tell them how to do it), so this behavior would not be a regression
from a user-friendliness perspective.
What I said of course doesn’t apply to systems not having standardized
$VISUAL or $EDITOR. I can’t comment on what would be a good fallback
there.
On 2020-05-29 16:00, PIERRE AUGIER wrote:
> From my experience, beginners are strongly disturbed when vi (or vim)
> is opened automatically (see
> https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/).
>
> For now, the default editor for Mercurial is vi. And to change the
> editor for one user, the dedicated Mercurial command (hg config
> --edit) opens... vi.
>
> In https://www.mercurial-scm.org/wiki/editor, it is written:
>
> "
> Mercurial tries to pick which program to call to edit a commit message
> by trying the following (in order):
>
> 1. HGEDITOR environment variable
> 2. editor configuration option in [ui] section (in hgrc or passed with
> --config ui.editor command-line option).
> 3. VISUAL environment variable
> 4. EDITOR environment variable
> 5. vi, if none of the above is set
>
> On Windows, the installer places a configuration file inside
> %programfiles%\Mercurial\hgrc.d\ that contains the editor settings
> (notepad by default). Thus, if you want to override it, you either
> have to redefine the configuration option or use an HGEDITOR
> environment variable (VISUAL and EDITOR will be ignored).
> "
>
> I think it is not a great design.
>
> - Default is vi, which is a poor choice for many users.
> - A particular mechanism for Windows, so that standard environment
> variables are not considered (VISUAL and EDITOR).
> - It assumes that "the installer" does something particular for
> Windows, which is not granted (there are different ways to install
> Mercurial on Windows)
>
> Instead, Mercurial could do something like:
>
> 5. nano (Unix) or notepad (Windows), if none of the above is set
> 6. vi, if previous editors are not available
>
> Then, no need to have "editor = notepad" in
> %programfiles%\Mercurial\hgrc.d and VISUAL and EDITOR would be
> considered on Windows like with other OS.
>
> Moreover, the default .hgrc content used by `hg config --edit` when
> there is no ~/.hgrc file could contain "editor = the-choosen-editor"
> so it would be very easy and intuitive for all users to change their
> editor, for example to change "nano" to "vi" for vi users on Unix if
> nano is installed.
>
> Do you think Mercurial could be changed in this direction? What would
> be the drawback of this choice?
>
> Pierre
>
> ----- Mail original -----
>> De: "Uwe Brauer" <oub at mat.ucm.es>
>> À: "mercurial" <mercurial at mercurial-scm.org>
>> Envoyé: Jeudi 28 Mai 2020 20:34:28
>> Objet: Re: how to configure the global .hgrc file from the commandline
>
>>>>> "PA" == PIERRE AUGIER <pierre.augier at univ-grenoble-alpes.fr>
>>>>> writes:
>>
>> > A side remark on the `hg config --edit` command:
>> > I encountered problems with students with the default editor.
>>
>> > On Windows, hg tries to open the config file with vi and just
>> prints an error if
>> > vi is not available (which is very common)!
>>
>> > On Linux, by default, hg opens the config file with vi, and most
>> of my students
>> > can't do anything with this editor.
>>
>> > It would be great if Mercurial could try to find an installed and
>> easy-to-use
>> > editor if no editor is specified in the config files.
>>
>> > For people used to vi, it would anyway be very easy to switch to
>> vi.
>>
>> For people who find Emacs to heavy zile is an good alternative, but I
>> have now idea whether it would be available on windows.
>>
>> _______________________________________________
>> Mercurial mailing list
>> Mercurial at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial
> _______________________________________________
> Mercurial mailing list
> Mercurial at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial
More information about the Mercurial
mailing list