[RFC PATCH 6/7] vim: mailcap: show all alternatives if none preferred
Nick Howell
nlhowell at gmail.com
Thu Oct 13 13:13:55 PDT 2016
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 | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 5cb8d20..da747eb 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -337,7 +337,24 @@ ruby << EOF
while parts.any?(&:multipart?)
parts = parts.collect do |part|
if part.multipart?
- part.parts
+ if part.mime_type == "multipart/alternative"
+ case alternative_display
+ when "best-only"
+ alternative_preference.each.collect do |mime_type|
+ part.parts.find { |p| File.fnmatch(mime_type, p.mime_type) }
+ end.reject(&:nil?).first || part.parts
+ when "best-sort"
+ part.parts.sort_by do |p|
+ alternative_preference.collect.with_index do |mime_type, i|
+ (File.fnmatch(mime_type, p.mime_type) ? 0 : 1) << i
+ end.reduce(:+)
+ end
+ when "verbatim"
+ part.parts
+ end
+ else
+ part.parts
+ end
else
part
end
--
2.7.3
More information about the notmuch
mailing list