diff options
author | Robin Jarry <robin@jarry.cc> | 2023-08-12 00:51:41 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-11-02 16:30:57 +0100 |
commit | 0b0095eeadaf7645b731f277c06e3f19e63ea981 (patch) | |
tree | d299d8b6a9b234eb3f2f7e0d7d9ec6b49838fb80 | |
parent | 44a55d41ad6b5c61c75456414e13aec94b367b02 (diff) | |
download | aerc-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>
-rw-r--r-- | config/aerc.conf | 4 | ||||
-rw-r--r-- | config/ui.go | 12 | ||||
-rw-r--r-- | doc/aerc-config.5.scd | 4 | ||||
-rw-r--r-- | lib/ui/textinput.go | 4 |
4 files changed, 23 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) { diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 34bfb882..ef35fd12 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -283,6 +283,10 @@ These options are configured in the *[ui]* section of _aerc.conf_. 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_ *border-char-vertical* = _"<char>"_++ diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go index 4b051d88..d1d46045 100644 --- a/lib/ui/textinput.go +++ b/lib/ui/textinput.go @@ -308,6 +308,10 @@ func (ti *TextInput) updateCompletions() { // no completer return } + if ti.completeMinChars == config.MANUAL_COMPLETE { + // only manually triggered completion + return + } if ti.completeDebouncer == nil { ti.completeDebouncer = time.AfterFunc(ti.completeDelay, func() { defer log.PanicHandler() |