about summary refs log tree commit diff
path: root/mcomp
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-20 16:58:37 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-20 16:58:37 +0200
commit3a77e01ef9f03e566cd68d15236d56243f57e3bd (patch)
tree91a3d10816da3b291ee52ffc5581279dcb9fc904 /mcomp
parent113676c48e3d7176576e243afd1e8b28adf12696 (diff)
downloadmblaze-3a77e01ef9f03e566cd68d15236d56243f57e3bd.tar.gz
mblaze-3a77e01ef9f03e566cd68d15236d56243f57e3bd.tar.xz
mblaze-3a77e01ef9f03e566cd68d15236d56243f57e3bd.zip
add mrepl
Diffstat (limited to 'mcomp')
-rwxr-xr-xmcomp62
1 files changed, 49 insertions, 13 deletions
diff --git a/mcomp b/mcomp
index f4ce30c..cf13d7c 100755
--- a/mcomp
+++ b/mcomp
@@ -8,18 +8,54 @@ done
 draft="snd.$i"
 
 {
-	echo -n "To: $1"
-	[ "$#" -gt 1 ] && shift
-	for rcpt; do
-		echo -n ", $rcpt"
-	done
-	echo
-	echo "Cc: "
-	echo "Bcc: "
-	echo "Subject: "
-	cat ~/.santoku/headers 2>/dev/null
-        echo
-        echo
+	case "$0" in
+	*mcomp*)
+		echo -n "To: $1"
+		[ "$#" -gt 1 ] && shift
+		for rcpt; do
+			echo -n ", $rcpt"
+		done
+		echo
+		echo "Cc: "
+		echo "Bcc: "
+		echo "Subject: "
+		cat ~/.santoku/headers 2>/dev/null
+		echo
+		echo
+		;;
+	*mrepl*)
+	[ "$#" -eq 0 ] && set -- .
+		# XXX reply-all
+		echo "To: $(mhdr -from "$1")"
+		echo "Cc: "
+		echo "Bcc: "
+		s=$(mhdr -subject "$1")
+		os=
+		while [ "$os" != "$s" ]; do
+			os=$s
+			s=${s% }
+			s=${s%[Rr][Ee]:}
+			s=${s%[Aa][Ww]:}
+			s=${s%[Ff][Ww][Dd]:}
+		done
+		echo "Subject: Re: $s"
+		cat ~/.santoku/headers 2>/dev/null
+		echo -n "References:"
+		{
+			mhdr -references "$1"
+			mhdr -message-id "$1"
+		} | sed 's/^[^<]*//g;s/[^>]*$//g;s/>[^<]*</>\n</g' |
+			uniq | sed 's/^/ /'
+		echo "In-Reply-To: $(mhdr -message-id "$1")"
+		echo
+
+		echo "$(mhdr -from "$1") wrote:"
+		mshow -R "$1" |
+			sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' |
+			sed 's/^/> /'
+		echo
+	esac
+
 	if [ -f ~/.signature ]; then
 		printf '%s\n' '-- '
 		cat ~/.signature
@@ -40,7 +76,7 @@ while :; do
 	e|edit)
 		c=
 		if ! ${EDITOR:-vi} $draft; then
-			c=q
+			c=c
 		fi
 		;;
 	*)