On 26Sep2015 08:00, Cameron Simpson <c...@zip.com.au> wrote:
The muttrc is read just once at startup. It looks like you want to source your per-domain files on folder switch. I'd be inclined to prepend "set imap_user = p...@domain1.com" to your muttrc.domain1.com file, and write the hooks like this:

account-hook imaps://em...@domain1.com@imap.localdomain.com 'source 
~/.mutt/muttrc.domain1.com'
account-hook imaps://em...@domain2.com@imap.localdomain.com 'source 
~/.mutt/muttrc.domain2.com'

and so forth. That way the _entire_ domainX.com setup is sources on folder 
switch.

I've been doing some tests (and swanking up my muttrc config). And reading the Fine Manual:

 http://www.mutt.org/doc/devel/manual.html#account-hook

It seems that the account-hooks are only consulted when mutt needs to access a remote folder (IMAP, etc). It is consulted not just when you visit an IMAP folder but also whe mutt polls a remote folder, etc. So anything in an account-hook might be run at any time, depending on your config.

By contrast the folder-hooks are used reliably for every folder entry.

So I've now got the following in my setup (somewhat edited here):

 set my_cs='c...@zip.com.au'
 set my_cs_iphone='email-which-delivers-to-my-phone@blah'
 set my_cs_clipboard='email-which-delivers-a-shared-folder@glargh'
 set my_local_mail="$HOME/mail"

 folder-hook . 'set my_account_email=$my_cs; set folder=$my_local_mail'
 folder-hook 'imaps://my-phone-imap/' 'set my_account_email=$my_cs_iphone'
 folder-hook 'imaps://the-clipboard-imap/' 'set 
my_account_email=$my_cs_clipboard'
 folder-hook . 'set status_format="$my_account_email [Msgs:%?M?%M/?%m%?n?  New:%n?%?o? 
Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b?  Inc:%b?%?l? 
%l?]---(%s/%S)-%>-(%P)"'

 account-hook . 'unset imap_user; unset imap_pass; unset tunnel'
 account-hook 'imaps://my-phone-imap/' 'source "cs-mutt-imap-settings cs-iphone-cc 
|"'
 account-hook 'imaps://the-clipboard-imap/' 'source "cs-mutt-imap-settings clipboard 
|"'

The folder-hooks run on every folder entry, including the last one which sets a per-folder $status_format. The account-* files set only usernames and passwords, sucked from my .fetchmailrc.

You might find it useful to move your status_format into folder-hooks and keep the account-hooks purely for passwords.

Cheers,
Cameron Simpson <c...@zip.com.au>

Reply via email to