From 5e11e51efe61cbbd0b77c660b638d977ce29f5e7 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 31 Dec 2011 17:04:27 +0100 Subject: [PATCH] Make Org work with bbdb 3.0 * lisp/org-bbdb.el (org-bbdb-old): New variable. (org-bbdb-store-link): (org-bbdb-open): Check for `org-bbdb-old'. (org-bbdb-open-old): (org-bbdb-open-new): New functions. Patch by Ivan Kanis --- lisp/org-bbdb.el | 71 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el index 61f82585e..ddb7e4ab8 100644 --- a/lisp/org-bbdb.el +++ b/lisp/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). -- 2.11.4.GIT