Skip to content

Commit

Permalink
complete: allow disabling automatic completion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rjarry committed Nov 2, 2023
1 parent 44a55d4 commit 0b0095e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/aerc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion config/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"bytes"
"fmt"
"math"
"path"
"regexp"
"strconv"
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions doc/aerc-config.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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>"_++
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0b0095e

Please sign in to comment.