.RB [ \-editor
.IR editor ]
.RB [ \-noedit ]
+.RB [ \-width
+.IR columns ]
+.RB [ \-from
+.IR address ]
+.RB [ \-to
+.IR address ]
+.RB [ \-cc
+.IR address ]
+.RB [ \-fcc
+.IR +folder ]
.RB [ \-whatnowproc
.IR program ]
.RB [ \-nowhatnowproc ]
.B \-noedit
is given, in which case the initial edit is suppressed).
.PP
-The default message form contains the following elements:
+The default message template \*(lqcomponents\*(rq will direct
+.B comp
+to construct the messgage draft as follows:
.PP
.RS 5
.nf
-%components%
+From: {from switch} or <Local-Mailbox> or <username@hostname>
+To: {to switch} or blank
+cc: {cc switch} or blank
+Fcc: {fcc switch} or +outbox
+Subject:
+--------
.fi
.RE
.PP
switchs will NOT be processed with
.BR mh\-format (5).
.PP
+In addition to the standard
+.BR mh\-format (5)
+escapes,
+.B comp
+the following
+.I component
+escapes are either new or have an alternate meaning:
+.PP
+.RS 5
+.nf
+.ta \w'Escape 'u +\w'Returns 'u
+.I Escape Returns Description
+fcc string Any folders specified with `\-fcc\ folder'
+from string Any addresses specified with `\-from\ address'
+to string Any addresses specified with `\-to\ address'
+cc string Any addresses specified with `\-cc\ address'
+.fi
+.RE
+.PP
+By default the \*(lqTo:\*(rq and \*(lqcc:\*(rq fields are empty. You may
+add addresses to these fields with the
+.B \-to
+.I address
+and
+.B \-cc
+.I address
+switches. You may give these switches multiple times to add multiple
+addresses.
+.PP
+By default the \*(lqFrom:\*(rq field has either the value of the
+.B Local\-Mailbox
+profile entry or a system default email address. This default can be
+overridden by using the
+.B \-from
+.I address
+switch.
+.PP
If the draft already exists,
.B comp
will ask you as to the disposition
{ "version", 0 },
#define HELPSW 12
{ "help", 0 },
+#define TOSW 13
+ { "to address", 0 },
+#define CCSW 14
+ { "cc address", 0 },
+#define FROMSW 15
+ { "from address", 0 },
+#define FCCSW 16
+ { "fcc mailbox", 0 },
+#define WIDTHSW 17
+ { "width colums", 0 },
{ NULL, 0 }
};
{ NULL, 0 }
};
+/*
+ * Add an item to a comma seperated list
+ */
+
+static char *addlist(char *, char *);
int
main (int argc, char **argv)
char *cp, *cwd, *maildir, *dfolder = NULL;
char *ed = NULL, *file = NULL, *form = NULL;
char *folder = NULL, *msg = NULL, buf[BUFSIZ];
+ char *to = NULL, *from = NULL, *cc = NULL, *fcc = NULL, *dp;
char drft[BUFSIZ], **argp, **arguments;
struct msgs *mp = NULL;
struct format *fmt;
dfolder = NULL;
isdf = NOTOK;
continue;
+
+ case TOSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ to = addlist(to, cp);
+ continue;
+
+ case CCSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ cc = addlist(cc, cp);
+ continue;
+
+ case FROMSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ from = addlist(from, cp);
+ continue;
+
+ case FCCSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ dp = NULL;
+ if (*cp == '@')
+ cp = dp = path(cp + 1, TSUBCWF);
+ fcc = addlist(fcc, cp);
+ if (dp)
+ free(dp);
+ continue;
+
+ case WIDTHSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ if ((outputlinelen = atoi(cp)) < 10)
+ adios (NULL, "impossible width %d", outputlinelen);
+ continue;
}
}
if (*cp == '+' || *cp == '@') {
if ((in = open (form = getcpy (m_name (mp->lowsel)), O_RDONLY)) == NOTOK)
adios (form, "unable to open message");
} else {
+ struct comp *cptr;
+
if (! form)
form = components;
cp = new_fs(form, NULL, NULL);
format_len = strlen(cp);
ncomps = fmt_compile(cp, &fmt);
- if (ncomps > 0) {
- adios(NULL, "format components not supported when using comp");
+
+ /*
+ * Set up any components that were fed to us on the command line
+ */
+
+ if (from) {
+ FINDCOMP(cptr, "from");
+ if (cptr)
+ cptr->c_text = from;
+ }
+ if (to) {
+ FINDCOMP(cptr, "to");
+ if (cptr)
+ cptr->c_text = to;
+ }
+ if (cc) {
+ FINDCOMP(cptr, "cc");
+ if (cptr)
+ cptr->c_text = cc;
+ }
+ if (fcc) {
+ FINDCOMP(cptr, "fcc");
+ if (cptr)
+ cptr->c_text = fcc;
}
}
done (1);
return 1;
}
+
+/*
+ * Append an item to a comma separated list
+ */
+
+static char *
+addlist (char *list, char *item)
+{
+ if (list)
+ list = add (", ", list);
+
+ return add (item, list);
+}