summaryrefslogtreecommitdiff
path: root/alot/commands/envelope.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/commands/envelope.py')
-rw-r--r--alot/commands/envelope.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index 84c1063e..0480cf0c 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -59,6 +59,33 @@ class AttachCommand(Command):
ui.current_buffer.rebuild()
+@registerCommand(MODE, 'unattach', arguments=[
+ (['hint'], {'nargs': '?', 'help': 'which attached file to remove'}),
+])
+class UnattachCommand(Command):
+ """remove attachments from current envelope"""
+ repeatable = True
+
+ def __init__(self, hint=None, **kwargs):
+ """
+ :param hint: which attached file to remove
+ :type hint: str
+ """
+ Command.__init__(self, **kwargs)
+ self.hint = hint
+
+ def apply(self, ui):
+ envelope = ui.current_buffer.envelope
+
+ if self.hint is not None:
+ for a in envelope.attachments:
+ if self.hint in a.get_filename():
+ envelope.attachments.remove(a)
+ else:
+ envelope.attachments = []
+ ui.current_buffer.rebuild()
+
+
@registerCommand(MODE, 'refine', arguments=[
(['key'], {'help': 'header to refine'})])
class RefineCommand(Command):