From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thomas Fitzsimmons Newsgroups: gmane.emacs.devel Subject: Re: Free variable warning about bbdb-version (bug#19678) Date: Sun, 08 Mar 2015 12:00:45 -0400 Message-ID: References: <87k2ysen0p.fsf@gnu.org> <48785.45472.390175.21755@gargle.gargle.HOWL> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1425830518 21412 80.91.229.3 (8 Mar 2015 16:01:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Mar 2015 16:01:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Roland Winkler" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 08 17:01:50 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 1YUdeH-0003WG-W4 for ged-emacs-devel@m.gmane.org; Sun, 08 Mar 2015 17:01:50 +0100 Original-Received: from localhost ([::1]:39547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YUdeG-0003Na-Rg for ged-emacs-devel@m.gmane.org; Sun, 08 Mar 2015 12:01:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YUddM-0001qF-7q for emacs-devel@gnu.org; Sun, 08 Mar 2015 12:00:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YUddI-0008Un-Vh for emacs-devel@gnu.org; Sun, 08 Mar 2015 12:00:52 -0400 Original-Received: from mail-ob0-f182.google.com ([209.85.214.182]:35004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YUddI-0008UN-Np for emacs-devel@gnu.org; Sun, 08 Mar 2015 12:00:48 -0400 Original-Received: by obbgq1 with SMTP id gq1so29234979obb.2 for ; Sun, 08 Mar 2015 09:00:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=ZVudBuqFbhn5Hg81OK8n0cUMfLDvdVMoEscOtwb9Xsk=; b=Z61flOhqpw3Y6t/OSvkSA7zkiUVhxpMH0LI/Ym2+HAzC0U1cIhVlDSs0XIZYU8pkZb onYRbn3lXF/8FDjaJOrShclCBqRjH4mHTxfsO79H+YfkQDfxJC0iWZ0moGTRunzX8bke TC4qIOxJHeF3CVEqw/0gXX9fptYoGgtSOvf+V27Lu6equc2tR3XHc0sY7MAcrXUszMcm aYIPYvt7lQt4vB6SaSJfTxUSGxQ/vDd8HsIzZN4BO4KVQpsiVpw0Oov7WK+yPMCE0Kia 0EdrY3Txh//ed0hGSKN5IEq4szX7X9aPXKVeszq5RTGBvfytoUuFvz1+ucqcg+MNFNq0 X3nw== X-Gm-Message-State: ALoCoQnrZgstmeTQ+u5DisQTR22J2pNJF+9yuoAOzPClGS2TipHV1B2lS9Y1A7w59kPg3lsvl/zT X-Received: by 10.202.18.72 with SMTP id 69mr17384970ois.61.1425830447827; Sun, 08 Mar 2015 09:00:47 -0700 (PDT) Original-Received: from hp-dv5t (69-165-165-189.dsl.teksavvy.com. [69.165.165.189]) by mx.google.com with ESMTPSA id t8sm10152518oib.4.2015.03.08.09.00.46 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 08 Mar 2015 09:00:46 -0700 (PDT) In-Reply-To: <48785.45472.390175.21755@gargle.gargle.HOWL> (Roland Winkler's message of "Sat, 7 Mar 2015 21:14:25 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.214.182 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:183731 Archived-At: --=-=-= Content-Type: text/plain "Roland Winkler" 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=bbdb-version-check.patch 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"))) --=-=-=--