diff options
-rw-r--r-- | piem-gnus.el | 3 | ||||
-rw-r--r-- | piem-notmuch.el | 3 | ||||
-rw-r--r-- | 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 @@ message itself if it looks like a patch." (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 @@ message itself if it looks like a patch." (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 () @@ -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. |