all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
To: "Roland Winkler" <winkler@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Free variable warning about bbdb-version (bug#19678)
Date: Sun, 08 Mar 2015 12:00:45 -0400	[thread overview]
Message-ID: <m361abbhsi.fsf@fitzsim.org> (raw)
In-Reply-To: <48785.45472.390175.21755@gargle.gargle.HOWL> (Roland Winkler's message of "Sat, 7 Mar 2015 21:14:25 -0600")

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

"Roland Winkler" <winkler@gnu.org> writes:

>> > I guess I would not try to be compatible with both versions.
>> 
>> Do you see any harm in being compatible with both versions?  The
>> patch is already written and tested, so I figure I might as well
>> push it.
>
> No, I do not see any (direct) harm.  Merely, I find that such things
> can significantly decrease readability of the code and thus make
> maintanence more difficult.  (Yet I do not know how intensely the
> code you talk about is linked to BBDB.  With just a few function
> calls from BBDB there should not be too much a problem.)

The patch isn't too bad (see attached), but the version check is ugly.
I'm trying to make the 2.x to 3.x transition as smooth as possible for
EUDC users.

I agree that it would nice to be able to avoid this type of check.
There are lots of references to BBDB throughout Emacs that might have
version dependencies though.  That's why, once the copyrights are clear,
I'd like to see BBDB bundled in Emacs, rather than added to GNU ELPA.
Is that the plan?  Are the Emacs maintainers on board with bundling?

> Also, features in BBDB 3 have been significantly expanded.  I do not
> know either whether your code might benefit from that.

For now, I'm just trying to maintain status quo for eudcb-bbdb.el.
If/when your BBDB version is bundled it'll be easier to take advantage
of the new features.

Thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bbdb-version-check.patch --]
[-- Type: text/x-patch, Size: 2005 bytes --]

diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index 5be2bec..bd5d453 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -42,6 +42,24 @@ (require 'bbdb-com nil t)
 (defvar eudc-bbdb-current-query nil)
 (defvar eudc-bbdb-current-return-attributes nil)
 
+(defvar bbdb-version)
+
+(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)
+	   (or
+	    ;; MELPA versions of BBDB may have a bad package version,
+	    ;; but they're all version 3 or later.
+	    (equal bbdb-version "@PACKAGE_VERSION@")
+	    ;; Development versions of BBDB can have the format "X.YZ
+	    ;; devo".  Split the string just in case.
+	    (version<= "3" (car (split-string bbdb-version)))))
+      'mail
+    field-symbol))
+
 (defvar eudc-bbdb-attributes-translation-alist
   '((name . lastname)
     (email . net)
@@ -85,7 +103,9 @@ (defun eudc-bbdb-filter-non-matching-record (record)
                    (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
@@ -168,7 +188,7 @@ (defun eudc-bbdb-format-record-as-result (record)
 	(setq val (eval
 		   (list (intern
 			  (concat "bbdb-record-"
-				  (symbol-name attr)))
+				  (symbol-name (eudc-bbdb-field attr))))
 			 'record))))
        (t
 	(error "Unknown BBDB attribute")))

      reply	other threads:[~2015-03-08 16:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06  8:48 Free variable warning about bbdb-version (bug#19678) Thomas Fitzsimmons
2015-03-06  9:09 ` Tassilo Horn
2015-03-06 17:42 ` Stefan Monnier
2015-03-07 17:27 ` Roland Winkler
2015-03-08  2:10   ` Thomas Fitzsimmons
2015-03-08  3:14     ` Roland Winkler
2015-03-08 16:00       ` Thomas Fitzsimmons [this message]

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=m361abbhsi.fsf@fitzsim.org \
    --to=fitzsim@fitzsim.org \
    --cc=emacs-devel@gnu.org \
    --cc=winkler@gnu.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 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.