From 0035813ee18f2549592c2d806f445ab20cc6e143 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 5 Mar 2018 13:44:16 +0100 Subject: remove superfluous list() for ConfigObj force_list() converts single items to lists already. Thus, remove a superfluous list() that could be mistaken for converting a single string into a list of chars. --- docs/source/configuration/accounts_table | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/source/configuration/accounts_table b/docs/source/configuration/accounts_table index 33c554a3..4ebe0746 100644 --- a/docs/source/configuration/accounts_table +++ b/docs/source/configuration/accounts_table @@ -87,7 +87,7 @@ list of tags to automatically add to outgoing messages :type: string list - :default: sent, + :default: sent .. _signature: -- cgit v1.2.3 From ce5aab2c3d77cf5a0da5eb31508f564139072600 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sat, 3 Mar 2018 21:37:57 +0100 Subject: provide defaults and doc for draft_tags draft_tags works the same way as sent_tags, so provide the same defaults and doc. --- alot/defaults/alot.rc.spec | 3 +++ docs/source/configuration/accounts_table | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'docs') diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index f0cd9f1d..8f7619d2 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -324,6 +324,9 @@ thread_focus_linewise = boolean(default=True) # list of tags to automatically add to outgoing messages sent_tags = force_list(default='sent') + # list of tags to automatically add to draft messages + draft_tags = force_list(default='draft') + # path to signature file that gets attached to all outgoing mails from this account, optionally # renamed to :ref:`signature_filename `. signature = string(default=None) diff --git a/docs/source/configuration/accounts_table b/docs/source/configuration/accounts_table index 4ebe0746..d2c81399 100644 --- a/docs/source/configuration/accounts_table +++ b/docs/source/configuration/accounts_table @@ -90,6 +90,16 @@ :default: sent +.. _draft-tags: + +.. describe:: draft_tags + + list of tags to automatically add to draft messages + + :type: string list + :default: draft + + .. _signature: .. describe:: signature -- cgit v1.2.3 From 716f2a9489f0586f8f13c94a3c3149668800b95d Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sat, 3 Mar 2018 21:39:11 +0100 Subject: 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. --- alot/account.py | 7 ++++++- alot/commands/envelope.py | 4 ++++ alot/commands/thread.py | 4 ++-- alot/db/envelope.py | 9 ++++++++- alot/defaults/alot.rc.spec | 6 ++++++ docs/source/configuration/accounts_table | 20 ++++++++++++++++++++ 6 files changed, 46 insertions(+), 4 deletions(-) (limited to 'docs') 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 ` 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 = 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 -- cgit v1.2.3