aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorJason Cox <dev@jasoncarloscox.com>2022-10-17 13:19:33 -0400
committerRobin Jarry <robin@jarry.cc>2022-10-17 22:41:00 +0200
commit7647dfb8b47edbcb8080bd0327529383142ec888 (patch)
tree80cdd42050598815e0fa872745def3cc7d2bea80 /config
parent8ffcd3e5adfa008f33989d4589a47ae1cd1a5e68 (diff)
downloadaerc-7647dfb8b47edbcb8080bd0327529383142ec888.tar.gz
compose: warn before sending without attachment
Prevent the embarrassing forgotten attachment scenario by warning the user before sending a message that may need an attachment but does not have one. Whether a message needs an attachment is determined by testing a configurable regex against the message body. Signed-off-by: Jason Cox <dev@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config')
-rw-r--r--config/aerc.conf12
-rw-r--r--config/config.go21
2 files changed, 29 insertions, 4 deletions
diff --git a/config/aerc.conf b/config/aerc.conf
index a980c70e..384a0db3 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -297,6 +297,18 @@ address-book-cmd=
# Default: true
reply-to-self=true
+#
+# Warn before sending an email that matches the specified regexp but does not
+# have any attachments. Leave empty to disable this feature.
+#
+# Uses Go's regexp syntax, documented at https://golang.org/s/re2syntax. The
+# "(?im)" flags are set by default (case-insensitive and multi-line).
+#
+# Example:
+# no-attachment-warning=^[^>]*attach(ed|ment)
+#
+no-attachment-warning=
+
[filters]
#
# Filters allow you to pipe an email body through a shell command to render
diff --git a/config/config.go b/config/config.go
index e40d964a..0de1780c 100644
--- a/config/config.go
+++ b/config/config.go
@@ -203,10 +203,11 @@ type BindingConfigContext struct {
}
type ComposeConfig struct {
- Editor string `ini:"editor"`
- HeaderLayout [][]string `ini:"-"`
- AddressBookCmd string `ini:"address-book-cmd"`
- ReplyToSelf bool `ini:"reply-to-self"`
+ Editor string `ini:"editor"`
+ HeaderLayout [][]string `ini:"-"`
+ AddressBookCmd string `ini:"address-book-cmd"`
+ ReplyToSelf bool `ini:"reply-to-self"`
+ NoAttachmentWarning *regexp.Regexp `ini:"-"`
}
type FilterConfig struct {
@@ -523,6 +524,18 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
if key == "header-layout" {
config.Compose.HeaderLayout = parseLayout(val)
}
+
+ if key == "no-attachment-warning" && len(val) > 0 {
+ re, err := regexp.Compile("(?im)" + val)
+ if err != nil {
+ return fmt.Errorf(
+ "Invalid no-attachment-warning '%s': %w",
+ val, err,
+ )
+ }
+
+ config.Compose.NoAttachmentWarning = re
+ }
}
}