aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-06-19 14:00:29 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-06-19 14:00:29 +0200
commiteeacad9fd8c6ba56ef20a19ca4a564a517ee6f51 (patch)
tree7bf9a7dcf7deb61c7ef676aff83f3781d35d9545
parent856883bf69bb54827c0854546131da39bef469f7 (diff)
downloadmblaze-eeacad9fd8c6ba56ef20a19ca4a564a517ee6f51.tar.gz
mcom: add -r to resume editing drafts
-rw-r--r--man/mcom.118
-rwxr-xr-xmcom44
2 files changed, 49 insertions, 13 deletions
diff --git a/man/mcom.1 b/man/mcom.1
index 1bee90a..d14d86d 100644
--- a/man/mcom.1
+++ b/man/mcom.1
@@ -8,7 +8,9 @@
.Nd compose new, forward, reply to, and send mail
.Sh SYNOPSIS
.Nm mcom
-.Op Ar recipient
+.Op Ar recipients\ ...
+.Nm mcom
+.Fl r Op draft
.Nm mfwd
.Op Fl r
.Op Ar msgs\ ...
@@ -19,15 +21,23 @@
creates a new draft mail and runs an editor.
After editing, a loop is started where the user can re-edit, send or
cancel the mail.
+Use
+.Sq Nm Fl r
+to resume editing a draft.
+By default, the last modified draft will be edited.
.Pp
.Nm mfwd
behaves like
.Nm mcom
-but fills the draft with subject and body prefilled to forward the messages.
-By default, messages are forwarded verbatim as MIME attachments.
+but fills the draft with subject and body to forward the messages.
+By default, messages are forwarded verbatim as MIME
+.Sq Li message/rfc822
+attachments.
Use
.Fl r
-to forward as rendered plain text, using RFC934 message encapsulation.
+to forward as
+.Xr mshow 1
+rendered plain text, using RFC934 message encapsulation.
.Pp
.Nm mrep
behaves like
diff --git a/mcom b/mcom
index 9fea4c6..31d655c 100755
--- a/mcom
+++ b/mcom
@@ -36,23 +36,49 @@ sendmail=$(mhdr -h sendmail "$MBLAZE/profile")
sendmail_args=$(mhdr -h sendmail-args "$MBLAZE/profile")
sendmail="${sendmail:-sendmail} ${sendmail_args:--t}"
+resume=
+case "$0" in
+ *mcom*)
+ if [ "$1" = -r ]; then
+ shift
+ resume=1
+ if [ "$#" -gt 0 ]; then
+ echo "used dreaft $1"
+ draft="$1"
+ shift
+ fi
+ fi
+ ;;
+esac
+
outbox=$(mhdr -h outbox "$MBLAZE/profile")
if [ -z "$outbox" ]; then
- i=0
- while [ -f "snd.$i" ]; do
- i=$((i+1))
- done
- draft="./snd.$i"
+ if [ -z "$resume" ]; then
+ i=0
+ while [ -f "snd.$i" ]; do
+ i=$((i+1))
+ done
+ draft="./snd.$i"
+ elif [ -z "$draft" ]; then
+ draft=$(ls -1t ./snd.*[0-9] | sed 1q)
+ fi
draftmime="./snd.$i.mime"
else
- draft="$(true | mdeliver -v -c -XD "$outbox")"
- if [ -z "$draft" ]; then
- printf '%s\n' "$0: failed to create draft in outbox $outbox." 1>&2
- exit 1
+ if [ -z "$resume" ]; then
+ draft="$(true | mdeliver -v -c -XD "$outbox")"
+ if [ -z "$draft" ]; then
+ printf '%s\n' "$0: failed to create draft in outbox $outbox." 1>&2
+ exit 1
+ fi
+ elif [ -z "$draft" ]; then
+ draft=$(mlist -D "$outbox" | msort -r -M | sed 1q)
fi
draftmime="$(printf '%s\n' "$draft" | sed 's,\(.*\)/cur/,\1/tmp/mime-,')"
fi
+echo $draft
+
+[ -z "$resume" ] &&
{
case "$0" in
*mcom*)