1 Return-Path: <james@hackervisions.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id B60164196F3
\r
6 for <notmuch@notmuchmail.org>; Thu, 25 Mar 2010 08:20:33 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.782 tagged_above=-999 required=5
\r
12 tests=[BAYES_50=0.8, RDNS_DYNAMIC=0.982, TO_NO_BRKTS_DYNIP=1]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id V66cuVd0x3Th for <notmuch@notmuchmail.org>;
\r
17 Thu, 25 Mar 2010 08:20:33 -0700 (PDT)
\r
18 Received: from hackervisions.org (67-207-143-141.slicehost.net
\r
20 by olra.theworths.org (Postfix) with ESMTP id 513B04196F2
\r
21 for <notmuch@notmuchmail.org>; Thu, 25 Mar 2010 08:20:33 -0700 (PDT)
\r
22 Received: from john-marshall.sflc.info ([216.27.154.200] helo=localhost)
\r
23 by hv with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69)
\r
24 (envelope-from <james@hackervisions.org>)
\r
25 id 1NuorI-0008AB-Jk; Thu, 25 Mar 2010 11:20:32 -0400
\r
26 From: James Vasile <james@hackervisions.org>
\r
27 To: notmuch@notmuchmail.org
\r
28 Date: Thu, 25 Mar 2010 11:20:23 -0400
\r
29 Message-ID: <87hbo4qvgo.fsf@hackervisions.org>
\r
31 Content-Type: multipart/mixed; boundary="=-=-="
\r
32 Subject: [notmuch] bbdb import notmuch addresses
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.13
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Thu, 25 Mar 2010 15:20:33 -0000
\r
49 I used notmuch_address.py to scrape email addresses from notmuch and
\r
50 generate elisp to showve them into bbdb. Tab completion via bbdb is
\r
51 much faster than via notmuch_addresses.
\r
53 Run the script, execute the results in emacs. I didn't care enough to
\r
54 do any merging, so records that clash with existing records are ignored.
\r
58 Content-Type: text/x-python
\r
59 Content-Disposition: inline; filename=scrape.py
\r
60 Content-Description: scrape.py
\r
64 from cnotmuch import notmuch
\r
65 import notmuch_addresses
\r
67 def get_matching_messages(self):
\r
68 notmuch_db = notmuch.Database(self.db_path)
\r
69 query_string = "(from:" + self.email
\r
71 for addr in self.other_emails:
\r
72 query_string += (" OR from:" + addr)
\r
76 query = notmuch.Query(notmuch_db, query_string)
\r
77 return query.search_messages()
\r
78 notmuch_addresses._get_matching_messages = get_matching_messages
\r
81 matcher = notmuch_addresses.NotmuchAddressMatcher('')
\r
82 matcher.generate_matches()
\r
85 (defun bbdb-snarf-email-alias (name email)
\r
86 "Import email alias into bbdb"
\r
87 (condition-case nil
\r
88 (unless (bbdb-search-simple nil email)
\r
89 (bbdb-create-internal name nil email nil nil nil))
\r
93 for elem in matcher.matches:
\r
97 print "(bbdb-snarf-email-alias \"%s\")" % elem.lower()
\r
99 elem = elem.replace('"', '')
\r
100 elem = elem.replace(' <', '" "')
\r
101 elem = elem.replace('>', '"')
\r
103 elem = '"%s' % elem
\r
104 print "(bbdb-snarf-email-alias %s)" % elem
\r