@@ -1330,9 +1330,14 @@ sub file_name_is_absolute {
1330
1330
return File::Spec::Functions::file_name_is_absolute($path );
1331
1331
}
1332
1332
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.
1336
1341
1337
1342
sub send_message {
1338
1343
my @recipients = unique_email_list(@to );
@@ -1404,15 +1409,17 @@ sub send_message {
1404
1409
1405
1410
EOF
1406
1411
}
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
1408
1413
# translation. The program will only accept English input
1409
1414
# 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 ,
1412
1417
default => $ask_default );
1413
1418
die __(" Send this email reply required" ) unless defined $_ ;
1414
1419
if (/ ^n/i ) {
1415
1420
return 0;
1421
+ } elsif (/ ^e/i ) {
1422
+ return -1;
1416
1423
} elsif (/ ^q/i ) {
1417
1424
cleanup_compose_files();
1418
1425
exit (0);
@@ -1552,7 +1559,12 @@ sub send_message {
1552
1559
$subject = $initial_subject ;
1553
1560
$message_num = 0;
1554
1561
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
+
1556
1568
open my $fh , " <" , $t or die sprintf (__(" can't open file %s " ), $t );
1557
1569
1558
1570
my $author = undef ;
@@ -1760,6 +1772,10 @@ sub send_message {
1760
1772
}
1761
1773
1762
1774
my $message_was_sent = send_message();
1775
+ if ($message_was_sent == -1) {
1776
+ do_edit($t );
1777
+ return 0;
1778
+ }
1763
1779
1764
1780
# set up for the next message
1765
1781
if ($thread && $message_was_sent &&
@@ -1781,6 +1797,14 @@ sub send_message {
1781
1797
undef $auth ;
1782
1798
sleep ($relogin_delay ) if defined $relogin_delay ;
1783
1799
}
1800
+
1801
+ return 1;
1802
+ }
1803
+
1804
+ foreach my $t (@files ) {
1805
+ while (!process_file($t )) {
1806
+ # user edited the file
1807
+ }
1784
1808
}
1785
1809
1786
1810
# Execute a command (e.g. $to_cmd) to get a list of email addresses
0 commit comments