Re: Default editor - how is it set?

Chris G <[email protected]> Wed, 3 Feb 2010 09:28:07 +0000
Newsgroups gmane.network.tin.user
Message-ID <20100203092807.GB13202@chris>
On Wed, Feb 03, 2010 at 12:09:28AM +0100, Urs Janßen wrote:
> In <20100202182149.GB10933@chris>, Chris G wrote:
> > For some reason my copy of tin has started selecting nano as my editor
> > instead of vi.  I have never had either EDITOR or VISUAL set in my
> > environment so I'm at a loss to understand why it has changed.
> > 
> > How does tin decide what editor to use?
> 
> first of all it looks at editor_format in attributes and/or tinrc, if
> there is a 'hardcoded' entry that will be used, if the entry uses %E
> then %E will expand to ${VISUAL:-"${EDITOR}":
> 
> tin(1)
> | ENVIRONMENT
> [...]
> |   VISUAL This  variable  has  precedence  over  the default editor (i.e.,
> |          vi(1)) that is used in all editing operations within tin  (e.g.,
> |          posting,  replying, follow-ups, ...). Evaluation order is ${VIS-
> |          UAL:-"${EDITOR:-vi}"}. See environ(5) for more infos.
> |
> |   EDITOR If $VISUAL is unset, then this  variable  is  looked up  for  a
> |          default  editor. If $EDITOR and $VISUAL are both unset, tin will
> |          uses the systems default editor (i.e. vi(1)) on UNIX-systems).
> |          See environ(5) for more infos.
> 
> if $VISUAL and $EDITOR are unset, tin falls back tin DEFAULT_EDITOR
> which usualy is determined during configure and is either the value
> specified via --with-editor or if that is not given the value of
> $EDITOR or $VISUAL. if neither is set if falls back to vi.
> 
> > The only thing I can think of that has changed recently which might
> > affect this is that I have moved vi from /usr/local/bin to /usr/bin.
> 
> just a guess: configured tin as root which has $EDITOR or $VISUAL set
> to nano or /usr/bin/editor which is a symlink to nano or the like.
> 
Thanks for the long and detailed explanation, it told me what I needed
to know.

You're right /usr/bin/editor points to nano (via /etc/alternatives/editor).

I can also explain to myself why tin stoppped picking up vi.  I *did*
have the ubuntu distributed version of vile installed, the apt-get
install sets /etc/alternatives/editor to point to vile.  However I
uninstalled it and built my own vile (because I wanted a fix in the
latest version).  That of course switched /etc/alternatives/editor
back to nano.  I manually changed /etc/alternatives/vi to point to
vile but missed /etc/alternatives/editor.

So not only is my problem fixed, I know *why* it happened too which
gives me nice warm feeling!  :-)

Thanks again.

-- 
Chris Green