From e78540990496cb3f4ff611c680b005022d9d2fad Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 19 Jun 2022 16:41:15 -0500 Subject: [PATCH] binds: add folder context for message list binds Add option to specify folder-specific binds for message lists. The binds are layered: any existing binds in [messages] are overwritten by a more specific bind in say, [messages:folder=Drafts]. The order is currently: [messages] < [messages:account=] < [messages:folder=] Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- config/config.go | 5 +++++ doc/aerc-config.5.scd | 10 ++++++++++ widgets/aerc.go | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index dae32b7..6410632 100644 --- a/config/config.go +++ b/config/config.go @@ -72,6 +72,7 @@ const ( UI_CONTEXT_ACCOUNT UI_CONTEXT_SUBJECT BIND_CONTEXT_ACCOUNT + BIND_CONTEXT_FOLDER ) type UIConfigContext struct { @@ -910,6 +911,10 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup continue } contextualBind.ContextType = BIND_CONTEXT_ACCOUNT + case "folder": + // No validation needed. If the folder doesn't exist, the binds + // never get used + contextualBind.ContextType = BIND_CONTEXT_FOLDER default: return fmt.Errorf("Unknown Context Bind Section: %s", sectionName) } diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 47ae752..9f61b94 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -701,12 +701,22 @@ You may also configure account specific key bindings for each context: keybindings for this context and account, where matches the account name you provided in *accounts.conf*. +Folder-specific bindings can be configured for message lists: + +*[messages:folder=]* + keybindings under this section will be specific to the folder named + . Keybindings from a *folder* specifier will take precedence + over *account* specifiers + Example: ``` [messages:account=Mailbox] c = :cf path:mailbox/** and [compose::editor:account=Mailbox2] + +[messages:folder=Drafts] + = :recall ... ``` diff --git a/widgets/aerc.go b/widgets/aerc.go index 8339180..53d5944 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -194,7 +194,8 @@ func (aerc *Aerc) getBindings() *config.KeyBindings { } switch view := aerc.SelectedTab().(type) { case *AccountView: - return aerc.conf.MergeContextualBinds(aerc.conf.Bindings.MessageList, config.BIND_CONTEXT_ACCOUNT, selectedAccountName, "messages") + binds := aerc.conf.MergeContextualBinds(aerc.conf.Bindings.MessageList, config.BIND_CONTEXT_ACCOUNT, selectedAccountName, "messages") + return aerc.conf.MergeContextualBinds(binds, config.BIND_CONTEXT_FOLDER, view.SelectedDirectory(), "messages") case *AccountWizard: return aerc.conf.Bindings.AccountWizard case *Composer: