summaryrefslogtreecommitdiff
path: root/alot/completion/accounts.py
blob: 20dbcfa6c7b26ecdec857258b876f3ec36a22a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Copyright (C) 2011-2019  Patrick Totzke <patricktotzke@gmail.com>
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file

from alot.settings.const import settings
from alot.db.utils import formataddr
from .stringlist import StringlistCompleter


class AccountCompleter(StringlistCompleter):
    """Completes users' own mailaddresses."""

    def __init__(self, **kwargs):
        accounts = settings.get_accounts()
        resultlist = [formataddr((a.realname, str(a.address)))
                      for a in accounts]
        StringlistCompleter.__init__(self, resultlist, match_anywhere=True,
                                     **kwargs)