<<< Date Index >>>     <<< Thread Index >>>

Re: send-hook not setting $from



On Thu, Dec 04, 2003 at 07:07:29PM -0600, Eugene Lee wrote:

> On Thu, Dec 04, 2003 at 03:50:48PM +0100, Michael Tatge wrote:
> : 
> : * On Thu, Dec 04, 2003 Eugene Lee (list-mutt@xxxxxxxx) muttered:
> : >
> : >   send-hook . 'set from=me@xxxxxxxxxx'
> : >   send-hook '~C abuse@xxxxxxx' 'set from=me+aol@xxxxxxxxxx'
> : 
> :                                       use my_hdr
> : 
> :     set from = me@xxxxxxxxxx
> :         send-hook . 'unmy_hdr from'
> :     send-hook '~C abuse@xxxxxxx' 'my_hdr From: me+aol@xxxxxxxxxx'
> 
> Michael (and Noir), thanks for your comments.  I know that my_hdr works.
> But I don't understand why "set $from" does not work in a send-hook.

In plain English, changing $from in a send-hook has no effect on the
message being composed because Mutt has already set your From: header
before it executes the send-hook (based on what $from was then - i.e.,
before your hook was called).  my_hdr works because it simply replaces
any existing header by the same name - in this case, the "From: " header.

> The docs mention nothing.

The docs specifically mention that changing $from has no effect on the
current message from within send-hooks.

> : > I don't have this problem if I manually change the From: header using
> : > my_hdr.
> : 
> : indeed. That is why you should use my_hdr in the first place.
> 
> The problem is, since setting $from is unreliable while "my_hdr From:"
> always works, what's the point of keeping this configuration variable?
> Get rid of what's broken and keep what works.

There, you have a feature request.  I'd rather keep both, but fix
evaluation of send-hooks so they happen before the "From: " header is
constructed.  The only problem is that doing so would prevent us from
being able to match on the "From: " header in a send-hook (since the
header wouldn't exist yet).  The "correct" solution is difficult to work
out, IMHO.  There are too many overlapping feature requests, and many of
them are incompatible by design.  The simplest way to solve your problem
is (a) using my custom-from-setting scripts, or (b) setting the entire
"From: " header all the time, rather than trying to set name and addy
independently (as my config does).

> Else, if $from is useful, what does it do that "my_hdr From:" cannot do?

Simple, it allows you to set your addy without changing your name.
You can have different hooks setting from and realname, effectively
constructing a custom "From: " header on-the-fly.  The only problem,
of course, is that your brand spankin' new "From: " header won't be
constructed in time for your current message :-(

> Just a bit confused since the docs (short of parsing the source code)
> doesn't match behavior.  Maybe I should file a bug report?

You can certainly file a wishlist, but since the docs _do_ predict this
behavior, it's not technically a "bug" as such.  (It's simply a documented
"feature" - and a rather annoying one, at that.)

 - Dave

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel

Attachment: pgpvGoHdpnvpy.pgp
Description: PGP signature