Re: Default editor/pager
On May 9, Ian Jackson wrote
> We've been round this several times, with lots of discussion, but I
> think it's time to do it again and hopefully get resolution.
> 1. Requirements:
> 1.1. Users of programs like man and trn and so forth should get the
> best editor or pager available by default.
> 1.2. All applications which invoke editors and pagers should be properly
> affected by EDITOR and PAGER.
> 1.3. vipw and vigr should invoke vi by default, if available and
> EDITOR is not set.
> 2. Observations:
> 2.1. Almost all programs obey EDITOR and PAGER already - we just need
> a sensible compiled-in default.
> 2.2. Programs which do not obey EDITOR and PAGER can be fixed, or if
> this is hard they can be pointed at script(s) which do obey these
> 2.3. We do not want to try to set EDITOR and PAGER conditionally in
> /etc/profile &c., both because the user's environment doesn't
> want to be cluttered and because this is hard to do for all
> 3. Conclusions:
> 3.1. From 1.3 and 1.1 we can see that we need versions of vipw and
> vigr which call the best editor if available, rather than
> defaulting to vi.
> 3.2. From 2.1 and 2.3 we can see that we need new pathnames which can
> be compiled into programs as the best editor and pager.
> 4. Proposals:
> 4.1. There should be /usr/bin/editor and /usr/bin/pager, managed using
> update-alternatives, with some appropriate centrally-specified
> 4.2. there should be editpw and editgr which set EDITOR to
> editor if it is not already set and then call vipw or
> 4.3. vipw and vigr should call EDITOR or vi (from the PATH); if
> vi is not available they should prompt or fail, and suggest
> editpw or editgr.
> 4.4. There should be scripts /usr/share/sensible-editor and
> /usr/share/sensible-pager which invoke EDITOR or PAGER, or
> editor or pager if the environment variables are not set.
> 5. Implementation - phase 1, provision:
> 5.1. At least emacs, ae and nvi need to be changed so that they
> use update-alternatives to provide editor, and at least less
> and util-linux (containing more) need to provide pager.
> 5.2. base-files should be made to contain /usr/share/sensible/editor
> and /usr/share/sensible-pager.
> 6. Implementation - phase 2, use:
> 6.1. editpw and editgr need to be added to the passwd package,
> and vipw and vigr changed to use vi unless EDITOR is set.
> 6.2. All other programs which have ae as a default editor for when
> EDITOR is unset or more as a default pager for when PAGER is
> unset need to be changed to use editor or pager.
> 6.3. All programs which do not honour EDITOR or PAGER should be
> changed to call sensible-editor and sensible-pager.
> TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
> firstname.lastname@example.org .
> Trouble? e-mail to email@example.com .
This approach has three problems, IMO:
1) it's impossibile start a different editor if the user is in X.
2) vipw and vigr use a different approach than the other programs (this is
only a elegance proble, I admit).
3) in general is not much flexible, because his behaviur is not determinated
by a run-time script.
My proposal is this:
editor and pager are scripts which read the file /etc/editor-choiches and
/etc/pager-choices when invoked. Exemplum of /etc/editor-choiches:
# program-to-invoke preference X11 preference tty preferred by
jed 3 2 -
xemacs 4 0 -
vi 2 1 vipw,vigr
if the user is in X11, xemacs wil be the choice, but if the user is in tty,
jed will be the choice; if editor is called by vipw vi is the choice.
When vi is installed on the system, the vi package modify (perhaps with a
program install-editor) /etc/editor-choices.
All program now must only call editor, and the rigth editor will be called.
If a user in X11 prefer xjed, he write a appropriate .editor-choices file.
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
Trouble? e-mail to firstname.lastname@example.org .