all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
To: Sergio Durigan Junior <sergiodj@sergiodj.net>
Cc: 19678@debbugs.gnu.org
Subject: bug#19678: [PATCH] EUDC does not support BBDB 3.x
Date: Sun, 25 Jan 2015 18:49:56 -0500	[thread overview]
Message-ID: <m3twzeqv2z.fsf@fitzsim.org> (raw)
In-Reply-To: <87mw57hhrd.fsf@sergiodj.net> (Sergio Durigan Junior's message of "Sat, 24 Jan 2015 18:37:58 -0500")

[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]

Sergio Durigan Junior <sergiodj@sergiodj.net> writes:

> 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.

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.

I'm also going to experiment with eudc-export which also may need to be
updated for BBDB 3 handling.

Longer term I hope to work toward bundling BBDB in Emacs which would
eliminate the need to support multiple versions.

Thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-EUDC-Support-BBDB-3.patch --]
[-- Type: text/x-patch, Size: 2635 bytes --]

From 34dbaf966d2875c1f129f35c9866122f88e0ac16 Mon Sep 17 00:00:00 2001
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Date: Sun, 25 Jan 2015 01:32:52 -0500
Subject: [PATCH 1/2] EUDC: Support BBDB >= 3

* 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         |  6 ++++++
 lisp/net/eudcb-bbdb.el | 16 ++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 70293af..e26e028 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-25  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-01-25  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacs-lisp/cl-generic.el (cl--generic-no-next-method-function): New fun.
diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index 0400e5b..7aed542 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)
@@ -84,7 +94,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 +179,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")))
-- 
1.8.1.4


  reply	other threads:[~2015-01-25 23:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-24 23:37 bug#19678: [PATCH] EUDC does not support BBDB 3.x Sergio Durigan Junior
2015-01-25 23:49 ` Thomas Fitzsimmons [this message]
2015-01-26 19:02   ` Sergio Durigan Junior
2015-01-26 22:21     ` Thomas Fitzsimmons
2015-01-26 22:47       ` Sergio Durigan Junior
2015-01-27  2:10         ` Thomas Fitzsimmons
2015-02-07  1:43           ` Sergio Durigan Junior
2015-03-09  1:22             ` Thomas Fitzsimmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3twzeqv2z.fsf@fitzsim.org \
    --to=fitzsim@fitzsim.org \
    --cc=19678@debbugs.gnu.org \
    --cc=sergiodj@sergiodj.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.