From 1dd8eb505ef646b8489a08edd60309ee97248143 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Tue, 21 Feb 2012 15:56:06 -0500 Subject: [PATCH] Add support for a -subject switch to comp. --- etc/components | 2 +- man/comp.man | 9 ++++++++- uip/comp.c | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/etc/components b/etc/components index 64a0337..d4d4f7c 100644 --- a/etc/components +++ b/etc/components @@ -21,5 +21,5 @@ %; make the default mailbox +outbox %; Fcc: %<{fcc}%(putstr)%|+outbox%> -Subject: +Subject:%<{subject} %(putstr)%> -------- diff --git a/man/comp.man b/man/comp.man index aa0c184..4a7152d 100644 --- a/man/comp.man +++ b/man/comp.man @@ -33,6 +33,8 @@ comp \- compose a message .IR address ] .RB [ \-fcc .IR +folder ] +.RB [ \-subject +.IR text ] .RB [ \-whatnowproc .IR program ] .RB [ \-nowhatnowproc ] @@ -57,7 +59,7 @@ From: {from switch} or or To: {to switch} or blank cc: {cc switch} or blank Fcc: {fcc switch} or +outbox -Subject: +Subject: {subject switch} or blank -------- .fi .RE @@ -140,6 +142,7 @@ 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' +subject string Any text specified with `\-subject\ text' .fi .RE .PP @@ -161,6 +164,10 @@ overridden by using the .I address switch. .PP +Any text you give to the +.B \-subject +switch will be placed in the \*(lqSubject:\*(rq field in the draft. +.PP If the draft already exists, .B comp will ask you as to the disposition diff --git a/uip/comp.c b/uip/comp.c index 812f596..c8189d1 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -49,6 +49,8 @@ static struct swit switches[] = { { "fcc mailbox", 0 }, #define WIDTHSW 17 { "width colums", 0 }, +#define SUBJECTSW 18 + { "subject text", 0 }, { NULL, 0 } }; @@ -93,6 +95,7 @@ main (int argc, char **argv) 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 *subject = NULL; char drft[BUFSIZ], **argp, **arguments; struct msgs *mp = NULL; struct format *fmt; @@ -219,6 +222,12 @@ main (int argc, char **argv) if ((outputlinelen = atoi(cp)) < 10) adios (NULL, "impossible width %d", outputlinelen); continue; + + case SUBJECTSW: + if (!(cp = *argp++) || *cp == '-') + adios (NULL, "missing argument to %s", argp[-2]); + subject = cp; + continue; } } if (*cp == '+' || *cp == '@') { @@ -317,6 +326,11 @@ main (int argc, char **argv) if (cptr) cptr->c_text = fcc; } + if (subject) { + FINDCOMP(cptr, "subject"); + if (cptr) + cptr->c_text = subject; + } } try_it_again: -- 1.7.10.4