acme: correct modified message after initial load; more detail in
message

http://codereview.appspot.com/123051
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
index ed8307e..740f361 100644
--- a/src/cmd/acme/acme.c
+++ b/src/cmd/acme/acme.c
@@ -19,7 +19,8 @@
 void	waitthread(void*);
 void	xfidallocthread(void*);
 void	newwindowthread(void*);
-void plumbproc(void*);
+void	plumbproc(void*);
+int	timefmt(Fmt*);
 
 Reffont	**fontcache;
 int		nfontcache;
@@ -127,6 +128,8 @@
 	fontnames[1] = estrdup(fontnames[1]);
 
 	quotefmtinstall();
+	fmtinstall('t', timefmt);
+
 	cputype = getenv("cputype");
 	objtype = getenv("objtype");
 	home = getenv("HOME");
@@ -1067,3 +1070,14 @@
 	n = strlen(mtpt);
 	return strncmp(file, mtpt, n) == 0 && ((n > 0 && mtpt[n-1] == '/') || file[n] == '/' || file[n] == 0);
 }
+
+int
+timefmt(Fmt *f)
+{
+	Tm *tm;
+
+	tm = localtime(va_arg(f->args, ulong));
+	return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d",
+		tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec);
+}
+
diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
index 8242da6..b15395f 100644
--- a/src/cmd/acme/dat.h
+++ b/src/cmd/acme/dat.h
@@ -134,7 +134,7 @@
 	Rune		*name;	/* name of associated file */
 	int		nname;	/* size of name */
 	uvlong	qidpath;	/* of file when read */
-	uint		mtime;	/* of file when read */
+	ulong		mtime;	/* of file when read */
 	int		dev;		/* of file when read */
 	int		unread;	/* file has not been read from disk */
 	int		editclean;	/* mark clean after edit command */
@@ -210,7 +210,7 @@
 void		textframescroll(Text*, int);
 void		textinit(Text*, File*, Rectangle, Reffont*, Image**);
 void		textinsert(Text*, uint, Rune*, uint, int);
-uint		textload(Text*, uint, char*, int);
+int		textload(Text*, uint, char*, int);
 Rune		textreadc(Text*, uint);
 void		textredraw(Text*, Rectangle, Font*, Image*, int);
 void		textreset(Text*);
diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
index 86c21d6..d24775d 100644
--- a/src/cmd/acme/exec.c
+++ b/src/cmd/acme/exec.c
@@ -644,14 +644,14 @@
 	d = dirstat(name);
 	if(d!=nil && runeeq(namer, nname, f->name, f->nname)){
 		/* f->mtime+1 because when talking over NFS it's often off by a second */
-		if(f->dev!=d->dev || f->qidpath!=d->qid.path || f->mtime+1<d->mtime){
-			f->dev = d->dev;
-			f->qidpath = d->qid.path;
-			f->mtime = d->mtime;
+		if(f->dev!=d->dev || f->qidpath!=d->qid.path || abs(f->mtime-d->mtime) > 1){
 			if(f->unread)
 				warning(nil, "%s not written; file already exists\n", name);
 			else
-				warning(nil, "%s modified%s%s since last read\n", name, d->muid[0]?" by ":"", d->muid);
+				warning(nil, "%s modified%s%s since last read\n\twas %t; now %t\n", name, d->muid[0]?" by ":"", d->muid, f->mtime, d->mtime);
+			f->dev = d->dev;
+			f->qidpath = d->qid.path;
+			f->mtime = d->mtime;
 			goto Rescue1;
 		}
 	}
diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
index 3a92e00..aec850b 100644
--- a/src/cmd/acme/look.c
+++ b/src/cmd/acme/look.c
@@ -754,7 +754,8 @@
 		w = makenewwindow(t);
 		t = &w->body;
 		winsetname(w, e->name, e->nname);
-		textload(t, 0, e->bname, 1);
+		if(textload(t, 0, e->bname, 1) >= 0)
+			t->file->unread = FALSE;
 		t->file->mod = FALSE;
 		t->w->dirty = FALSE;
 		winsettag(t->w);
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index 1b56076..7ea4131 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -188,7 +188,7 @@
 	}
 }
 
-uint
+int
 textload(Text *t, uint q0, char *file, int setqid)
 {
 	Rune *rp;
@@ -203,16 +203,16 @@
 		error("text.load");
 	if(t->w->isdir && t->file->nname==0){
 		warning(nil, "empty directory name");
-		return 0;
+		return -1;
 	}
 	if(ismtpt(file)){
 		warning(nil, "will not open self mount point %s\n", file);
-		return 0;
+		return -1;
 	}
 	fd = open(file, OREAD);
 	if(fd < 0){
 		warning(nil, "can't open %s: %r\n", file);
-		return 0;
+		return -1;
 	}
 	d = dirfstat(fd);
 	if(d == nil){
@@ -303,7 +303,7 @@
 
     Rescue:
 	close(fd);
-	return 0;
+	return -1;
 }
 
 uint