aboutsummaryrefslogtreecommitdiffstats
path: root/config/config.go
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 /config/config.go
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 'config/config.go')
-rw-r--r--config/config.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
index 2da4559f..7d84476e 100644
--- a/config/config.go
+++ b/config/config.go
@@ -175,6 +175,7 @@ type AccountConfig struct {
FoldersSort []string `ini:"folders-sort" delim:","`
AddressBookCmd string `ini:"address-book-cmd"`
SendAsUTC bool `ini:"send-as-utc"`
+ LocalizedRe *regexp.Regexp
// CheckMail
CheckMail time.Duration `ini:"check-mail"`
@@ -313,6 +314,8 @@ func loadAccountConfig(path string, accts []string) ([]AccountConfig, error) {
Params: make(map[string]string),
EnableFoldersSort: true,
CheckMailTimeout: 10 * time.Second,
+ // localizedRe contains a list of known translations for the common Re:
+ LocalizedRe: regexp.MustCompile(`(?i)^((AW|RE|SV|VS|ODP|R): ?)+`),
}
if err = sec.MapTo(&account); err != nil {
return nil, err
@@ -360,6 +363,13 @@ func loadAccountConfig(path string, accts []string) ([]AccountConfig, error) {
account.PgpOpportunisticEncrypt, _ = strconv.ParseBool(val)
case "address-book-cmd":
account.AddressBookCmd = val
+ case "subject-re-pattern":
+ re, err := regexp.Compile(val)
+ if err != nil {
+ return nil, fmt.Errorf(
+ "%s=%s %w", key, val, err)
+ }
+ account.LocalizedRe = re
default:
if key != "name" {
account.Params[key] = val