Add support for a -subject switch to comp.
authorKen Hornstein <kenh@pobox.com>
Tue, 21 Feb 2012 20:56:06 +0000 (15:56 -0500)
committerKen Hornstein <kenh@pobox.com>
Tue, 21 Feb 2012 20:56:06 +0000 (15:56 -0500)
etc/components
man/comp.man
uip/comp.c

index 64a0337..d4d4f7c 100644 (file)
@@ -21,5 +21,5 @@
 %; make the default mailbox +outbox
 %;
 Fcc: %<{fcc}%(putstr)%|+outbox%>
 %; make the default mailbox +outbox
 %;
 Fcc: %<{fcc}%(putstr)%|+outbox%>
-Subject:
+Subject:%<{subject} %(putstr)%>
 --------
 --------
index aa0c184..4a7152d 100644 (file)
@@ -33,6 +33,8 @@ comp \- compose a message
 .IR address ]
 .RB [ \-fcc
 .IR +folder ]
 .IR address ]
 .RB [ \-fcc
 .IR +folder ]
+.RB [ \-subject
+.IR text ]
 .RB [ \-whatnowproc
 .IR program ]
 .RB [ \-nowhatnowproc ]
 .RB [ \-whatnowproc
 .IR program ]
 .RB [ \-nowhatnowproc ]
@@ -57,7 +59,7 @@ From: {from switch} or <Local-Mailbox> or <username@hostname>
 To: {to switch} or blank
 cc: {cc switch} or blank
 Fcc: {fcc switch} or +outbox
 To: {to switch} or blank
 cc: {cc switch} or blank
 Fcc: {fcc switch} or +outbox
-Subject:
+Subject: {subject switch} or blank
 --------
 .fi
 .RE
 --------
 .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'
 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
 .fi
 .RE
 .PP
@@ -161,6 +164,10 @@ overridden by using the
 .I address
 switch.
 .PP
 .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
 If the draft already exists,
 .B comp
 will ask you as to the disposition
index 812f596..c8189d1 100644 (file)
@@ -49,6 +49,8 @@ static struct swit switches[] = {
     { "fcc mailbox", 0 },
 #define WIDTHSW                      17
     { "width colums", 0 },
     { "fcc mailbox", 0 },
 #define WIDTHSW                      17
     { "width colums", 0 },
+#define SUBJECTSW             18
+    { "subject text", 0 },
     { NULL, 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 *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;
     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;
                    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 == '@') {
            }
        }
        if (*cp == '+' || *cp == '@') {
@@ -317,6 +326,11 @@ main (int argc, char **argv)
            if (cptr)
                cptr->c_text = fcc;
        }
            if (cptr)
                cptr->c_text = fcc;
        }
+       if (subject) {
+           FINDCOMP(cptr, "subject");
+           if (cptr)
+               cptr->c_text = subject;
+       }
     }
 
 try_it_again:
     }
 
 try_it_again: