aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-05-10 23:56:30 +0200
committerRobin Jarry <robin@jarry.cc>2023-05-16 13:41:36 +0200
commitbbb9b0695e1b8a0962423f5223a4b559b4ef02f6 (patch)
tree7f56564d1a2ad1c3ce3889ca4451d9f749e47c68 /commands
parent9c3f12379b34dd86b1208a8aa6e1e458b4f883c5 (diff)
downloadaerc-bbb9b0695e1b8a0962423f5223a4b559b4ef02f6.tar.gz
search/filter: update completion
Update the completion system by implementing the OptionsProvider and OptionComleter interfaces. The command flags that expect arguments can be completed now: -x,-X with the available flags, -t,-f,-c with the address book (after more then 3 characters), -d with a selected suggestion for useful dates. Examples: :filter -<Tab> lists the available option flags :filter -t org<Tab> fills the completion menu with address from your address-book-cmd matching "org" (same with -f and -c) :filter -x <Tab> lists the available flags (same with -X) :filter -d <Tab> lists a few convenient date terms Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands')
-rw-r--r--commands/account/search.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/commands/account/search.go b/commands/account/search.go
index 71833afd..d7884f15 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -4,6 +4,7 @@ import (
"errors"
"strings"
+ "git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib/state"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
@@ -17,10 +18,32 @@ func init() {
register(SearchFilter{})
}
+func (SearchFilter) Options() string {
+ return "rubax:X:t:H:f:c:d:"
+}
+
func (SearchFilter) Aliases() []string {
return []string{"search", "filter"}
}
+func (s SearchFilter) CompleteOption(
+ aerc *widgets.Aerc,
+ r rune,
+ search string,
+) []string {
+ var valid []string
+ switch r {
+ case 'x', 'X':
+ valid = commands.GetFlagList()
+ case 't', 'f', 'c':
+ valid = commands.GetAddress(aerc, search)
+ case 'd':
+ valid = commands.GetDateList()
+ default:
+ }
+ return commands.CompletionFromList(aerc, valid, []string{search})
+}
+
func (SearchFilter) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
}