aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
authorjp39 <jp39@gmx.com>2022-11-10 19:39:19 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-13 17:13:53 +0100
commit40cc540357d92aee07fba2819801e168d3bf0f33 (patch)
treec85e42e5298a56308bcbd9d242c01460492aa378 /commands/msg
parent76002741072a61d1adcf97f708a3db9d544b27de (diff)
downloadaerc-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')
-rw-r--r--commands/msg/invite.go2
-rw-r--r--commands/msg/reply.go7
2 files changed, 3 insertions, 6 deletions
diff --git a/commands/msg/invite.go b/commands/msg/invite.go
index 37a194a6..4b2507f4 100644
--- a/commands/msg/invite.go
+++ b/commands/msg/invite.go
@@ -48,7 +48,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
return fmt.Errorf("no invitation found (missing text/calendar)")
}
- subject := trimLocalizedRe(msg.Envelope.Subject)
+ subject := trimLocalizedRe(msg.Envelope.Subject, acct.AccountConfig().LocalizedRe)
switch args[0] {
case "accept":
subject = "Accepted: " + subject
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): ?)+`)