From 006e9186b1fed6be1d5292015185a0d3278a370b Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Thu, 5 Mar 2020 19:29:22 +0000 Subject: [PATCH] Pipeto specific mime part format. While `pipeto --format mimepart` pipes whichever part is currently selected, the 'html' and 'plain' formats override the selected mime part (and preferences in settings). This is useful because the mime type you want displayed in alot isn't necessarily the one you want piped and also for setting keybindings to pipe specific mime types to specific applications (plain -> text editor, html -> web browser). --- alot/commands/thread.py | 7 +++++-- docs/source/usage/modes/thread.rst | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/alot/commands/thread.py b/alot/commands/thread.py index a6468b752..60faa56b2 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -633,7 +633,8 @@ def matches(msgt): (['--all'], {'action': 'store_true', 'help': 'pass all messages'}), (['--format'], {'help': 'output format', 'default': 'raw', 'choices': [ - 'raw', 'decoded', 'id', 'filepath', 'mimepart']}), + 'raw', 'decoded', 'id', 'filepath', 'mimepart', + 'plain', 'html']}), (['--separately'], {'action': 'store_true', 'help': 'call command once for each message'}), (['--background'], {'action': 'store_true', @@ -744,7 +745,9 @@ async def apply(self, ui): bodytext = msg.get_body_text() msgtext = '%s\n\n%s' % (headertext, bodytext) pipestrings.append(msgtext) - elif self.output_format == 'mimepart': + 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))) diff --git a/docs/source/usage/modes/thread.rst b/docs/source/usage/modes/thread.rst index 62a8765a8..155b50dd0 100644 --- a/docs/source/usage/modes/thread.rst +++ b/docs/source/usage/modes/thread.rst @@ -72,7 +72,7 @@ The following commands are available in thread mode: optional arguments :---all: pass all messages - :---format: output format; valid choices are: 'raw','decoded','id','filepath','mimepart' (defaults to: 'raw') + :---format: output format; valid choices are: 'raw','decoded','id','filepath','mimepart','plain','html' (defaults to: 'raw') :---separately: call command once for each message :---background: don't stop the interface :---add_tags: add 'Tags' header to the message