summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seren <guillaumeseren@gmail.com>2015-11-02 22:44:59 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2015-12-16 16:02:00 +0000
commit8b065ebdd292c84d63a56a1b506e44259b9932ea (patch)
treeb7f96c70bde3303ed10bf8b3a1d3cce55224ee79
parent13295e387efb433f5d452ca81f1696c8eda0f47d (diff)
Add --list option to reply Mailing list
Provide an option to the reply command ':reply --list': * In reply to someone to a list (not you), it will take if available (Reply-To, X-BeenThere or X-Mailing-List). * In the rare reply to you sending to a list, it will take the To which is the list mail. This work start/rebase/refactor from this 'old' (3 years) PR on github: https://github.com/pazz/alot/pull/479#issuecomment-152750321
-rw-r--r--alot/commands/thread.py22
-rw-r--r--docs/source/usage/modes/thread.rst1
2 files changed, 22 insertions, 1 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 1d39fc4d..21e2721b 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -105,6 +105,7 @@ def determine_sender(mail, action='reply'):
@registerCommand(MODE, 'reply', arguments=[
(['--all'], {'action': 'store_true', 'help': 'reply to all'}),
+ (['--list'], {'action': 'store_true', 'dest': 'listreply', 'help': 'reply to list'}),
(['--spawn'], {'action': BooleanAction, 'default': None,
'help': 'open editor in new window'})])
class ReplyCommand(Command):
@@ -112,17 +113,20 @@ class ReplyCommand(Command):
"""reply to message"""
repeatable = True
- def __init__(self, message=None, all=False, spawn=None, **kwargs):
+ def __init__(self, message=None, all=False, listreply=False, spawn=None, **kwargs):
"""
:param message: message to reply to (defaults to selected message)
:type message: `alot.db.message.Message`
:param all: group reply; copies recipients from Bcc/Cc/To to the reply
:type all: bool
+ :param listreply: reply to list
+ :type listreply: bool
:param spawn: force spawning of editor in a new terminal
:type spawn: bool
"""
self.message = message
self.groupreply = all
+ self.listreply = listreply
self.force_spawn = spawn
Command.__init__(self, **kwargs)
@@ -212,6 +216,22 @@ class ReplyCommand(Command):
to = ', '.join(recipients)
logging.debug('reply to: %s' % to)
+
+ if self.listreply:
+ # To choose the target of the reply --list
+ # Reply-To is standart reply target RFC 2822:, RFC 1036: 2.2.1
+ # X-BeenThere is needed by sourceforge ML also winehq
+ # X-Mailing-List is also standart and is used by git-send-mail
+ to = mail['Reply-To'] or mail['X-BeenThere'] or mail['X-Mailing-List']
+ # Some mail server (gmail) will not resend you own mail, so you have
+ # to deal with the one in sent
+ if to is None:
+ to = mail['To']
+ logging.debug('mail list reply to: %s' % to)
+ # Cleaning the 'To' in this case
+ envelope.__delitem__('To')
+
+ # Finally setup the 'To' header
envelope.add('To', decode_header(to))
# if any of the recipients is a mailinglist that we are subscribed to,
diff --git a/docs/source/usage/modes/thread.rst b/docs/source/usage/modes/thread.rst
index e849c3c3..1db63f61 100644
--- a/docs/source/usage/modes/thread.rst
+++ b/docs/source/usage/modes/thread.rst
@@ -167,6 +167,7 @@ The following commands are available in thread mode
optional arguments
:---all: reply to all.
+ :---list: reply to list.
:---spawn: open editor in new window.
.. _cmd.thread.save: