summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-22 18:13:57 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-22 18:13:57 +0100
commit81365335e1b3ae40ff36af13fd16ff0e5872e85d (patch)
treeaf58df4c926f7e224eab17fa90f3815d1de18409 /alot
parentbc299dd30a3f7c55bf1bb8da4caee215791443f7 (diff)
better handling of missing from headers in compose
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/globals.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index f7c29fd6..59e20ab7 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -447,25 +447,21 @@ class ComposeCommand(Command):
# get missing From header
if not 'From' in self.mail:
accounts = ui.accountman.get_accounts()
- if len(accounts) == 0:
- ui.notify('no accounts set')
- return
- elif len(accounts) == 1:
+ if len(accounts) == 1:
a = accounts[0]
+ self.mail['From'] = "%s <%s>" % (a.realname, a.address)
else:
cmpl = AccountCompleter(ui.accountman)
fromaddress = yield ui.prompt(prefix='From>', completer=cmpl,
tab=1)
- validaddresses = [a.address for a in accounts] + [None]
- while fromaddress not in validaddresses: # TODO: not cool
- ui.notify('no account for this address. (<esc> cancels)')
- fromaddress = yield ui.prompt(prefix='From>',
- completer=cmpl)
- if not fromaddress:
+ if fromaddress is None:
ui.notify('canceled')
return
a = ui.accountman.get_account_by_address(fromaddress)
- self.mail['From'] = "%s <%s>" % (a.realname, a.address)
+ if a is not None:
+ self.mail['From'] = "%s <%s>" % (a.realname, a.address)
+ else:
+ self.mail['From'] = fromaddress
# get missing To header
if 'To' not in self.mail: