aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
authorSebastien Binet <s@sbinet.org>2024-01-09 17:06:24 +0100
committerRobin Jarry <robin@jarry.cc>2024-01-17 12:00:01 +0100
commitec8b22b8eec40a745978547f296c2ab3ad2a5569 (patch)
tree2d7df497d76bee5a01828ebf93e212639ef9dc7e /commands/msg
parent680244d0533d2687039d947e00ff9c19abcf3ba8 (diff)
downloadaerc-ec8b22b8eec40a745978547f296c2ab3ad2a5569.tar.gz
reply,forward: use selected message part
Use the currently selected message part (if any) as the original message for quote-reply and forward. Honor viewer::alternatives if no message part was selected. Signed-off-by: Sebastien Binet <s@sbinet.org> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/forward.go3
-rw-r--r--commands/msg/reply.go9
-rw-r--r--commands/msg/utils.go15
3 files changed, 18 insertions, 9 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 4147e8c7..20e945c1 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -143,11 +143,12 @@ func (f forward) Execute(args []string) error {
f.Template = config.Templates.Forwards
}
- part := lib.FindPlaintext(msg.BodyStructure, nil)
+ part := getMessagePart(msg, widget)
if part == nil {
part = lib.FindFirstNonMultipart(msg.BodyStructure, nil)
// if it's still nil here, we don't have a multipart msg, that's fine
}
+
err = addMimeType(msg, part, &original)
if err != nil {
return err
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 4b3e7c81..333b3e3a 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -222,14 +222,7 @@ func (r reply) Execute(args []string) error {
return nil
}
- var part []int
- for _, mime := range config.Viewer.Alternatives {
- part = lib.FindMIMEPart(mime, msg.BodyStructure, nil)
- if part != nil {
- break
- }
- }
-
+ part := getMessagePart(msg, widget)
if part == nil {
// mkey... let's get the first thing that isn't a container
// if that's still nil it's either not a multipart msg (ok) or
diff --git a/commands/msg/utils.go b/commands/msg/utils.go
index 42693348..d6dffd50 100644
--- a/commands/msg/utils.go
+++ b/commands/msg/utils.go
@@ -6,6 +6,7 @@ import (
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/models"
)
@@ -59,3 +60,17 @@ func (h *helper) messages() ([]*models.MessageInfo, error) {
}
return commands.MsgInfoFromUids(store, uid, h.statusInfo)
}
+
+func getMessagePart(msg *models.MessageInfo, provider app.ProvidesMessage) []int {
+ p := provider.SelectedMessagePart()
+ if p != nil {
+ return p.Index
+ }
+ for _, mime := range config.Viewer.Alternatives {
+ part := lib.FindMIMEPart(mime, msg.BodyStructure, nil)
+ if part != nil {
+ return part
+ }
+ }
+ return nil
+}