#!/usr/bin/perl
#
# Reply message
#
# This copies the message file to a new file (with "e" at the  end  of
# its  name), and starts up an xterm with $EDITOR running in it.  When
# the $EDITOR exits, we mail the resulting file.

$editor = $ENV{"VISUAL"} || $ENV{"EDITOR"} || 'vi';
$shell = $ENV{"SHELL"} || 'csh';
$msg = $ARGV[0] || 'tmp';
$hdr = $msg . 'h';	# Build reply headers from this file.
$rpl = $msg . 'e';	# Build reply message in this file.

system "Mrpl <$hdr >$rpl";

open(M, "<$msg") || die "$0: Can't read \"$msg\" [$!]\n";
open(R,">>$rpl") || die "$0: Can't write \"$rpl\" [$!]\n";

for (<M>) {
	s/^/| /;
	print R;
}
close M;
close R;

system "xterm -e $shell -c '$editor $rpl'";

system "Msnd $rpl";

# Note that we don't delete the reply.  It is left in the folder, with
# the 'e' suffix, in case we want to refer to it later. So far, little
# is done with this fact, but it's there for later use.
