** Paul Tansom <p...@aptanet.com> [2015-09-26 17:43]:
> ** Cameron Simpson <c...@zip.com.au> [2015-09-26 12:58]:
> > 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.
> ** end quote [Cameron Simpson]
> 
> Looks interesting, I'll have to explore further. I've been tidying my config 
> too. Initially removed some folder-hook lines at the bottom that seemed to 
> duplicate everything that was in the source files for my account-hook lines 
> (a legacy from earlier configs I think). Having looked at your previous email 
> I experimented with moving the imap_user into the source'd file and it did 
> allow the config to modify the status_format.
> 
> There were a few downsides to this:
> 
> Firstly, the tab completion of the accounts when changing directory vanished; 
> I used to be able to start with im for imaps:// and tab complete from there.
> 
> Secondly, once all accounts were modified it stalled on sorting mail; this 
> was fixed by putting an imap_user in for the default account.
> 
> Thirdly, once I manually type account details in (imaps://... etc.) and 
> switch to a different account the performance nose dives and everything 
> pauses before each action, even when I switch back to the main account 
> performance is poor - likely due to the fact that using = hasn't switch to 
> referring to the main account. I've also just noticed I've lost my signature.
> 
> Clearly this needs more work, and I'm learning quite a bit in the process. It 
> is amazing how long you can get along using some software without fully 
> understanding everything about it. I started using Mutt back in 2001 I think.
** end quote [Paul Tansom]

I think I've got it sorted. I've had a bit of fun with my muttrc and will
probably experiment further as I'm sure I could tidy and improve things more.

My account-hook lines now just have the imap_user line with them and everything
else that was in the file sourced has moved to matching folder-hook lines. For
a while I had these in separate files linked using a source entry, but in the
end I moved the account-hook line into my main muttrc and left the rest of the
configuration in the sourced file. I suspect I might be able to put things back
the way they were since the reason I tried that change has been solved by
another modification - namely putting all my mailbox lines into a single file
that is sourced higher up the main muttrc. That said, with the folder-hook
within the source'd files I did find I had problems with multiple timeouts of
the connection to the IMAP server, so I'm not rushing to play with this. This
means I can tab complete and cycle through folders easily; when these were in
the individual files for the folder-hooks they weren't read until the account
was accessed. The other thing I've done is put a default spoolfile and folder
line in the main muttrc because all my accounts use IMAP so without these mutt
tries to use a local mailbox that doesn't exist.

Everything now seems to be working as it was, but with the aditional indication
of which account I'm in. Looking at your config above I think I can improve
things with some use of variables, but I'll have to experiment a bit to see how
generic I can make the config.

The only other thing I've done is start all my config files with muttrc_. They
are already in a .muttrc folder, but using muttrc_colours, muttrc_mailboxes,
etc. and not using .'s in my file names (i.e. not having them ending in .com
for my .com domains) means I get proper syntax highlighting in vim - not a mutt
issue, but made things easier for me once I'd made the changes to all
references!

Thanks for the help.

-- 
 Paul Tansom  |  Aptanet Ltd.  |  https://www.aptanet.com/  |  023 9238 0001
 Vice Chair, FSB Portsmouth & SE Hampshire Branch  |  http://www.fsb.org.uk/
=============================================================================
Registered in England | Company No: 4905028 | Registered Office: Ralls House,
Parklands Business Park, Forrest Road, Denmead, Waterlooville, Hants, PO7 6XP

Reply via email to