From: ekeberg@kth.se
To: notmuch@notmuchmail.org
Subject: [PATCH 1/2] emacs: limit search for attachment to stop at first mime-part
Date: Fri, 13 Dec 2019 00:35:35 +0100 [thread overview]
Message-ID: <20191212233536.7786-2-ekeberg@kth.se> (raw)
In-Reply-To: <20191212233536.7786-1-ekeberg@kth.se>
From: Örjan Ekeberg <ekeberg@kth.se>
This commit changes the behaviour of notmuch-mua-attachment-check
so that it stops searching for notmuch-mua-attachment-regexp when a
new mime-part is reached. This avoids false warnings when matching
words occur inside forwarded messages.
---
emacs/notmuch-mua.el | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 7fdd76bc..76572b87 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -137,17 +137,20 @@ Typically this is added to `notmuch-mua-send-hook'."
;; When the message mentions attachment...
(save-excursion
(message-goto-body)
- (loop while (re-search-forward notmuch-mua-attachment-regexp (point-max) t)
- ;; For every instance of the "attachment" string
- ;; found, examine the text properties. If the text
- ;; has either a `face' or `syntax-table' property
- ;; then it is quoted text and should *not* cause the
- ;; user to be asked about a missing attachment.
- if (let ((props (text-properties-at (match-beginning 0))))
- (not (or (memq 'syntax-table props)
- (memq 'face props))))
- return t
- finally return nil))
+ ;; Limit search from reaching other possible parts of the message
+ (let ((search-limit (search-forward "\n<#" nil t)))
+ (message-goto-body)
+ (loop while (re-search-forward notmuch-mua-attachment-regexp search-limit t)
+ ;; For every instance of the "attachment" string
+ ;; found, examine the text properties. If the text
+ ;; has either a `face' or `syntax-table' property
+ ;; then it is quoted text and should *not* cause the
+ ;; user to be asked about a missing attachment.
+ if (let ((props (text-properties-at (match-beginning 0))))
+ (not (or (memq 'syntax-table props)
+ (memq 'face props))))
+ return t
+ finally return nil)))
;; ...but doesn't have a part with a filename...
(save-excursion
(message-goto-body)
--
2.24.0
next prev parent reply other threads:[~2019-12-12 23:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 17:19 [BUG] emacs: notmuch-mua-attachment-check finds triggering string inside forwarded messages Örjan Ekeberg
2019-06-09 23:12 ` Daniel Kahn Gillmor
2019-12-12 23:35 ` [PATCH 0/2] Limit attachment check to stop before forwarded message ekeberg
2019-12-12 23:35 ` ekeberg [this message]
2019-12-12 23:35 ` [PATCH 2/2] test: extend test of attachment warnings ekeberg
2019-12-13 10:26 ` [PATCH 0/2] Limit attachment check to stop before forwarded message David Edmondson
2019-12-14 11:39 ` David Bremner
2021-12-25 18:04 ` [BUG] emacs: notmuch-mua-attachment-check finds triggering string inside forwarded messages David Bremner
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=20191212233536.7786-2-ekeberg@kth.se \
--to=ekeberg@kth.se \
--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).