aboutsummaryrefslogtreecommitdiff
path: root/commands/account
diff options
context:
space:
mode:
Diffstat (limited to 'commands/account')
-rw-r--r--commands/account/cf.go6
-rw-r--r--commands/account/clear.go34
-rw-r--r--commands/account/search.go30
3 files changed, 61 insertions, 9 deletions
diff --git a/commands/account/cf.go b/commands/account/cf.go
index 6c928ea..2ebc294 100644
--- a/commands/account/cf.go
+++ b/commands/account/cf.go
@@ -34,14 +34,20 @@ func (_ ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
if acct == nil {
return errors.New("No account selected")
}
+ store := acct.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
previous := acct.Directories().Selected()
if args[1] == "-" {
if dir, ok := history[acct.Name()]; ok {
+ store.ApplyClear()
acct.Directories().Select(dir)
} else {
return errors.New("No previous folder to return to")
}
} else {
+ store.ApplyClear()
acct.Directories().Select(args[1])
}
history[acct.Name()] = previous
diff --git a/commands/account/clear.go b/commands/account/clear.go
new file mode 100644
index 0000000..bb9c04e
--- /dev/null
+++ b/commands/account/clear.go
@@ -0,0 +1,34 @@
+package account
+
+import (
+ "errors"
+ "git.sr.ht/~sircmpwn/aerc/widgets"
+)
+
+type Clear struct{}
+
+func init() {
+ register(Clear{})
+}
+
+func (_ Clear) Aliases() []string {
+ return []string{"clear"}
+}
+
+func (_ Clear) Complete(aerc *widgets.Aerc, args []string) []string {
+ return nil
+}
+
+func (_ Clear) Execute(aerc *widgets.Aerc, args []string) error {
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
+ store := acct.Store()
+ if store == nil {
+ return errors.New("Cannot perform action. Messages still loading")
+ }
+ store.ApplyClear()
+ aerc.SetStatus("Clear complete.")
+ return nil
+}
diff --git a/commands/account/search.go b/commands/account/search.go
index 0687c5b..da7ab03 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -16,7 +16,7 @@ func init() {
}
func (_ SearchFilter) Aliases() []string {
- return []string{"search"}
+ return []string{"search", "filter"}
}
func (_ SearchFilter) Complete(aerc *widgets.Aerc, args []string) []string {
@@ -54,13 +54,25 @@ func (_ SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
if store == nil {
return errors.New("Cannot perform action. Messages still loading")
}
- aerc.SetStatus("Searching...")
- store.Search(criteria, func(uids []uint32) {
- aerc.SetStatus("Search complete.")
- acct.Logger().Printf("Search results: %v", uids)
- store.ApplySearch(uids)
- // TODO: Remove when stores have multiple OnUpdate handlers
- acct.Messages().Scroll()
- })
+
+ var cb func([]uint32)
+ if args[0] == "filter" {
+ aerc.SetStatus("Filtering...")
+ cb = func(uids []uint32) {
+ aerc.SetStatus("Filter complete.")
+ acct.Logger().Printf("Filter results: %v", uids)
+ store.ApplyFilter(uids)
+ }
+ } else {
+ aerc.SetStatus("Searching...")
+ cb = func(uids []uint32) {
+ aerc.SetStatus("Search complete.")
+ acct.Logger().Printf("Search results: %v", uids)
+ store.ApplySearch(uids)
+ // TODO: Remove when stores have multiple OnUpdate handlers
+ acct.Messages().Scroll()
+ }
+ }
+ store.Search(criteria, cb)
return nil
}