about summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2020-04-24 11:42:21 +0200
committerDrew DeVault <sir@cmpwn.com>2020-04-24 12:59:21 -0400
commit7f033278eb3afc3b9ae2dca28efe8d4a3514d14a (patch)
treeee02c27cb1dfadd54be0178e91d6f2d5f0cbf4dc /widgets
parent447e662057c663f47f5c8a490543b1a52b26bc86 (diff)
downloadaerc-7f033278eb3afc3b9ae2dca28efe8d4a3514d14a.tar.gz
Add postpone command
This command uses the Postpone folder from the account config to save
messages to. Messages are saved as though they were sent so have a valid
'to' recipient address and should be able to be read back in for later
editing.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/aerc.go4
-rw-r--r--widgets/compose.go44
2 files changed, 28 insertions, 20 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 8307bd0..779e386 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -293,6 +293,8 @@ func (aerc *Aerc) SelectedAccount() *AccountView {
 		return tab
 	case *MessageViewer:
 		return tab.SelectedAccount()
+	case *Composer:
+		return tab.Account()
 	}
 	return nil
 }
@@ -494,7 +496,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
 			defaults[header] = strings.Join(vals, ",")
 		}
 	}
-	composer, err := NewComposer(aerc, aerc.Config(),
+	composer, err := NewComposer(aerc, acct, aerc.Config(),
 		acct.AccountConfig(), acct.Worker(), "", defaults, models.OriginalMail{})
 	if err != nil {
 		return nil
diff --git a/widgets/compose.go b/widgets/compose.go
index 9ceabf6..66877cc 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -32,9 +32,10 @@ import (
 type Composer struct {
 	editors map[string]*headerEditor
 
-	acct   *config.AccountConfig
-	config *config.AercConfig
-	aerc   *Aerc
+	acctConfig *config.AccountConfig
+	config     *config.AercConfig
+	acct       *AccountView
+	aerc       *Aerc
 
 	attachments []string
 	date        time.Time
@@ -57,7 +58,7 @@ type Composer struct {
 	width int
 }
 
-func NewComposer(aerc *Aerc, conf *config.AercConfig,
+func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
 	acct *config.AccountConfig, worker *types.Worker, template string,
 	defaults map[string]string, original models.OriginalMail) (*Composer, error) {
 
@@ -65,7 +66,7 @@ func NewComposer(aerc *Aerc, conf *config.AercConfig,
 		defaults = make(map[string]string)
 	}
 	if from := defaults["From"]; from == "" {
-		defaults["From"] = acct.From
+		defaults["From"] = acctConfig.From
 	}
 
 	templateData := templates.ParseTemplateData(defaults, original)
@@ -82,16 +83,17 @@ func NewComposer(aerc *Aerc, conf *config.AercConfig,
 	}
 
 	c := &Composer{
-		acct:     acct,
-		aerc:     aerc,
-		config:   conf,
-		date:     time.Now(),
-		defaults: defaults,
-		editors:  editors,
-		email:    email,
-		layout:   layout,
-		msgId:    mail.GenerateMessageID(),
-		worker:   worker,
+		acct:       acct,
+		acctConfig: acctConfig,
+		aerc:       aerc,
+		config:     conf,
+		date:       time.Now(),
+		defaults:   defaults,
+		editors:    editors,
+		email:      email,
+		layout:     layout,
+		msgId:      mail.GenerateMessageID(),
+		worker:     worker,
 		// You have to backtab to get to "From", since you usually don't edit it
 		focused:   1,
 		focusable: focusable,
@@ -215,7 +217,7 @@ func (c *Composer) AddTemplate(template string, data interface{}) error {
 
 func (c *Composer) AddSignature() {
 	var signature []byte
-	if c.acct.SignatureCmd != "" {
+	if c.acctConfig.SignatureCmd != "" {
 		var err error
 		signature, err = c.readSignatureFromCmd()
 		if err != nil {
@@ -228,7 +230,7 @@ func (c *Composer) AddSignature() {
 }
 
 func (c *Composer) readSignatureFromCmd() ([]byte, error) {
-	sigCmd := c.acct.SignatureCmd
+	sigCmd := c.acctConfig.SignatureCmd
 	cmd := exec.Command("sh", "-c", sigCmd)
 	signature, err := cmd.Output()
 	if err != nil {
@@ -238,7 +240,7 @@ func (c *Composer) readSignatureFromCmd() ([]byte, error) {
 }
 
 func (c *Composer) readSignatureFromFile() []byte {
-	sigFile := c.acct.SignatureFile
+	sigFile := c.acctConfig.SignatureFile
 	if sigFile == "" {
 		return nil
 	}
@@ -354,6 +356,10 @@ func (c *Composer) Focus(focus bool) {
 }
 
 func (c *Composer) Config() *config.AccountConfig {
+	return c.acctConfig
+}
+
+func (c *Composer) Account() *AccountView {
 	return c.acct
 }
 
@@ -771,7 +777,7 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
 	} else {
 		// TODO: source this from actual keybindings?
 		grid.AddChild(ui.NewText(
-			"Send this email? [y]es/[n]o/[e]dit/[a]ttach")).At(0, 0)
+			"Send this email? [y]es/[n]o/[p]ostpone/[e]dit/[a]ttach")).At(0, 0)
 		grid.AddChild(ui.NewText("Attachments:").
 			Reverse(true)).At(1, 0)
 		if len(composer.attachments) == 0 {