From 4aec805399497c6082bd5328d95197a94ef32b9d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 3 Feb 2021 11:57:44 +0100 Subject: commands/thread: drop the select command It no longer makes sense since the buffer has been split into two windows. Replace it with a new 'openattachment' command for opening attachments. --- alot/commands/thread.py | 39 +++++++++++---------------------------- alot/defaults/default.bindings | 2 +- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 72c607b1..98355f4c 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -920,23 +920,21 @@ class SaveAttachmentCommand(Command): self._save_attachment(ui, path, a) +@registerCommand(MODE, 'openattachment') class OpenAttachmentCommand(Command): """displays an attachment according to mailcap""" - def __init__(self, attachment, **kwargs): - """ - :param attachment: attachment to open - :type attachment: :class:`~alot.db.attachment.Attachment` - """ - super().__init__(**kwargs) - self.attachment = attachment - async def apply(self, ui): - logging.info('open attachment') - data = self.attachment.data - mimetype = self.attachment.content_type - params = self.attachment.params - fname = self.attachment.filename + attachment = ui.current_buffer.get_selected_attachment() + if attachment is None: + return + + logging.info('open attachment: %s', attachment) + + data = attachment.data + mimetype = attachment.content_type + params = attachment.params + fname = attachment.filename h = MailcapHandler(data, mimetype, params, fname, 'view') if not h: @@ -1030,21 +1028,6 @@ class MoveFocusCommand(MoveCommand): # TODO: add next by date.. -@registerCommand(MODE, 'select') -class ThreadSelectCommand(Command): - - """select focussed element: - - if it is a message summary, toggle visibility of the message; - - if it is an attachment line, open the attachment""" - async def apply(self, ui): - attachment = ui.current_buffer.get_selected_attachment() - if attachment is not None: - logging.info('open attachment') - await ui.apply_command(OpenAttachmentCommand(attachment)) - else: - ui.current_buffer.focus_toggle() - - RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand) diff --git a/alot/defaults/default.bindings b/alot/defaults/default.bindings index 16d9d04a..acbb4c46 100644 --- a/alot/defaults/default.bindings +++ b/alot/defaults/default.bindings @@ -61,7 +61,7 @@ q = exit enter = select [thread] - enter = select + enter = openattachment [ = indent - ] = indent + { = weight - -- cgit v1.2.3