diff options
author | jp39 <jp39@gmx.com> | 2022-11-10 19:39:19 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-13 17:13:53 +0100 |
commit | 40cc540357d92aee07fba2819801e168d3bf0f33 (patch) | |
tree | c85e42e5298a56308bcbd9d242c01460492aa378 /commands/msg/reply.go | |
parent | 76002741072a61d1adcf97f708a3db9d544b27de (diff) | |
download | aerc-40cc540357d92aee07fba2819801e168d3bf0f33.tar.gz |
reply: allow to override localized Re regexp in configuration
My corporate email server annoyingly adds an "[External] " prefix when
delivering emails from outside my organization. I'd like to be able to
automatically strip it from the subject line when replying to external
emails.
With this patch, I can achieve it by setting this line in my account
configuration:
subject-re-pattern = ^(\[External\] : )?((?i)((AW|RE|SV|VS|ODP|R): ?)+)
Signed-off-by: jp39 <jp39@gmx.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'commands/msg/reply.go')
-rw-r--r-- | commands/msg/reply.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go index f577a963..bd57f4b1 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -158,7 +158,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { recSet.AddList(cc) } - subject := "Re: " + trimLocalizedRe(msg.Envelope.Subject) + subject := "Re: " + trimLocalizedRe(msg.Envelope.Subject, conf.LocalizedRe) h := &mail.Header{} h.SetAddressList("to", to) @@ -331,9 +331,6 @@ func addMimeType(msg *models.MessageInfo, part []int, } // trimLocalizedRe removes known localizations of Re: commonly used by Outlook. -func trimLocalizedRe(subject string) string { +func trimLocalizedRe(subject string, localizedRe *regexp.Regexp) 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): ?)+`) |