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

Marcus Harnisch mh-mercurial at online.de
Sat Jun 6 10:29:43 UTC 2020


On 05/06/2020 17.47, Marcin Kasperski wrote:
> Risky business, hunting editors.
Indeed.

>     Case b) happens if some gedit is already running, maybe on another
>     virtual desktop. Yes, one can use `gedit --standalone`, of course
>     depending on the version installed as this option is rather new.

Looks like it was added to gedit almost exactly 10 years ago. However, 
the fundamental issue (in this context) of GUI tools merely spawning a 
new window/background process by default is real.

The more I am thinking about this the less convinced I am that Mercurial 
should go out of its way trying to solve this universally.

While on Windows it is safe to assume that Notepad.exe is present, the 
situation on Unices (incl. Linux) is a bit more fragmented. Which 
options are available to e.g. BSD folks?

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.

As a compromise Mercurial could ask confirmation to start vi or abort if 
an editor hasn't been configured (regardless of EDITOR or VISUAL).

I could also imagine adding a ‘--check’ or ‘--trace’ option to ‘hg 
config’. It would by default print config file paths and evaluation 
order, variable values set in each respective config level (optionally 
including environment variables) and the effective value. Certain 
essential options could be flagged if no value has been set (e.g. 
username, editor).

Cheers,
Marcus




More information about the Mercurial mailing list