[PATCH] make send-hooks work for batch mode
Please don't shoot me! ;-)
I can't see a good reason that send-hooks are ignored in batch
mode. This certainly screws up my ability to send batch mail,
because I have the sequence:
1. send-hook sets $from based on recipient
2. send-hook2 sets outgoing server based on $from
This is broken for me in mutt's batch mode, because #1 never
fires. Consequently I always get my default $from and default
outgoing server.
Some pre-reading comments on this patch:
1. It turns out that pre-setting msg->env->from isn't necessary
once you remove the out-of-line batch mode. msg->env->from
is set later based on the same conditions, and nothing prior
to that code needs it.
2. While touching these conditional lines, I also cleaned them up
a bit:
- if (option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor
&& mutt_strcmp (Editor, "builtin") != 0))
+ if (option (OPTSIGONTOP) && ! (flags & (SENDMAILX|SENDKEY|SENDBATCH)) &&
mutt_strcmp (Editor, "builtin") != 0)
The two cleanups here are:
* don't pre-test Editor; that's the point of mutt_strcmp
* remove a superfluous and misleading set of parens
Comments please?
Thanks,
Aron
# HG changeset patch
# User Aron Griffis <agriffis@xxxxxxxxx>
# Date 1216766567 14400
# Branch HEAD
# Node ID de94c225a70173ca324fb1a1757369ddde845c73
# 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
15 unnecessary lines of code.
Signed-off-by: Aron Griffis <agriffis@xxxxxxxxx>
diff -r f72fce68ca19 -r de94c225a701 send.c
--- a/send.c Wed Jul 02 18:26:17 2008 +0200
+++ b/send.c Tue Jul 22 18:42:47 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,10 @@
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)) &&
mutt_strcmp (Editor, "builtin") != 0)
append_signature (tempfp);
/* include replies/forwarded messages, unless we are given a template */
@@ -1314,7 +1299,7 @@
&& 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)) &&
mutt_strcmp (Editor, "builtin") != 0)
append_signature (tempfp);
/*
@@ -1322,7 +1307,7 @@
* can take effect.
*/
- if (WithCrypto && !(flags & SENDMAILX))
+ if (WithCrypto && !(flags & (SENDMAILX|SENDBATCH)))
{
if (option (OPTCRYPTAUTOSIGN))
msg->security |= SIGN;