[RFC PATCHv2 7/8] vim: mailcap: show all alternatives if none preferred

Subject: [RFC PATCHv2 7/8] vim: mailcap: show all alternatives if none preferred

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

To: notmuch@notmuchmail.org

Cc: nlhowell@gmail.com

From: Nick Howell


Display all parts of a multipart/alternative message (or message-part)
if no alternative_preference matches any of the alternative mimetypes.

E.g. if a message is multipart/alternative with options text/plain and
text/html, and the alternative_preference is ['application/pdf'], no
preference option matches any of the parts. This patch would just
display both parts.

Better configuration is to have '*/*' as an option in your
alternative_preference, e.g. ['text/plain', 'text/*', '*/*'], so that
there is always a catch-all.
---
 vim/notmuch.vim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 795ab26..cdcaa5f 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -346,7 +346,7 @@ ruby << EOF
 							when "best-only"
 								alternative_preference.each.collect do |mime_type|
 									part.parts.find { |p| File.fnmatch(mime_type, p.mime_type) }
-								end.first
+								end.reject(&:nil?).first || part.parts
 							when "best-sort"
 								part.parts.sort_by do |p|
 									alternative_preference.collect.with_index do |mime_type, i|
-- 
2.7.3


Thread: