From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sergio Durigan Junior Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Adjust EUDC to use BBDB 3.x Date: Sat, 24 Jan 2015 18:42:39 -0500 Message-ID: <87wq4bg2z4.fsf@sergiodj.net> References: <87h9vml5l5.fsf@sergiodj.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422142975 18778 80.91.229.3 (24 Jan 2015 23:42:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Jan 2015 23:42:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thomas Fitzsimmons Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 25 00:42:55 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YFALt-0003HO-SQ for ged-emacs-devel@m.gmane.org; Sun, 25 Jan 2015 00:42:54 +0100 Original-Received: from localhost ([::1]:36417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFALt-00031I-65 for ged-emacs-devel@m.gmane.org; Sat, 24 Jan 2015 18:42:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFALm-00031B-4Z for emacs-devel@gnu.org; Sat, 24 Jan 2015 18:42:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFALh-0000LM-US for emacs-devel@gnu.org; Sat, 24 Jan 2015 18:42:46 -0500 Original-Received: from kwanyin.sergiodj.net ([176.31.208.32]:49319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFALh-0000L7-Ni for emacs-devel@gnu.org; Sat, 24 Jan 2015 18:42:41 -0500 X-URL: http://blog.sergiodj.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 176.31.208.32 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181736 Archived-At: On Saturday, January 24 2015, Thomas Fitzsimmons wrote: > Hi Sergio, Hey Thomas, > Sergio Durigan Junior writes: > >> With the release of BBDB 3.x, EUDC does not work properly anymore. The >> reason is because BBDB renamed a few fields internally, and EUDC is >> still using the old names. Specifically, the problem happens because of >> the 'net' -> 'mail' rename. >> >> The following patch fixes this issue. I tested it with my current .gnus >> configuration, and it works fine. >> >> I have the copyright assignment on file for contributing with GDB and >> binutils, but I still do not have it for Emacs (this is my third patch >> to the project IIRC). So I will contact the copyright clerk at FSF and >> get it done. Meanwhile, I'd appreciate reviews and comments. > > This is an issue I've run into as well. > > I'm concerned that this patch will break compatibility with BBDB 2.x. > It looks like the newer distribution releases are starting to package > BBDB 3.x (I just checked Fedora), so this may be less of a concern in > the future. However, I think it's worth trying to make a patch that > supports both. Can you file a bug report for this? You're right, the patch only takes into account BBDB 3.x. I filed a bug about the issue as requested: And I adjusted the initial patch to be backwards-compatible with BBDB 2.x. I'd appreciate if you could take a look and tell me WDYT. Thanks, -- 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 + + 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 * 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-"