From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id YO74HDTOul/xWQAAsNZ9tg (envelope-from ) for ; Sun, 22 Nov 2020 20:46:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qKuxGDTOul+RUAAAbx9fmQ (envelope-from ) for ; Sun, 22 Nov 2020 20:46:44 +0000 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E5C0E9402D6 for ; Sun, 22 Nov 2020 20:46:43 +0000 (UTC) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 9090C100735; Sun, 22 Nov 2020 15:46:42 -0500 (EST) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=b9Ffr20XMnvFe68A0qf8OyX4t iw=; b=OaVh01VY+TJIFVEYiY1kUNtagTpHW7dXg5fCZf1GCYN+7aym7yeXo2N72 xDyotlg2hrPnDpLOMhgaJe++LKM+9af4byg4dvTW2dRJ/k28SfwdzKWHRdZ5H6Sz VOREwStj/g0nRHAQihZbanpGKebtaPYb45KRxPbxUyBY+kuKXY= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 8A99F100734; Sun, 22 Nov 2020 15:46:42 -0500 (EST) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=mesmtp; bh=hF55sM0rH4rGSp/mTNmsBWQl2hhG38Bnmo2qpVbjd84=; b=Lg0P/lr/Z6jLVAqaEolSg/63Ci4nbwXVWKXEXPbDzpKLXt/3DRClJmr7EYSb8lpq8gAwHgyGGsRQpMMT91QrXsz5w7GihEuvuTRj5/J9Aq/f2QXBJgoemAmrJhRNh5furGL1NNem0g+wZRxRLBgWoE9IGzptHuoS5lEvhxehtFE= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id F41F0100725; Sun, 22 Nov 2020 15:46:39 -0500 (EST) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 4/4] gnus, notmuch: Consider text/plain patch attachments Date: Sun, 22 Nov 2020 15:46:09 -0500 Message-Id: <20201122204609.12604-5-kyle@kyleam.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201122204609.12604-1-kyle@kyleam.com> References: <20201122204609.12604-1-kyle@kyleam.com> MIME-Version: 1.0 X-Pobox-Relay-ID: D23B86F8-2D03-11EB-8D2C-E43E2BB96649-24757444!pb-smtp20.pobox.com Content-Transfer-Encoding: quoted-printable X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=OaVh01VY; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=Lg0P/lr/; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 173.228.157.52 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: GiShaSNg1rr9 When inspecting attachments for generating an am-ready mbox, both -notmuch and -gnus limit the operation to attachments with text/x-diff or text/x-patch content types. That has worked okay for me, though I've run into a few cases where I couldn't apply a patch attachment because it had a text/plain content type. To do something useful in this case, check the file name to see whether it looks like a patch. --- piem-gnus.el | 3 ++- piem-notmuch.el | 3 ++- piem.el | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/piem-gnus.el b/piem-gnus.el index ca128fb..9dc4ae8 100644 --- a/piem-gnus.el +++ b/piem-gnus.el @@ -70,7 +70,8 @@ (defun piem-gnus-am-ready-mbox () (mapcar (lambda (handle) (and (listp handle) (piem-am-patch-attachment-p - (mm-handle-media-type handle)) + (mm-handle-media-type handle) + (mm-handle-filename handle)) (with-temp-buffer (mm-display-inline handle) (buffer-substring-no-properties diff --git a/piem-notmuch.el b/piem-notmuch.el index 8f5ef77..58e4d88 100644 --- a/piem-notmuch.el +++ b/piem-notmuch.el @@ -92,7 +92,8 @@ (defun piem-notmuch-am-ready-mbox () (delq nil (mapcar (lambda (part) (and (piem-am-patch-attachment-p - (plist-get part :content-type= )) + (plist-get part :content-type= ) + (plist-get part :filename)) (plist-get part :content))) (plist-get body :content))))) (cons (lambda () diff --git a/piem.el b/piem.el index 9cc6a88..bee17c0 100644 --- a/piem.el +++ b/piem.el @@ -561,10 +561,14 @@ (defun piem-inject-thread-into-maildir (mid &option= al message-only) =0C ;;;; Patch handling =20 -(defun piem-am-patch-attachment-p (type) +(defun piem-am-patch-attachment-p (type filename) "Return non-nil if an attachment should be treated as a patch. -TYPE is a media type such as \"text/x-patch\"." - (member type '("text/x-diff" "text/x-patch"))) +TYPE is a media type such as \"text/x-patch\". FILENAME is the +attachment file name, if any." + (or (member type '("text/x-diff" "text/x-patch")) + (and filename + (equal type "text/plain") + (string-match-p "\\.patch\\'" filename)))) =20 (defun piem-extract-mbox-info (&optional buffer) "Collect information from message in BUFFER. --=20 2.29.2