Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Key sequences and timing in vi

Path: gmdzi!unido!mcsun!uunet!ncrlnk!ncrstp!mercer
From: mer...@ncrstp.StPaul.NCR.COM (Dan Mercer)
Newsgroups: comp.editors
Subject: Re: Key sequences and timing in vi
Message-ID: <395@ncrstp.StPaul.NCR.COM>
Date: 20 Apr 90 18:21:28 GMT
References: <737@ssp11.idca.tds.philips.nl>
Reply-To: mer...@ncrstp.StPaul.NCR.COM (Dan Mercer)
Organization: St. Paul
Lines: 64
Posted: Fri Apr 20 19:21:28 1990

In article <7...@ssp11.idca.tds.philips.nl> d...@idca.tds.PHILIPS.nl (Dolf Grunbauer) writes:
:
:I have defined some vi macros in my shell variable EXINIT. Some of them I
:use to execute certain shell scripts like:
:
:map @s :w
:
:which checks the current file for spelling errors (of course I have used it
:for this article :-)
:Sometimes invocation of this macro (by typing @s in edit mode) fails with
:the error: "Nothing in register s"
:It seems to happen when there is too much time between typing the "@" and "s".
:Is this true ? If so: what is the time limit ? Is there a bypass for always
:successful invocation ? Why would vi want to check for typing speed (or skill)?
:-- 
:Dolf Grunbauer      Tel: +31 55 433233 Internet d...@idca.tds.philips.nl
:Philips Information Systems            UUCP     ...!mcsun!philapd!dolf
:Dept. BS Software,  P.O. Box 245, 7300 AE Apeldoorn, The Netherlands 
:read: error in reading .signature

Why are you trying to redefine the @ command?  @s says take the text
stored in register s and execute it as a macro.  The way vi macro 
resolution works,  if it matches on a key sequence,  it will try
to complete that key sequence (using a one second alarm).  If the timer
expires,  the accumulated characters are processed as characters (thus
the message).

Why?  Because vi is a gloriuos kludge.  It is a visual interface to
the ex line editor (it is the same file linked 5 different ways).
Ex was designed before the advent of pf keys,  and uses the escape
key to change states.  When terminals became more advanced,  gained
screen addressability,  those new functions were implemented either
by use of control characters or escape sequences.  Similarly,  pf keys,
cursor keys and others were implemented as escape sequences.

Rather than fold these key sequences into vi proper,  they were
implemented as macros (map will reveal their sequences).  How then
to differentiate the escape that begins an escape sequence from one
that is used to change states?  Timing.

The drawback is,  sleep and alarm do not provide discrete 1 second
timers.  Sleep(1) expires when the next one second timer on the system
expires,  always less than one second and possibly even virtually no
time later.  In fact,  there used to be warnings against specifying
sleep (1) since the timer might have been exhausted before the sleep
completed and you never would come back.  That bug has been fixed.

It could have been avoided if the key bindings were made dynamic -
but that would no longer be backward compatible.

You can disable the timeout by :set notimeout.

While this prevents timing out it can have bizarre side effects (having
to hit escape twice.  Accidentally invoking pf keys.  VT100 pf keys
begin \EO.  If you enter escape to stop input on current line,  then
start typing O and the first character on the above line,  you may
actully complete a pfkey sequence.  If that key is set to :q!,  well.
too bad.

Why not set macro to \Eg - guaranteed to be safe.
-- 

Dan Mercer
Reply-To: mer...@ncrstp.StPaul.NCR.COM (Dan Mercer)