]> code.delx.au - gnu-emacs/commitdiff
EUDC: Support BBDB >= 3
authorSergio Durigan Junior <sergiodj@sergiodj.net>
Fri, 6 Mar 2015 08:18:36 +0000 (03:18 -0500)
committerThomas Fitzsimmons <fitzsim@fitzsim.org>
Mon, 9 Mar 2015 01:12:11 +0000 (21:12 -0400)
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.

lisp/ChangeLog
lisp/net/eudcb-bbdb.el

index 5f26239ecdce491788bfe78f13f61917a0589061..ed28911497a949b1de8c0954c129fc02eaea3d1e 100644 (file)
@@ -1,3 +1,10 @@
+2015-03-06  Sergio Durigan Junior  <sergiodj@sergiodj.net>
+           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.
+
 2015-03-08  Dmitry Gutov  <dgutov@yandex.ru>
 
        * progmodes/ruby-mode.el (ruby-font-lock-keywords): Use
index 5be2bec0c5da3ee5896673d0147cd0a4be82ccd4..bd5d4536aab3061f2d590fda8350b5377774b14e 100644 (file)
 (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)
                    (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")))