On Tue, Mar 09, 1999 at 12:19:31 -0500, Rob Reid wrote: > send-hook tea@astro "my_hdr Subject: Tea and cookies in the Astrolounge at 3:30" > send-hook !tea@astro "unmy_hdr Subject" > > Everything works except the subject line, which shows up on the _n_e_x_t > message I write, even if it isn't to "tea@astro". Can anybody help me > (free cookie if you show up here at 3:30 on a Tuesday :) or explain > why my From: line gets set properly but my Subject line is delayed > until the next message? The subject will not set in messages sent to tea@astro because subjects are handled before the send-hooks are executed. And when you send the next message, its subject will for the same reason be set before the send-hooks remove the "my_hdr Subject"-setting again. Another bug is that "my_hdr Subject" cannot be turned off by unsetting $hdrs. And send-hooks are not executed at all when sending in batchmode. All 3 things should be fixed in the attached patch. Regards - Byrial
--- send.c-old Thu Jan 14 00:55:59 1999 +++ send.c Wed Mar 10 18:14:02 1999 @@ -192,47 +192,35 @@ 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 (mutt_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); } - safe_free ((void **) &en->subject); - en->subject = safe_strdup (buf); + safe_free ((void **) subject); + *subject = safe_strdup (buf); return 0; } @@ -274,10 +262,15 @@ static void process_user_header (ENVELOP rfc822_free_address (&env->reply_to); env->reply_to = rfc822_parse_adrlist (env->reply_to, uh->data + 9); } + else if (mutt_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); + } else if (mutt_strncasecmp ("to:", uh->data, 3) != 0 && mutt_strncasecmp ("cc:", uh->data, 3) != 0 && - mutt_strncasecmp ("bcc:", uh->data, 4) != 0 && - mutt_strncasecmp ("subject:", uh->data, 8) != 0) + mutt_strncasecmp ("bcc:", uh->data, 4) != 0) { if (last) { @@ -965,6 +958,7 @@ ci_send_message (int flags, /* send mod if (option (OPTHDRS)) { process_user_recips (msg->env); + mutt_send_hook (msg); process_user_header (msg->env); } } @@ -1008,6 +1002,15 @@ 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; + }