diff options
author | vrs <none> | 2015-07-30 22:56:42 +0200 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2015-12-16 15:51:38 +0000 |
commit | fbceaeff19bea7b1bdb28566d108f4e7f7733b81 (patch) | |
tree | bbae01be3e112e9062caf0e3d6882d3dd01202f4 /alot | |
parent | 668465c4bea2782d352ab88ba983c6615e94a9a1 (diff) |
add account option alias_regexp
Diffstat (limited to 'alot')
-rw-r--r-- | alot/account.py | 14 | ||||
-rw-r--r-- | alot/commands/thread.py | 6 | ||||
-rw-r--r-- | alot/defaults/alot.rc.spec | 3 |
3 files changed, 16 insertions, 7 deletions
diff --git a/alot/account.py b/alot/account.py index 4a62f0b4..0e40a816 100644 --- a/alot/account.py +++ b/alot/account.py @@ -33,6 +33,8 @@ class Account(object): """this accounts main email address""" aliases = [] """list of alternative addresses""" + alias_regexp = [] + """regex matching alternative addresses""" realname = None """real name used to format from-headers""" gpg_key = None @@ -47,13 +49,15 @@ class Account(object): """addressbook (:class:`addressbook.AddressBook`) managing this accounts contacts""" - def __init__(self, address=None, aliases=None, realname=None, - gpg_key=None, signature=None, signature_filename=None, - signature_as_attachment=False, sent_box=None, - sent_tags=['sent'], draft_box=None, draft_tags=['draft'], - abook=None, sign_by_default=False, **rest): + def __init__(self, address=None, aliases=None, alias_regexp=None, + realname=None, gpg_key=None, signature=None, + signature_filename=None, signature_as_attachment=False, + sent_box=None, sent_tags=['sent'], draft_box=None, + draft_tags=['draft'], abook=None, sign_by_default=False, + **rest): self.address = address self.aliases = aliases + self.alias_regexp = alias_regexp self.realname = realname self.gpg_key = gpg_key self.signature = signature diff --git a/alot/commands/thread.py b/alot/commands/thread.py index ca73c75f..0c8c64f9 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -72,11 +72,13 @@ def determine_sender(mail, action='reply'): # pick the most important account that has an address in candidates # and use that accounts realname and the address found here for account in my_accounts: - acc_addresses = account.get_addresses() + acc_addresses = map(re.escape, account.get_addresses()) + if account.alias_regexp is not None: + acc_addresses.append(account.alias_regexp) for alias in acc_addresses: if realname is not None: break - regex = re.compile(re.escape(alias), flags=re.IGNORECASE) + regex = re.compile('^' + alias + '$', flags=re.IGNORECASE) for seen_name, seen_address in candidate_addresses: if regex.match(seen_address): logging.debug("match!: '%s' '%s'" % (seen_address, alias)) diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index e0525279..77a4df0a 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -243,6 +243,9 @@ prefer_plaintext = boolean(default=False) # used to clear your addresses/ match account when formatting replies aliases = force_list(default=list()) + # a regex for catching further aliases (like + extensions). + alias_regexp = string(default=None) + # sendmail command. This is the shell command used to send out mails via the sendmail protocol sendmail_command = string(default='sendmail -t') |