summaryrefslogtreecommitdiff
path: root/alot/commands.py
diff options
context:
space:
mode:
authorpatrick <p.totzke@ed.ac.uk>2011-07-26 14:18:30 +0100
committerpatrick <p.totzke@ed.ac.uk>2011-07-26 14:18:30 +0100
commitd64475a92e472865d50f5ac6b7c0c39c6654ff5c (patch)
tree05896b770d6f7976606793e64b09ba8362772fc4 /alot/commands.py
parent475b65bde3ee4a331676a8ac8ebbd2f91d049e22 (diff)
reply command
Diffstat (limited to 'alot/commands.py')
-rw-r--r--alot/commands.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/alot/commands.py b/alot/commands.py
index 6324988a..dde5fdf4 100644
--- a/alot/commands.py
+++ b/alot/commands.py
@@ -73,7 +73,7 @@ class OpenThreadCommand(Command):
# in case the thread is yet unread, remove this tag
if 'unread' in self.thread.get_tags():
- self.thread.remove_tags(['unread'])
+ self.thread.remove_tags(['unread'], sync_maildir_flags=True)
ui.apply_command(FlushCommand())
self.thread.refresh()
@@ -429,6 +429,42 @@ class ComposeCommand(Command):
refocus=False))
+class ReplyCommand(Command):
+
+ def __init__(self, groupreply=True, **kwargs):
+ self.groupreply = groupreply
+ Command.__init__(self, **kwargs)
+
+ def apply(self, ui):
+ msg = ui.current_buffer.get_selected_message()
+ mail = msg.get_email()
+ mailcontent = ''
+ # set In-Reply-To header
+ mailcontent += 'In-Reply-To: %s' % msg.get_message_id()
+
+ # set References header
+ old_references = mail['References']
+ if old_references:
+ old_references = old_references.split()
+ references = old_references[-8:]
+ if len(old_references)>8:
+ references = old_references[:1] + references
+ references.append(msg.get_message_id())
+ mailcontent += 'References: %s' % ' '.join(references)
+
+ # extract from address from to,cc,bcc fields or leave blank
+ # (composeCommand will prompt)
+
+ # set body text
+ mailcontent += '\nOn %s, %s wrote' % (msg.get_datestring(),
+ msg.get_author()[0])
+ for line in msg.accumulate_body().split():
+ mailcontent += '>' + line + '\n'
+
+ reply = email.message_from_string(mailcontent)
+ ui.apply_command(ComposeCommand(mail=reply))
+
+
class RetagPromptCommand(Command):
"""start a commandprompt to retag selected threads' tags"""