* bbdb import notmuch addresses
@ 2010-03-25 15:20 James Vasile
0 siblings, 0 replies; only message in thread
From: James Vasile @ 2010-03-25 15:20 UTC (permalink / raw
To: notmuch
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-03-25 15:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-25 15:20 bbdb import notmuch addresses James Vasile
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).