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

Re: rerunning hooks



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday, September 24 at 01:22 PM, quoth martin f krafft:
> also sprach Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx> [2008.09.23.1523 +0200]:
>> Not really, because it's impossible to know which hooks "apply". 
>> Hooks are associated with actions, not with states. The send-hook 
>> applies whenever you attempt to *send* a message, the message-hook 
>> applies whenever you attempt to *view* a message, and so forth. If 
>> you are currently sending a message, but are relying on a setting 
>> that was set by viewing a message (or perhaps are relying on the 
>> fact that the last message you sent triggered a hook), how is mutt 
>> to know?
>
> It could pretend that it's reopening the folder, or reviewing 
> a message, or restarting the composing of an email, etc.

Since *you* know which of those hooks are important, *you* can tell it 
to do that. Something I do a lot in my pager macros is the 
<exit><display-message> combo, which (as it happens) will re-trigger 
any hooks involved in viewing that particular message and doesn't 
require an extra screen redraw (i.e. it doesn't ever actually display 
the index). Something else you could try (from the pager) would be 
this:

     <exit><change-folder>^<enter><display-message>

You may have to do some extra work to make sure that the message you 
display is the same one that you're currently on, but that would 
reopen the folder and review the message.

But Rocco is absolutely right: many people build up a bit of a history 
with their hook settings *intentionally*, and figuring out the exact 
history would require, at minimum, re-triggering every hook that's 
been triggered (and maintaining all the message state) since mutt 
began.

For example, imagine that I had the following in my muttrc:

     set sendmail=oldsendmail
     message-hook '=b foo' 'set sendmail=newsendmail'

After you've been running mutt for a while, you now want to re-trigger 
all the hooks that "apply". So here's the question: what should the 
value of $sendmail be, and how can mutt ensure that it's correct? 
Notice that I didn't say whether you'd read a message that had foo in 
the body... is that important? How is mutt to know whether you've read 
a message that had foo in the body since mutt was first launched?

Let's add another twist:

     set sendmail=oldsendmail
     send-hook . 'set sendmail=newsendmail'
     message-hook '=b foo' 'unhook send-hook'
     message-hook '=b bar' 'send-hook "=b foo" "set sendmail=oldsendmail"'

NOW what is the correct value of $sendmail? How much state does mutt 
have to remember in order to figure out the correct value?

And we're not even considering issues like Rocco brought up, such as:

     send-hook . 'source genconfig.sh|'

~Kyle
- -- 
No one loves armed missionaries.
                                              -- Maximilien Robespierre
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkjaTW4ACgkQBkIOoMqOI15nbACdHD/mdG6QnMhH5WX76OD/IDAQ
jPkAoLoUN8ioWdzLSLIncLTYlBkqoGWx
=hkeH
-----END PGP SIGNATURE-----