commit e263d6604efde8b1c1853f72c781d01571667b62 Author: Leo Date: Thu Apr 21 20:04:46 2011 +0800 Fix org-bbdb.el for BBDB 3.x --- doc/org.texi | 2 +- lisp/org-bbdb.el | 61 ++++++++++++++++++++++++------------------------- lisp/org-capture.el | 2 +- lisp/org-remember.el | 2 +- 4 files changed, 33 insertions(+), 34 deletions(-) Modified doc/org.texi diff --git a/doc/org.texi b/doc/org.texi index 844de6da..d891a205 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -6493,7 +6493,7 @@ similar way.}: @smallexample Link type | Available keywords -------------------+---------------------------------------------- -bbdb | %:name %:company +bbdb | %:name %:organization irc | %:server %:port %:nick vm, wl, mh, mew, rmail | %:type %:subject %:message-id | %:from %:fromname %:fromaddress Modified lisp/org-bbdb.el diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el index b772f442..0f5ed8d9 100644 --- a/lisp/org-bbdb.el +++ b/lisp/org-bbdb.el @@ -101,23 +101,22 @@ (eval-when-compile ;; Declare external functions and variables -(declare-function bbdb "ext:bbdb-com" (string elidep)) -(declare-function bbdb-company "ext:bbdb-com" (string elidep)) -(declare-function bbdb-current-record "ext:bbdb-com" - (&optional planning-on-modifying)) -(declare-function bbdb-name "ext:bbdb-com" (string elidep)) +(declare-function bbdb "ext:bbdb-com" (regexp &optional layout)) +(declare-function bbdb-search-organization "ext:bbdb-com" + (regexp &optional layout)) +(declare-function bbdb-current-record "ext:bbdb" (&optional full)) +(declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout)) +(declare-function bbdb-record-name "ext:bbdb-com" (record)) +(declare-function bbdb-record-organization "ext:bbdb-com" (record)) +(declare-function bbdb-record-note-split "ext:bbdb" (record label)) +(declare-function bbdb-split "ext:bbdb" (separator string)) +(declare-function bbdb-string-trim "ext:bbdb" (string)) +(declare-function bbdb-records "ext:bbdb") (declare-function bbdb-completing-read-record "ext:bbdb-com" (prompt &optional omit-records)) -(declare-function bbdb-record-getprop "ext:bbdb" (record property)) -(declare-function bbdb-record-name "ext:bbdb" (record)) -(declare-function bbdb-records "ext:bbdb" - (&optional dont-check-disk already-in-db-buffer)) -(declare-function bbdb-split "ext:bbdb" (string separators)) -(declare-function bbdb-string-trim "ext:bbdb" (string)) - -(declare-function calendar-leap-year-p "calendar" (year)) (declare-function diary-ordinal-suffix "diary-lib" (n)) +(defvar bbdb-buffer-name) (defvar date) ;; dynamically scoped from Org ;; Customization @@ -198,9 +197,10 @@ (defun org-bbdb-store-link () (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)) + (organization (apply #'bbdb-concat 'organization + (bbdb-record-organization (bbdb-current-record)))) (link (org-make-link "bbdb:" name))) - (org-store-link-props :type "bbdb" :name name :company company + (org-store-link-props :type "bbdb" :name name :organization organization :link link :description name) link))) @@ -219,31 +219,31 @@ (defun org-bbdb-open (name) "Follow a BBDB link to NAME." (require 'bbdb) (let ((inhibit-redisplay (not debug-on-error)) - (bbdb-electric-p nil)) + (bbdb-electric nil)) (catch 'exit ;; Exact match on name - (bbdb-name (concat "\\`" name "\\'") nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + (bbdb-search-name (concat "\\`" name "\\'") nil) + (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil)) ;; Exact match on name - (bbdb-company (concat "\\`" name "\\'") nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + (bbdb-search-organization (concat "\\`" name "\\'") nil) + (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil)) ;; Partial match on name - (bbdb-name name nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + (bbdb-search-name name nil) + (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil)) ;; Partial match on company - (bbdb-company name nil) - (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) + (bbdb-search-organization name nil) + (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (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*")) + (when (= 0 (buffer-size (get-buffer bbdb-buffer-name))) + (delete-window (get-buffer-window bbdb-buffer-name)) (error "No matching BBDB record"))))) (defun org-bbdb-anniv-extract-date (time-str) "Convert YYYY-MM-DD to (month date year). Argument TIME-STR is the value retrieved from BBDB. If YYYY- is omitted it will be considered unknown." - (multiple-value-bind (a b c) (values-list (bbdb-split time-str "-")) + (multiple-value-bind (a b c) (values-list (bbdb-split "-" time-str)) (if (eq c nil) (list (string-to-number a) (string-to-number b) @@ -274,10 +274,9 @@ (defun org-bbdb-make-anniv-hash () (let (split tmp annivs) (clrhash org-bbdb-anniv-hash) (dolist (rec (bbdb-records)) - (when (setq annivs (bbdb-record-getprop - rec org-bbdb-anniversary-field)) - (setq annivs (bbdb-split annivs "\n")) - (while annivs + (when (setq annivs (bbdb-record-note-split + rec org-bbdb-anniversary-field)) + (while annivs (setq split (org-bbdb-anniv-split (pop annivs))) (multiple-value-bind (m d y) (values-list (funcall org-bbdb-extract-date-fun (car split))) Modified lisp/org-capture.el diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 3327080e..4f89455a 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -245,7 +245,7 @@ (defcustom org-capture-templates nil Link type | Available information ------------------------+------------------------------------------------------ -bbdb | %:type %:name %:company +bbdb | %:type %:name %:organization vm, wl, mh, mew, rmail | %:type %:subject %:message-id | %:from %:fromname %:fromaddress | %:to %:toname %:toaddress Modified lisp/org-remember.el diff --git a/lisp/org-remember.el b/lisp/org-remember.el index cf2d4543..21bd751b 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -162,7 +162,7 @@ (defcustom org-remember-templates nil Link type | Available information -------------------+------------------------------------------------------ -bbdb | %:type %:name %:company +bbdb | %:type %:name %:organization vm, wl, mh, rmail | %:type %:subject %:message-id | %:from %:fromname %:fromaddress | %:to %:toname %:toaddress