shithub: Nail

Download patch

ref: f402381351f0648e4c2142906db1bea2dda23d75
parent: efc2d967bb2d6ca8ef68bcc43f89bcd0e0f0be3a
author: Ori Bernstein <[email protected]>
date: Thu Nov 5 00:40:34 EST 2020

improve attachment handling, show when message is sent

--- a/comp.c
+++ b/comp.c
@@ -61,6 +61,8 @@
 	if(n == -1)
 		return;
 
+	if(fprint(c->ctl, "name %s:Sent\n", c->path) == -1)
+		sysfatal("write ctl: %r");
 	if(c->replyto != nil){
 		if((m = mesglookup(c->rname, c->rdigest)) == nil)
 			return;
@@ -150,11 +152,10 @@
 
 	c = emalloc(sizeof(Comp));
 	if(r != nil)
-		path = esmprint("%s%s%s.%d", mbox.path, r->name, "Reply", ncompose++);
+		c->path = esmprint("%s%s%s.%d", mbox.path, r->name, "Reply", ncompose++);
 	else
-		path = esmprint("%sCompose.%d", mbox.path, ncompose++);
-	wininit(c, path);
-	free(path);
+		c->path = esmprint("%sCompose.%d", mbox.path, ncompose++);
+	wininit(c, c->path);
 
 	wintagwrite(c, "Delmesg Save Post ");
 	wfd = bwinopen(c, "body", OWRITE);
--- a/mail.h
+++ b/mail.h
@@ -61,6 +61,7 @@
 	char	*replyto;
 	char	*rname;
 	char	*rdigest;
+	char	*path;
 
 	int	quitting;
 	Comp	*qnext;
--- a/mbox.c
+++ b/mbox.c
@@ -698,7 +698,7 @@
 Fn mboxfn[] = {
 	{"Put",	mbflush},
 	{"Delmesg", delmesg},
-	{"Delmesg", undelmesg},
+	{"Undelmesg", undelmesg},
 	{"Mark", mbmarkmesg},
 	{"Del", quitall},
 #ifdef NOTYET
--- a/mesg.c
+++ b/mesg.c
@@ -254,7 +254,7 @@
 
 	home = getenv("home");
 	if(m->nattachments != 0)
-		fprint(wfd, "\n\n");
+		fprint(wfd, "\n");
 	for(i = 0; i < m->nattachments; i++){
 		a = m->attachments[i];
 		if(a == b)
@@ -262,20 +262,23 @@
 		name = a->name;
 		if(strncmp(a->name, m->name, strlen(m->name)) == 0)
 			name += strlen(m->name);
-		fprint(wfd, "===> %s (%s)\n", name, a->type);
-		if(a->disposition != nil && strcmp(a->disposition, "inline") == 0){
-			path = estrjoin(mbox.path, b->name, "body", nil);
+		fprint(wfd, "\n===> %s (%s)\n", name, a->type);
+		if(a->disposition != nil
+		&& strcmp(a->disposition, "inline") == 0
+		&& strcmp(a->type, "text/plain") == 0){
+			path = estrjoin(mbox.path, a->name, "body", nil);
 			if((rfd = open(path, OREAD)) != -1){
 				copy(wfd, rfd);
 				close(rfd);
 			}
-		}else{
-			name = a->filename;
-			if(name == nil)
-				name = "body";
-			fprint(wfd, "\tcp %s%sbody %s/%s\n", mbox.path, a->name, home, name);
+			free(path);
 			continue;
 		}
+		name = a->filename;
+		if(name == nil)
+			name = "body";
+		fprint(wfd, "\tcp %s%sbody %s/%s\n", mbox.path, a->name, home, name);
+		continue;
 	}
 	close(wfd);
 	free(home);
--- a/win.c
+++ b/win.c
@@ -275,7 +275,7 @@
 	char *s;
 	int q0, q1, ns;
 
-	if(e->q0 != e->q1)
+	if(e->action != 'L' || e->q0 != e->q1)
 		return nil;
 
 	q0 = wineval(w, "#%d-%s", e->q0, delim);
@@ -316,7 +316,7 @@
 
 	if(strncmp(text, mbox.path, strlen(mbox.path)) == 0)
 		return 1;
-	if(regexec(mesgpat, text, nil, 0)){
+	else if(regexec(mesgpat, text, nil, 0)){
 		if((p = strchr(text, '/')) != nil)
 			p[1] = 0;
 		return 1;