summaryrefslogtreecommitdiff
path: root/alot/commands/envelope.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2013-05-26 19:52:56 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-05-26 20:37:28 +0100
commit9ca50195a6832a88fff7471d37e29af965eb06d6 (patch)
tree73f25d9cdcbe013293ff429b4f12c31ac9fd69c2 /alot/commands/envelope.py
parent64003392b9ee09007f98c6549e3da02618fd381b (diff)
add 'unattach' command for envelope 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):