diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-02-03 11:57:44 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-02-03 11:58:57 +0100 |
commit | 4aec805399497c6082bd5328d95197a94ef32b9d (patch) | |
tree | 609760ac2cfe97fd915690abc663fe4959e11c58 | |
parent | 5f7571eeaf30f054b71327100caab2a15431cf66 (diff) |
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.
-rw-r--r-- | alot/commands/thread.py | 39 | ||||
-rw-r--r-- | 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 - |