Date: Mon, 9 Jul 2001 21:30:08 -0500 From: Tim <tim@futuresouth.com> To: GH <grasshacker@over-yonder.net> Cc: Bill Fenner <fenner@research.att.com>, ticso@mail.cicely.de, arch@FreeBSD.ORG Subject: Re: nvi maintainer? Message-ID: <20010709213007.A18204@futuresouth.com> In-Reply-To: <20010709164715.F85805@over-yonder.net>; from grasshacker@over-yonder.net on Mon, Jul 09, 2001 at 04:47:15PM -0500 References: <200107072203.PAA09299@windsor.research.att.com> <xzp3d88s3o0.fsf@flood.ping.uio.no> <20010708005155.J8775@canonware.com> <20010708032002.D97456@bohr.physics.purdue.edu> <20010709150739.A23210@cicely20.cicely.de> <200107091817.LAA16879@windsor.research.att.com> <20010709164715.F85805@over-yonder.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline % alias vi vim I think 99% of the people wouldn't notice if you just put vim in place of vi. I don't claim to know or have used most of vi's features, but I have used vi on a near daily basis for over ten years and put in the above alias about a year ago. Haven't noticed any problems of note. Check out the vi maze solver attached (edit the maze4vi file, or include output from the popular maze program, :source vi-mazer, and type "g") - nvi and vim both run it fine. Tim On Mon, Jul 09, 2001 at 04:47:15PM -0500, GH wrote: > On Mon, Jul 09, 2001 at 11:17:16AM -0700, some SMTP stream spewed forth: > > >What is wrong with nvi? > > > > Two things that are wrong with what we have: > > - "vi -r" failures, such as "failed to recover line NNNN". I think this > > is the bug that Keith says required DB3 to fix. > > - Dumping core when the information about the user running vi goes away > > between starting vi and making the first change requiring creation of > > a recovery file (see FreeBSD PR 3170). > > > > I run into the first one way too often. The second one isn't much of a > > problem for me any more since our NIS servers at AT&T are pretty reliable. > > How are people planning to maintain functional and semantic compatible > with nvi upon switching to a new 'vi'? 'nvi' and I have become very close > friends and it troubles me to think of what would happen to anyone coming > between us. > > > Bill > > gh > > -- > > What, no one sings along with Ricky Martin anymore? > My kid sister does (but then, she prefers pico to vi ...) > -- Suresh Ramasubramanian, alt.sysadmin.recovery > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=maze4vi ._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ | ._| . . ._| | |_._._. . ._|_._._._._. ._|_. ._|_._. ._| | . ._|_. | . ._._. . | ._|_| |_. | | | | ._._|_._|_._. . |_. | | | ._._| |_._._._| | ._. ._| . . |_| |_._._._. | ._|_. ._._._. | | ._. |_._. . | ._._| |_. | . ._._._. |_. | |_|_| | | | . |_._| . ._._._| ._._. ._._| | | |_| . | |_. . ._|_|_| ._._. |_._|_| . | | |_._|_._._._|_._._._|_|_._._._|_._|_._._._|_._._._|_._._._._|_._._._._._._|_._| | --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=vi-mazer Content-Transfer-Encoding: quoted-printable " These macros 'solve' any maze produced by the a-maze-ing maze.c program. "=20 " First, a bit of maze theory. " If you were put into a maze, a guaranteed method of finding your way " out of the maze is to put your left hand onto a wall and just keep walkin= g, " never taking your hand off the wall. This technique is only guaranteed to " work if the maze does not have any 'islands', or if the 'exit' is on the " same island as your starting point. These conditions hold for the mazes " under consideration. "=20 " Assuming that the maze is made up of horizontal and vertical walls spaced " one step apart and that you can move either north, south, east or west, " then you can automate this procedure by carrying out the following steps. "=20 " 1. Put yourself somewhere in the maze near a wall. " 2. Check if you have a wall on your left. If so, go to step 4. " 3. There is no wall on your left, so turn on the spot to your left and st= ep " forward by one step and repeat step 2. " 4. Check what is directly in front of you. If it is a wall, turn on the " spot to your right by 90 degrees and repeat step 4. " 5. There is no wall in front of you, so step forward one step and " go to step 2. "=20 " In this way you will cover all the corridors of the maze (until you get b= ack " to where you started from, if you do not stop). "=20 " By examining a maze produced by the maze.c program you will see that=20 " each square of the maze is one character high and two characters wide. " To go north or south, you move by a one character step, but to move east = or " west you move by a two character step. Also note that in any position " there are four places where walls could be put - to the north, to the sou= th, " to the east and to the west. " A wall exists to the north of you if the character to the north of " you is a _ (otherwise it is a space). " A wall exists to the east of you if the character to the east of you " is a | (otherwise it is a .). " A wall exists to the west of you if the character to the west of you " is a | (otherwise it is a .). " A wall exists to the south of you if the character where you are " is a _ (otherwise it is a space). "=20 " Note the difference for direction south, where we must examine the charac= ter " where the cursor is rather than an adjacent cell. "=20 " If you were implementing the above procedure is a normal computer language " you could use a loop with if statements and continue statements,=20 " However, these constructs are not available in vi macros so I have used " a state machine with 8 states. Each state signifies the direction you " are going in and whether or not you have checked if there is a wall on " your left. "=20 " The transition from state to state and the actions taken on each transiti= on " are given in the state table below. " The names of the states are N1, N2, S1, S2, E1, E2, W1, W2, where each le= tter " stands for a direction of the compass, the number 1 indicates that the we " have not yet checked to see if there is a wall on our left and the number= 2 " indicates that we have checked and there is a wall on our left. "=20 " For each state we must consider the existence or not of a wall in a " particular direction. This direction is given in the following table. "=20 " NextChar table: " state direction vi commands " N1 W hF " N2 N kF " S1 E lF " S2 S F " E1 N kF " E2 E lF " W1 S F " W2 W hF "=20 " where F is a macro which yanks the character under the cursor into " the NextChar register (n). "=20 " State table: " In the 'vi commands' column is given the actions to carry out when in " this state and the NextChar is as given. The commands k, j, ll, hh move " the current position north, south, east and west respectively. The " command mm is used as a no-op command. " In the 'next state' column is given the new state of the machine after " the action is carried out. "=20 " current state NextChar vi commands next state " N1 . hh W1 " N1 | mm N2 " N2 _ mm E1 " N2 space k N1 " S1 . ll E1 " S1 | mm S2 " S2 _ mm W1 " S2 space j S1 " E1 space k N1 " E1 _ mm E2 " E2 | mm S1 " E2 . ll E1 " W1 space j S1 " W1 _ mm W2 " W2 | mm N1 " W2 . hh W1 " "=20 " Complaint about vi macros: " It seems that you cannot have more than one 'undo-able' vi command " in the one macro, so you have to make lots of little macros and " put them together. " " I'll explain what I mean by an example. Edit a file and " type ':map Q rXY'. This should map the Q key to 'replace the " character under the cursor with X and yank the line'. " But when I type Q, vi tells me 'Can't yank inside global/macro' and " goes into ex mode. However if I type ':map Q rXT' and ':map T Y', " everything is OK. I`m doing all this on a Sparcstation. " If anyone reading this has an answer to this problem, the author would " love to find out. Mail to gregm@otc.otca.oz.au. " " The macros: " The macro to run the maze solver is 'g'. This simply calls two other " macros: I, to initialise everything, and L, to loop forever running " through the state table. " Both of these macros are long sequences of calls to other macros. All " of these other macros are quite simple and so to understand how this " works, all you need to do is examine macros I and L and learn what they " do (a simple sequence of vi actions) and how L loops (by calling U, which " simply calls L again). " " Macro I sets up the state table and NextChar table at the end of the file. " Macro L then searches these tables to find out what actions to perform and " what state changes to make. " " The entries in the state table all begin with a key consisting of the " letter 's', the current state and the NextChar. After this is the " action to take in this state and after this is the next state to change t= o. " " The entries in the NextChar table begin with a key consisting of the " letter 'n' and the current state. After this is the action to take to " obtain NextChar - the character that must be examined to change state. " " One way to see what each part of the macros is doing is to type in the " body of the macros I and L manually (instead of typing 'g') and see " what happens at each step. " " Good luck. " " Registers used by the macros: " s (State) - holds the state the machine is in " c (Char) - holds the character under the current position " m (Macro) - holds a vi command string to be executed later " n (NextChar) - holds the character we must examine to change state " r (Second Macro) - holds a second vi command string to be executed later " set remap set nomagic set noterse set wrapscan " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " g - go runs the whole show " I - initialise " L - then loop forever map g IL " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " I - initialise everything before running the loop " G$?.^M - find the last . in the maze " ^ - replace it with an X (the goal) " GYKeDP - print the state table and next char table at the end of the fi= le " 0S - initialise the state of the machine to E1 " 2Gl - move to the top left cell of the maze map I G$?.=0D^GYKeDP0S2Gl " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " L - the loop which is executed forever " Q - save the current character in the Char register " A - replace the current character with an 'O' " ma - mark the current position with mark 'a' " GNB - on bottom line, create a command to search the NextChar table " for the current state " 0M0E@m^M - yank the command into the Macro register and execute it " wX - we have now found the entry in the table, now yank the " following word into the Macro register " `a@m - go back to the current position and execute the macro, this wi= ll " yank the NextChar in register n " GT$B$R - on bottom line, create a command to search the state table " for the current state and NextChar " 0M0E@m^M - yank the command into the Macro register and execute it " 2WS - we have now found the entry in the table, now yank the " next state into the State macro " bX - and yank the action corresponding to this state table entry " into the Macro register " GVJ - on bottom line, create a command to restore the current charac= ter " 0H - and save the command into the second Macro register " `a@r - go back to the current position and exectute the macro to rest= ore " the current character " @m - execute the action associated with this state " U - and repeat map L QAmaGNB0M0E@m=0DwX`a@mGT$B$R0M0E@m=0D2WSbXGVJ0H`a@r@mU " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " U - no tail recursion allowed in vi macros so cheat and set U =3D L map U L " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " S - yank the next two characters into the State register map S "sy2l " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " Q - save the current character in the Char register map Q "cyl " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " A - replace the current character with an 'O' map A rO " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " N - replace this line with the string 'n' map N C/n=1B " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " B - put the current state map B "sp " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " M - yank this line into the Macro register map M "my$ " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " E - delete to the end of the line map E d$ " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " X - yank this word into the Macro register map X "myt=20 " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " T - replace this line with the string 's' map T C/s=1B " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " R - put NextChar map R "np " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " V - add the letter 'r' (the replace vi command) map V ar=1B " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " J - restore the current character map J "cp " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " H - yank this line into the second Macro register map H "ry$ " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " F - yank NextChar (this macro is called from the Macro register) map F "nyl " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " ^ - replace the current character with an 'X' map ^ rX " "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D " YKeDP - create the state table, NextChar table and initial state " Note that you have to escape the bar character, since it is special to " the map command (it indicates a new line). map Y osE1 k N1 sE1_ mm E2 sE2=16| mm S1 sE2. ll E1=1B map K osW1 j S1 sW1_ mm W2 sW2=16| mm N1 sW2. hh W1=1B map e osN1. hh W1 sN1=16| mm N2 sN2 k N1 sN2_ mm E1=1B map D osS1. ll E1 sS1=16| mm S2 sS2 j S1 sS2_ mm W1=1B map P onE1 kF nE2 lF nW1 G$JF nW2 hF nN1 hF nN2 kF nS1 lF nS2 G$JF =0DE1= =1B --ZPt4rx8FFjLCG7dd-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010709213007.A18204>