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=<account>] < [messages:folder=<folder>] Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
7aa71d334b
commit
e785409904
|
@ -72,6 +72,7 @@ const (
|
||||||
UI_CONTEXT_ACCOUNT
|
UI_CONTEXT_ACCOUNT
|
||||||
UI_CONTEXT_SUBJECT
|
UI_CONTEXT_SUBJECT
|
||||||
BIND_CONTEXT_ACCOUNT
|
BIND_CONTEXT_ACCOUNT
|
||||||
|
BIND_CONTEXT_FOLDER
|
||||||
)
|
)
|
||||||
|
|
||||||
type UIConfigContext struct {
|
type UIConfigContext struct {
|
||||||
|
@ -910,6 +911,10 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
contextualBind.ContextType = BIND_CONTEXT_ACCOUNT
|
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:
|
default:
|
||||||
return fmt.Errorf("Unknown Context Bind Section: %s", sectionName)
|
return fmt.Errorf("Unknown Context Bind Section: %s", sectionName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,12 +701,22 @@ You may also configure account specific key bindings for each context:
|
||||||
keybindings for this context and account, where <AccountName> matches
|
keybindings for this context and account, where <AccountName> matches
|
||||||
the account name you provided in *accounts.conf*.
|
the account name you provided in *accounts.conf*.
|
||||||
|
|
||||||
|
Folder-specific bindings can be configured for message lists:
|
||||||
|
|
||||||
|
*[messages:folder=<FolderName>]*
|
||||||
|
keybindings under this section will be specific to the folder named
|
||||||
|
<FolderName>. Keybindings from a *folder* specifier will take precedence
|
||||||
|
over *account* specifiers
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```
|
```
|
||||||
[messages:account=Mailbox]
|
[messages:account=Mailbox]
|
||||||
c = :cf path:mailbox/** and<space>
|
c = :cf path:mailbox/** and<space>
|
||||||
|
|
||||||
[compose::editor:account=Mailbox2]
|
[compose::editor:account=Mailbox2]
|
||||||
|
|
||||||
|
[messages:folder=Drafts]
|
||||||
|
<Enter> = :recall<Enter>
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,8 @@ func (aerc *Aerc) getBindings() *config.KeyBindings {
|
||||||
}
|
}
|
||||||
switch view := aerc.SelectedTab().(type) {
|
switch view := aerc.SelectedTab().(type) {
|
||||||
case *AccountView:
|
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:
|
case *AccountWizard:
|
||||||
return aerc.conf.Bindings.AccountWizard
|
return aerc.conf.Bindings.AccountWizard
|
||||||
case *Composer:
|
case *Composer:
|
||||||
|
|
Loading…
Reference in New Issue