contrib/lisp/org-bbdb.el: Use `bbdb-record-xfield' when available

* contrib/lisp/org-bbdb.el (bbdb-record-xfield): Declare.
(org-bbdb-make-anniv-hash): Use it and fall back on
`bbdb-record-note' if not defined.

TINYCHANGE
This commit is contained in:
Rasmus 2013-04-03 13:54:17 +02:00 committed by Bastien Guerry
parent a597a8b622
commit 04b13a0e0e
1 changed files with 8 additions and 3 deletions

View File

@ -116,8 +116,10 @@
(declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
(declare-function bbdb-search-organization "ext:bbdb-com" (regexp &optional layout))
;; `bbdb-record-note' is part of BBDB v3.x
;; `bbdb-record-xfield' was part of BBDB v3.x
(declare-function bbdb-record-note "ext:bbdb" (record label))
;; `bbdb-record-xfield' replaces it in recent BBDB v3.x+
(declare-function bbdb-record-xfield "ext:bbdb" (record label))
(declare-function calendar-leap-year-p "calendar" (year))
(declare-function diary-ordinal-suffix "diary-lib" (n))
@ -306,14 +308,17 @@ The hash table is created on first use.")
"Create a hash with anniversaries extracted from BBDB, for fast access.
The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
(let ((old-bbdb (fboundp 'bbdb-record-getprop))
(record-func (if (fboundp 'bbdb-record-xfield)
'bbdb-record-xfield
'bbdb-record-note))
split tmp annivs)
(clrhash org-bbdb-anniv-hash)
(dolist (rec (bbdb-records))
(when (setq annivs (if old-bbdb
(bbdb-record-getprop
rec org-bbdb-anniversary-field)
(bbdb-record-note
rec org-bbdb-anniversary-field)))
(funcall record-func
rec org-bbdb-anniversary-field)))
(setq annivs (if old-bbdb
(bbdb-split annivs "\n")
;; parameter order is reversed in new bbdb