Skip to content

Commit a15a41e

Browse files
committed
Pipe focused mime part from the mime tree.
When the mimetree is toggled on and a mime part is focused, pipeto should pipe the focused mime part rather than the currently selected part. This is only applicable to --format's that pipe a single part, which are decoded and mimepart.
1 parent e506686 commit a15a41e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

alot/commands/thread.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from ..db.utils import decode_header
3030
from ..db.utils import formataddr
3131
from ..db.utils import get_body_part
32+
from ..db.utils import extract_body_part
3233
from ..db.utils import extract_headers
3334
from ..db.utils import clear_my_address
3435
from ..db.utils import ensure_unique_address
@@ -736,20 +737,22 @@ async def apply(self, ui):
736737
else:
737738
for msg in to_print:
738739
mail = msg.get_email()
740+
mimepart = getattr(
741+
ui.get_deep_focus(), 'mimepart', False) or msg.mime_part
739742
if self.add_tags:
740743
mail.add_header('Tags', ', '.join(msg.get_tags()))
741744
if self.output_format == 'raw':
742745
pipestrings.append(mail.as_string())
743746
elif self.output_format == 'decoded':
744747
headertext = extract_headers(mail)
745-
bodytext = msg.get_body_text()
748+
bodytext = extract_body_part(mimepart)
746749
msgtext = '%s\n\n%s' % (headertext, bodytext)
747750
pipestrings.append(msgtext)
748751
elif self.output_format in ['mimepart', 'plain', 'html']:
749752
if self.output_format in ['plain', 'html']:
750753
mimepart = get_body_part(mail, self.output_format)
751754
pipestrings.append(string_sanitize(remove_cte(
752-
msg.mime_part, as_string=True)))
755+
mimepart, as_string=True)))
753756

754757
if not self.separately:
755758
pipestrings = [separator.join(pipestrings)]

0 commit comments

Comments
 (0)