~sircmpwn/aerc

aerc: clean up getCompletions, remove unused variable v3 PROPOSED

Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/%3C20190903193409.10996-1-wgrriffel%40gmail.com%3E/mbox | git am -3
Learn more about email & git

[PATCH v3 1/8] aerc: clean up getCompletions, remove unused variable Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
v3:
    leave `completions` slice to its zero value

 aerc.go | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/aerc.go b/aerc.go
index c5d93ac..5ba9fab 100644
--- a/aerc.go
+++ b/aerc.go
@@ -74,21 +74,14 @@ func execCommand(aerc *widgets.Aerc, ui *libui.UI, cmd []string) error {
 }
 
 func getCompletions(aerc *widgets.Aerc, cmd string) []string {
-	cmds := getCommands((*aerc).SelectedTab())
-	completions := make([]string, 0)
-	for _, set := range cmds {
-		opts := set.GetCompletions(aerc, cmd)
-		if len(opts) > 0 {
-			for _, opt := range opts {
-				completions = append(completions, opt)
-			}
-		}
+	var completions []string
+	for _, set := range getCommands((*aerc).SelectedTab()) {
+		completions = append(completions, set.GetCompletions(aerc, cmd)...)
 	}
 	return completions
 }
 
 var (
-	Prefix   string
 	ShareDir string
 	Version  string
 )
-- 
2.23.0
This should be two commits.

[PATCH v3 2/8] all: purge redundant underscores Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 commands/account/cf.go             | 6 +++---
 commands/account/clear.go          | 6 +++---
 commands/account/compose.go        | 6 +++---
 commands/account/mkdir.go          | 6 +++---
 commands/account/next-folder.go    | 6 +++---
 commands/account/next-result.go    | 6 +++---
 commands/account/next.go           | 6 +++---
 commands/account/search.go         | 6 +++---
 commands/account/select.go         | 6 +++---
 commands/account/view.go           | 6 +++---
 commands/cd.go                     | 6 +++---
 commands/compose/abort.go          | 6 +++---
 commands/compose/attach.go         | 6 +++---
 commands/compose/cc-bcc.go         | 6 +++---
 commands/compose/detach.go         | 6 +++---
 commands/compose/edit.go           | 6 +++---
 commands/compose/next-field.go     | 6 +++---
 commands/compose/send.go           | 6 +++---
 commands/ct.go                     | 6 +++---
 commands/exec.go                   | 6 +++---
 commands/help.go                   | 6 +++---
 commands/msg/archive.go            | 6 +++---
 commands/msg/copy.go               | 6 +++---
 commands/msg/delete.go             | 6 +++---
 commands/msg/forward.go            | 6 +++---
 commands/msg/move.go               | 6 +++---
 commands/msg/pipe.go               | 6 +++---
 commands/msg/read.go               | 6 +++---
 commands/msg/reply.go              | 6 +++---
 commands/msgview/close.go          | 6 +++---
 commands/msgview/next-part.go      | 6 +++---
 commands/msgview/next.go           | 6 +++---
 commands/msgview/open.go           | 6 +++---
 commands/msgview/save.go           | 6 +++---
 commands/msgview/toggle-headers.go | 6 +++---
 commands/new-account.go            | 6 +++---
 commands/next-tab.go               | 6 +++---
 commands/prompt.go                 | 6 +++---
 commands/pwd.go                    | 6 +++---
 commands/quit.go                   | 6 +++---
 commands/set.go                    | 6 +++---
 commands/term.go                   | 6 +++---
 commands/terminal/close.go         | 6 +++---
 widgets/aerc.go                    | 2 +-
 widgets/exline.go                  | 4 ++--
 45 files changed, 132 insertions(+), 132 deletions(-)

diff --git a/commands/account/cf.go b/commands/account/cf.go
index f318374..cbef308 100644
--- a/commands/account/cf.go
+++ b/commands/account/cf.go
@@ -19,15 +19,15 @@ func init() {
 	register(ChangeFolder{})
 }
 
-func (_ ChangeFolder) Aliases() []string {
+func (ChangeFolder) Aliases() []string {
 	return []string{"cf"}
 }
 
-func (_ ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string {
+func (ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string {
 	return commands.GetFolders(aerc, args)
 }
 
-func (_ ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
+func (ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) < 2 {
 		return errors.New("Usage: cf <folder>")
 	}
diff --git a/commands/account/clear.go b/commands/account/clear.go
index bb9c04e..392fdd0 100644
--- a/commands/account/clear.go
+++ b/commands/account/clear.go
@@ -11,15 +11,15 @@ func init() {
 	register(Clear{})
 }
 
-func (_ Clear) Aliases() []string {
+func (Clear) Aliases() []string {
 	return []string{"clear"}
 }
 
-func (_ Clear) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Clear) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Clear) Execute(aerc *widgets.Aerc, args []string) error {
+func (Clear) Execute(aerc *widgets.Aerc, args []string) error {
 	acct := aerc.SelectedAccount()
 	if acct == nil {
 		return errors.New("No account selected")
diff --git a/commands/account/compose.go b/commands/account/compose.go
index a4836b7..e61b593 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -15,15 +15,15 @@ func init() {
 	register(Compose{})
 }
 
-func (_ Compose) Aliases() []string {
+func (Compose) Aliases() []string {
 	return []string{"compose"}
 }
 
-func (_ Compose) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Compose) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Compose) Execute(aerc *widgets.Aerc, args []string) error {
+func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
 	body, err := buildBody(args)
 	if err != nil {
 		return err
diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go
index be9b14a..d42928e 100644
--- a/commands/account/mkdir.go
+++ b/commands/account/mkdir.go
@@ -16,15 +16,15 @@ func init() {
 	register(MakeDir{})
 }
 
-func (_ MakeDir) Aliases() []string {
+func (MakeDir) Aliases() []string {
 	return []string{"mkdir"}
 }
 
-func (_ MakeDir) Complete(aerc *widgets.Aerc, args []string) []string {
+func (MakeDir) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ MakeDir) Execute(aerc *widgets.Aerc, args []string) error {
+func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 2 {
 		return errors.New("Usage: :mkdir <name>")
 	}
diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go
index 537a351..6a22772 100644
--- a/commands/account/next-folder.go
+++ b/commands/account/next-folder.go
@@ -14,15 +14,15 @@ func init() {
 	register(NextPrevFolder{})
 }
 
-func (_ NextPrevFolder) Aliases() []string {
+func (NextPrevFolder) Aliases() []string {
 	return []string{"next-folder", "prev-folder"}
 }
 
-func (_ NextPrevFolder) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevFolder) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error {
+func (NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 2 {
 		return nextPrevFolderUsage(args[0])
 	}
diff --git a/commands/account/next-result.go b/commands/account/next-result.go
index 24d53be..ab050af 100644
--- a/commands/account/next-result.go
+++ b/commands/account/next-result.go
@@ -13,15 +13,15 @@ func init() {
 	register(NextPrevResult{})
 }
 
-func (_ NextPrevResult) Aliases() []string {
+func (NextPrevResult) Aliases() []string {
 	return []string{"next-result", "prev-result"}
 }
 
-func (_ NextPrevResult) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevResult) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error {
+func (NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 1 {
 		return nextPrevResultUsage(args[0])
 	}
diff --git a/commands/account/next.go b/commands/account/next.go
index 1ba4b1b..604dcd7 100644
--- a/commands/account/next.go
+++ b/commands/account/next.go
@@ -15,16 +15,16 @@ func init() {
 	register(NextPrevMsg{})
 }
 
-func (_ NextPrevMsg) Aliases() []string {
+func (NextPrevMsg) Aliases() []string {
 	return []string{"next", "next-message", "prev", "prev-message"}
 }
 
-func (_ NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
 	var err, n, pct = ParseNextPrevMessage(args)
+func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
 	if err != nil {
 		return err
 	}
diff --git a/commands/account/search.go b/commands/account/search.go
index ca51917..1d2e7a2 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -12,15 +12,15 @@ func init() {
 	register(SearchFilter{})
 }
 
-func (_ SearchFilter) Aliases() []string {
+func (SearchFilter) Aliases() []string {
 	return []string{"search", "filter"}
 }
 
-func (_ SearchFilter) Complete(aerc *widgets.Aerc, args []string) []string {
+func (SearchFilter) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
+func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
 	acct := aerc.SelectedAccount()
 	if acct == nil {
 		return errors.New("No account selected")
diff --git a/commands/account/select.go b/commands/account/select.go
index 70e08ac..b41b234 100644
--- a/commands/account/select.go
+++ b/commands/account/select.go
@@ -13,15 +13,15 @@ func init() {
 	register(SelectMessage{})
 }
 
-func (_ SelectMessage) Aliases() []string {
+func (SelectMessage) Aliases() []string {
 	return []string{"select", "select-message"}
 }
 
-func (_ SelectMessage) Complete(aerc *widgets.Aerc, args []string) []string {
+func (SelectMessage) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ SelectMessage) Execute(aerc *widgets.Aerc, args []string) error {
+func (SelectMessage) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 2 {
 		return errors.New("Usage: :select-message <n>")
 	}
diff --git a/commands/account/view.go b/commands/account/view.go
index cec65aa..af39360 100644
--- a/commands/account/view.go
+++ b/commands/account/view.go
@@ -12,15 +12,15 @@ func init() {
 	register(ViewMessage{})
 }
 
-func (_ ViewMessage) Aliases() []string {
+func (ViewMessage) Aliases() []string {
 	return []string{"view-message", "view"}
 }
 
-func (_ ViewMessage) Complete(aerc *widgets.Aerc, args []string) []string {
+func (ViewMessage) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ ViewMessage) Execute(aerc *widgets.Aerc, args []string) error {
+func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: view-message")
 	}
diff --git a/commands/cd.go b/commands/cd.go
index 3630cae..1d033e4 100644
--- a/commands/cd.go
+++ b/commands/cd.go
@@ -19,11 +19,11 @@ func init() {
 	register(ChangeDirectory{})
 }
 
-func (_ ChangeDirectory) Aliases() []string {
+func (ChangeDirectory) Aliases() []string {
 	return []string{"cd"}
 }
 
-func (_ ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string {
+func (ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string {
 	path := ""
 	if len(args) >= 1 {
 		path = args[0]
@@ -42,7 +42,7 @@ func (_ ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string {
 	return dirs
 }
 
-func (_ ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error {
+func (ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) < 1 || len(args) > 2 {
 		return errors.New("Usage: cd [directory]")
 	}
diff --git a/commands/compose/abort.go b/commands/compose/abort.go
index 4c121d7..74d0395 100644
--- a/commands/compose/abort.go
+++ b/commands/compose/abort.go
@@ -12,15 +12,15 @@ func init() {
 	register(Abort{})
 }
 
-func (_ Abort) Aliases() []string {
+func (Abort) Aliases() []string {
 	return []string{"abort"}
 }
 
-func (_ Abort) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Abort) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Abort) Execute(aerc *widgets.Aerc, args []string) error {
+func (Abort) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: abort")
 	}
diff --git a/commands/compose/attach.go b/commands/compose/attach.go
index 7501a33..969d12e 100644
--- a/commands/compose/attach.go
+++ b/commands/compose/attach.go
@@ -17,11 +17,11 @@ func init() {
 	register(Attach{})
 }
 
-func (_ Attach) Aliases() []string {
+func (Attach) Aliases() []string {
 	return []string{"attach"}
 }
 
-func (_ Attach) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Attach) Complete(aerc *widgets.Aerc, args []string) []string {
 	path := ""
 	if len(args) >= 1 {
 		path = args[0]
@@ -30,7 +30,7 @@ func (_ Attach) Complete(aerc *widgets.Aerc, args []string) []string {
 	return commands.CompletePath(path)
 }
 
-func (_ Attach) Execute(aerc *widgets.Aerc, args []string) error {
+func (Attach) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 2 {
 		return fmt.Errorf("Usage: :attach <path>")
 	}
diff --git a/commands/compose/cc-bcc.go b/commands/compose/cc-bcc.go
index db5f5b6..ce62242 100644
--- a/commands/compose/cc-bcc.go
+++ b/commands/compose/cc-bcc.go
@@ -12,15 +12,15 @@ func init() {
 	register(CC{})
 }
 
-func (_ CC) Aliases() []string {
+func (CC) Aliases() []string {
 	return []string{"cc", "bcc"}
 }
 
-func (_ CC) Complete(aerc *widgets.Aerc, args []string) []string {
+func (CC) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ CC) Execute(aerc *widgets.Aerc, args []string) error {
+func (CC) Execute(aerc *widgets.Aerc, args []string) error {
 	var addrs string
 	if len(args) > 1 {
 		addrs = strings.Join(args[1:], " ")
diff --git a/commands/compose/detach.go b/commands/compose/detach.go
index e700ab6..dc70ff9 100644
--- a/commands/compose/detach.go
+++ b/commands/compose/detach.go
@@ -14,17 +14,17 @@ func init() {
 	register(Detach{})
 }
 
-func (_ Detach) Aliases() []string {
+func (Detach) Aliases() []string {
 	return []string{"detach"}
 }
 
-func (_ Detach) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Detach) Complete(aerc *widgets.Aerc, args []string) []string {
 	composer, _ := aerc.SelectedTab().(*widgets.Composer)
 
 	return composer.GetAttachments()
 }
 
-func (_ Detach) Execute(aerc *widgets.Aerc, args []string) error {
+func (Detach) Execute(aerc *widgets.Aerc, args []string) error {
 	var path string
 	composer, _ := aerc.SelectedTab().(*widgets.Composer)
 
diff --git a/commands/compose/edit.go b/commands/compose/edit.go
index e888350..e788022 100644
--- a/commands/compose/edit.go
+++ b/commands/compose/edit.go
@@ -12,15 +12,15 @@ func init() {
 	register(Edit{})
 }
 
-func (_ Edit) Aliases() []string {
+func (Edit) Aliases() []string {
 	return []string{"edit"}
 }
 
-func (_ Edit) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Edit) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Edit) Execute(aerc *widgets.Aerc, args []string) error {
+func (Edit) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: edit")
 	}
diff --git a/commands/compose/next-field.go b/commands/compose/next-field.go
index 3496dfd..43ae644 100644
--- a/commands/compose/next-field.go
+++ b/commands/compose/next-field.go
@@ -13,15 +13,15 @@ func init() {
 	register(NextPrevField{})
 }
 
-func (_ NextPrevField) Aliases() []string {
+func (NextPrevField) Aliases() []string {
 	return []string{"next-field", "prev-field"}
 }
 
-func (_ NextPrevField) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevField) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevField) Execute(aerc *widgets.Aerc, args []string) error {
+func (NextPrevField) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 2 {
 		return nextPrevFieldUsage(args[0])
 	}
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 202d8c6..5a12428 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -28,15 +28,15 @@ func init() {
 	register(Send{})
 }
 
-func (_ Send) Aliases() []string {
+func (Send) Aliases() []string {
 	return []string{"send"}
 }
 
-func (_ Send) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Send) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Send) Execute(aerc *widgets.Aerc, args []string) error {
+func (Send) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 1 {
 		return errors.New("Usage: send")
 	}
diff --git a/commands/ct.go b/commands/ct.go
index 4e66331..f84e8a9 100644
--- a/commands/ct.go
+++ b/commands/ct.go
@@ -15,11 +15,11 @@ func init() {
 	register(ChangeTab{})
 }
 
-func (_ ChangeTab) Aliases() []string {
+func (ChangeTab) Aliases() []string {
 	return []string{"ct", "change-tab"}
 }
 
-func (_ ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
+func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
 	if len(args) == 0 {
 		return aerc.TabNames()
 	}
@@ -32,7 +32,7 @@ func (_ ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
 	return out
 }
 
-func (_ ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {
+func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 2 {
 		return errors.New(fmt.Sprintf("Usage: %s <tab>", args[0]))
 	}
diff --git a/commands/exec.go b/commands/exec.go
index 27edf5d..f615b71 100644
--- a/commands/exec.go
+++ b/commands/exec.go
@@ -17,15 +17,15 @@ func init() {
 	register(ExecCmd{})
 }
 
-func (_ ExecCmd) Aliases() []string {
+func (ExecCmd) Aliases() []string {
 	return []string{"exec"}
 }
 
-func (_ ExecCmd) Complete(aerc *widgets.Aerc, args []string) []string {
+func (ExecCmd) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ ExecCmd) Execute(aerc *widgets.Aerc, args []string) error {
+func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) < 2 {
 		return errors.New("Usage: exec [cmd...]")
 	}
diff --git a/commands/help.go b/commands/help.go
index c4ed4ff..b27c2f0 100644
--- a/commands/help.go
+++ b/commands/help.go
@@ -12,15 +12,15 @@ func init() {
 	register(Help{})
 }
 
-func (_ Help) Aliases() []string {
+func (Help) Aliases() []string {
 	return []string{"help"}
 }
 
-func (_ Help) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Help) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Help) Execute(aerc *widgets.Aerc, args []string) error {
+func (Help) Execute(aerc *widgets.Aerc, args []string) error {
 	page := "aerc"
 	if len(args) == 2 {
 		page = "aerc-" + args[1]
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index 63d6de0..6bf231d 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -24,15 +24,15 @@ func init() {
 	register(Archive{})
 }
 
-func (_ Archive) Aliases() []string {
+func (Archive) Aliases() []string {
 	return []string{"archive"}
 }
 
-func (_ Archive) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Archive) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Archive) Execute(aerc *widgets.Aerc, args []string) error {
+func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 2 {
 		return errors.New("Usage: archive <flat|year|month>")
 	}
diff --git a/commands/msg/copy.go b/commands/msg/copy.go
index 8056e38..398beae 100644
--- a/commands/msg/copy.go
+++ b/commands/msg/copy.go
@@ -17,15 +17,15 @@ func init() {
 	register(Copy{})
 }
 
-func (_ Copy) Aliases() []string {
+func (Copy) Aliases() []string {
 	return []string{"cp", "copy"}
 }
 
-func (_ Copy) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Copy) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Copy) Execute(aerc *widgets.Aerc, args []string) error {
+func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args, "p")
 	if err != nil {
 		return err
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 06cef9c..677ea63 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -16,15 +16,15 @@ func init() {
 	register(Delete{})
 }
 
-func (_ Delete) Aliases() []string {
+func (Delete) Aliases() []string {
 	return []string{"delete", "delete-message"}
 }
 
-func (_ Delete) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Delete) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error {
+func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: :delete")
 	}
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 7f23a0a..b925a49 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -23,15 +23,15 @@ func init() {
 	register(forward{})
 }
 
-func (_ forward) Aliases() []string {
+func (forward) Aliases() []string {
 	return []string{"forward"}
 }
 
-func (_ forward) Complete(aerc *widgets.Aerc, args []string) []string {
+func (forward) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ forward) Execute(aerc *widgets.Aerc, args []string) error {
+func (forward) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args, "A")
 	if err != nil {
 		return err
diff --git a/commands/msg/move.go b/commands/msg/move.go
index b7d52ff..2f8c61e 100644
--- a/commands/msg/move.go
+++ b/commands/msg/move.go
@@ -18,15 +18,15 @@ func init() {
 	register(Move{})
 }
 
-func (_ Move) Aliases() []string {
+func (Move) Aliases() []string {
 	return []string{"mv", "move"}
 }
 
-func (_ Move) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Move) Complete(aerc *widgets.Aerc, args []string) []string {
 	return commands.GetFolders(aerc, args)
 }
 
-func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
+func (Move) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args, "p")
 	if err != nil {
 		return err
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 77e5d96..2faa5de 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -23,15 +23,15 @@ func init() {
 	register(Pipe{})
 }
 
-func (_ Pipe) Aliases() []string {
+func (Pipe) Aliases() []string {
 	return []string{"pipe"}
 }
 
-func (_ Pipe) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Pipe) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Pipe) Execute(aerc *widgets.Aerc, args []string) error {
+func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
 	var (
 		background bool
 		pipeFull   bool
diff --git a/commands/msg/read.go b/commands/msg/read.go
index 3497ef1..0da664b 100644
--- a/commands/msg/read.go
+++ b/commands/msg/read.go
@@ -19,15 +19,15 @@ func init() {
 	register(Read{})
 }
 
-func (_ Read) Aliases() []string {
+func (Read) Aliases() []string {
 	return []string{"read", "unread"}
 }
 
-func (_ Read) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Read) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Read) Execute(aerc *widgets.Aerc, args []string) error {
+func (Read) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args, "t")
 	if err != nil {
 		return err
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index bab16e1..34d03d5 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -23,15 +23,15 @@ func init() {
 	register(reply{})
 }
 
-func (_ reply) Aliases() []string {
+func (reply) Aliases() []string {
 	return []string{"reply"}
 }
 
-func (_ reply) Complete(aerc *widgets.Aerc, args []string) []string {
+func (reply) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ reply) Execute(aerc *widgets.Aerc, args []string) error {
+func (reply) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args, "aq")
 	if err != nil {
 		return err
diff --git a/commands/msgview/close.go b/commands/msgview/close.go
index 6a7eb0a..9966735 100644
--- a/commands/msgview/close.go
+++ b/commands/msgview/close.go
@@ -12,15 +12,15 @@ func init() {
 	register(Close{})
 }
 
-func (_ Close) Aliases() []string {
+func (Close) Aliases() []string {
 	return []string{"close"}
 }
 
-func (_ Close) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Close) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Close) Execute(aerc *widgets.Aerc, args []string) error {
+func (Close) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: close")
 	}
diff --git a/commands/msgview/next-part.go b/commands/msgview/next-part.go
index 8f25e02..c9423cc 100644
--- a/commands/msgview/next-part.go
+++ b/commands/msgview/next-part.go
@@ -14,15 +14,15 @@ func init() {
 	register(NextPrevPart{})
 }
 
-func (_ NextPrevPart) Aliases() []string {
+func (NextPrevPart) Aliases() []string {
 	return []string{"next-part", "prev-part"}
 }
 
-func (_ NextPrevPart) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevPart) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error {
+func (NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 2 {
 		return nextPrevPartUsage(args[0])
 	}
diff --git a/commands/msgview/next.go b/commands/msgview/next.go
index 647aafb..3943ac9 100644
--- a/commands/msgview/next.go
+++ b/commands/msgview/next.go
@@ -11,16 +11,16 @@ func init() {
 	register(NextPrevMsg{})
 }
 
-func (_ NextPrevMsg) Aliases() []string {
+func (NextPrevMsg) Aliases() []string {
 	return []string{"next", "next-message", "prev", "prev-message"}
 }
 
-func (_ NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
 	err, n, pct := account.ParseNextPrevMessage(args)
+func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
 	if err != nil {
 		return err
 	}
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index f4a0931..ab023a1 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -20,15 +20,15 @@ func init() {
 	register(Open{})
 }
 
-func (_ Open) Aliases() []string {
+func (Open) Aliases() []string {
 	return []string{"open"}
 }
 
-func (_ Open) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Open) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Open) Execute(aerc *widgets.Aerc, args []string) error {
+func (Open) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: open")
 	}
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 75ba56f..3b38ec7 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -22,15 +22,15 @@ func init() {
 	register(Save{})
 }
 
-func (_ Save) Aliases() []string {
+func (Save) Aliases() []string {
 	return []string{"save"}
 }
 
-func (_ Save) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Save) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Save) Execute(aerc *widgets.Aerc, args []string) error {
+func (Save) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, optind, err := getopt.Getopts(args, "p")
 	if err != nil {
 		return err
diff --git a/commands/msgview/toggle-headers.go b/commands/msgview/toggle-headers.go
index d9d7eba..f13e27d 100644
--- a/commands/msgview/toggle-headers.go
+++ b/commands/msgview/toggle-headers.go
@@ -13,15 +13,15 @@ func init() {
 	register(ToggleHeaders{})
 }
 
-func (_ ToggleHeaders) Aliases() []string {
+func (ToggleHeaders) Aliases() []string {
 	return []string{"toggle-headers"}
 }
 
-func (_ ToggleHeaders) Complete(aerc *widgets.Aerc, args []string) []string {
+func (ToggleHeaders) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ ToggleHeaders) Execute(aerc *widgets.Aerc, args []string) error {
+func (ToggleHeaders) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 1 {
 		return toggleHeadersUsage(args[0])
 	}
diff --git a/commands/new-account.go b/commands/new-account.go
index 8d2fef5..ff585c0 100644
--- a/commands/new-account.go
+++ b/commands/new-account.go
@@ -13,15 +13,15 @@ func init() {
 	register(NewAccount{})
 }
 
-func (_ NewAccount) Aliases() []string {
+func (NewAccount) Aliases() []string {
 	return []string{"new-account"}
 }
 
-func (_ NewAccount) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NewAccount) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NewAccount) Execute(aerc *widgets.Aerc, args []string) error {
+func (NewAccount) Execute(aerc *widgets.Aerc, args []string) error {
 	opts, _, err := getopt.Getopts(args, "t")
 	if err != nil {
 		return errors.New("Usage: new-account [-t]")
diff --git a/commands/next-tab.go b/commands/next-tab.go
index aa6e1dc..5af8692 100644
--- a/commands/next-tab.go
+++ b/commands/next-tab.go
@@ -14,15 +14,15 @@ func init() {
 	register(NextPrevTab{})
 }
 
-func (_ NextPrevTab) Aliases() []string {
+func (NextPrevTab) Aliases() []string {
 	return []string{"next-tab", "prev-tab"}
 }
 
-func (_ NextPrevTab) Complete(aerc *widgets.Aerc, args []string) []string {
+func (NextPrevTab) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ NextPrevTab) Execute(aerc *widgets.Aerc, args []string) error {
+func (NextPrevTab) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) > 2 {
 		return nextPrevTabUsage(args[0])
 	}
diff --git a/commands/prompt.go b/commands/prompt.go
index 3734881..fe152c8 100644
--- a/commands/prompt.go
+++ b/commands/prompt.go
@@ -13,15 +13,15 @@ func init() {
 	register(Prompt{})
 }
 
-func (_ Prompt) Aliases() []string {
+func (Prompt) Aliases() []string {
 	return []string{"prompt"}
 }
 
-func (_ Prompt) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Prompt) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil // TODO: add completions
 }
 
-func (_ Prompt) Execute(aerc *widgets.Aerc, args []string) error {
+func (Prompt) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) < 3 {
 		return errors.New(fmt.Sprintf("Usage: %s <prompt> <cmd>", args[0]))
 	}
diff --git a/commands/pwd.go b/commands/pwd.go
index 4903c29..d3f0e0c 100644
--- a/commands/pwd.go
+++ b/commands/pwd.go
@@ -14,15 +14,15 @@ func init() {
 	register(PrintWorkDir{})
 }
 
-func (_ PrintWorkDir) Aliases() []string {
+func (PrintWorkDir) Aliases() []string {
 	return []string{"pwd"}
 }
 
-func (_ PrintWorkDir) Complete(aerc *widgets.Aerc, args []string) []string {
+func (PrintWorkDir) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ PrintWorkDir) Execute(aerc *widgets.Aerc, args []string) error {
+func (PrintWorkDir) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: pwd")
 	}
diff --git a/commands/quit.go b/commands/quit.go
index 535ee61..63bc94a 100644
--- a/commands/quit.go
+++ b/commands/quit.go
@@ -12,11 +12,11 @@ func init() {
 	register(Quit{})
 }
 
-func (_ Quit) Aliases() []string {
+func (Quit) Aliases() []string {
 	return []string{"quit", "exit"}
 }
 
-func (_ Quit) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Quit) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
@@ -26,7 +26,7 @@ func (err ErrorExit) Error() string {
 	return "exit"
 }
 
-func (_ Quit) Execute(aerc *widgets.Aerc, args []string) error {
+func (Quit) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: quit")
 	}
diff --git a/commands/set.go b/commands/set.go
index f5366ff..1d20f06 100644
--- a/commands/set.go
+++ b/commands/set.go
@@ -19,12 +19,12 @@ func init() {
 	register(Set{})
 }
 
-func (_ Set) Aliases() []string {
+func (Set) Aliases() []string {
 	return []string{"set"}
 
 }
 
-func (_ Set) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Set) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
@@ -64,6 +64,6 @@ func SetCore(aerc *widgets.Aerc, args []string) error {
 	return nil
 }
 
-func (_ Set) Execute(aerc *widgets.Aerc, args []string) error {
+func (Set) Execute(aerc *widgets.Aerc, args []string) error {
 	return SetCore(aerc, args)
 }
diff --git a/commands/term.go b/commands/term.go
index 8575019..459f405 100644
--- a/commands/term.go
+++ b/commands/term.go
@@ -16,11 +16,11 @@ func init() {
 	register(Term{})
 }
 
-func (_ Term) Aliases() []string {
+func (Term) Aliases() []string {
 	return []string{"terminal", "term"}
 }
 
-func (_ Term) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Term) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
@@ -55,6 +55,6 @@ func TermCore(aerc *widgets.Aerc, args []string) error {
 	return nil
 }
 
-func (_ Term) Execute(aerc *widgets.Aerc, args []string) error {
+func (Term) Execute(aerc *widgets.Aerc, args []string) error {
 	return TermCore(aerc, args)
 }
diff --git a/commands/terminal/close.go b/commands/terminal/close.go
index 8256e67..aca0166 100644
--- a/commands/terminal/close.go
+++ b/commands/terminal/close.go
@@ -12,15 +12,15 @@ func init() {
 	register(Close{})
 }
 
-func (_ Close) Aliases() []string {
+func (Close) Aliases() []string {
 	return []string{"close"}
 }
 
-func (_ Close) Complete(aerc *widgets.Aerc, args []string) []string {
+func (Close) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-func (_ Close) Execute(aerc *widgets.Aerc, args []string) error {
+func (Close) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: close")
 	}
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 345f3ea..87009cd 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -301,7 +301,7 @@ func (aerc *Aerc) SelectTab(name string) bool {
 }
 
 func (aerc *Aerc) SelectTabIndex(index int) bool {
-	for i, _ := range aerc.tabs.Tabs {
+	for i := range aerc.tabs.Tabs {
 		if i == index {
 			aerc.tabs.Select(i)
 			return true
diff --git a/widgets/exline.go b/widgets/exline.go
index 8ec69d6..1482f0e 100644
--- a/widgets/exline.go
+++ b/widgets/exline.go
@@ -92,7 +92,7 @@ type nullHistory struct {
 	input *ui.TextInput
 }
 
-func (_ *nullHistory) Add(string) {}
+func (*nullHistory) Add(string) {}
 
 func (h *nullHistory) Next() string {
 	return h.input.String()
@@ -102,4 +102,4 @@ func (h *nullHistory) Prev() string {
 	return h.input.String()
 }
 
-func (_ *nullHistory) Reset() {}
+func (*nullHistory) Reset() {}
-- 
2.23.0

[PATCH v3 3/8] all: use fmt.Errorf for fomartting errors Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 commands/account/next-folder.go    | 2 +-
 commands/account/next-result.go    | 2 +-
 commands/account/next.go           | 2 +-
 commands/compose/next-field.go     | 3 +--
 commands/ct.go                     | 2 +-
 commands/msgview/next-part.go      | 3 +--
 commands/msgview/toggle-headers.go | 3 +--
 commands/next-tab.go               | 3 +--
 commands/prompt.go                 | 3 +--
 config/bindings.go                 | 2 +-
 10 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go
index 6a22772..037cd31 100644
--- a/commands/account/next-folder.go
+++ b/commands/account/next-folder.go
@@ -49,5 +49,5 @@ func (NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error {
 }
 
 func nextPrevFolderUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s [n]", cmd))
+	return fmt.Errorf("Usage: %s [n]", cmd)
 }
diff --git a/commands/account/next-result.go b/commands/account/next-result.go
index ab050af..78d437d 100644
--- a/commands/account/next-result.go
+++ b/commands/account/next-result.go
@@ -46,5 +46,5 @@ func (NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error {
 }
 
 func nextPrevResultUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd))
+	return fmt.Errorf("Usage: %s [<n>[%%]]", cmd)
 }
diff --git a/commands/account/next.go b/commands/account/next.go
index 604dcd7..e1d3eeb 100644
--- a/commands/account/next.go
+++ b/commands/account/next.go
@@ -78,5 +78,5 @@ func ExecuteNextPrevMessage(args []string, acct *widgets.AccountView, pct bool,
 }
 
 func nextPrevMessageUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd))
+	return fmt.Errorf("Usage: %s [<n>[%%]]", cmd)
 }
diff --git a/commands/compose/next-field.go b/commands/compose/next-field.go
index 43ae644..a81852e 100644
--- a/commands/compose/next-field.go
+++ b/commands/compose/next-field.go
@@ -1,7 +1,6 @@
 package compose
 
 import (
-	"errors"
 	"fmt"
 
 	"git.sr.ht/~sircmpwn/aerc/widgets"
@@ -35,5 +34,5 @@ func (NextPrevField) Execute(aerc *widgets.Aerc, args []string) error {
 }
 
 func nextPrevFieldUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s", cmd))
+	return fmt.Errorf("Usage: %s", cmd)
 }
diff --git a/commands/ct.go b/commands/ct.go
index f84e8a9..3cae0bd 100644
--- a/commands/ct.go
+++ b/commands/ct.go
@@ -34,7 +34,7 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
 
 func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 2 {
-		return errors.New(fmt.Sprintf("Usage: %s <tab>", args[0]))
+		return fmt.Errorf("Usage: %s <tab>", args[0])
 	}
 	if args[1] == "-" {
 		ok := aerc.SelectPreviousTab()
diff --git a/commands/msgview/next-part.go b/commands/msgview/next-part.go
index c9423cc..a98e96a 100644
--- a/commands/msgview/next-part.go
+++ b/commands/msgview/next-part.go
@@ -1,7 +1,6 @@
 package msgview
 
 import (
-	"errors"
 	"fmt"
 	"strconv"
 
@@ -48,5 +47,5 @@ func (NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error {
 }
 
 func nextPrevPartUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s [n]", cmd))
+	return fmt.Errorf("Usage: %s [n]", cmd)
 }
diff --git a/commands/msgview/toggle-headers.go b/commands/msgview/toggle-headers.go
index f13e27d..e777d9b 100644
--- a/commands/msgview/toggle-headers.go
+++ b/commands/msgview/toggle-headers.go
@@ -1,7 +1,6 @@
 package msgview
 
 import (
-	"errors"
 	"fmt"
 
 	"git.sr.ht/~sircmpwn/aerc/widgets"
@@ -31,5 +30,5 @@ func (ToggleHeaders) Execute(aerc *widgets.Aerc, args []string) error {
 }
 
 func toggleHeadersUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s", cmd))
+	return fmt.Errorf("Usage: %s", cmd)
 }
diff --git a/commands/next-tab.go b/commands/next-tab.go
index 5af8692..fc668f1 100644
--- a/commands/next-tab.go
+++ b/commands/next-tab.go
@@ -1,7 +1,6 @@
 package commands
 
 import (
-	"errors"
 	"fmt"
 	"strconv"
 
@@ -47,5 +46,5 @@ func (NextPrevTab) Execute(aerc *widgets.Aerc, args []string) error {
 }
 
 func nextPrevTabUsage(cmd string) error {
-	return errors.New(fmt.Sprintf("Usage: %s [n]", cmd))
+	return fmt.Errorf("Usage: %s [n]", cmd)
 }
diff --git a/commands/prompt.go b/commands/prompt.go
index fe152c8..2d6d01d 100644
--- a/commands/prompt.go
+++ b/commands/prompt.go
@@ -1,7 +1,6 @@
 package commands
 
 import (
-	"errors"
 	"fmt"
 
 	"git.sr.ht/~sircmpwn/aerc/widgets"
@@ -23,7 +22,7 @@ func (Prompt) Complete(aerc *widgets.Aerc, args []string) []string {
 
 func (Prompt) Execute(aerc *widgets.Aerc, args []string) error {
 	if len(args) < 3 {
-		return errors.New(fmt.Sprintf("Usage: %s <prompt> <cmd>", args[0]))
+		return fmt.Errorf("Usage: %s <prompt> <cmd>", args[0])
 	}
 
 	prompt := args[1]
diff --git a/config/bindings.go b/config/bindings.go
index 46e6924..a19d4f3 100644
--- a/config/bindings.go
+++ b/config/bindings.go
@@ -122,7 +122,7 @@ func ParseKeyStrokes(keystrokes string) ([]KeyStroke, error) {
 			if key, ok := keyNames[strings.ToLower(name)]; ok {
 				strokes = append(strokes, key)
 			} else {
-				return nil, errors.New(fmt.Sprintf("Unknown key '%s'", name))
+				return nil, fmt.Errorf("Unknown key '%s'", name)
 			}
 		case '>':
 			return nil, errors.New("Found '>' without '<'")
-- 
2.23.0

[PATCH v3 4/8] all: rewrite references to strings.Index to strings.Contains Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 commands/account/compose.go | 2 +-
 worker/lib/parse.go         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/account/compose.go b/commands/account/compose.go
index e61b593..ad48fe6 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -53,7 +53,7 @@ func buildBody(args []string) (string, error) {
 	for _, opt := range opts {
 		switch opt.Option {
 		case 'H':
-			if strings.Index(opt.Value, ":") != -1 {
+			if strings.Contains(opt.Value, ":") {
 				// ensure first colon is followed by a single space
 				re := regexp.MustCompile(`^(.*?):\s*(.*)`)
 				headers += re.ReplaceAllString(opt.Value, "$1: $2") + "\n"
diff --git a/worker/lib/parse.go b/worker/lib/parse.go
index 9f9fa62..df9683a 100644
--- a/worker/lib/parse.go
+++ b/worker/lib/parse.go
@@ -173,7 +173,7 @@ func parseAddressList(h *mail.Header, key string) ([]*models.Address, error) {
 	var converted []*models.Address
 	addrs, err := h.AddressList(key)
 	if err != nil {
-		if hdr, err := h.Text(key); err != nil && strings.Index(hdr, "@") < 0 {
+		if hdr, err := h.Text(key); err != nil && strings.Contains(hdr, "@") {
 			return []*models.Address{&models.Address{
 				Name: hdr,
 			}}, nil
-- 
2.23.0

[PATCH v3 5/8] commands: move ParseNextPrevMessage error value to its last return value Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 commands/account/next.go | 10 +++++-----
 commands/msgview/next.go |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/commands/account/next.go b/commands/account/next.go
index e1d3eeb..5e4838e 100644
--- a/commands/account/next.go
+++ b/commands/account/next.go
@@ -23,8 +23,8 @@ func (NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-	var err, n, pct = ParseNextPrevMessage(args)
 func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
+	n, pct, err := ParseNextPrevMessage(args)
 	if err != nil {
 		return err
 	}
@@ -35,9 +35,9 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
 	return ExecuteNextPrevMessage(args, acct, pct, n)
 }
 
-func ParseNextPrevMessage(args []string) (error, int, bool) {
+func ParseNextPrevMessage(args []string) (int, bool, error) {
 	if len(args) > 2 {
-		return nextPrevMessageUsage(args[0]), 0, false
+		return 0, false, nextPrevMessageUsage(args[0])
 	}
 	var (
 		n   int = 1
@@ -51,10 +51,10 @@ func ParseNextPrevMessage(args []string) (error, int, bool) {
 		}
 		n, err = strconv.Atoi(args[1])
 		if err != nil {
-			return nextPrevMessageUsage(args[0]), 0, false
+			return 0, false, nextPrevMessageUsage(args[0])
 		}
 	}
-	return nil, n, pct
+	return n, pct, nil
 }
 
 func ExecuteNextPrevMessage(args []string, acct *widgets.AccountView, pct bool, n int) error {
diff --git a/commands/msgview/next.go b/commands/msgview/next.go
index 3943ac9..4dc504c 100644
--- a/commands/msgview/next.go
+++ b/commands/msgview/next.go
@@ -19,8 +19,8 @@ func (NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string {
 	return nil
 }
 
-	err, n, pct := account.ParseNextPrevMessage(args)
 func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
+	n, pct, err := account.ParseNextPrevMessage(args)
 	if err != nil {
 		return err
 	}
-- 
2.23.0

[PATCH v3 6/8] widgets: remove redundant key check, delete is no-op if key is empty Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 lib/msgstore.go | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/msgstore.go b/lib/msgstore.go
index 77f0fe5..bbdfa57 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -105,9 +105,7 @@ func (store *MessageStore) FetchFull(uids []uint32, cb func(io.Reader)) {
 			switch msg.(type) {
 			case *types.Error:
 				for _, uid := range toFetch {
-					if _, ok := store.bodyCallbacks[uid]; ok {
-						delete(store.bodyCallbacks, uid)
-					}
+					delete(store.bodyCallbacks, uid)
 				}
 			}
 		})
@@ -209,9 +207,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
 		for _, uid := range msg.Uids {
 			toDelete[uid] = nil
 			delete(store.Messages, uid)
-			if _, ok := store.Deleted[uid]; ok {
-				delete(store.Deleted, uid)
-			}
+			delete(store.Deleted, uid)
 		}
 		uids := make([]uint32, len(store.uids)-len(msg.Uids))
 		j := 0
-- 
2.23.0

[PATCH v3 7/8] widgets: rewrite references to os.SET_SEEK to io.SeekStart Export this patch

Os.SET_SEEK is deprecated, it's recommended to use contants from io
package

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 widgets/compose.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/widgets/compose.go b/widgets/compose.go
index a49a947..bd4301a 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -131,10 +131,10 @@ func buildComposeHeader(layout HeaderLayout, defaults map[string]string) (
 // Note: this does not reload the editor. You must call this before the first
 // Draw() call.
 func (c *Composer) SetContents(reader io.Reader) *Composer {
-	c.email.Seek(0, os.SEEK_SET)
+	c.email.Seek(0, io.SeekStart)
 	io.Copy(c.email, reader)
 	c.email.Sync()
-	c.email.Seek(0, os.SEEK_SET)
+	c.email.Seek(0, io.SeekStart)
 	return c
 }
 
@@ -248,7 +248,7 @@ func (c *Composer) PrepareHeader() (*mail.Header, []string, error) {
 		header = reader.Header
 		defer reader.Close()
 	} else {
-		c.email.Seek(0, os.SEEK_SET)
+		c.email.Seek(0, io.SeekStart)
 	}
 	// Update headers
 	mhdr := (*message.Header)(&header.Header)
@@ -336,7 +336,7 @@ func (c *Composer) WriteMessage(header *mail.Header, writer io.Writer) error {
 		body = part.Body
 		defer reader.Close()
 	} else {
-		c.email.Seek(0, os.SEEK_SET)
+		c.email.Seek(0, io.SeekStart)
 		body = c.email
 	}
 
-- 
2.23.0

[PATCH v3 8/8] widgets: gofmt Export this patch

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
---
 widgets/msglist.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/widgets/msglist.go b/widgets/msglist.go
index 39d57e0..8ed716b 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -28,7 +28,7 @@ type MessageList struct {
 }
 
 type msgSorter struct {
-	uids []uint32
+	uids  []uint32
 	store *lib.MessageStore
 }
 
@@ -40,7 +40,7 @@ func (s *msgSorter) Less(i, j int) bool {
 	msgI := s.store.Messages[s.uids[i]]
 	msgJ := s.store.Messages[s.uids[j]]
 	if msgI == nil && msgJ == nil {
-		return false; // doesn't matter which order among nulls
+		return false // doesn't matter which order among nulls
 	} else if msgI == nil && msgJ != nil {
 		return true // say i is before j so we sort i to bottom
 	} else if msgI != nil && msgJ == nil {
-- 
2.23.0
Rest of this series LGTM. I'll split up the one patch for you.
Thanks!

To git.sr.ht:~sircmpwn/aerc
   2257b29..e28f45b  master -> master
View this thread in the archives