@@ -1330,9 +1330,14 @@ sub file_name_is_absolute {
13301330 return File::Spec::Functions::file_name_is_absolute($path );
13311331}
13321332
1333- # Returns 1 if the message was sent, and 0 otherwise.
1334- # In actuality, the whole program dies when there
1335- # is an error sending a message.
1333+ # Prepares the email, then asks the user what to do.
1334+ #
1335+ # If the user chooses to send the email, it's sent and 1 is returned.
1336+ # If the user chooses not to send the email, 0 is returned.
1337+ # If the user decides they want to make further edits, -1 is returned and the
1338+ # caller is expected to call send_message again after the edits are performed.
1339+ #
1340+ # If an error occurs sending the email, this just dies.
13361341
13371342sub send_message {
13381343 my @recipients = unique_email_list(@to );
@@ -1404,15 +1409,17 @@ sub send_message {
14041409
14051410EOF
14061411 }
1407- # TRANSLATORS: Make sure to include [y] [n] [q] [a] in your
1412+ # TRANSLATORS: Make sure to include [y] [n] [e] [ q] [a] in your
14081413 # translation. The program will only accept English input
14091414 # at this point.
1410- $_ = ask(__(" Send this email? ([y]es|[n]o|[q]uit|[a]ll): " ),
1411- valid_re => qr / ^(?:yes|y|no|n|quit|q|all|a)/ i ,
1415+ $_ = ask(__(" Send this email? ([y]es|[n]o|[e]dit|[ q]uit|[a]ll): " ),
1416+ valid_re => qr / ^(?:yes|y|no|n|edit|e| quit|q|all|a)/ i ,
14121417 default => $ask_default );
14131418 die __(" Send this email reply required" ) unless defined $_ ;
14141419 if (/ ^n/i ) {
14151420 return 0;
1421+ } elsif (/ ^e/i ) {
1422+ return -1;
14161423 } elsif (/ ^q/i ) {
14171424 cleanup_compose_files();
14181425 exit (0);
@@ -1552,7 +1559,12 @@ sub send_message {
15521559$subject = $initial_subject ;
15531560$message_num = 0;
15541561
1555- foreach my $t (@files ) {
1562+ # Prepares the email, prompts the user, sends it out
1563+ # Returns 0 if an edit was done and the function should be called again, or 1
1564+ # otherwise.
1565+ sub process_file {
1566+ my ($t ) = @_ ;
1567+
15561568 open my $fh , " <" , $t or die sprintf (__(" can't open file %s " ), $t );
15571569
15581570 my $author = undef ;
@@ -1760,6 +1772,10 @@ sub send_message {
17601772 }
17611773
17621774 my $message_was_sent = send_message();
1775+ if ($message_was_sent == -1) {
1776+ do_edit($t );
1777+ return 0;
1778+ }
17631779
17641780 # set up for the next message
17651781 if ($thread && $message_was_sent &&
@@ -1781,6 +1797,14 @@ sub send_message {
17811797 undef $auth ;
17821798 sleep ($relogin_delay ) if defined $relogin_delay ;
17831799 }
1800+
1801+ return 1;
1802+ }
1803+
1804+ foreach my $t (@files ) {
1805+ while (!process_file($t )) {
1806+ # user edited the file
1807+ }
17841808}
17851809
17861810# Execute a command (e.g. $to_cmd) to get a list of email addresses
0 commit comments