summary refs log tree commit diff stats
path: root/commands/msg
diff options
context:
space:
mode:
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/archive.go5
-rw-r--r--commands/msg/copy.go5
-rw-r--r--commands/msg/delete.go6
-rw-r--r--commands/msg/move.go5
-rw-r--r--commands/msg/pipe.go5
-rw-r--r--commands/msg/read.go5
-rw-r--r--commands/msg/reply.go5
-rw-r--r--commands/msg/unsubscribe.go6
8 files changed, 32 insertions, 10 deletions
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index 40fb48b..fe391d2 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -41,7 +41,10 @@ func (_ Archive) Execute(aerc *widgets.Aerc, args []string) error {
 	if acct == nil {
 		return errors.New("No account selected")
 	}
-	msg := widget.SelectedMessage()
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
+	}
 	store := widget.Store()
 	archiveDir := acct.AccountConfig().Archive
 	store.Next()
diff --git a/commands/msg/copy.go b/commands/msg/copy.go
index 4d65d24..48bccd4 100644
--- a/commands/msg/copy.go
+++ b/commands/msg/copy.go
@@ -44,7 +44,10 @@ func (_ Copy) Execute(aerc *widgets.Aerc, args []string) error {
 	}
 
 	widget := aerc.SelectedTab().(widgets.ProvidesMessage)
-	msg := widget.SelectedMessage()
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
+	}
 	store := widget.Store()
 	store.Copy([]uint32{msg.Uid}, args[optind], createParents, func(
 		msg types.WorkerMessage) {
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 104e1e1..36b8d8c 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -35,10 +35,10 @@ func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error {
 		return errors.New("No account selected")
 	}
 	store := widget.Store()
-	if len(store.Uids) == 0 {
-		return errors.New("No message selected")
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
 	}
-	msg := widget.SelectedMessage()
 	_, isMsgView := widget.(*widgets.MessageViewer)
 	if isMsgView {
 		aerc.RemoveTab(widget)
diff --git a/commands/msg/move.go b/commands/msg/move.go
index c98157e..8b19a10 100644
--- a/commands/msg/move.go
+++ b/commands/msg/move.go
@@ -49,7 +49,10 @@ func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
 	if acct == nil {
 		return errors.New("No account selected")
 	}
-	msg := widget.SelectedMessage()
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
+	}
 	store := widget.Store()
 	_, isMsgView := widget.(*widgets.MessageViewer)
 	if isMsgView {
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 9f4a009..821f359 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -112,7 +112,10 @@ func (_ Pipe) Execute(aerc *widgets.Aerc, args []string) error {
 
 	if pipeFull {
 		store := provider.Store()
-		msg := provider.SelectedMessage()
+		msg, err := provider.SelectedMessage()
+		if err != nil {
+			return err
+		}
 		store.FetchFull([]uint32{msg.Uid}, func(reader io.Reader) {
 			if background {
 				doExec(reader)
diff --git a/commands/msg/read.go b/commands/msg/read.go
index db463f1..30c6822 100644
--- a/commands/msg/read.go
+++ b/commands/msg/read.go
@@ -30,7 +30,10 @@ func (_ Read) Execute(aerc *widgets.Aerc, args []string) error {
 	}
 
 	widget := aerc.SelectedTab().(widgets.ProvidesMessage)
-	msg := widget.SelectedMessage()
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
+	}
 	store := widget.Store()
 	store.Read([]uint32{msg.Uid}, args[0] == "read", func(
 		msg types.WorkerMessage) {
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 68c2089..5295ee6 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -60,7 +60,10 @@ func (_ reply) Execute(aerc *widgets.Aerc, args []string) error {
 	conf := acct.AccountConfig()
 	us, _ := gomail.ParseAddress(conf.From)
 	store := widget.Store()
-	msg := widget.SelectedMessage()
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
+	}
 	acct.Logger().Println("Replying to email " + msg.Envelope.MessageId)
 
 	var (
diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go
index d4a7e9a..720ff43 100644
--- a/commands/msg/unsubscribe.go
+++ b/commands/msg/unsubscribe.go
@@ -34,7 +34,11 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error {
 		return errors.New("Usage: unsubscribe")
 	}
 	widget := aerc.SelectedTab().(widgets.ProvidesMessage)
-	headers := widget.SelectedMessage().RFC822Headers
+	msg, err := widget.SelectedMessage()
+	if err != nil {
+		return err
+	}
+	headers := msg.RFC822Headers
 	if !headers.Has("list-unsubscribe") {
 		return errors.New("No List-Unsubscribe header found")
 	}