From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wes Hardaker Subject: org-contacts from bbdb: a starting solution Date: Tue, 08 Mar 2011 12:51:38 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=49301 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Px3sd-0002ma-Hd for emacs-orgmode@gnu.org; Tue, 08 Mar 2011 15:51:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Px3sb-0005ND-TX for emacs-orgmode@gnu.org; Tue, 08 Mar 2011 15:51:43 -0500 Received: from mail.hardakers.net ([168.150.236.43]:51963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Px3sb-0005Mt-Dq for emacs-orgmode@gnu.org; Tue, 08 Mar 2011 15:51:41 -0500 Received: from localhost (wjh.hardakers.net [10.0.0.2]) by mail.hardakers.net (Postfix) with ESMTPSA id 6511C23FAB for ; Tue, 8 Mar 2011 12:51:38 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain I finally decided to take a wack at a bbdb to org-contacts converter. I'm attaching the file below. It should prompt for a file and insert all your existing bbdb records into the file using the formats and fields that I decided was appropriate ;-) (require 'bbdb-to-org-contacts) M-x bbdb-to-org-contacts Now... I've been using bbdb for a very very long time. That means that I have a lot of records. That means that this was a good chance to find out how well org-contacts scales. The sad news is that it doesn't. Once I point org-contacts at my newly generated file containing 831 records it make org-contacts really really slow down. I wouldn't care about the normal record searching process for just looking something up, but it makes loading a message in gnus unusable (5 second delay per message). So... I need to filter down to "current ones I need to keep" or we need to optimize the contacts a bit to cache file points where a record for a given email address is stored or something. -- Wes Hardaker My Pictures: http://capturedonearth.com/ My Thoughts: http://pontifications.hardakers.net/ --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=bbdb-to-org-contacts.el (require 'bbdb) (require 'bbdb-com) (defvar bbdb-to-org-contacts-record-prefix "***") (defvar bbdb-to-org-contacts-record-blanks " ") (defun bbdb-to-org-contacts (to-file) "outputs a org-contacts file" (interactive (list (read-file-name "Save in file: "))) (let* ((filename (expand-file-name to-file)) (records (bbdb-records))) (find-file filename) (while records (bbdb-record-to-org-record (car records)) (setq records (cdr records))) )) (defun bbdb-record-to-org-record (record) "converts a single record" (let* ( (name (bbdb-record-name record)) (company (bbdb-record-company record)) (net (bbdb-record-net record)) (aka (bbdb-record-aka record)) (phone (bbdb-record-phones record)) (address (bbdb-record-addresses record)) (notes (bbdb-record-notes record)) ) (insert (format "%s %s\n" bbdb-to-org-contacts-record-prefix name)) (insert (format "%s :PROPERTIES:\n" bbdb-to-org-contacts-record-blanks)) (when aka (insert (format "%s :AKA:\t%s\n" bbdb-to-org-contacts-record-blanks (mapconcat (function (lambda(str) str)) aka ", ")))) (when net (insert (format "%s :EMAIL:\t%s\n" bbdb-to-org-contacts-record-blanks (mapconcat (function (lambda(str) str)) net " ")))) (when company (insert (format "%s :COMPANY:\t%s\n" bbdb-to-org-contacts-record-blanks company))) (when phone (insert (mapconcat (function (lambda(rec) (if (stringp (elt rec 1)) (format "%s :PHONE_%s:\t%s" bbdb-to-org-contacts-record-blanks (upcase (elt rec 0)) (elt rec 1)) (let ((len (length rec)) (count 2) (output (format "%d" (elt rec 1)))) (while (< count (1- len)) (setq output (concat output (format "-%d" (elt rec count)))) (setq count (1+ count))) (format "%s :PHONE_%s:\t%s" bbdb-to-org-contacts-record-blanks (upcase (elt rec 0)) output))))) phone "\n")) (insert "\n")) (when notes (insert (format "%s :NOTES:\t%s\n" bbdb-to-org-contacts-record-blanks notes))) (insert (format "%s :END:\n" bbdb-to-org-contacts-record-blanks)) )) (provide 'bbdb-to-org-contacts) --=-=-=--