GNU bug report logs - #19678
[PATCH] EUDC does not support BBDB 3.x

Previous Next

Package: emacs;

Reported by: Sergio Durigan Junior <sergiodj <at> sergiodj.net>

Date: Sat, 24 Jan 2015 23:39:02 UTC

Severity: normal

Tags: patch

Fixed in version 25.1

Done: Thomas Fitzsimmons <fitzsim <at> fitzsim.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Thomas Fitzsimmons <fitzsim <at> fitzsim.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#19678: closed ([PATCH] EUDC does not support BBDB 3.x)
Date: Mon, 09 Mar 2015 01:23:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 08 Mar 2015 21:22:21 -0400
with message-id <m3mw3n9d82.fsf <at> fitzsim.org>
and subject line Re: bug#19678: [PATCH] EUDC does not support BBDB 3.x
has caused the debbugs.gnu.org bug report #19678,
regarding [PATCH] EUDC does not support BBDB 3.x
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
19678: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19678
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Sergio Durigan Junior <sergiodj <at> sergiodj.net>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] EUDC does not support BBDB 3.x
Date: Sat, 24 Jan 2015 18:37:58 -0500
This bug was opened due to a request made at:

  <https://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00800.html>

As explained at:

  <https://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00542.html>

With the release of BBDB 3.x, EUDC needs adjustments to properly work
with it.  Actually, after some investigation, I noticed that the only
adjustment was to replace the occurrences of 'net' by 'mail' in the
code.  The second link above contains a patch that does that, but Thomas
Fitzsimmons correctly noted (in the first link) that the patch breaks
compatibility with BBDB 2.x.

The following patch is a first attempt to implement the support for both
BBDB 2.x and 3.x.

-- 
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 15518a7..0ed1d67 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
+2015-01-24  Sergio Durigan Junior  <sergiodj <at> sergiodj.net>
+
+	Adapt EUDC to BBDB 3.x
+	* net/eudcb-bbdb.el (eudc-bbdb-get-major-version-number): New
+	function.
+	(eudc-bbdb-attributes-translation-alist): Use
+	eudc-bbdb-get-major-version-number to decide whether to use 'net'
+	(BBDB 2.x) or 'mail' (BBDB 3.x).
+	(eudc-bbdb-format-query): Likewise.
+	(eudc-bbdb-filter-non-matching-record): Likewise.
+	(eudc-bbdb-format-record-as-result): Likewise.
+
 2015-01-23  Thomas Fitzsimmons  <fitzsim <at> fitzsim.org>
 
 	* net/ldap.el (ldap-search-internal): Mention binddn in invalid
diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index 0400e5b..d400871 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -41,9 +41,18 @@
 (defvar eudc-bbdb-current-query nil)
 (defvar eudc-bbdb-current-return-attributes nil)
 
+(defun eudc-bbdb-get-major-version-number ()
+  "Return the major version number of the BBDB version we are
+  currently using.  Return nil if we could not load BBDB."
+  (if (require 'bbdb nil t)
+      (string-to-number (substring bbdb-version 0 1))
+    0))
+
 (defvar eudc-bbdb-attributes-translation-alist
   '((name . lastname)
-    (email . net)
+    (email . (if (= (eudc-bbdb-get-major-version-number) 3)
+		 mail
+	       net))
     (phone . phones))
   "Alist mapping EUDC attribute names to BBDB names.")
 
@@ -63,10 +72,13 @@
 		   firstname
 		   lastname))
 	(company (cdr (assq 'company query)))
-	(net (cdr (assq 'net query)))
+	(mail (cdr (assq (if (= (eudc-bbdb-get-major-version-number) 3)
+			     'mail
+			   'net)
+			 query)))
 	(notes (cdr (assq 'notes query)))
 	(phone (cdr (assq 'phone query))))
-    (list name company net notes phone)))
+    (list name company mail notes phone)))
 
 
 (defun eudc-bbdb-filter-non-matching-record (record)
@@ -80,7 +92,10 @@
               (case-fold-search t)
               bbdb-val)
           (or (and (memq attr '(firstname lastname aka company phones
-                                addresses net))
+				addresses
+			        (if (= (eudc-bbdb-get-major-version-number) 3)
+				    mail
+				  net)))
                    (progn
                      (setq bbdb-val
                            (eval (list (intern (concat "bbdb-record-"
@@ -151,7 +166,11 @@
 The record is filtered according to `eudc-bbdb-current-return-attributes'"
   (require 'bbdb)
   (let ((attrs (or eudc-bbdb-current-return-attributes
-		   '(firstname lastname aka company phones addresses net notes)))
+		   '(firstname lastname aka company phones addresses
+		     (if (= (eudc-bbdb-get-major-version-number) 3)
+			 mail
+		       net)
+		     notes)))
 	attr
 	eudc-rec
 	val)
@@ -163,7 +182,11 @@ The record is filtered according to `eudc-bbdb-current-return-attributes'"
 	(setq val (eudc-bbdb-extract-phones record)))
        ((eq attr 'addresses)
 	(setq val (eudc-bbdb-extract-addresses record)))
-       ((memq attr '(firstname lastname aka company net notes))
+       ((memq attr '(firstname lastname aka company
+		     (if (= (eudc-bbdb-get-major-version-number) 3)
+			 mail
+		       net)
+		     notes))
 	(setq val (eval
 		   (list (intern
 			  (concat "bbdb-record-"


[Message part 3 (message/rfc822, inline)]
From: Thomas Fitzsimmons <fitzsim <at> fitzsim.org>
To: 19678-done <at> debbugs.gnu.org
Subject: Re: bug#19678: [PATCH] EUDC does not support BBDB 3.x
Date: Sun, 08 Mar 2015 21:22:21 -0400
Hi,

I pushed our patch, with some extra version checks I discovered were
needed during testing.

Thanks for reporting and providing a patch,
Thomas


This bug report was last modified 10 years and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.