Trigger account-hook when changing between mailboxes of different accounts #4103
thyssentishman
started this conversation in
Development
Replies: 2 comments
-
Would parsing $folder from both mailboxes' realpath be enough? |
Beta Was this translation helpful? Give feedback.
0 replies
-
What about something like this: diff --git a/index/dlg_index.c b/index/dlg_index.c
index 4bb52760f..dcd1213dd 100644
--- a/index/dlg_index.c
+++ b/index/dlg_index.c
@@ -672,6 +672,10 @@ void change_folder_mailbox(struct Menu *menu, struct Mailbox *m, int *oldcount,
char *dup_path = mutt_str_dup(mailbox_path(m));
char *dup_name = mutt_str_dup(m->name);
+ const char *const c_folder = cs_subset_string(shared->sub, "folder");
+ if (!mutt_regex_match(mutt_regex_new(c_folder, 0, NULL), dup_path))
+ mutt_account_hook(dup_path);
+
mutt_folder_hook(dup_path, dup_name);
if (m)
{ This compares the
Multi-account setups using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Following a discussion about folder-hook vs account-hook on IRC, I'd like to suggest having the account-hook be triggered when changing between mailboxes of different accounts.
From the account-hook entry in the manual:
The "not just" in the above sentence kind of implies that the account-hook is basically a folder-hook plus the extra stuff. However from reading the code base, I believe the account-hook is not actually triggered when changing between mailboxes, but only by the following events (might be incomplete):
In a multi-account setup where
unmailboxes *
is used when switching between accounts this is perfectly enough, since on every switch the mailboxes of the account being switched to are opened and therefore the account-hook is triggered. However in other multi-account setups whereunmailboxes *
is not used and all mailboxes from all accounts are kept open, the account-hook is not triggered when switching accounts (that is when switching from e.g. mailbox account1/INBOX to account2/INBOX). A workaround is to rely on the folder hook, but then the hook is unnecessarily triggered even when switching between mailboxes of the same account and we lose the other benefits of the account hook. Another option is to call the account hook when changing between any mailboxes, but then it would pretty much do everything the folder hook does and more, making the folder hook redundant. The only alternative that I think makes sense and allows for both the folder and account hook to coexist, is to also trigger the account hook when changing between mailboxes of different accounts.I'd very much like to help implement this. I think it should be as trivial as comparing the current and new mailbox and checking if the accounts they belong to match or not. If not, then we call the account-hook here. I've started fiddling with the code already, but I'm unsure about how to go about differentiating between accounts purely based on the mailbox. For imap mailboxes, comparing host urls should be enough, but for other/local mailboxes?
Beta Was this translation helpful? Give feedback.
All reactions