aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-08-12 00:51:41 +0200
committerRobin Jarry <robin@jarry.cc>2023-11-02 16:30:57 +0100
commit0b0095eeadaf7645b731f277c06e3f19e63ea981 (patch)
treed299d8b6a9b234eb3f2f7e0d7d9ec6b49838fb80 /config
parent44a55d41ad6b5c61c75456414e13aec94b367b02 (diff)
downloadaerc-0b0095eeadaf7645b731f277c06e3f19e63ea981.tar.gz
complete: allow disabling automatic completion
Allow setting complete-min-chars = manual to disable automatic completion. Changelog-added: Setting `complete-min-chars=manual` in `aerc.conf` now disables automatic completion, leaving only manually triggered completion. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'config')
-rw-r--r--config/aerc.conf4
-rw-r--r--config/ui.go12
2 files changed, 15 insertions, 1 deletions
diff --git a/config/aerc.conf b/config/aerc.conf
index d8142197..0dfab7fc 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -241,6 +241,10 @@
# The minimum required characters to allow auto-completion to be triggered after
# completion-delay.
#
+# Setting this to "manual" disables automatic completion, leaving only the
+# manually triggered completion with the $complete key (see aerc-binds(5) for
+# more details).
+#
# Default: 1
#completion-min-chars=1
diff --git a/config/ui.go b/config/ui.go
index 3b637278..17f2339f 100644
--- a/config/ui.go
+++ b/config/ui.go
@@ -3,6 +3,7 @@ package config
import (
"bytes"
"fmt"
+ "math"
"path"
"regexp"
"strconv"
@@ -66,7 +67,7 @@ type UIConfig struct {
Sort []string `ini:"sort" delim:" "`
NextMessageOnDelete bool `ini:"next-message-on-delete" default:"true"`
CompletionDelay time.Duration `ini:"completion-delay" default:"250ms"`
- CompletionMinChars int `ini:"completion-min-chars" default:"1"`
+ CompletionMinChars int `ini:"completion-min-chars" default:"1" parse:"ParseCompletionMinChars"`
CompletionPopovers bool `ini:"completion-popovers" default:"true"`
StyleSetDirs []string `ini:"stylesets-dirs" delim:":"`
StyleSetName string `ini:"styleset-name" default:"default"`
@@ -317,6 +318,15 @@ func (*UIConfig) ParseIndexColumns(section *ini.Section, key *ini.Key) ([]*Colum
return ParseColumnDefs(key, section)
}
+const MANUAL_COMPLETE = math.MaxInt
+
+func (*UIConfig) ParseCompletionMinChars(section *ini.Section, key *ini.Key) (int, error) {
+ if key.String() == "manual" {
+ return MANUAL_COMPLETE, nil
+ }
+ return key.Int()
+}
+
var indexFmtRegexp = regexp.MustCompile(`%(-?\d+)?(\.\d+)?([ACDFRTZadfgilnrstuv])`)
func convertIndexFormat(indexFormat string) ([]*ColumnDef, error) {