summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J Gruber <github@grubix.eu>2018-03-03 21:39:11 +0100
committerMichael J Gruber <github@grubix.eu>2018-03-05 13:51:40 +0100
commit716f2a9489f0586f8f13c94a3c3149668800b95d (patch)
tree6394510008d0d9e2d2e81c8f740c73e128d79f41
parentce5aab2c3d77cf5a0da5eb31508f564139072600 (diff)
implement replied and passed tags
maildir knows R and P flags which denote messages that have been replied to resp. passed on (fowarded, bounced). They correspond to IMAP flags \Replied and $Forwarded which are used by many clients and by synchronisation software. E.g., mbsync syncs \Replied to R, a patch for P is pending. Implement replied_tags and passed_tags for alot which work similar to sent_tags: sent_tags tags the sent message; replied_tags (resp. passed_tags) tags the message being replied to (resp. being fowarded). Basically, setting the replied_tags config to `replied` and replying to a message has the same effect as doing `tag replied; reply`, but the latter would tag even sending the reply is aborted or fails. The implementation in this patch makes sure that the tagging is done only if and when the reply resp. forward has been sent successfully.
-rw-r--r--alot/account.py7
-rw-r--r--alot/commands/envelope.py4
-rw-r--r--alot/commands/thread.py4
-rw-r--r--alot/db/envelope.py9
-rw-r--r--alot/defaults/alot.rc.spec6
-rw-r--r--docs/source/configuration/accounts_table20
6 files changed, 46 insertions, 4 deletions
diff --git a/alot/account.py b/alot/account.py
index c672686d..00c65753 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -208,7 +208,8 @@ class Account(object):
realname=None, gpg_key=None, signature=None,
signature_filename=None, signature_as_attachment=False,
sent_box=None, sent_tags=None, draft_box=None,
- draft_tags=None, abook=None, sign_by_default=False,
+ draft_tags=None, replied_tags=None, passed_tags=None,
+ abook=None, sign_by_default=False,
encrypt_by_default=u"none", encrypt_to_self=None,
case_sensitive_username=False, **_):
sent_tags = sent_tags or []
@@ -217,6 +218,8 @@ class Account(object):
draft_tags = draft_tags or []
if 'draft' not in draft_tags:
draft_tags.append('draft')
+ replied_tags = replied_tags or []
+ passed_tags = passed_tags or []
self.address = Address.from_string(address, case_sensitive=case_sensitive_username)
self.aliases = [Address.from_string(a, case_sensitive=case_sensitive_username)
@@ -233,6 +236,8 @@ class Account(object):
self.sent_tags = sent_tags
self.draft_box = draft_box
self.draft_tags = draft_tags
+ self.replied_tags = replied_tags
+ self.passed_tags = passed_tags
self.abook = abook
# Handle encrypt_by_default in an backwards compatible way. The
# logging info call can later be upgraded to warning or error.
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index d008d227..0aa95cf2 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -248,6 +248,10 @@ class SendCommand(Command):
cmd = commands.globals.BufferCloseCommand(self.envelope_buffer)
ui.apply_command(cmd)
ui.notify('mail sent successfully')
+ if self.envelope.replied:
+ self.envelope.replied.add_tags(account.replied_tags)
+ if self.envelope.passed:
+ self.envelope.passed.add_tags(account.passed_tags)
# store mail locally
# This can raise StoreMailError
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 609a4f3a..17fc6c3b 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -160,7 +160,7 @@ class ReplyCommand(Command):
for line in self.message.accumulate_body().splitlines():
mailcontent += quote_prefix + line + '\n'
- envelope = Envelope(bodytext=mailcontent)
+ envelope = Envelope(bodytext=mailcontent, replied=self.message)
# copy subject
subject = decode_header(mail.get('Subject', ''))
@@ -346,7 +346,7 @@ class ForwardCommand(Command):
self.message = ui.current_buffer.get_selected_message()
mail = self.message.get_email()
- envelope = Envelope()
+ envelope = Envelope(passed=self.message)
if self.inline: # inline mode
# set body text
diff --git a/alot/db/envelope.py b/alot/db/envelope.py
index 017dbaa4..90a58654 100644
--- a/alot/db/envelope.py
+++ b/alot/db/envelope.py
@@ -50,7 +50,8 @@ class Envelope(object):
def __init__(
self, template=None, bodytext=None, headers=None, attachments=None,
- sign=False, sign_key=None, encrypt=False, tags=None):
+ sign=False, sign_key=None, encrypt=False, tags=None, replied=None,
+ passed=None):
"""
:param template: if not None, the envelope will be initialised by
:meth:`parsing <parse_template>` this string before
@@ -64,6 +65,10 @@ class Envelope(object):
:type attachments: list of :class:`~alot.db.attachment.Attachment`
:param tags: tags to add after successful sendout and saving this msg
:type tags: list of str
+ :param replied: message being replied to
+ :type replied: :class:`~alot.db.message.Message`
+ :param passed: message being passed on
+ :type replied: :class:`~alot.db.message.Message`
"""
logging.debug('TEMPLATE: %s', template)
if template:
@@ -80,6 +85,8 @@ class Envelope(object):
self.encrypt = encrypt
self.encrypt_keys = {}
self.tags = tags or [] # tags to add after successful sendout
+ self.replied = replied # message being replied to
+ self.passed = passed # message being passed on
self.sent_time = None
self.modified_since_sent = False
self.sending = False # semaphore to avoid accidental double sendout
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec
index 8f7619d2..75e76841 100644
--- a/alot/defaults/alot.rc.spec
+++ b/alot/defaults/alot.rc.spec
@@ -327,6 +327,12 @@ thread_focus_linewise = boolean(default=True)
# list of tags to automatically add to draft messages
draft_tags = force_list(default='draft')
+ # list of tags to automatically add to replied messages
+ replied_tags = force_list(default='replied')
+
+ # list of tags to automatically add to passed messages
+ passed_tags = force_list(default='passed')
+
# path to signature file that gets attached to all outgoing mails from this account, optionally
# renamed to :ref:`signature_filename <signature-filename>`.
signature = string(default=None)
diff --git a/docs/source/configuration/accounts_table b/docs/source/configuration/accounts_table
index d2c81399..2215df51 100644
--- a/docs/source/configuration/accounts_table
+++ b/docs/source/configuration/accounts_table
@@ -100,6 +100,26 @@
:default: draft
+.. _replied-tags:
+
+.. describe:: replied_tags
+
+ list of tags to automatically add to replied messages
+
+ :type: string list
+ :default: replied
+
+
+.. _passed-tags:
+
+.. describe:: passed_tags
+
+ list of tags to automatically add to passed messages
+
+ :type: string list
+ :default: passed
+
+
.. _signature:
.. describe:: signature