Subject: sam as a synchronous thing

From: Michael John Haertel <[email-masked]>
Date: Mon, 12 Apr 1993 20:16:44 -0400

rsalz wrote:

>How do I
>tell the "editor" that I'm done editing?

This is the best solution I've come up with.

#! /bin/sh
B $1
waitforchanges $1

where "waitforchanges" is the following small C program:

#include <sys/types.h>
#include <sys/stat.h>

main(int argc, char *argv[])
{
	struct stat ost, nst;

	if (argc != 2)
		exit(1);
	if (stat(argv[1], &ost) < 0)
		exit(1);
	for (;;) {
		sleep(3);
		if (stat(argv[1], &nst) < 0)
			exit(1);
		if (nst.st_mtime != ost.st_mtime)
			break;
	}
	exit(0);
}

---

From: John (Most modern computers would break if you stood on them) Mackin <john@ civil.su.oz.au>
Date: Mon, 12 Apr 1993 20:36:14 -0400

waitforchanges $1

Danger, Will Robinson!

Seriously, that will work in some sense but I think there are some
problems with it.  Clearly, that commits you to saying your $EDITOR
finishes the instant you write your changes out.  I have what I think
is a good habit of writing out changes to files at random times while
I'm editing.  This will totally discourage people developing that habit,
and that means they're all the more likely to lose their editing if
something goes bad.  Yes, we do have sam.save, but sam doesn't always
get a chance to do that.  I think that no matter what editor you're
using, writing out your file frequently is a good habit to have, and
one that shouldn't be discouraged.

I have some ideas for other solutions which I will send mail about
when I have thought over them some more.  They're not solid enough
to send out yet.

OK,
John.