aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-07 00:02:47 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-08 00:42:58 +0100
commit66c532f859dd477ce57e222107c6b371e66064b8 (patch)
tree215d74f96cc1442cef496663dd266af5adf5926c
parent35040bec9962cac3c92039fac85a4068e148b0a0 (diff)
downloadaerc-66c532f859dd477ce57e222107c6b371e66064b8.tar.gz
templates: make SubjectBase official api
Document .SubjectBase. Fix its value along the way. Do not reuse d.Subject() which may be empty if d.threadSameSubject is true. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
-rw-r--r--config/templates.go1
-rw-r--r--doc/aerc-templates.7.scd6
-rw-r--r--lib/state/templates.go9
-rw-r--r--models/templates.go1
4 files changed, 16 insertions, 1 deletions
diff --git a/config/templates.go b/config/templates.go
index 96fbccb1..98be7781 100644
--- a/config/templates.go
+++ b/config/templates.go
@@ -76,6 +76,7 @@ func (d *dummyData) DateAutoFormat(time.Time) string { return "" }
func (d *dummyData) Header(string) string { return "" }
func (d *dummyData) ThreadPrefix() string { return "└─>" }
func (d *dummyData) Subject() string { return "Re: [PATCH] hey" }
+func (d *dummyData) SubjectBase() string { return "[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/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd
index 63d9df6a..8a2a3381 100644
--- a/doc/aerc-templates.7.scd
+++ b/doc/aerc-templates.7.scd
@@ -83,6 +83,12 @@ available always.
{{.ThreadPrefix}}{{.Subject}}
```
+ The subject of the email stripped of any _Re:_ and _Fwd:_ prefixes.
+
+ ```
+ {{.SubjectBase}}
+ ```
+
*Flags*
List of message flags, not available when composing, replying nor
forwarding. This is a list of strings that may be converted to a single
diff --git a/lib/state/templates.go b/lib/state/templates.go
index 2e351a7a..b5a5ee05 100644
--- a/lib/state/templates.go
+++ b/lib/state/templates.go
@@ -244,7 +244,14 @@ func (d *TemplateData) Subject() string {
}
func (d *TemplateData) SubjectBase() string {
- base, _ := sortthread.GetBaseSubject(d.Subject())
+ var subject string
+ switch {
+ case d.info != nil && d.info.Envelope != nil:
+ subject = d.info.Envelope.Subject
+ case d.headers != nil:
+ subject = d.Header("subject")
+ }
+ base, _ := sortthread.GetBaseSubject(subject)
return base
}
diff --git a/models/templates.go b/models/templates.go
index 5ee516ac..54537a31 100644
--- a/models/templates.go
+++ b/models/templates.go
@@ -21,6 +21,7 @@ type TemplateData interface {
Header(name string) string
ThreadPrefix() string
Subject() string
+ SubjectBase() string
Number() int
Labels() []string
Flags() []string