From: James Vasile <james@hackervisions.org>
To: notmuch@notmuchmail.org
Subject: bbdb import notmuch addresses
Date: Thu, 25 Mar 2010 11:20:23 -0400 [thread overview]
Message-ID: <87hbo4qvgo.fsf@hackervisions.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 324 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: scrape.py --]
[-- Type: text/x-python, Size: 1195 bytes --]
#!/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
reply other threads:[~2010-03-25 15:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hbo4qvgo.fsf@hackervisions.org \
--to=james@hackervisions.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).