diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/msg/reply.go | 31 | ||||
-rw-r--r-- | commands/msg/utils.go | 32 |
2 files changed, 32 insertions, 31 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go index e4c4577..762c15e 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -196,34 +196,3 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { return addTab() } } - -func findPlaintext(bs *models.BodyStructure, path []int) []int { - for i, part := range bs.Parts { - cur := append(path, i+1) - if strings.ToLower(part.MIMEType) == "text" && - strings.ToLower(part.MIMESubType) == "plain" { - return cur - } - if strings.ToLower(part.MIMEType) == "multipart" { - if path := findPlaintext(part, cur); path != nil { - return path - } - } - } - return nil -} - -func findFirstNonMultipart(bs *models.BodyStructure, path []int) []int { - for i, part := range bs.Parts { - cur := append(path, i+1) - mimetype := strings.ToLower(part.MIMEType) - if mimetype != "multipart" { - return path - } else if mimetype == "multipart" { - if path := findPlaintext(part, cur); path != nil { - return path - } - } - } - return nil -} diff --git a/commands/msg/utils.go b/commands/msg/utils.go index cad0f82..5eb5fe5 100644 --- a/commands/msg/utils.go +++ b/commands/msg/utils.go @@ -2,6 +2,7 @@ package msg import ( "errors" + "strings" "git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/lib" @@ -48,3 +49,34 @@ func (h *helper) messages() ([]*models.MessageInfo, error) { } return commands.MsgInfoFromUids(store, uid) } + +func findPlaintext(bs *models.BodyStructure, path []int) []int { + for i, part := range bs.Parts { + cur := append(path, i+1) + if strings.ToLower(part.MIMEType) == "text" && + strings.ToLower(part.MIMESubType) == "plain" { + return cur + } + if strings.ToLower(part.MIMEType) == "multipart" { + if path := findPlaintext(part, cur); path != nil { + return path + } + } + } + return nil +} + +func findFirstNonMultipart(bs *models.BodyStructure, path []int) []int { + for i, part := range bs.Parts { + cur := append(path, i+1) + mimetype := strings.ToLower(part.MIMEType) + if mimetype != "multipart" { + return path + } else if mimetype == "multipart" { + if path := findPlaintext(part, cur); path != nil { + return path + } + } + } + return nil +} |