From 718f854205f71294706def6688efcb1967cdc34c Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Fri, 29 Jul 2016 11:18:36 +0200 Subject: [PATCH] Allow send(1) to send from folder other than +drafts This allows having multiple draft folders or queueing drafts for automatic sending. --- man/send.man1 | 15 +++++++++------ uip/send.c | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/man/send.man1 b/man/send.man1 index b4a9fcc..02e64fe 100644 --- a/man/send.man1 +++ b/man/send.man1 @@ -8,8 +8,9 @@ send \- send a message .HP 5 .na .B send -.RB [ \-verbose " | " \-noverbose ] +.RI [ +folder ] .RI [ msgs ] +.RB [ \-verbose " | " \-noverbose ] .RB [ \-Version ] .RB [ \-help ] .ad @@ -70,13 +71,14 @@ will request verbose information of the transport system. .PP .B Send with no +.I +folder +and .I msgs -argument will send the current message in the draft folder. +arguments will send the current message in the draft folder. .B Send -always takes messages from the draft folder. -(But, a +sends messages from the draft folder, unless .I +folder -argument might be added in the future.) +is given. Consult the .BR mh-draft (7) man page for more information. @@ -167,7 +169,8 @@ comp(1), dist(1), forw(1), repl(1), mh\-alias(5), spost(8) .SH DEFAULTS .nf -.RB ` msgs "' defaults to the current message in the draft folder" +.RB ` msgs "' defaults to the current message" +.RB ` +folder "' defaults to the draft folder" .RB ` \-noverbose ' .fi diff --git a/uip/send.c b/uip/send.c index 619ff62..c1665b2 100644 --- a/uip/send.c +++ b/uip/send.c @@ -81,7 +81,7 @@ main(int argc, char **argv) int msgnum, status; int in, out; int n; - char *cp, *maildir = NULL; + char *cp, *maildir = NULL, *folder = NULL; char buf[BUFSIZ], **argp, **arguments; char *msgs[MAXARGS], *vec[MAXARGS]; char *files[MAXARGS]; @@ -125,6 +125,12 @@ main(int argc, char **argv) vec[vecp++] = --cp; continue; } + } else if (*cp == '+' || *cp == '@') { + if (folder) { + adios(EX_USAGE, NULL, "only one folder at a time!"); + } else { + folder = mh_xstrdup(expandfol(cp)); + } } else { if (*cp == '/') { files[nfiles++] = cp; @@ -139,17 +145,18 @@ main(int argc, char **argv) } if (nmsgs) { - maildir = toabsdir(draftfolder); + folder = folder ? folder : draftfolder; + maildir = toabsdir(folder); if (chdir(maildir) == NOTOK) { adios(EX_OSERR, maildir, "unable to change directory to"); } - if (!(mp = folder_read(draftfolder))) { - adios(EX_IOERR, NULL, "unable to read draft folder %s", - draftfolder); + if (!(mp = folder_read(folder))) { + adios(EX_IOERR, NULL, "unable to read folder %s", + folder); } if (mp->nummsg == 0) { - adios(EX_DATAERR, NULL, "no messages in draft folder %s", - draftfolder); + adios(EX_DATAERR, NULL, "no messages in folder %s", + folder); } /* parse all the msgranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < nmsgs; msgnum++) { -- 1.7.10.4