diff options
author | Bence Ferdinandy <bence@ferdinandy.com> | 2023-11-22 11:54:22 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-11-23 00:14:54 +0100 |
commit | 91b26ad93f93743f3222515755d688e5864d61bd (patch) | |
tree | a70e3c0527f79f38915f1fe641977b175b8bdf14 /commands/account/view.go | |
parent | 019a1a5813fc30440fb8c552b9e03dfe8d5d5d17 (diff) | |
download | aerc-91b26ad93f93743f3222515755d688e5864d61bd.tar.gz |
ui: make viewer tab title configurable via templates
We had account and composer tab title configuration fields already, but
not for viewer. Add tab-title-viewer configuration, which defaults to
Subject if it is not empty and to "(no subject)" when it is empty.
Changelog-added: New `[ui].tab-title-viewer` setting to configure the
message viewer tab title.
Changelog-changed: Message viewer tab titles will now show `(no subject)`
if there is no subject in the viewed email.
Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/account/view.go')
-rw-r--r-- | commands/account/view.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/commands/account/view.go b/commands/account/view.go index 0cdc175d..87705a1a 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -1,10 +1,14 @@ package account import ( + "bytes" "errors" "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib" + "git.sr.ht/~rjarry/aerc/lib/state" + "git.sr.ht/~rjarry/aerc/lib/templates" + "git.sr.ht/~rjarry/aerc/models" ) type ViewMessage struct { @@ -48,7 +52,18 @@ func (v ViewMessage) Execute(args []string) error { return } viewer := app.NewMessageViewer(acct, view) - app.NewTab(viewer, msg.Envelope.Subject) + data := state.NewDataSetter() + data.SetAccount(acct.AccountConfig()) + data.SetFolder(acct.Directories().SelectedDirectory()) + data.SetHeaders(msg.RFC822Headers, &models.OriginalMail{}) + var buf bytes.Buffer + err = templates.Render(acct.UiConfig().TabTitleViewer, &buf, + data.Data()) + if err != nil { + acct.PushError(err) + return + } + app.NewTab(viewer, buf.String()) }) return nil } |