aboutsummaryrefslogtreecommitdiffstats
path: root/completer/completer.go
Commit message (Collapse)AuthorAgeFilesLines
* logging: rename package to logRobin Jarry2022-12-021-6/+4
| | | | | | | | | | Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* address-book-cmd: be more lenient with errorsRobin Jarry2022-11-031-6/+14
| | | | | | | | | | | | | | Instead of failing completely when address-book-cmd returns an invalid line, ignore the line and report a warning in the logs. Do not wait for 100 "valid" addresses before bailing out as the command could only output garbage in large quantities. The issue of the command not printing any new line characters still exists. We could address this but I think it would be overkill. Reported-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* address-book-cmd: ignore completion above 100 itemsRobin Jarry2022-11-021-0/+17
| | | | | | | | | | | | | | | | | Avoid aerc from consuming all memory on the system if an address book command returns 12 million addresses. Read at most the first 100 lines and kill the command if it has not finished. Display a warning in the logs for good measure. The command is now assigned an different PGID (equal to its PID) to allow killing it *and* all of its children. When the address book command is a shell script that forks a process which never exits, it will avoid killing the shell process and leaving its children without parents. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* go: removed io/ioutilMoritz Poldrack2022-08-221-2/+1
| | | | | | | | | | Since the minimum required version of Go has been bumped to 1.16, the deprecation of io/ioutil can now be acted upon. This Commit removes the remaining dependencies on ioutil and replaces them with their io or os counterparts. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: work nicely with wrapped errors (errorlint)Moritz Poldrack2022-08-041-5/+6
| | | | | | | | Error wrapping as introduced in Go 1.13 adds some additional logic to use for comparing errors and adding information to it. Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: homogenize operations and minor fixes (gocritic)Moritz Poldrack2022-08-041-1/+1
| | | | | | | | | | | | | | | | | | Apply GoDoc comment policy (comments for humans should have a space after the //; machine-readable comments shouldn't) Use strings.ReplaceAll instead of strings.Replace when appropriate Remove if/else chains by replacing them with switches Use short assignment/increment notation Replace single case switches with if statements Combine else and if when appropriate Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: ensure errors are at least logged (errcheck)Moritz Poldrack2022-08-041-1/+1
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* completer: remove useless logger parameterRobin Jarry2022-07-171-11/+16
| | | | | | | Report the error to the user directly. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* completions: add support for completing multiple addressesParasrah2022-01-071-15/+28
| | | | | | | as per the discussion https://lists.sr.ht/~sircmpwn/aerc/patches/15367 this handles completions in `completer/completer.go` by enabling the completer to return a `prefix` that will be prepended to the selected completion candidate.
* Strip trailing newline from address book entries without namesBen Burwell2020-01-091-9/+11
| | | | | | | When the list of completions from the external command doesn't have associated contact names, the email address we attempt to parse was being terminated with a newline. Now, we strip the trailing newline if present.
* Handle MIME encoded addresses in address bookBen Burwell2019-12-301-2/+12
| | | | | | | | | | | When addresses contain special characters, net/mail MIME-encodes them to a valid RFC 5322 address for use in headers. However, these are not pleasant for human consumption, so we decode them for use in the completion list. Aerc properly encodes addresses when the message is sent. This patch also removes surrounding white space from contact names, if present.
* Add address book completion in composerBen Burwell2019-12-211-0/+153
Complete email address fields in the message composer with an external address book command, compatible with mutt's query_cmd.