From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id IJoPLC3Oul+rTAAAsNZ9tg (envelope-from ) for ; Sun, 22 Nov 2020 20:46:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aOXaJy3Oul/WaAAA1q6Kng (envelope-from ) for ; Sun, 22 Nov 2020 20:46:37 +0000 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) (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 D147E9402D6 for ; Sun, 22 Nov 2020 20:46:36 +0000 (UTC) Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 2D3EB116823; Sun, 22 Nov 2020 15:46:35 -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=v1IxF5Kl87Pbz8b1xsMdvHuuy Yg=; b=WZReW+boUuAoInoFHTOZ8EQwq15Vx9SkaViEFXhclsi9M720nLrKVdXa1 6D/X6dJbrHYxH2yxEzJnkzTelmeh5J/agYqT6w4hTlawRjKY9SLlb3psny0ddD/x ZFq/wH38d79SbA4TOXzjYFyMhfWIFhrTqMKxvh6EA0i/HB0XAY= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 2600A116822; Sun, 22 Nov 2020 15:46:35 -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=mGHYSIy+qywFohc/yG7zhkoHyJeVRyyhToKhxTGaxtU=; b=Hz8uMkBH7hWHXzHDAhJW/PbUAzlE1RF/rEdrFtEtS74F4xjBEK68VTZD+8zhscSOq1Z6gkw2YEi27cJcvpg53DIhRCF7bo2z6hjSfgDTNca5jfbMiRnifK8A7xRfUuU0FOd4E8fV4idrqZr2ZQG+K0oeYDA122GksfaMMooFmTM= 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-smtp21.pobox.com (Postfix) with ESMTPSA id 98220116821; Sun, 22 Nov 2020 15:46:32 -0500 (EST) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 2/4] gnus, notmuch: Share "attachment is patch?" logic Date: Sun, 22 Nov 2020 15:46:07 -0500 Message-Id: <20201122204609.12604-3-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: CDD4F5CC-2D03-11EB-849E-D609E328BF65-24757444!pb-smtp21.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=WZReW+bo; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=Hz8uMkBH; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 173.228.157.53 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: DjELUagr1qie This will gain another condition. Avoid repeating it across two spots. --- piem-gnus.el | 4 ++-- piem-notmuch.el | 4 ++-- piem.el | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/piem-gnus.el b/piem-gnus.el index 237eeb1..c1551ce 100644 --- a/piem-gnus.el +++ b/piem-gnus.el @@ -69,8 +69,8 @@ (defun piem-gnus-am-ready-mbox () (delq nil (mapcar (lambda (handle) (and (listp handle) - (member (mm-handle-media-type handle) - '("text/x-diff" "text/x-patch"= )) + (piem-am-patch-attachment-p + (mm-handle-media-type handle)) (with-temp-buffer (mm-display-inline handle) (buffer-substring-no-properties diff --git a/piem-notmuch.el b/piem-notmuch.el index cd3153a..ccfae75 100644 --- a/piem-notmuch.el +++ b/piem-notmuch.el @@ -91,8 +91,8 @@ (defun piem-notmuch-am-ready-mbox () (let ((patches (delq nil (mapcar (lambda (part) - (and (member (plist-get part :content-ty= pe) - '("text/x-diff" "text/x-pat= ch")) + (and (piem-am-patch-attachment-p + (plist-get part :content-type)) (plist-get part :content))) (plist-get body :content))))) (when patches diff --git a/piem.el b/piem.el index 784d0b3..9cc6a88 100644 --- a/piem.el +++ b/piem.el @@ -561,6 +561,11 @@ (defun piem-inject-thread-into-maildir (mid &optiona= l message-only) =0C ;;;; Patch handling =20 +(defun piem-am-patch-attachment-p (type) + "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"))) + (defun piem-extract-mbox-info (&optional buffer) "Collect information from message in BUFFER. If BUFFER is nil, the current buffer is used. Any message after --=20 2.29.2