summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/account/compose.go3
-rw-r--r--commands/account/view.go3
-rw-r--r--commands/commands.go18
-rw-r--r--commands/compose/postpone.go6
-rw-r--r--commands/msg/unsubscribe.go3
-rw-r--r--commands/msgview/next.go5
6 files changed, 32 insertions, 6 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go
index d4128db..1a62d0a 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -30,6 +30,9 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
return err
}
acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
if template == "" {
template = aerc.Config().Templates.NewMessage
}
diff --git a/commands/account/view.go b/commands/account/view.go
index 4f59d94..53ad267 100644
--- a/commands/account/view.go
+++ b/commands/account/view.go
@@ -26,6 +26,9 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("Usage: view-message")
}
acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
if acct.Messages().Empty() {
return nil
}
diff --git a/commands/commands.go b/commands/commands.go
index cb5b63b..70a77b9 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -117,11 +117,15 @@ func (cmds *Commands) GetCompletions(aerc *widgets.Aerc, cmd string) []string {
func GetFolders(aerc *widgets.Aerc, args []string) []string {
out := make([]string, 0)
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return out
+ }
if len(args) == 0 {
- return aerc.SelectedAccount().Directories().List()
+ return acct.Directories().List()
}
- for _, dir := range aerc.SelectedAccount().Directories().List() {
- if foundInString(dir, args[0], aerc.SelectedAccount().UiConfig().FuzzyFolderComplete) {
+ for _, dir := range acct.Directories().List() {
+ if foundInString(dir, args[0], acct.UiConfig().FuzzyFolderComplete) {
out = append(out, dir)
}
}
@@ -144,8 +148,12 @@ func CompletionFromList(valid []string, args []string) []string {
}
func GetLabels(aerc *widgets.Aerc, args []string) []string {
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return make([]string, 0)
+ }
if len(args) == 0 {
- return aerc.SelectedAccount().Labels()
+ return acct.Labels()
}
// + and - are used to denote tag addition / removal and need to be striped
@@ -165,7 +173,7 @@ func GetLabels(aerc *widgets.Aerc, args []string) []string {
trimmed := strings.TrimLeft(last, "+-")
out := make([]string, 0)
- for _, label := range aerc.SelectedAccount().Labels() {
+ for _, label := range acct.Labels() {
if hasCaseSmartPrefix(label, trimmed) {
var prev string
if len(others) > 0 {
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index f918b52..9462a9c 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -31,6 +31,10 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: postpone")
}
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
composer, _ := aerc.SelectedTab().(*widgets.Composer)
config := composer.Config()
tabName := aerc.TabNames()[aerc.SelectedTabIndex()]
@@ -48,7 +52,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
header.SetContentType("text/plain", map[string]string{"charset": "UTF-8"})
header.Set("Content-Transfer-Encoding", "quoted-printable")
worker := composer.Worker()
- dirs := aerc.SelectedAccount().Directories().List()
+ dirs := acct.Directories().List()
alreadyCreated := false
for _, dir := range dirs {
if dir == config.Postpone {
diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go
index 3a69ff9..428e872 100644
--- a/commands/msg/unsubscribe.go
+++ b/commands/msg/unsubscribe.go
@@ -89,6 +89,9 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) {
func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
acct := widget.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
h := &mail.Header{}
h.SetSubject(u.Query().Get("subject"))
diff --git a/commands/msgview/next.go b/commands/msgview/next.go
index 4291a6a..742bc66 100644
--- a/commands/msgview/next.go
+++ b/commands/msgview/next.go
@@ -1,6 +1,8 @@
package msgview
import (
+ "errors"
+
"git.sr.ht/~rjarry/aerc/commands/account"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -27,6 +29,9 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
}
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
acct := mv.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
store := mv.Store()
err = account.ExecuteNextPrevMessage(args, acct, pct, n)
if err != nil {