aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/aerc.go4
-rw-r--r--widgets/compose.go20
2 files changed, 24 insertions, 0 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 35c32fe3..81d07474 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -598,6 +598,10 @@ func (aerc *Aerc) BeginExCommand(cmd string) {
aerc.focus(exline)
}
+func (aerc *Aerc) PushPrompt(prompt *ExLine) {
+ aerc.prompts.Push(prompt)
+}
+
func (aerc *Aerc) RegisterPrompt(prompt string, cmd []string) {
p := NewPrompt(aerc.conf, prompt, func(text string) {
if text != "" {
diff --git a/widgets/compose.go b/widgets/compose.go
index dc0c21aa..6e34365a 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -776,6 +776,26 @@ func (c *Composer) WriteMessage(header *mail.Header, writer io.Writer) error {
}
}
+func (c *Composer) ShouldWarnAttachment() (bool, error) {
+ regex := c.config.Compose.NoAttachmentWarning
+
+ if regex == nil || len(c.attachments) > 0 {
+ return false, nil
+ }
+
+ err := c.reloadEmail()
+ if err != nil {
+ return false, errors.Wrap(err, "reloadEmail")
+ }
+
+ body, err := io.ReadAll(c.email)
+ if err != nil {
+ return false, errors.Wrap(err, "io.ReadAll")
+ }
+
+ return regex.Match(body), nil
+}
+
func writeMsgImpl(c *Composer, header *mail.Header, writer io.Writer) error {
if len(c.attachments) == 0 && len(c.textParts) == 0 {
// no attachments