aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/compose/send.go25
-rw-r--r--commands/msg/archive.go16
-rw-r--r--commands/msg/reply.go7
-rw-r--r--doc/aerc.1.scd4
-rw-r--r--widgets/compose.go8
5 files changed, 46 insertions, 14 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 9edb168e..c5f4be3b 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -10,6 +10,7 @@ import (
"strings"
"time"
+ "git.sr.ht/~sircmpwn/getopt"
"github.com/emersion/go-sasl"
"github.com/emersion/go-smtp"
"github.com/google/shlex"
@@ -40,8 +41,18 @@ func (Send) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (Send) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) > 1 {
- return errors.New("Usage: send")
+ opts, optind, err := getopt.Getopts(args, "a:")
+ if err != nil {
+ return err
+ }
+ if optind != len(args) {
+ return errors.New("Usage: send [-a <flat|year|month>]")
+ }
+ var archive string
+ for _, opt := range opts {
+ if opt.Option == 'a' {
+ archive = opt.Value
+ }
}
tab := aerc.SelectedTab()
if tab == nil {
@@ -112,7 +123,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
msg+" Abort send? [Y/n] ",
func(text string) {
if text == "n" || text == "N" {
- send(aerc, composer, ctx, header, tabName)
+ send(aerc, composer, ctx, header, tabName, archive)
}
}, func(cmd string) ([]string, string) {
if cmd == "" {
@@ -125,14 +136,14 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
aerc.PushPrompt(prompt)
} else {
- send(aerc, composer, ctx, header, tabName)
+ send(aerc, composer, ctx, header, tabName, archive)
}
return nil
}
func send(aerc *widgets.Aerc, composer *widgets.Composer, ctx sendCtx,
- header *mail.Header, tabName string,
+ header *mail.Header, tabName string, archive string,
) {
// we don't want to block the UI thread while we are sending
// so we do everything in a goroutine and hide the composer from the user
@@ -203,13 +214,13 @@ func send(aerc *widgets.Aerc, composer *widgets.Composer, ctx sendCtx,
"message sent, but copying to %v failed: %v",
config.CopyTo, err.Error())
aerc.PushError(errmsg)
- composer.SetSent()
+ composer.SetSent(archive)
composer.Close()
return
}
}
aerc.PushStatus("Message sent.", 10*time.Second)
- composer.SetSent()
+ composer.SetSent(archive)
composer.Close()
}()
}
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index 149d7a5f..aeb65738 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -39,29 +39,35 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("Usage: archive <flat|year|month>")
}
h := newHelper(aerc)
- acct, err := h.account()
+ msgs, err := h.messages()
if err != nil {
return err
}
- store, err := h.store()
+ err = archive(aerc, msgs, args[1])
+ return err
+}
+
+func archive(aerc *widgets.Aerc, msgs []*models.MessageInfo, archiveType string) error {
+ h := newHelper(aerc)
+ acct, err := h.account()
if err != nil {
return err
}
- msgs, err := h.messages()
+ store, err := h.store()
if err != nil {
return err
}
- archiveDir := acct.AccountConfig().Archive
var uids []uint32
for _, msg := range msgs {
uids = append(uids, msg.Uid)
}
+ archiveDir := acct.AccountConfig().Archive
marker := store.Marker()
marker.ClearVisualMark()
next := findNextNonDeleted(uids, store)
var uidMap map[string][]uint32
- switch args[1] {
+ switch archiveType {
case ARCHIVE_MONTH:
uidMap = groupBy(msgs, func(msg *models.MessageInfo) string {
dir := path.Join(archiveDir,
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 8f536c14..52265950 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -7,6 +7,7 @@ import (
"io"
"regexp"
"strings"
+ "time"
"git.sr.ht/~sircmpwn/getopt"
@@ -210,6 +211,12 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
composer.OnClose(func(c *widgets.Composer) {
switch {
+ case c.Sent() && c.Archive() != "":
+ store.Answered([]uint32{msg.Uid}, true, nil)
+ err := archive(aerc, []*models.MessageInfo{msg}, c.Archive())
+ if err != nil {
+ aerc.PushStatus("Archive failed", 10*time.Second)
+ }
case c.Sent():
store.Answered([]uint32{msg.Uid}, true, nil)
case mv != nil && closeOnReply:
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 949eb6ee..aac014c9 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -554,11 +554,13 @@ message list, the message in the message viewer, etc).
specified is a directory or ends in _/_, aerc will use the attachment filename
if available or a generated name if not.
-*:send*
+*:send* [*-a* _<scheme>_]
Sends the message using this accounts default outgoing transport
configuration. For details on configuring outgoing mail delivery consult
*aerc-accounts*(5).
+ *-a*: Archive the message being replied to. See *:archive* for schemes.
+
*:switch-account* _<account-name>_++
*:switch-account* *-n*++
*:switch-account* *-p*
diff --git a/widgets/compose.go b/widgets/compose.go
index 4f08afa3..a625e7eb 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -56,6 +56,7 @@ type Composer struct {
focusable []ui.MouseableDrawableInteractive
focused int
sent bool
+ archive string
onClose []func(ti *Composer)
@@ -255,14 +256,19 @@ func (c *Composer) buildComposeHeader(aerc *Aerc, cmpl *completer.Completer) {
}
}
-func (c *Composer) SetSent() {
+func (c *Composer) SetSent(archive string) {
c.sent = true
+ c.archive = archive
}
func (c *Composer) Sent() bool {
return c.sent
}
+func (c *Composer) Archive() string {
+ return c.archive
+}
+
func (c *Composer) SetAttachKey(attach bool) error {
if !attach {
name := c.crypto.signKey + ".asc"