From 5c6f90081fad69a8430e81e7d9e04212f7f3e009 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 22 Nov 2020 15:46:09 -0500 Subject: gnus, notmuch: Consider text/plain patch attachments 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. Message-Id: <20201122204609.12604-5-kyle@kyleam.com> --- piem.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'piem.el') diff --git a/piem.el b/piem.el index 9cc6a88..cf43503 100644 --- a/piem.el +++ b/piem.el @@ -561,10 +561,14 @@ This function depends on :url being configured for entries in ;;;; Patch handling -(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)))) (defun piem-extract-mbox-info (&optional buffer) "Collect information from message in BUFFER. -- cgit v1.2.3