diff options
author | Koni Marti <koni.marti@gmail.com> | 2024-08-23 11:16:41 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-08-24 15:49:17 +0200 |
commit | f07038bd98de5282703cd80c32959e58a47da86b (patch) | |
tree | f2cc85e41d9adf163aebfbddd391bd532e790b14 /app | |
parent | 7346d20343b9fa8b192c9a5294b26efac9186c4f (diff) | |
download | aerc-f07038bd98de5282703cd80c32959e58a47da86b.tar.gz |
patch: add auto-switch option
Add an auto-switch option that changes the project of the patch manager
based on the subject line of a message if it contains a '[PATCH
<project>]' segment.
A subject line with '[PATCH aerc v2]' would switch to the 'aerc' project
if that project is available in the patch manager.
The auto switching can be activated per account by adding
'pama-auto-switch = true' to your account config.
Implements: https://todo.sr.ht/~rjarry/aerc/226
Changelog-added: Auto-switch projects based on the message subject
for the :patch command.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app')
-rw-r--r-- | app/account.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/account.go b/app/account.go index 7a2cf582..5577e461 100644 --- a/app/account.go +++ b/app/account.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "strings" "sync" "time" @@ -12,6 +13,7 @@ import ( "git.sr.ht/~rjarry/aerc/lib/hooks" "git.sr.ht/~rjarry/aerc/lib/log" "git.sr.ht/~rjarry/aerc/lib/marker" + "git.sr.ht/~rjarry/aerc/lib/pama" "git.sr.ht/~rjarry/aerc/lib/sort" "git.sr.ht/~rjarry/aerc/lib/state" "git.sr.ht/~rjarry/aerc/lib/templates" @@ -337,7 +339,27 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore { PushError(msg) } }, - acct.updateSplitView, + func(msg *models.MessageInfo) { + acct.updateSplitView(msg) + + auto := false + if c := acct.AccountConfig(); c != nil { + r, ok := c.Params["pama-auto-switch"] + if ok { + if strings.ToLower(r) == "true" { + auto = true + } + } + } + if !auto { + return + } + var name string + if msg != nil && msg.Envelope != nil { + name = pama.FromSubject(msg.Envelope.Subject) + } + pama.DebouncedSwitchProject(name) + }, ) store.Configure(acct.SortCriteria(uiConf)) store.SetMarker(marker.New(store)) |