[RFC PATCHv2 3/8] vim: mailcap: gracefully handle missing mimetype

Subject: [RFC PATCHv2 3/8] vim: mailcap: gracefully handle missing mimetype

Date: Thu, 13 Oct 2016 14:47:51 -0600

To: notmuch@notmuchmail.org

Cc: nlhowell@gmail.com

From: Nick Howell


Some plaintext messages do not specify a mimetype. Instead of failing in
this situation, just assume the part is plaintext. (Maybe a better
strategy would be to check if the message contains non-unicode first?)
---
 vim/notmuch.vim | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 947fec0..89fa2dc 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -345,9 +345,9 @@ ruby << EOF
 			end
 
 			parts.each do |part|
-				b << "--- %s ---" % part.mime_type
+				b << "--- %s ---" % ( [part.mime_type || "unknown", part.filename].find_all { |x| x }.join(" ") )
 				begin
-					IO.popen(mailcap % part.mime_type, "r+b") do |io|
+					IO.popen(mailcap % (part.mime_type || "text/plain"), "r+b") do |io|
 						io.write(part.decoded)
 						io.close_write
 						io.each_line do |l|
-- 
2.7.3


Thread: