From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ivan Kanis Subject: [PATCH] integration with bbdb 3.0 Date: Wed, 28 Dec 2011 20:06:07 +0100 Message-ID: <87ty4kectc.fsf@googlemail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RfypP-0001DF-7l for emacs-orgmode@gnu.org; Wed, 28 Dec 2011 14:06:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RfypN-0007jL-S6 for emacs-orgmode@gnu.org; Wed, 28 Dec 2011 14:06:19 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:63781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RfypN-0007j9-Mx for emacs-orgmode@gnu.org; Wed, 28 Dec 2011 14:06:17 -0500 Received: by wibhq12 with SMTP id hq12so7780481wib.0 for ; Wed, 28 Dec 2011 11:06:16 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Guerry Cc: org mode , bbdb mailing list --=-=-= Content-Type: text/plain Hi Bastien, The following patch fixes linking bbdb 3.0 records. Let me know if the patch needs improvement. Take care, Ivan Kanis --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-bbdb.patch diff --git a/emacs/org/org-bbdb.el b/emacs/org/org-bbdb.el index 61f8258..ddb7e4a 100644 --- a/emacs/org/org-bbdb.el +++ b/emacs/org/org-bbdb.el @@ -118,6 +118,9 @@ (defvar date) ;; dynamically scoped from Org +;; Support for version 2.35 +(defvar org-bbdb-old (fboundp 'bbdb-record-get-field-internal)) + ;; Customization (defgroup org-bbdb-anniversaries nil @@ -195,8 +198,11 @@ date year)." "Store a link to a BBDB database entry." (when (eq major-mode 'bbdb-mode) ;; This is BBDB, we make this link! - (let* ((name (bbdb-record-name (bbdb-current-record))) - (company (bbdb-record-getprop (bbdb-current-record) 'company)) + (let* ((rec (bbdb-current-record)) + (name (bbdb-record-name rec)) + (company (if org-bbdb-old + (bbdb-record-getprop rec 'company) + (car (bbdb-record-get-field rec 'organization)))) (link (org-make-link "bbdb:" name))) (org-store-link-props :type "bbdb" :name name :company company :link link :description name) @@ -218,24 +224,49 @@ italicized, in all other cases it is left unchanged." (require 'bbdb) (let ((inhibit-redisplay (not debug-on-error)) (bbdb-electric-p nil)) - (catch 'exit - ;; Exact match on name - (bbdb-name (concat "\\`" name "\\'") nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) - ;; Exact match on name - (bbdb-company (concat "\\`" name "\\'") nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) - ;; Partial match on name - (bbdb-name name nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) - ;; Partial match on company - (bbdb-company name nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) - ;; General match including network address and notes - (bbdb name nil) - (when (= 0 (buffer-size (get-buffer "*BBDB*"))) - (delete-window (get-buffer-window "*BBDB*")) - (error "No matching BBDB record"))))) + (if org-bbdb-old + (org-bbdb-open-old) + (org-bbdb-open-new)))) + +(defun org-bbdb-open-old () + (catch 'exit + ;; Exact match on name + (bbdb-name (concat "\\`" name "\\'") nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; Exact match on name + (bbdb-company (concat "\\`" name "\\'") nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; Partial match on name + (bbdb-name name nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; Partial match on company + (bbdb-company name nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; General match including network address and notes + (bbdb name nil) + (when (= 0 (buffer-size (get-buffer "*BBDB*"))) + (delete-window (get-buffer-window "*BBDB*")) + (error "No matching BBDB record")))) + +(defun org-bbdb-open-new () + (catch 'exit + ;; Exact match on name + (bbdb-search-name (concat "\\`" name "\\'") nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; Exact match on name + (bbdb-search-organization (concat "\\`" name "\\'") nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; Partial match on name + (bbdb-search-name name nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; Partial match on company + (bbdb-search-organization name nil) + (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + ;; General match including network address and notes + (bbdb name nil) + (when (= 0 (buffer-size (get-buffer "*BBDB*"))) + (delete-window (get-buffer-window "*BBDB*")) + (error "No matching BBDB record")))) (defun org-bbdb-anniv-extract-date (time-str) "Convert YYYY-MM-DD to (month date year). --=-=-=--