aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/templates.go6
-rw-r--r--doc/aerc-templates.7.scd11
-rw-r--r--lib/state/templates.go19
-rw-r--r--models/templates.go6
4 files changed, 27 insertions, 15 deletions
diff --git a/config/templates.go b/config/templates.go
index f9dda0ea..3fce9857 100644
--- a/config/templates.go
+++ b/config/templates.go
@@ -101,6 +101,6 @@ func (d *dummyData) OriginalDate() time.Time { return time.Now() }
func (d *dummyData) OriginalFrom() []*mail.Address { return d.From() }
func (d *dummyData) OriginalMIMEType() string { return "text/plain" }
func (d *dummyData) OriginalHeader(string) string { return "" }
-func (d *dummyData) Recent() int { return 1 }
-func (d *dummyData) Unread() int { return 3 }
-func (d *dummyData) Exists() int { return 14 }
+func (d *dummyData) Recent(...string) int { return 1 }
+func (d *dummyData) Unread(...string) int { return 3 }
+func (d *dummyData) Exists(...string) int { return 14 }
diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd
index f5998b23..5f208067 100644
--- a/doc/aerc-templates.7.scd
+++ b/doc/aerc-templates.7.scd
@@ -148,11 +148,20 @@ available always.
{{.Folder}}
```
- Current message counts
+ Current message counts for all folders:
+
```
{{.Recent}} {{.Unread}} {{.Exists}}
```
+ Current message counts for specific folders:
+
+ ```
+ {{.Recent "inbox"}}
+ {{.Unread "inbox" "aerc/pending"}}
+ {{.Exists "archive" "spam" "foo/baz" "foo/bar"}}
+ ```
+
# TEMPLATE FUNCTIONS
Besides the standard functions described in go's text/template documentation,
diff --git a/lib/state/templates.go b/lib/state/templates.go
index fdf662c5..b199cf25 100644
--- a/lib/state/templates.go
+++ b/lib/state/templates.go
@@ -324,10 +324,13 @@ func (d *TemplateData) OriginalHeader(name string) string {
return text
}
-func (d *TemplateData) rue() (int, int, int) {
+func (d *TemplateData) rue(folders ...string) (int, int, int) {
var recent, unread, exists int
if d.getRUEcount != nil {
- for _, dir := range d.folders {
+ if len(folders) == 0 {
+ folders = d.folders
+ }
+ for _, dir := range folders {
r, u, e := d.getRUEcount(dir)
recent += r
unread += u
@@ -337,17 +340,17 @@ func (d *TemplateData) rue() (int, int, int) {
return recent, unread, exists
}
-func (d *TemplateData) Recent() int {
- r, _, _ := d.rue()
+func (d *TemplateData) Recent(folders ...string) int {
+ r, _, _ := d.rue(folders...)
return r
}
-func (d *TemplateData) Unread() int {
- _, u, _ := d.rue()
+func (d *TemplateData) Unread(folders ...string) int {
+ _, u, _ := d.rue(folders...)
return u
}
-func (d *TemplateData) Exists() int {
- _, _, e := d.rue()
+func (d *TemplateData) Exists(folders ...string) int {
+ _, _, e := d.rue(folders...)
return e
}
diff --git a/models/templates.go b/models/templates.go
index 84f68c21..bdc93b9c 100644
--- a/models/templates.go
+++ b/models/templates.go
@@ -30,7 +30,7 @@ type TemplateData interface {
OriginalFrom() []*mail.Address
OriginalMIMEType() string
OriginalHeader(name string) string
- Recent() int
- Unread() int
- Exists() int
+ Recent(folders ...string) int
+ Unread(folders ...string) int
+ Exists(folders ...string) int
}