From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v1 1/2] emacs: Optionally check for missing attachments in outgoing messages
Date: Thu, 6 Sep 2018 19:14:55 +0100 [thread overview]
Message-ID: <20180906181456.21719-2-dme@dme.org> (raw)
In-Reply-To: <20180906181456.21719-1-dme@dme.org>
Query the user if the message text indicates that an attachment is
expected but no MML referencing an attachment is found.
This is not enabled by default - see the documentation for
`notmuch-mua-attachment-check'.
---
emacs/notmuch-mua.el | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index fc8ac687..ceb9f3a9 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -115,8 +115,35 @@ multiple parts get a header."
(function :tag "Other"))
:group 'notmuch-reply)
+(defcustom notmuch-mua-attachment-regexp
+ "\\b\\(attache\?ment\\|attached\\|attach\\|pi[èe]ce\s+jointe?\\)\\b"
+ "Message body text indicating that an attachment is expected.
+
+This is not used unless `notmuch-mua-attachment-check' is added
+to `notmuch-mua-send-hook'.")
+
;;
+(defun notmuch-mua-attachment-check ()
+ "Signal an error if the message text indicates that an
+attachment is expected but no MML referencing an attachment is
+found.
+
+Typically this is added to `notmuch-mua-send-hook'."
+ (when (and
+ ;; When the message mentions attachment...
+ (save-excursion
+ (message-goto-body)
+ (re-search-forward notmuch-mua-attachment-regexp nil t))
+ ;; ...but doesn't have a part with a filename...
+ (save-excursion
+ (message-goto-body)
+ (not (re-search-forward "^<#part [^>]*filename=" nil t)))
+ ;; ...and that's not okay...
+ (not (y-or-n-p "Attachment mentioned, but no attachment - is that okay?")))
+ ;; ...signal an error.
+ (error "Missing attachment")))
+
(defun notmuch-mua-get-switch-function ()
"Get a switch function according to `notmuch-mua-compose-in'."
(cond ((eq notmuch-mua-compose-in 'current-window)
--
2.11.0
next prev parent reply other threads:[~2018-09-06 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 18:14 [PATCH v1 0/2] emacs: Optionally warn if attachments are mentioned in an outgoing David Edmondson
2018-09-06 18:14 ` David Edmondson [this message]
2018-09-06 18:14 ` [PATCH v1 2/2] test: Add emacs attachment check tests David Edmondson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180906181456.21719-2-dme@dme.org \
--to=dme@dme.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).