aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-23 21:27:10 +0200
committerRobin Jarry <robin@jarry.cc>2022-11-09 21:15:22 +0100
commit20554d8460e96a408cfd779e1158dec78b639028 (patch)
tree2bd6f5f4b1e7d4205a4df1d56f7223e6f5bcd13a
parentf479ae8c6e550dade0f183da9d3d7760f406d806 (diff)
downloadaerc-20554d8460e96a408cfd779e1158dec78b639028.tar.gz
composer: add message preview
Add message preview to the composer. Add preview option to the review window. Open the message in a message viewer before sending to check the headers and attachments. Implements: https://todo.sr.ht/~rjarry/aerc/86 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--CHANGELOG.md1
-rw-r--r--commands/eml.go13
-rw-r--r--config/binds.conf1
-rw-r--r--doc/aerc.1.scd4
-rw-r--r--widgets/compose.go14
5 files changed, 25 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 43aa30c4..f0ad50d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Display threads from bottom to top with `reverse-thread-order=true` in
`aerc.conf`.
- Style search results in the message list with `msglist_result.*`
+- Preview messages with their attachments before sending with `:preview`
### Fixed
diff --git a/commands/eml.go b/commands/eml.go
index 45dd4f25..864145ce 100644
--- a/commands/eml.go
+++ b/commands/eml.go
@@ -1,6 +1,7 @@
package commands
import (
+ "bytes"
"fmt"
"io"
"os"
@@ -17,7 +18,7 @@ func init() {
}
func (Eml) Aliases() []string {
- return []string{"eml"}
+ return []string{"eml", "preview"}
}
func (Eml) Complete(aerc *widgets.Aerc, args []string) []string {
@@ -54,6 +55,16 @@ func (Eml) Execute(aerc *widgets.Aerc, args []string) error {
case *widgets.MessageViewer:
part := tab.SelectedMessagePart()
tab.MessageView().FetchBodyPart(part.Index, showEml)
+ case *widgets.Composer:
+ var buf bytes.Buffer
+ h, err := tab.PrepareHeader()
+ if err != nil {
+ return err
+ }
+ if err := tab.WriteMessage(h, &buf); err != nil {
+ return err
+ }
+ showEml(&buf)
default:
return fmt.Errorf("unsupported operation")
}
diff --git a/config/binds.conf b/config/binds.conf
index 9e23ab91..ff067e56 100644
--- a/config/binds.conf
+++ b/config/binds.conf
@@ -113,6 +113,7 @@ $ex = <C-x>
# Keybindings used when reviewing a message to be sent
y = :send<Enter>
n = :abort<Enter>
+v = :preview<Enter>
p = :postpone<Enter>
q = :choose -o d discard abort -o p postpone postpone<Enter>
e = :edit<Enter>
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 2c062816..9fe1dd59 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -83,9 +83,11 @@ These commands work in any context.
*Note*: commands executed in this way are not executed with the shell.
*eml* [<path>]
+*preview*
Opens an eml file and displays the message in the message viewer.
- Can also be used in the message viewer to open an rfc822 attachment.
+ Can also be used in the message viewer to open an rfc822 attachment or
+ in the composer to preview the message.
*pwd*
Displays aerc's current working directory in the status bar.
diff --git a/widgets/compose.go b/widgets/compose.go
index c3f396bd..ca7c8b8f 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -681,13 +681,14 @@ func (c *Composer) PrepareHeader() (*mail.Header, error) {
return nil, err
}
}
- if !c.header.Has("Date") {
- if c.acctConfig.SendAsUTC {
- c.header.SetDate(time.Now().UTC())
- } else {
- c.header.SetDate(time.Now())
- }
+
+ // update the "Date" header every time PrepareHeader is called
+ if c.acctConfig.SendAsUTC {
+ c.header.SetDate(time.Now().UTC())
+ } else {
+ c.header.SetDate(time.Now())
}
+
return c.header, nil
}
@@ -1244,6 +1245,7 @@ var reviewCommands = [][]string{
{":attach<space>", "Add attachment"},
{":detach<space>", "Remove attachment"},
{":postpone<enter>", "Postpone"},
+ {":preview<enter>", "Preview message"},
{":abort<enter>", "Abort (discard message, no confirmation)"},
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
}