From: Sergio Durigan Junior <sergiodj@sergiodj.net>
To: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Cc: 19678@debbugs.gnu.org
Subject: bug#19678: [PATCH] EUDC does not support BBDB 3.x
Date: Mon, 26 Jan 2015 14:02:36 -0500 [thread overview]
Message-ID: <87lhkpjrg3.fsf@sergiodj.net> (raw)
In-Reply-To: <m3twzeqv2z.fsf@fitzsim.org> (Thomas Fitzsimmons's message of "Sun, 25 Jan 2015 18:49:56 -0500")
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 <fitzsim@fitzsim.org>
+ Sergio Durigan Junior <sergiodj@sergiodj.net>
+
+ * 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 <monnier@iro.umontreal.ca>
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")))
next prev parent reply other threads:[~2015-01-26 19:02 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
2015-01-26 19:02 ` Sergio Durigan Junior [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lhkpjrg3.fsf@sergiodj.net \
--to=sergiodj@sergiodj.net \
--cc=19678@debbugs.gnu.org \
--cc=fitzsim@fitzsim.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).