From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sergio Durigan Junior Newsgroups: gmane.emacs.bugs Subject: bug#19678: [PATCH] EUDC does not support BBDB 3.x Date: Mon, 26 Jan 2015 14:02:36 -0500 Message-ID: <87lhkpjrg3.fsf@sergiodj.net> References: <87mw57hhrd.fsf@sergiodj.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422299153 26754 80.91.229.3 (26 Jan 2015 19:05:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Jan 2015 19:05:53 +0000 (UTC) Cc: 19678@debbugs.gnu.org To: Thomas Fitzsimmons Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 26 20:05:46 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1YFoym-0006hl-79 for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jan 2015 20:05:44 +0100 Original-Received: from localhost ([::1]:43515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFoyk-0002Ym-Kg for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jan 2015 14:05:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFowF-0006Kg-LK for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 14:03:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFowA-00023C-GP for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 14:03:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFowA-000238-Cv for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 14:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YFow9-0003dn-VM for bug-gnu-emacs@gnu.org; Mon, 26 Jan 2015 14:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Sergio Durigan Junior Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Jan 2015 19:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19678 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 19678-submit@debbugs.gnu.org id=B19678.142229896413949 (code B ref 19678); Mon, 26 Jan 2015 19:03:01 +0000 Original-Received: (at 19678) by debbugs.gnu.org; 26 Jan 2015 19:02:44 +0000 Original-Received: from localhost ([127.0.0.1]:57325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFovr-0003cv-P7 for submit@debbugs.gnu.org; Mon, 26 Jan 2015 14:02:44 -0500 Original-Received: from kwanyin.sergiodj.net ([176.31.208.32]:41887) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YFovo-0003cd-Iy for 19678@debbugs.gnu.org; Mon, 26 Jan 2015 14:02:42 -0500 X-URL: http://blog.sergiodj.net In-Reply-To: (Thomas Fitzsimmons's message of "Sun, 25 Jan 2015 18:49:56 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98767 Archived-At: On Sunday, January 25 2015, Thomas Fitzsimmons wrote: > Can you see if the attached patch works for you? It works for me, > introduces minimal changes and allows for upgrading BBDB 2 to BBDB 3 > without restarting Emacs. The defvar change in your patch concerns me > because it will miss if the BBDB version changes after the variable is > first assigned. Almost there... The patch doesn't work as-is because 'eudc-bbdb-current-return-attributes' is set to '(firstname lastname mail) for me when eudc-bbdb-format-record-as-result is called. It means that, in the while loop, it will try to call eq/memq against 'mail, and it fails. What I've done now is to call eudc-bbdb-field when we are composing the variables that will hold the BBDB attributes to match against. > I'm also going to experiment with eudc-export which also may need to be > updated for BBDB 3 handling. Nice. Let me know if you need some help. > Longer term I hope to work toward bundling BBDB in Emacs which would > eliminate the need to support multiple versions. That would be awesome. Again, I could help with the task. So, the following patch is the last version of what works for my case. I hope it is OK to apply. Cheers, -- Sergio GPG key ID: 0x65FC5E36 Please send encrypted e-mail if possible http://sergiodj.net/ diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ff352a2..4bee79b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2015-01-25 Thomas Fitzsimmons + Sergio Durigan Junior + + * net/eudcb-bbdb.el (eudc-bbdb-field): New function. + (eudc-bbdb-format-query): Call eudc-bbdb-field. + (eudc-bbdb-filter-non-matching-record): Likewise. + (eudc-bbdb-format-record-as-result): Likewise. + 2015-01-26 Stefan Monnier diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el index 0400e5b..10c2c86 100644 --- a/lisp/net/eudcb-bbdb.el +++ b/lisp/net/eudcb-bbdb.el @@ -41,6 +41,16 @@ (defvar eudc-bbdb-current-query nil) (defvar eudc-bbdb-current-return-attributes nil) +(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) + (version<= "3" bbdb-version)) + 'mail + field-symbol)) + (defvar eudc-bbdb-attributes-translation-alist '((name . lastname) (email . net) @@ -63,7 +73,7 @@ firstname lastname)) (company (cdr (assq 'company query))) - (net (cdr (assq 'net query))) + (net (cdr (assq (eudc-bbdb-field 'net) query))) (notes (cdr (assq 'notes query))) (phone (cdr (assq 'phone query)))) (list name company net notes phone))) @@ -79,12 +89,14 @@ (val (cdr condition)) (case-fold-search t) bbdb-val) - (or (and (memq attr '(firstname lastname aka company phones - addresses net)) + (or (and (memq attr `(firstname lastname aka company phones + addresses ,(eudc-bbdb-field '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 @@ -151,7 +163,8 @@ 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 + ,(eudc-bbdb-field 'net) notes))) attr eudc-rec val) @@ -163,11 +176,12 @@ 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 + ,(eudc-bbdb-field 'net) notes)) (setq val (eval (list (intern (concat "bbdb-record-" - (symbol-name attr))) + (symbol-name (eudc-bbdb-field attr)))) 'record)))) (t (error "Unknown BBDB attribute")))