Re: [PATCH v2] make send-hooks work for batch mode
This patch makes me uneasy (especially during a freeze), but I'm
willing to apply it if no one else objects. I don't see what kind of
damage a hook might do in batch mode, but I can't convince myself that
it's harmless either.
On Tuesday, 22 July 2008 at 19:13, Aron Griffis wrote:
> I realized immediately after I sent that patch what the point was
> of pre-testing Editor. I thought it was protecting the strcmp
> but actually it was making sure Editor was set to something. So
> here is the same patch without that change.
>
> Thanks,
> Aron
>
> # HG changeset patch
> # User Aron Griffis <agriffis@xxxxxxxxx>
> # Date 1216768179 14400
> # Branch HEAD
> # Node ID 9e4b670e7d83075f9a6a105ed8e65150d50e848b
> # Parent f72fce68ca1922a321ee7351f656c4f7e1670947
> make send-hooks work for batch mode
>
> Handle SENDBATCH inline with the normal sending code, instead of handling it
> separately. This allows send-hooks to run, along with removing a number of
> unnecessary lines of code.
>
> Signed-off-by: Aron Griffis <agriffis@xxxxxxxxx>
>
> diff -r f72fce68ca19 -r 9e4b670e7d83 send.c
> --- a/send.c Wed Jul 02 18:26:17 2008 +0200
> +++ b/send.c Tue Jul 22 19:09:39 2008 -0400
> @@ -1217,24 +1217,7 @@
> msg->env->from = set_reverse_name (cur->env);
> }
>
> - if (!msg->env->from && option (OPTUSEFROM) && !(flags &
> (SENDPOSTPONED|SENDRESEND)))
> - {
> - msg->env->from = mutt_default_from ();
> - if (!(flags & SENDBATCH))
> - killfrom = 1; /* $use_from will be re-checked after send-hooks */
> - }
> -
> - if (flags & SENDBATCH)
> - {
> - mutt_copy_stream (stdin, tempfp);
> - if (option (OPTHDRS))
> - {
> - process_user_recips (msg->env);
> - process_user_header (msg->env);
> - }
> - mutt_expand_aliases_env (msg->env);
> - }
> - else if (! (flags & (SENDPOSTPONED|SENDRESEND)))
> + if (! (flags & (SENDPOSTPONED|SENDRESEND)))
> {
> if ((flags & (SENDREPLY | SENDFORWARD)) && ctx &&
> envelope_defaults (msg->env, ctx, cur, flags) == -1)
> @@ -1249,7 +1232,7 @@
> if (flags & SENDREPLY)
> mutt_fix_reply_recipients (msg->env);
>
> - if (! (flags & SENDMAILX) &&
> + if (! (flags & (SENDMAILX|SENDBATCH)) &&
> ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
> ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
> {
> @@ -1305,8 +1288,11 @@
> if (option (OPTHDRS))
> process_user_header (msg->env);
>
> + if (flags & SENDBATCH)
> + mutt_copy_stream (stdin, tempfp);
>
> - if (option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor
> && mutt_strcmp (Editor, "builtin") != 0))
> + if (option (OPTSIGONTOP) && ! (flags & (SENDMAILX|SENDKEY|SENDBATCH))
> + && Editor && mutt_strcmp (Editor, "builtin") != 0)
> append_signature (tempfp);
>
> /* include replies/forwarded messages, unless we are given a template */
> @@ -1314,7 +1300,8 @@
> && generate_body (tempfp, msg, flags, ctx, cur) == -1)
> goto cleanup;
>
> - if (!option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) &&
> Editor && mutt_strcmp (Editor, "builtin") != 0))
> + if (!option (OPTSIGONTOP) && ! (flags & (SENDMAILX|SENDKEY|SENDBATCH))
> + && Editor && mutt_strcmp (Editor, "builtin") != 0)
> append_signature (tempfp);
>
> /*
> @@ -1322,7 +1309,7 @@
> * can take effect.
> */
>
> - if (WithCrypto && !(flags & SENDMAILX))
> + if (WithCrypto && !(flags & (SENDMAILX|SENDBATCH)))
> {
> if (option (OPTCRYPTAUTOSIGN))
> msg->security |= SIGN;
>