[comp.editors] vi Turing machine, once again

dcarson@unix.cis.pittsburgh.edu (David Carson) (07/29/89)

I, too, have had problems getting the Turing machine 
simulation to work.  I noticed discussion of the
line:	map	k	|D

In the package I have, there is the file "tm" and a file
"tm.uuecode".  I notice that in "tm" the line is as above,
and I get the "missing rhs" error message when I try
to ":so tm"  (I'm on a Sun 3/50 under SunOS 4.0.x).

The file that "tm.uuencode" produces, let's call it "tm2",
has the line:	map	k	^V|D
as was discussed in previous messages. (I didn't check if all other
lines are the same.)  The ":so tm2" succeeds
this time, but when I type "g" I get the first few movements,
followed by the error message: "can't put inside a global/macro".

Any ideas what this can be traced to?

hitz@auspex.auspex.com (Dave Hitz) (07/30/89)

In article <18904@unix.cis.pittsburgh.edu> dcarson@unix.cis.pittsburgh.edu (David  Carson) writes:
> I, too, have had problems getting the Turing machine 
> simulation to work.
>
> [...]
>
> The ":so tm2" succeeds this time, but when I type "g" I get the first
> few movements, followed by the error message: "can't put inside a
> global/macro".

Vi wants undo to work for macros.  Unfortunately, vi's undo is very
simple.  Rather than allow complex macros to break undo, vi disallows
complex macros.  I believe this is a *big* mistake.  I'd much rather
give up undo than powerful macros.

Fortunately (for those who want real macros), the code that figures out
whether a macro will break undo is *very* broken.

For instance, throwing in an "mx" (mark location x) at the front of
the rhs of a macro often calms vi down.  For some reason, this sends
vi through an alternate path on which the macro checking is not as strict.

Likewise, breaking a single macro into multiple macros that call each
other can also fool vi.  In the turing machine code I define:

	map     X       "bY

and then use:

	1GkwEX@b

instead of

	1GkwE"bY@b

Using "bY directly doesn't work, but (on most systems anyway), using
the macro X does.  

If it weren't for these bugs I'm exploiting, I would have written the
entire turning machine as a single macro.  Each of the TM's 20 macros
indicate another place where the code wouldn't run inline, but worked
as a sub-macro.

So what does it mean that you got the "can't put inside a global/macro"
message?  Probably it means that your UNIX vendor "fixed" vi to
recognize that a yank can break undo, even if it's in a called macro.

So rise up.  Tell your UNIX vendor that you're tired of being coddled
like an MS-DOS user!  If you intended to undo that macro, you wouldn't
have executed it in the first place.  Don't let meddling
johny-come-lately UNIX vendors destroy the venerable fuck-the-user
tradition that has made UNIX great.  Make them put it back the way it
was.

-- 
Dave Hitz					home: 408-739-7116
UUCP: {uunet,mips,sun,bridge2}!auspex!hitz 	play: 408-970-8970