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

Nick Howell nlhowell at gmail.com
Thu Oct 13 13:47:51 PDT 2016


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



More information about the notmuch mailing list