Gregory Seidman wrote:
> Well, I sort of like it. Incidentally, I'm the one who brought up the
> problem. I'm not sure I like it better than have a search pattern (~R,
> maybe?) for when reverse_name has come up with something. It seems a little
> kludgy to make one header behave differently, rather than allowing the hook
> to be more specfic. In particular, I expect that there will be occasions
> when one wants the reverse_name to be overridden and occasions when one
> does not, even for the same user. (Example: I *always* want mail sent to
> the local LAN to have my short address, regardless of what address received
> the email. For everything else, though, I want reverse_name to supersede.)
I believe the following approach is a good compromise. This patch adds
a reply-hook command which is just like the send-hook, except that it
matches against the message you are replying to rather than the message
you are sending. All reply-hook's are execute prior to send-hook's.
However, you can inhibit send-hook's in the reply case by using the
pattern '! ~Q' (not-replied) in the send-hook to tell when reply-hook's
have been executed.
Therefore, your above example would become:
set reverse_name
reply-hook . 'unmy_hdr from'
# if i was not listed as an explicit recipient, use a default from:
# address
reply-hook '! ~p' 'my_hdr From: Long Form <[EMAIL PROTECTED]>'
# when not replying, clear the default from: addrss from the last email
send-hook '! ~Q' 'unmy_hdr from'
# always use a short address for local email
send-hook '! ~t @' 'my_hdr From: Short Form '
Incidentally, this reply-hook also solves another problem. Say that I
use [EMAIL PROTECTED] when replying to email from the mutt-* lists. Right now
I would have something like:
send-hook '~Cmutt' 'my_hdr from: [EMAIL PROTECTED]'
so that when I reply to this list, the proper return address is set.
However, if I do a personal reply to a post on the list, that hook will
not be triggered and my default from address will be used instead. The
reply-hook lets me do
reply-hook '~Cmutt' 'my_hdr from: [EMAIL PROTECTED]'
so that when I do a personal reply to a message sent to mutt-users, my
return address is set to [EMAIL PROTECTED] as I want it to.
> Even better than a boolean search pattern would be a search pattern that
> gives the current from address (only applicable to send-hook, maybe?),
> which might have been generated from $from or reverse_name or my_hdr (in or
> out of a send-hook).
You can't do a substitution, but you can figure out which address was
used by reverse_name. Consider the following example:
set alternates=me@(mutt|sigpipe)\.org
# match when i use [EMAIL PROTECTED] as default from:
send-hook '~f me@mutt\.org' '...'
# match when i use [EMAIL PROTECTED] as default from:
send-hook '~f me@sigpipe\.org' '...'
Index: hook.c
===
RCS file: /home/roessler/cvs/mutt/hook.c,v
retrieving revision 3.3
diff -u -r3.3 hook.c
--- hook.c 5 Feb 2002 21:30:31 - 3.3
+++ hook.c 17 Jul 2002 17:27:57 -
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1996-2000 Michael R. Elkins <[EMAIL PROTECTED]>, and others
+ * Copyright (C) 1996-2002 Michael R. Elkins <[EMAIL PROTECTED]>, and others
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -65,7 +65,7 @@
goto error;
}
- mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_SENDHOOK |
M_ACCOUNTHOOK)) ? M_TOKEN_SPACE : 0);
+ mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_SENDHOOK | M_ACCOUNTHOOK
+| M_REPLYHOOK)) ? M_TOKEN_SPACE : 0);
if (!command.data)
{
@@ -118,7 +118,7 @@
ptr->rx.not == not &&
!mutt_strcmp (pattern.data, ptr->rx.pattern))
{
- if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK))
+ if (data & (M_FOLDERHOOK | M_SENDHOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK |
+M_REPLYHOOK))
{
/* these hooks allow multiple commands with the same
* pattern, so if we've already seen this pattern/command pair, just
@@ -147,10 +147,10 @@
break;
}
- if (data & (M_SENDHOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK))
+ if (data & (M_SENDHOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK | M_REPLYHOOK))
{
if ((pat = mutt_pattern_comp (pattern.data,
- (data & (M_SENDHOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG,
+ (data & (M_SENDHOOK | M_REPLYHOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG,
err)) == NULL)
goto error;
}
Index: init.h
===
RCS file: /home/roessler/cvs/mutt/init.h,v
retrieving revision 3.17
diff -u -r3.17 init.h
--- init.h 7 Jul 2002 19:33:48 - 3.17
+++ init.h 17 Jul 2002 17:28:00 -
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1996-2000 Michael R. Elkins <[EMAIL PROTEC