reply: add automatic replacement of localized Re:
Some MUAs (namely Outlook) use localized prefixes for replied-to and forwarded mail. With this patch aerc replaces known localized prefixes and repetitions with the common Re: prefix. Link: https://office-watch.com/2014/outlook-reply-forward-prefixes/ Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
515a8b56f6
commit
2f575c00ec
1 changed files with 10 additions and 6 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.sr.ht/~sircmpwn/getopt"
|
"git.sr.ht/~sircmpwn/getopt"
|
||||||
|
@ -154,12 +155,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
recSet.AddList(cc)
|
recSet.AddList(cc)
|
||||||
}
|
}
|
||||||
|
|
||||||
var subject string
|
subject := "Re: " + trimLocalizedRe(msg.Envelope.Subject)
|
||||||
if !strings.HasPrefix(strings.ToLower(msg.Envelope.Subject), "re: ") {
|
|
||||||
subject = "Re: " + msg.Envelope.Subject
|
|
||||||
} else {
|
|
||||||
subject = msg.Envelope.Subject
|
|
||||||
}
|
|
||||||
|
|
||||||
h := &mail.Header{}
|
h := &mail.Header{}
|
||||||
h.SetAddressList("to", to)
|
h.SetAddressList("to", to)
|
||||||
|
@ -298,3 +294,11 @@ func addMimeType(msg *models.MessageInfo, part []int,
|
||||||
orig.MIMEType = fmt.Sprintf("%s/%s", bs.MIMEType, bs.MIMESubType)
|
orig.MIMEType = fmt.Sprintf("%s/%s", bs.MIMEType, bs.MIMESubType)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trimLocalizedRe removes known localizations of Re: commonly used by Outlook.
|
||||||
|
func trimLocalizedRe(subject string) string {
|
||||||
|
return strings.TrimPrefix(subject, localizedRe.FindString(subject))
|
||||||
|
}
|
||||||
|
|
||||||
|
// localizedRe contains a list of known translations for the common Re:
|
||||||
|
var localizedRe = regexp.MustCompile(`(?i)^((AW|RE|SV|VS|ODP|R): ?)+`)
|
||||||
|
|
Loading…
Reference in a new issue