Re: match replies in a send-hook

2007-07-13 Thread Aron Griffis
Aron Griffis wrote:  [Thu Jul 12 2007, 07:54:57PM EDT]
>   1. reply-hooks should run inline with send-hooks instead of before
>  them.  The only difference between reply-hooks and send-hooks
>  should be which message they're matching against.
> 
>   2. send-hooks should be able to recognize when they're running on
>  a message that is a reply.  Something better than the subject
>  hack.

Bob Bell pointed out to me ~Q, which according to the doc matches
"messages which have been replied to".  This seems to be intended for
us in  or .

Whether intentional or inadvertent, it also seems to work for #2
above...

send-hook '~Q'  'my_hdr X-Q-Status: this is a reply'
send-hook '!~Q' 'my_hdr X-Q-Status: this is not a reply'

Thanks Bob!

>   3. send-hooks should be able to tell if reverse_name succeeded or
>  failed.  Right now there is no way to do this short of extremely
>  ugly hacks (think of "reply-hook . set from=bogus")
> 
>   4. There should be a way to run send-hooks on ALL sent messages
>  including bounced messages.  Presently no hooks run when
>  a message is bounced, so you just have to get lucky with the
>  folder-hook settings when you hit 'b'.


Re: match replies in a send-hook

2007-07-12 Thread Aron Griffis
Aron Griffis wrote:  [Mon Jul 09 2007, 05:12:41PM EDT]
> As far as I can tell, there's no way to determine in a send-hook if
> the message is a reply.  Is that right?

I'll explain a bit more what I'm trying to accomplish.

I want to send mails with my From address determined by the following
algorithm:
  1. reverse_name if possible
  2. otherwise, depending on the recipients

Here is a solution to this problem.  Note that mutt's priority order
for setting From is:
  1. set by my_hdr
  2. set by reverse_name
  3. $from

--
# Current mutt

alternates '(^|[-<, ])(aron|agriffis|aron.griffis)@'
set from="Aron Griffis <[EMAIL PROTECTED]>" # default needed for (b)ounce
set reverse_name=yes

# Recipient-based hooks; setting $from isn't effective here
send-hook '~C @foo.org'  'my_hdr From: Aron Griffis <[EMAIL PROTECTED]>'
send-hook '~C @work1.com''my_hdr From: Aron Griffis <[EMAIL PROTECTED]>'
send-hook '~C @partner1.com' 'my_hdr From: Aron Griffis <[EMAIL PROTECTED]>'
send-hook '~C @work2.com''my_hdr From: Aron Griffis <[EMAIL PROTECTED]>'

# After recipient-based hooks, try to determine if the message is
# a reply for which reverse_name succeeded.  The best we can do is
# look at the subject and hope this is definitive.  In that case, kill
# the custom header in favor of reverse_name.
send-hook '~s "^Re:"' unmy_hdr From

--
# Mutt with patch http://article.gmane.org/gmane.mail.mutt.devel/14042

alternates '(^|[-<, ])(aron|agriffis|aron.griffis)@'
set from="Aron Griffis <[EMAIL PROTECTED]>" # default needed for (b)ounce
set reverse_name=yes

# Recipient-based hooks
send-hook '~C @foo.org'  'set from="Aron Griffis <[EMAIL PROTECTED]>"'
send-hook '~C @work1.com''set from="Aron Griffis <[EMAIL PROTECTED]>"'
send-hook '~C @partner1.com' 'set from="Aron Griffis <[EMAIL PROTECTED]>"'
send-hook '~C @work2.com''set from="Aron Griffis <[EMAIL PROTECTED]>"'

--
Frankly, I'm of two minds regarding the patch-based solution.

PRO: The ~s "^Re:" send-hook is hackish and best avoided.  It could
 also be avoided with the q-pattern patch but that met zero
 feedback last time I posted it.  http://n01se.net/paste/850

PRO: Modifying $from is advantageous because it affects the envelope
 sender as well as the From: header.  This is important when
 sending mail from multiple accounts using a single mutt instance.

CON: Modifying $from will affect messages sent after the current one,
 including *bounced* messages.  To counter this, you'll find
 a pretty serious hack.  There are three ways to return to the
 index from the compose menu.  Either you send the message, abort
 it, or postpone it.
macro compose P ' set ...'
macro compose q ' set ...'
macro compose y ' set ...'

 ...and of course it's worse than that.  If you want different
 settings for different folders, it gets deep quick.  Full details
 at http://n01se.net/agriffis/skel.hg/?file/tip/muttrc.in

Oh well.  Now that I've written all this, I'm not certain it's
anything but a rant about my frustration trying to find an elegant
solution to a seemingly simple problem in mutt.  Probably what's
needed to alleviate this frustration is:

  1. reply-hooks should run inline with send-hooks instead of before
 them.  The only difference between reply-hooks and send-hooks
 should be which message they're matching against.

  2. send-hooks should be able to recognize when they're running on
 a message that is a reply.  Something better than the subject
 hack.

  3. send-hooks should be able to tell if reverse_name succeeded or
 failed.  Right now there is no way to do this short of extremely
 ugly hacks (think of "reply-hook . set from=bogus")

  4. There should be a way to run send-hooks on ALL sent messages
 including bounced messages.  Presently no hooks run when
 a message is bounced, so you just have to get lucky with the
 folder-hook settings when you hit 'b'.

Is anybody else frustrated by these shortcomings or is it just me?
Did anybody really read this entire message? :-)

Aron


Re: match replies in a send-hook

2007-07-09 Thread Aron Griffis
Gary Johnson wrote:  [Mon Jul 09 2007, 05:43:51PM EDT]
> On 2007-07-09, Aron Griffis <[EMAIL PROTECTED]> wrote:
> > As far as I can tell, there's no way to determine in a send-hook if
> > the message is a reply.  Is that right?
> > 
> > This is the most obvious thing to try, but it doesn't work because ~h
> > is invalid in the context of a send-hook:
> > 
> > send-hook '=h In-Reply-To:' ...
> > 
> > Here's what I'm using presently, but I'd prefer something more
> > definitive:
> > 
> > send-hook '~s "^Re:"' ...
> 
> Would a reply-hook work for you?

Nope, because what I'm really trying to do is match messages that are
*not* replies.  Additionally I want to keep my hooks in order, which
reply-hook breaks.

Thanks,
Aron


Re: match replies in a send-hook

2007-07-09 Thread Gary Johnson
On 2007-07-09, Aron Griffis <[EMAIL PROTECTED]> wrote:
> As far as I can tell, there's no way to determine in a send-hook if
> the message is a reply.  Is that right?
> 
> This is the most obvious thing to try, but it doesn't work because ~h
> is invalid in the context of a send-hook:
> 
> send-hook '=h In-Reply-To:' ...
> 
> Here's what I'm using presently, but I'd prefer something more
> definitive:
> 
> send-hook '~s "^Re:"' ...

Would a reply-hook work for you?

HTH,
Gary


match replies in a send-hook

2007-07-09 Thread Aron Griffis
As far as I can tell, there's no way to determine in a send-hook if
the message is a reply.  Is that right?

This is the most obvious thing to try, but it doesn't work because ~h
is invalid in the context of a send-hook:

send-hook '=h In-Reply-To:' ...

Here's what I'm using presently, but I'd prefer something more
definitive:

send-hook '~s "^Re:"' ...

Thanks,
Aron