aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Ovchinnikov <v@ovch.ru>2023-10-30 15:35:59 +0000
committerRobin Jarry <robin@jarry.cc>2023-11-02 11:59:39 +0100
commitfb8e60c041d7b4a61e5862d6bce6fd3bd8fca000 (patch)
tree7ca068423a22492126290e5c1922d4532f184303
parent4bd93fccbf18a855016bd26a3ec8cd9ca7cf5600 (diff)
downloadaerc-fb8e60c041d7b4a61e5862d6bce6fd3bd8fca000.tar.gz
binds: folder-specific bindings for composer
Add folder-specific bindings for composer, so custom binginds might be specified for a composer opened in a given folder. Changlelog-Added: `[compose::editor:folder=$name]` binding context. Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--app/aerc.go8
-rw-r--r--app/compose.go7
-rw-r--r--doc/aerc-binds.5.scd10
3 files changed, 20 insertions, 5 deletions
diff --git a/app/aerc.go b/app/aerc.go
index f51aa242..046c7871 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -243,17 +243,19 @@ func (aerc *Aerc) getBindings() *config.KeyBindings {
case *AccountWizard:
return config.Binds.AccountWizard
case *Composer:
+ var binds *config.KeyBindings
switch view.Bindings() {
case "compose::editor":
- return config.Binds.ComposeEditor.ForAccount(
+ binds = config.Binds.ComposeEditor.ForAccount(
selectedAccountName)
case "compose::review":
- return config.Binds.ComposeReview.ForAccount(
+ binds = config.Binds.ComposeReview.ForAccount(
selectedAccountName)
default:
- return config.Binds.Compose.ForAccount(
+ binds = config.Binds.Compose.ForAccount(
selectedAccountName)
}
+ return binds.ForFolder(view.SelectedDirectory())
case *MessageViewer:
switch view.Bindings() {
case "view::passthrough":
diff --git a/app/compose.go b/app/compose.go
index 101a5765..9ab8206b 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -42,6 +42,7 @@ type Composer struct {
acctConfig *config.AccountConfig
acct *AccountView
+ seldir string
attachments []lib.Attachment
editor *Terminal
@@ -92,6 +93,7 @@ func NewComposer(
c := &Composer{
acct: acct,
acctConfig: acctConfig,
+ seldir: acct.Directories().Selected(),
header: h,
parent: orig,
email: email,
@@ -127,6 +129,10 @@ func NewComposer(
return c, nil
}
+func (c *Composer) SelectedDirectory() string {
+ return c.seldir
+}
+
func (c *Composer) SwitchAccount(newAcct *AccountView) error {
if c.acct == newAcct {
log.Tracef("same accounts: no switch")
@@ -1682,6 +1688,7 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
bindings := config.Binds.ComposeReview.ForAccount(
composer.acctConfig.Name,
)
+ bindings = bindings.ForFolder(composer.SelectedDirectory())
reviewCommands := [][]string{
{":send<enter>", "Send", ""},
diff --git a/doc/aerc-binds.5.scd b/doc/aerc-binds.5.scd
index f3e44574..228c6cd1 100644
--- a/doc/aerc-binds.5.scd
+++ b/doc/aerc-binds.5.scd
@@ -61,9 +61,12 @@ You may also configure account specific key bindings for each context:
keybindings for this context and account, where _AccountName_ is a
regular expression that matches the account name you provided in _accounts.conf_.
-Folder-specific bindings can be configured for message lists:
+Folder and context-specific bindings can be configured for message lists:
-*[messages:folder=*_FolderName_*]*
+*[messages:folder=*_FolderName_*]*++
+*[compose:folder=*_FolderName_*]*++
+*[compose::editor:folder=*_FolderName_*]*++
+*[compose::review:folder=*_FolderName_*]*
keybindings under this section will be specific to the folder that
matches the regular expression _FolderName_.
Keybindings from a folder specifier will take precedence over account specifiers
@@ -76,6 +79,9 @@ c = :cf path:mailbox/** and<space>
[compose::editor:account=Mailbox2]
+[compose::editor:folder=aerc]
+y = :send -t aerc
+
[messages:folder=Drafts]
<Enter> = :recall<Enter>