Skip to content

Commit

Permalink
Pipeto specific mime part format.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ryneeverett committed Jan 26, 2022
1 parent cf57830 commit 19b8201
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions alot/commands/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ def apply(self, ui):
(['--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',
Expand Down Expand Up @@ -746,7 +747,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)))

Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage/modes/thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 19b8201

Please sign in to comment.