Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B60164196F3 for ; Thu, 25 Mar 2010 08:20:33 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 2.782 X-Spam-Level: ** X-Spam-Status: No, score=2.782 tagged_above=-999 required=5 tests=[BAYES_50=0.8, RDNS_DYNAMIC=0.982, TO_NO_BRKTS_DYNIP=1] autolearn=no Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V66cuVd0x3Th for ; Thu, 25 Mar 2010 08:20:33 -0700 (PDT) Received: from hackervisions.org (67-207-143-141.slicehost.net [67.207.143.141]) by olra.theworths.org (Postfix) with ESMTP id 513B04196F2 for ; Thu, 25 Mar 2010 08:20:33 -0700 (PDT) Received: from john-marshall.sflc.info ([216.27.154.200] helo=localhost) by hv with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1NuorI-0008AB-Jk; Thu, 25 Mar 2010 11:20:32 -0400 From: James Vasile To: notmuch@notmuchmail.org Date: Thu, 25 Mar 2010 11:20:23 -0400 Message-ID: <87hbo4qvgo.fsf@hackervisions.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: [notmuch] bbdb import notmuch addresses X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Mar 2010 15:20:33 -0000 --=-=-= I used notmuch_address.py to scrape email addresses from notmuch and generate elisp to showve them into bbdb. Tab completion via bbdb is much faster than via notmuch_addresses. Run the script, execute the results in emacs. I didn't care enough to do any merging, so records that clash with existing records are ignored. --=-=-= Content-Type: text/x-python Content-Disposition: inline; filename=scrape.py Content-Description: scrape.py #!/usr/bin/python from cnotmuch import notmuch import notmuch_addresses def get_matching_messages(self): notmuch_db = notmuch.Database(self.db_path) query_string = "(from:" + self.email for addr in self.other_emails: query_string += (" OR from:" + addr) query_string += ")" query = notmuch.Query(notmuch_db, query_string) return query.search_messages() notmuch_addresses._get_matching_messages = get_matching_messages matcher = notmuch_addresses.NotmuchAddressMatcher('') matcher.generate_matches() print """ (defun bbdb-snarf-email-alias (name email) "Import email alias into bbdb" (condition-case nil (unless (bbdb-search-simple nil email) (bbdb-create-internal name nil email nil nil nil)) (error nil))) """ for elem in matcher.matches: if not '@' in elem: continue if not '<' in elem: print "(bbdb-snarf-email-alias \"%s\")" % elem.lower() else: elem = elem.replace('"', '') elem = elem.replace(' <', '" "') elem = elem.replace('>', '"') if elem[0] != '"': elem = '"%s' % elem print "(bbdb-snarf-email-alias %s)" % elem --=-=-=--