- clean up man page. - add -t flag to modify the h/b commands to be more useful for mail boxes of sent messages. example: ladd; mail -tf Sent 5985 messages, 5864 unread : b 1 * 969 5/21 13:41 9fans@9fans.net Re: [9fans] syscall 53 2 * 1835 5/21 12:25 9fans@9fans.net Re: [9fans] syscall 53 Reference: /n/atom/patch/applied/nedsentmail Date: Wed May 21 20:27:49 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/upas/ned/nedmail.c Wed May 21 20:25:33 2014 +++ /sys/src/cmd/upas/ned/nedmail.c Wed May 21 20:25:33 2014 @@ -188,6 +188,8 @@ int doflush; int interrupted; int longestfrom = 12; +int longestto = 12; +int hcmdfmt; Qid mbqid; int mbvers; char mbname[Pathlen]; @@ -361,6 +363,9 @@ natural = 1; reverse = 0; break; + case 't': + hcmdfmt = 1; + break; default: usage(); break; @@ -734,11 +739,15 @@ /* renumber and file longest from */ i = 1; longestfrom = 12; + longestto = 12; for(m = first; m != nil; m = m->next){ m->id = natural ? m->fileno : i++; n = strlen(m->from); if(n > longestfrom) longestfrom = n; + n = strlen(m->to); + if(n > longestto) + longestto = n; } return 0; } @@ -963,10 +972,25 @@ void pheader0(char *buf, int len, Message *m) { - char *p, *q, timebuf[32], h[5]; + char *f, *p, *q, frombuf[40], timebuf[32], h[5]; + int max; hds(h, m); - if(*m->from == 0) + if(hcmdfmt == 0){ + f = m->from; + max = longestfrom; + }else{ + snprint(frombuf, sizeof frombuf-5, "%s", m->to); + p = strchr(frombuf, ' '); + if(p != nil) + snprint(p, 5, " ..."); + f = frombuf; + max = longestto; + if(max > sizeof frombuf) + max = sizeof frombuf; + } + + if(*f == 0) snprint(buf, len, "%3D %s %6d %s", m, m->type, m->len, m->filename); else if(*m->subject){ @@ -977,14 +1001,12 @@ p[50] = 0; cracktime(m->date, timebuf, sizeof timebuf); snprint(buf, len, "%3D %s %6d %11.11s %-*.*s %s", - m, h, m->len, timebuf, - longestfrom, longestfrom, m->from, p); + m, h, m->len, timebuf, max, max, f, p); free(q); } else { cracktime(m->date, timebuf, sizeof timebuf); snprint(buf, len, "%3D %s %6d %11.11s %s", - m, h, m->len, timebuf, - m->from); + m, h, m->len, timebuf, f); } } --- /sys/man/1/nedmail Wed May 21 20:25:33 2014 +++ /sys/man/1/nedmail Wed May 21 20:25:33 2014 @@ -4,11 +4,11 @@ .SH SYNOPSIS .B upas/nedmail [ -.B -nr +.B -nrt ] [ .B -f -.I mailfile +.I box ] [ .B -s @@ -28,20 +28,16 @@ command line option specifies an alternate mailbox. Unrooted path names are interpreted relative to .BI /mail/box/ username. -If the -.I mailfile -argument is omitted, the name defaults to -.BR stored . .PP The options are: .TF "-f mailfile" .TP .BI -c " dir -Create a mailbox. If +Create a mail box. If .I dir -is specified, the new mailbox is created in +is specified, the new mail box is created in .BI /mail/box/ username / dir /mbox\f1. -Otherwise, the default mailbox is created. +Otherwise, the default mail box is created. .TP .B -r Reverse: show messages in first-in, first-out order; the default is last-in, first-out. @@ -52,18 +48,26 @@ .B -r option. .TP -.BI -f " mailfile" -Read messages from the specified file (see above) instead of the default mailbox. +.BI -f " box" +Read messages from +.I box +instead of the default. .TP .BI -s " mailfile" Read a single message file .IR mailfile , as produced by .IR fs , -and treat it as an entire mailbox. +and treat it as an entire mail box. This is provided for use in plumbing rules; see .IR faces (1). +.TP +.B -t +modify the +.B h +command to include the recipient rather than the sender. +This is useful for mail boxes containing sent messages. .PD .PP .I Nedmail