From 35040bec9962cac3c92039fac85a4068e148b0a0 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 3 Mar 2023 17:37:05 +0100 Subject: templates: separate thread prefix from subject Extract {{.ThreadPrefix}} from {{.Subject}} so that the prefix can be styled in a different color. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- config/aerc.conf | 2 +- config/templates.go | 3 ++- config/ui.go | 4 ++-- config/ui_test.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/aerc.conf b/config/aerc.conf index 9d1f120e..cb6e8649 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -63,7 +63,7 @@ #column-date={{.DateAutoFormat .Date.Local}} #column-name={{index (.From | names) 0}} #column-flags={{.Flags | join ""}} -#column-subject={{.Subject}} +#column-subject={{.ThreadPrefix}}{{.Subject}} # # String separator inserted between columns. When the column width specifier is diff --git a/config/templates.go b/config/templates.go index d3e7cfb0..96fbccb1 100644 --- a/config/templates.go +++ b/config/templates.go @@ -74,7 +74,8 @@ func (d *dummyData) ReplyTo() []*mail.Address { return nil } func (d *dummyData) Date() time.Time { return time.Now() } func (d *dummyData) DateAutoFormat(time.Time) string { return "" } func (d *dummyData) Header(string) string { return "" } -func (d *dummyData) Subject() string { return "[PATCH] hey" } +func (d *dummyData) ThreadPrefix() string { return "└─>" } +func (d *dummyData) Subject() string { return "Re: [PATCH] hey" } func (d *dummyData) Number() int { return 0 } func (d *dummyData) Labels() []string { return nil } func (d *dummyData) Flags() []string { return nil } diff --git a/config/ui.go b/config/ui.go index f52cf7f8..4b2a303a 100644 --- a/config/ui.go +++ b/config/ui.go @@ -284,7 +284,7 @@ func (*UIConfig) ParseIndexColumns(section *ini.Section, key *ini.Key) ([]*Colum _, _ = section.NewKey("column-flags", `{{.Flags | join ""}}`) } if !section.HasKey("column-subject") { - _, _ = section.NewKey("column-subject", `{{.Subject}}`) + _, _ = section.NewKey("column-subject", `{{.ThreadPrefix}}{{.Subject}}`) } return ParseColumnDefs(key, section) } @@ -382,7 +382,7 @@ func indexVerbToTemplate(verb rune) (f, name string) { f = `{{.Cc | persons | join ", "}}` name = "cc" case 's': - f = "{{.Subject}}" + f = "{{.ThreadPrefix}}{{.Subject}}" name = "subject" case 't': f = "{{(index .To 0).Address}}" diff --git a/config/ui_test.go b/config/ui_test.go index 80373da2..188fae01 100644 --- a/config/ui_test.go +++ b/config/ui_test.go @@ -43,7 +43,7 @@ func TestConvertIndexFormat(t *testing.T) { assert.Equal(t, "subject", columns[3].Name) assert.Equal(t, 0.0, columns[3].Width) assert.Equal(t, ALIGN_LEFT|WIDTH_AUTO, columns[3].Flags) - assert.Equal(t, `{{.Subject}}`, templateText(columns[3].Template)) + assert.Equal(t, `{{.ThreadPrefix}}{{.Subject}}`, templateText(columns[3].Template)) } func TestConvertDirlistFormat(t *testing.T) { -- cgit