Question

In my configuration I have two online IMAP accounts, say A and B. My simplified configuration file looks like that:

## Account A settings
source ~/.mutt/a/config
folder-hook 'a.com' 'source ~/.mutt/a/config'

## Account B settings
folder-hook 'b.com' 'source ~/.mutt/b/config'

macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/a/config<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/b/config<enter><change-folder>!<enter>'

Configuration files of both accounts are similar and looks like this:

set imap_user = usera
set imap_pass = userasecret
unset folder
set folder    = "imaps://mail.a.com/"
set spoolfile = "+INBOX"
mailboxes "+INBOX"

and

set imap_user = userb
set imap_pass = userbsecret
unset folder
set folder    = "imaps://mail.b.com/"
set spoolfile = "+INBOX"
mailboxes "+INBOX"

I can switch between accounts using F2 nad F3 keys, but the problem is when I try to change the mailbox. At the beginning (i.e., before using F-key) pressing c? gives me the list of available IMAP folders. However, when I switch to the second account - by pressing F3 - and then try to list IMAP folders there is an error. Mutt try to fetch folders from the first server: imaps://mail.a.com and fails because of the wrong credentials (as imap_user is already set to userb). I have to wait a while, then press c again and change the directory name to the current folder variable value. After this operation I can list the folders again. Until the next switch...

Why is mutt sticking with the old directory path after changing the folder and how can I change this behaviour?

Was it helpful?

Solution

I don't know if you still care, but I found this solution:

With the above shortcuts (or with the sidebar) you will find that changing folders (with c by default) is not contextual, i.e. it will not list the folders of the current mailbox, but of the one used the last time you changed folders. To make the behaviour more contextual, the trick is to press = or + for current mailbox. You can automate this with the following macro:

macro index 'c' '<change-folder>?<change-dir><home>^K=<enter>'

See the website: https://wiki.archlinux.org/index.php/Mutt

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top