From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Tue, 8 May 2007 12:18:43 -0700 From: "Micah Stetson" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] Sam: m and "changes not in sequence" In-Reply-To: <46400475.CD8IinOH3SQR21Fj%yard-ape@telus.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2899e2610705062257r3f619e72v1de67f779c0a1cf4@mail.gmail.com> <32d987d50705062302p63ec0931m608d0ee03b9454e5@mail.gmail.com> <2899e2610705062304k1a9ef778y79c1e6a405697aea@mail.gmail.com> <2899e2610705062353p32697498n601a7566b905b78a@mail.gmail.com> <20070507083522.GA898@shodan.homeunix.net> <32d987d50705070311j1ebf0379od50947ae03d456cd@mail.gmail.com> <2899e2610705071710i47125c9dl22727abfe13233c3@mail.gmail.com> <46400475.CD8IinOH3SQR21Fj%yard-ape@telus.net> Topicbox-Message-UUID: 5fb59688-ead2-11e9-9d60-3106f5b1d025 > In Sam, I tried variations of: > > x g/foobar/m0 > > but consistently received "changes not in sequence" errors. > > I don't understand. As I read Mr. Pike's paper, Sam works much as ed in these > loops; one pass over the file to mark the changes to be made, another to make > the changes. That's correct, as I understand it, but the changes have to proceed in sequence from the beginning of the file to the end -- no jumping around. When you run x g/foobar/m0 you get a set of changes like . Those changes jump back and forth in the file, and sam won't allow it. The only way I know to work around it is to use a temporary file. Say you're working on a file named foo and you have an empty file open named tmp, then you can do this: x g/foobar/m"tmp X/tmp/,m"foo"0 Though I would probably just use the first command and work with the lines in the temporary file. It would be nice if sam converted 'x g/foobar/m0' to , etc. I don't know how hard that would be, though. Micah