--- send.c~ Sat Oct 13 09:06:53 2001 +++ send.c Sat Oct 13 10:10:23 2001 @@ -198,46 +198,34 @@ static int edit_address (ADDRESS **a, /* static int edit_envelope (ENVELOPE *en) { - char buf[HUGE_STRING]; - LIST *uh = UserHeader; - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) return (-1); if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) return (-1); if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) return (-1); + return 0; +} - if (en->subject) +static int edit_subject (char *subject[]) +{ + char buf[HUGE_STRING]; + + if (*subject) { if (option (OPTFASTREPLY)) return (0); else - strfcpy (buf, en->subject, sizeof (buf)); + strfcpy (buf, *subject, sizeof (buf)); } - else - { - char *p; - buf[0] = 0; - for (; uh; uh = uh->next) - { - if (ascii_strncasecmp ("subject:", uh->data, 8) == 0) - { - p = uh->data + 8; - SKIPWS (p); - strncpy (buf, p, sizeof (buf)); - } - } - } - if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) != 0 || (!buf[0] && query_quadoption (OPT_SUBJECT, _("No subject, abort?")) != 0)) { mutt_message _("No subject, aborting."); return (-1); } - mutt_str_replace (&en->subject, buf); + mutt_str_replace (subject, buf); return 0; } @@ -281,10 +269,15 @@ static void process_user_header (ENVELOP } else if (ascii_strncasecmp ("message-id:", uh->data, 11) == 0) mutt_str_replace (&env->message_id, uh->data + 11); + else if (ascii_strncasecmp ("subject:", uh->data, 8) == 0) + { + /* Don't overrule the default subject settings in replies and forwards */ + if (! env->subject) + env->subject = safe_strdup (uh->data + 9); + } else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 && ascii_strncasecmp ("cc:", uh->data, 3) != 0 && - ascii_strncasecmp ("bcc:", uh->data, 4) != 0 && - ascii_strncasecmp ("subject:", uh->data, 8) != 0) + ascii_strncasecmp ("bcc:", uh->data, 4) != 0) { if (last) { @@ -1176,6 +1169,7 @@ ci_send_message (int flags, /* send mod if (option (OPTHDRS)) { process_user_recips (msg->env); + mutt_message_hook (NULL, msg, M_SENDHOOK); process_user_header (msg->env); } } @@ -1220,6 +1214,13 @@ ci_send_message (int flags, /* send mod if (option (OPTHDRS)) process_user_header (msg->env); + if (! (flags & SENDMAILX) && + ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) && + ! ((flags & SENDREPLY) && option (OPTFASTREPLY))) + { + if (edit_subject (&msg->env->subject) == -1) + goto cleanup; + } if (option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0)) append_signature (tempfp);