From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 672276DE0083 for ; Thu, 6 Sep 2018 11:15:10 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.412 X-Spam-Level: X-Spam-Status: No, score=0.412 tagged_above=-999 required=5 tests=[AWL=-0.241, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tp6_f7QmNA8n for ; Thu, 6 Sep 2018 11:15:01 -0700 (PDT) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by arlo.cworth.org (Postfix) with ESMTPS id CFF6C6DE00AC for ; Thu, 6 Sep 2018 11:15:00 -0700 (PDT) Received: by mail-wm0-f48.google.com with SMTP id b19-v6so12326892wme.3 for ; Thu, 06 Sep 2018 11:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QYKwqptwV/EljyBtC+XU7rNUD43zkKE9TGhXZkL/LPw=; b=SdIQ1tb/+ufQaW26B8VixHojqrU+Y2cHjMHkVqwfnUt0SNb6O8r5HWPBoRE4+g7yFG z7VV1no3E8o7VtnQvE37fO1klyOJZOGY5XOUMISw60+VFcpHPLACb2Qvs6yOqP7wfIVe ZPhS/p0Pv/xpxR+wYrfQlh87f9NEF1ENcfZl4Cltlak+KV8n67z8iGZR2h95gaZv0Bfj g9m8uFuMgLiEAyzmfpQ5iRAoKM9RT+h8b/UpmTFZjkdUPH/FAE1p7cxsCwU+OsoPlm/Z jodSxVm6bMDoXNiX+Awv9BNCYdblnDHPp0gbD3DMwUQw+PTuRt5G2EHfMPle7ByhY7FO xEvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QYKwqptwV/EljyBtC+XU7rNUD43zkKE9TGhXZkL/LPw=; b=eyVX9AQKOwhZsjJ9tch6Z0gz3DjbH8ZXtXEiHe/0TZRl8vWmsN14Fs3LQm6Fp020wG 4WDws7hRZnczHv0O4ujFuP9sk7DqSA8IjJQKX6DLZmV7S2/H79b/hY654f5w5ZNrwzXm E8ZXHRbDxp00d58JtIjt6P18plcEciODljT519SwQD1FgGkqQ8P38fk6jJZ82LvIrtVZ RrPvQkDfHlXVs/Q+zrXtFt2M6m7wMjcx/YMR11WWpmm0F7dKRNrwXvUA/7ST/bURTxzJ L0py0Qb7kKCLA7e6HpnzExrVQJKN6PocojgfNDAHHByJXya1TNGSbXoE8GP151lT7Iqa UQ+w== X-Gm-Message-State: APzg51AsbK/qaULxovVuG8z1/MzlgqRibTK0yXBA7LGXDhjmnEmeoJir CnRrwhE+Ev0y+NdNljI18b5IAMDRjfw= X-Google-Smtp-Source: ANB0VdaZvzuWQLWDu81mfFrMjw609j96IkO4PisIv0EgMCulF/nP1eIr+aIMP/eol797iLn5iSKVHQ== X-Received: by 2002:a1c:e286:: with SMTP id z128-v6mr2922081wmg.30.1536257698720; Thu, 06 Sep 2018 11:14:58 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id b124-v6sm3806430wmg.47.2018.09.06.11.14.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 11:14:57 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 208305de for ; Thu, 6 Sep 2018 18:14:56 +0000 (UTC) From: David Edmondson 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 Message-Id: <20180906181456.21719-2-dme@dme.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180906181456.21719-1-dme@dme.org> References: <20180906181456.21719-1-dme@dme.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 18:15:10 -0000 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