From 5a62564c9676b1c74a33b9f31862f58a08b89e80 Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Wed, 11 Mar 2020 15:52:18 +0000 Subject: [PATCH] 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. --- alot/commands/thread.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 60faa56b2..4eafef3bf 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -29,6 +29,7 @@ from ..db.utils import decode_header from ..db.utils import formataddr from ..db.utils import get_body_part +from ..db.utils import extract_body_part from ..db.utils import extract_headers from ..db.utils import clear_my_address from ..db.utils import ensure_unique_address @@ -736,20 +737,22 @@ async def apply(self, ui): else: for msg in to_print: mail = msg.get_email() + mimepart = getattr( + ui.get_deep_focus(), 'mimepart', False) or msg.mime_part if self.add_tags: mail.add_header('Tags', ', '.join(msg.get_tags())) if self.output_format == 'raw': pipestrings.append(mail.as_string()) elif self.output_format == 'decoded': headertext = extract_headers(mail) - bodytext = msg.get_body_text() + bodytext = extract_body_part(mimepart) msgtext = '%s\n\n%s' % (headertext, bodytext) pipestrings.append(msgtext) elif self.output_format in ['mimepart', 'plain', 'html']: if self.output_format in ['plain', 'html']: mimepart = get_body_part(mail, self.output_format) pipestrings.append(string_sanitize(remove_cte( - msg.mime_part, as_string=True))) + mimepart, as_string=True))) if not self.separately: pipestrings = [separator.join(pipestrings)]