]> git.neil.brown.name Git - edlib.git/commitdiff
notmuch: handle display of alternatives that are multipart.
authorNeilBrown <neil@brown.name>
Fri, 12 May 2023 09:10:19 +0000 (19:10 +1000)
committerNeilBrown <neil@brown.name>
Sat, 20 May 2023 00:10:49 +0000 (10:10 +1000)
An alternative can be multipart, e.g. multipart/related.
In that case it won't be the last segment of the path which
says "alternative".  We have to look earlier.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
python/module-notmuch.py

index 292164dacd5a5444569db2f39e2ede73ea122e31..68753f6b5b98aea7066bff90e389ff5342c13ffc 100644 (file)
@@ -35,7 +35,7 @@ Bugs to be fixed
 - [X] line break in <a hseq="2"\nhref=.....   isn't handled.
 - [X] utf-8 output from w3m gets displayed a bytes!!
        This is actually buggy spam which claims not to be utf-8
-- [ ] email: when alternative/1 is related and text/html, is isn't
+- [X] email: when alternative/1 is related and text/html, is isn't
        displayed by default.
 - [X] email: when a convertion pane is created on a 'text' component
       it should be given utf-8 and not have to use "bytes" like html does.
index 6e58442a075a90065cf8d82cc7bafa99ddd960d5..6a967563eaebbd76bdfa0ef5e67dba249c380938 100644 (file)
@@ -3182,11 +3182,21 @@ class notmuch_message_view(edlib.Pane):
             # know which is invisible when we get to the end.
             # So record the visibility of each group of alternatives
             # now, and the walk through again setting visibility.
+            # An alternative itself may be multi-part, typically
+            # multipart/related.  In this case we only look at
+            # whether we can handle the type of the first part.
             p = path.split(',')
-            if p[-1].startswith("alternative:"):
+            i = len(p)-1
+            while (i > 0 and p[i].endswith(":0") and
+                   not p[i].startswith("alternative:")):
+                # Might be the first part of a multi-path alternative,
+                # look earlier in the path
+                i -= 1
+            edlib.LOG("consider", p, i, )
+            if p[i].startswith("alternative:"):
                 # this is one of several - can we handle it?
-                group = ','.join(p[:-1])
-                this = p[-1][12:]
+                group = ','.join(p[:i])
+                this = p[i][12:]
                 if type in ['text/plain', 'text/calendar', 'text/rfc822-headers',
                             'message/rfc822']:
                     choose[group] = this