summaryrefslogtreecommitdiff
path: root/lisp/net/eudcb-bbdb.el
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@sergiodj.net>2015-03-06 03:18:36 -0500
committerThomas Fitzsimmons <fitzsim@fitzsim.org>2015-03-08 21:12:11 -0400
commit6df13146cccc062c8bef9ed9c52827ec07c5885e (patch)
tree71adaa60f16854f07a9c94f0101fda3bc60cea99 /lisp/net/eudcb-bbdb.el
parent6b134bcba9de5605086ee9382c0be13174480cac (diff)
downloademacs-6df13146cccc062c8bef9ed9c52827ec07c5885e.tar.gz
emacs-6df13146cccc062c8bef9ed9c52827ec07c5885e.tar.bz2
emacs-6df13146cccc062c8bef9ed9c52827ec07c5885e.zip
EUDC: Support BBDB >= 3
Fixes: bug#19678 Co-authored-by: Thomas Fitzsimmons <fitzsim@fitzsim.org> * net/eudcb-bbdb.el (eudc-bbdb-field): New function. (eudc-bbdb-filter-non-matching-record): Call eudc-bbdb-field. (eudc-bbdb-format-record-as-result): Likewise.
Diffstat (limited to 'lisp/net/eudcb-bbdb.el')
-rw-r--r--lisp/net/eudcb-bbdb.el24
1 files changed, 22 insertions, 2 deletions
diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index 5be2bec0c5d..bd5d4536aab 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -42,6 +42,24 @@
(defvar eudc-bbdb-current-query nil)
(defvar eudc-bbdb-current-return-attributes nil)
+(defvar bbdb-version)
+
+(defun eudc-bbdb-field (field-symbol)
+ "Convert FIELD-SYMBOL so that it is recognized by the current BBDB version.
+BBDB < 3 used `net'; BBDB >= 3 uses `mail'."
+ ;; This just-in-time translation permits upgrading from BBDB 2 to
+ ;; BBDB 3 without restarting Emacs.
+ (if (and (eq field-symbol 'net)
+ (or
+ ;; MELPA versions of BBDB may have a bad package version,
+ ;; but they're all version 3 or later.
+ (equal bbdb-version "@PACKAGE_VERSION@")
+ ;; Development versions of BBDB can have the format "X.YZ
+ ;; devo". Split the string just in case.
+ (version<= "3" (car (split-string bbdb-version)))))
+ 'mail
+ field-symbol))
+
(defvar eudc-bbdb-attributes-translation-alist
'((name . lastname)
(email . net)
@@ -85,7 +103,9 @@
(progn
(setq bbdb-val
(eval (list (intern (concat "bbdb-record-"
- (symbol-name attr)))
+ (symbol-name
+ (eudc-bbdb-field
+ attr))))
'record)))
(if (listp bbdb-val)
(if eudc-bbdb-enable-substring-matches
@@ -168,7 +188,7 @@ The record is filtered according to `eudc-bbdb-current-return-attributes'"
(setq val (eval
(list (intern
(concat "bbdb-record-"
- (symbol-name attr)))
+ (symbol-name (eudc-bbdb-field attr))))
'record))))
(t
(error "Unknown BBDB attribute")))