From f34f2a23b355f020759f714eb8fb567871de587c Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 5 Oct 2013 13:58:14 +0100 Subject: Output each name/addr only once with mutt-query --- clab | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'clab') diff --git a/clab b/clab index d47700a..33307a7 100755 --- a/clab +++ b/clab @@ -147,12 +147,18 @@ class CommandLineAddressBook(cliapp.Application): self.output.write('No matches\n') sys.exit(1) self.output.write('clab found matches:\n') + + name_addr_pairs = set() for entry in entries: name = entry.get_single('name', '') emails = entry.get_subdict('email') for email in emails: - n = name.encode('utf-8') - self.output.write('%s\t%s\n' % (emails[email], n)) + name_addr_pairs.add((name, emails[email])) + + for name, addr in sorted(name_addr_pairs): + n = name.encode('utf-8') + a = addr.encode('utf-8') + self.output.write('%s\t%s\n' % (a, n)) CommandLineAddressBook().run() -- cgit v1.2.1