summaryrefslogtreecommitdiff
path: root/lisp/net/eudcb-bbdb.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/eudcb-bbdb.el')
-rw-r--r--lisp/net/eudcb-bbdb.el31
1 files changed, 26 insertions, 5 deletions
diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index d9d2aa5fe85..0545304b4a3 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -1,9 +1,10 @@
-;;; eudcb-bbdb.el --- Emacs Unified Directory Client - BBDB Backend -*- coding: utf-8 -*-
+;;; eudcb-bbdb.el --- Emacs Unified Directory Client - BBDB Backend
-;; Copyright (C) 1998-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2015 Free Software Foundation, Inc.
;; Author: Oscar Figueiredo <oscar@cpe.fr>
-;; Maintainer: Pavel Janík <Pavel@Janik.cz>
+;; Pavel Janík <Pavel@Janik.cz>
+;; Maintainer: Thomas Fitzsimmons <fitzsim@fitzsim.org>
;; Keywords: comm
;; Package: eudc
@@ -41,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)
@@ -84,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
@@ -167,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")))