Skip to content

Commit 9394b82

Browse files
committed
togglemimepart: switch between html and plaintext.
1 parent c3b259f commit 9394b82

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

alot/commands/thread.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,11 @@ async def apply(self, ui):
514514
forced={'mimetree': 'toggle'},
515515
arguments=[(['query'], {'help': 'query used to filter messages to affect',
516516
'nargs': '*'})])
517+
@registerCommand(
518+
MODE, 'togglemimepart', help='switch between html and plain text message',
519+
forced={'mimepart': 'toggle'},
520+
arguments=[(['query'], {'help': 'query used to filter messages to affect',
521+
'nargs': '*'})])
517522
class ChangeDisplaymodeCommand(Command):
518523

519524
"""fold or unfold messages"""
@@ -590,7 +595,14 @@ def matches(msgt):
590595
all_headers = not mt.display_all_headers \
591596
if self.all_headers == 'toggle' else self.all_headers
592597
if self.mimepart:
593-
mt.set_mimepart(ui.get_deep_focus().mimepart)
598+
if self.mimepart == 'toggle':
599+
message = mt.get_message()
600+
mimetype = {'plain': 'html', 'html': 'plain'}[
601+
message.mime_part.get_content_subtype()]
602+
mimepart = get_body_part(message.get_email(), mimetype)
603+
elif self.mimepart is True:
604+
mimepart = ui.get_deep_focus().mimepart
605+
mt.set_mimepart(mimepart)
594606
if self.mimetree == 'toggle':
595607
tbuffer.focus_selected_message()
596608
mimetree = not mt.display_mimetree \

alot/completion/command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def f(completed, pos):
194194
elif self.mode == 'thread' and cmd in ['fold', 'unfold',
195195
'togglesource',
196196
'toggleheaders',
197-
'togglemimetree']:
197+
'togglemimetree',
198+
'togglemimepart']:
198199
res = self._querycompleter.complete(params, localpos)
199200
elif self.mode == 'thread' and cmd in ['tag', 'retag', 'untag',
200201
'toggletags']:

0 commit comments

Comments
 (0)