Commit d055a49d authored by Sriram Karra's avatar Sriram Karra

First element of email list in BBDB will be treated as the primary address

Gmail has a flag to identify the primary email address. In Emacs,
bbdb sets the first email address for tab completion and for completing
using the mail-alias field etc. So preserving this semantics is good.
This is what we acheive with this commit - ensure that the first
email is treated as the primary address - while reading as well as
when writing out to the BBDB database.
parent 039a6a37
##
## Created : Fri Apr 06 19:08:32 IST 2012
## Last Modified : Thu May 24 18:43:12 IST 2012
## Last Modified : Thu Jul 05 12:53:59 IST 2012
##
## Copyright (C) 2012 Sriram Karra <karra.etc@gmail.com>
##
......@@ -242,6 +242,9 @@ class BBContact(Contact):
else:
self.add_email_work(em)
if not self.get_email_prim():
self.set_email_prim(em)
def _classify_email_addr (self, addr, domains):
"""Return a tuple of (home, work, other) booleans classifying if the
specified address falls within one of the domains."""
......@@ -535,6 +538,14 @@ class BBContact(Contact):
ems.extend([unchompq(e) for e in self.get_email_work()])
ems.extend([unchompq(e) for e in self.get_email_other()])
# The primary email address should be the first in the list.
emp = self.get_email_prim()
if emp:
emp = unchompq(emp)
if emp in ems:
ems.remove(emp)
ems.insert(0, emp)
ret = ' '.join(ems)
if ret == '':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment