Re: Order of send-hook and folder-hook options.
On 2007-10-10, Benjamin A'Lee <bma+lists@xxxxxxxxxxxxxx> wrote:
>
> I'm trying to set up hooks to modify my From address. I have two
> conditions.
>
> a) If I'm in a specific folder (in this case =lists) or its subfolders,
> use Address B.
> b) If I'm sending to a specific domain, use Address C.
>
> Otherwise, use address A.
>
> I can do a):
>
> folder-hook . my_hdr From: address_a
> folder-hook =lists my_hdr From: address_b
>
> Or, I can do b):
>
> send-hook . my_hdr From: address_a
> send-hook @example.com my_hdr From: address_c
>
> What I can't do is have both. The send-hook runs on every message, so
> overrides the configured address for the folder.
>
> Can somebody suggest a way to have both the send-hooks and the
What I've done is nest them, so that a set of folder-hooks define
the set of send-hooks and/or message-hooks to be used within that
folder. It looks a little complicated at first, but it works quite
well.
Here's one example: the hooks I use for setting my signature. I
had to edit it a bit for public consumption, so I hope I didn't
leave out anything important.
# Set the default 'signature' for the current folder. This may be
# overridden for particular recipients.
#
folder-hook . 'unhook send-hook'
folder-hook . 'send-hook . "set
signature=$HOME/.mutt/signature.external"'
folder-hook +Incoming/. 'send-hook . "set
signature="'
folder-hook +Incoming/mutt-dev 'send-hook . "set
signature=$HOME/.mutt/signature.external.mutt"'
folder-hook +Incoming/mutt-users 'send-hook . "set
signature=$HOME/.mutt/signature.external.mutt"'
folder-hook . 'send-hook "^~t \"@my_company\.com$\"" "set
signature=$HOME/.mutt/signature.internal"'
folder-hook . 'send-hook "^~t \"@some_company\.com$\"" "set
signature=$HOME/.mutt/signature.external_sea_w_phone"'
I've also avoided the long lines and awkward quoting in one place by
sourcing a file containing message-hooks:
folder-hook . 'unhook message-hook'
folder-hook . 'source ~/.mutt/default-message-hooks'
HTH,
Gary