aboutsummaryrefslogtreecommitdiffstats
path: root/commands/eml.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-23 21:27:08 +0200
committerRobin Jarry <robin@jarry.cc>2022-11-09 21:14:31 +0100
commit3e52278e86d07192a21a2624ccbabdc1d3ea5ad6 (patch)
tree88e23c7f9299f85ad607c942ccc7ec7cb97560f2 /commands/eml.go
parent492f89d7cde937011ebb8bce245eedd0e44e9839 (diff)
downloadaerc-3e52278e86d07192a21a2624ccbabdc1d3ea5ad6.tar.gz
viewer: open rfc822 attachments
Open message/rfc822 attachments from the message viewer when no filter is defined for this mimetype. When the rfc822 part is selected, call the eml command to open the attachment in a new message viewer. Suggested-by: Jens Grassel <jens@wegtam.com> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/eml.go')
-rw-r--r--commands/eml.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/commands/eml.go b/commands/eml.go
index a88a13b3..45dd4f25 100644
--- a/commands/eml.go
+++ b/commands/eml.go
@@ -49,15 +49,25 @@ func (Eml) Execute(aerc *widgets.Aerc, args []string) error {
})
}
- path := strings.Join(args[1:], " ")
- if _, err := os.Stat(path); err != nil {
- return err
- }
- f, err := os.Open(path)
- if err != nil {
- return err
+ if len(args) == 1 {
+ switch tab := aerc.SelectedTabContent().(type) {
+ case *widgets.MessageViewer:
+ part := tab.SelectedMessagePart()
+ tab.MessageView().FetchBodyPart(part.Index, showEml)
+ default:
+ return fmt.Errorf("unsupported operation")
+ }
+ } else {
+ path := strings.Join(args[1:], " ")
+ if _, err := os.Stat(path); err != nil {
+ return err
+ }
+ f, err := os.Open(path)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ showEml(f)
}
- defer f.Close()
- showEml(f)
return nil
}