Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '0.3.3-feature-plussing-515'

  • Loading branch information...
commit 27c91058c49d8755d2813d5b78094f40f36ec905 2 parents fcf24cf + 7536499
@pazz authored
Showing with 34 additions and 11 deletions.
  1. +24 −11 alot/commands/thread.py
  2. +10 −0 alot/defaults/alot.rc.spec
View
35 alot/commands/thread.py
@@ -2,6 +2,7 @@
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
import os
+import re
import logging
import tempfile
from twisted.internet.defer import inlineCallbacks
@@ -54,22 +55,36 @@ def recipient_to_from(mail, my_accounts):
if delivered_to is not None:
recipients.append(delivered_to)
+ logging.debug('recipients: %s' % recipients)
# pick the most important account that has an address in recipients
# and use that accounts realname and the found recipient address
for acc in my_accounts:
acc_addresses = acc.get_addresses()
- for rec in recipients:
- _, raddress = parseaddr(rec)
- raddress = raddress.decode()
- if raddress in acc_addresses and realname is None:
- realname = acc.realname
- address = raddress
+ for alias_re in acc_addresses:
+ if realname is not None:
+ break
+ regex = re.compile(alias_re)
+ for rec in recipients:
+ seen_name, seen_address = parseaddr(rec)
+ if regex.match(seen_address):
+ logging.debug("match!: '%s' '%s'" % (seen_address, alias_re))
+ if settings.get('reply_force_realname'):
+ realname = acc.realname
+ else:
+ realname = seen_name
+ if settings.get('reply_force_address'):
+ address = acc.address
+ else:
+ address = seen_address
# revert to default account if nothing found
if realname is None:
realname = my_accounts[0].realname
address = my_accounts[0].address
- return realname, address
+ logging.debug('using realname: "%s"' % realname)
+ logging.debug('using address: %s' % address)
+
+ return address if realname == '' else '%s <%s>' % (realname, address)
@registerCommand(MODE, 'reply', arguments=[
@@ -135,8 +150,7 @@ def apply(self, ui):
envelope.add('Subject', subject)
# set From
- realname, address = recipient_to_from(mail, my_accounts)
- envelope.add('From', '%s <%s>' % (realname, address))
+ envelope.add('From', recipient_to_from(mail, my_accounts))
# set To
sender = mail['Reply-To'] or mail['From']
@@ -258,8 +272,7 @@ def apply(self, ui):
envelope.add('Subject', subject)
# set From
- realname, address = recipient_to_from(mail, my_accounts)
- envelope.add('From', '%s <%s>' % (realname, address))
+ envelope.add('From', recipient_to_from(mail, my_accounts))
# continue to compose
ui.apply_command(ComposeCommand(envelope=envelope,
View
10 alot/defaults/alot.rc.spec
@@ -169,6 +169,16 @@ quote_prefix = string(default='> ')
# only if original subject doesn't start with 'Re:' or this prefix
reply_subject_prefix = string(default='Re: ')
+# Always use the proper realname when constructing "From" headers
+# for replies/forwards. Set this to False to use the realname string
+# as received in the original message.
+reply_force_realname = boolean(default=True)
+
+# Always use the accounts main address when constructing "From" headers
+# for replies/forwards. Set this to False to use the address string
+# as received in the original message.
+reply_force_address = boolean(default=False)
+
# String prepended to subject header on forward
# only if original subject doesn't start with 'Fwd:' or this prefix
forward_subject_prefix = string(default='Fwd: ')
Please sign in to comment.
Something went wrong with that request. Please try again.