From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/62426 Path: news.gmane.org!not-for-mail From: Bill Wohler Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: defcustom :version Date: Tue, 28 Mar 2006 17:45:53 -0800 Organization: Newt Software Message-ID: <6274.1143596753@olgas.newt.com> References: <15499.1142047137@olgas.newt.com> <200603110447.k2B4lbt10750@raven.dms.auburn.edu> <9584.1142109654@olgas.newt.com> <17232.1142195412@olgas.newt.com> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1143596803 12909 80.91.229.2 (29 Mar 2006 01:46:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 29 Mar 2006 01:46:43 +0000 (UTC) Cc: ding@gnus.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 29 03:46:36 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FOPlK-0002DZ-Ez for ged-emacs-devel@m.gmane.org; Wed, 29 Mar 2006 03:46:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FOPlJ-0001Qb-Q4 for ged-emacs-devel@m.gmane.org; Tue, 28 Mar 2006 20:46:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FOPl5-0001QL-PB for emacs-devel@gnu.org; Tue, 28 Mar 2006 20:46:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FOPl5-0001Q9-4F for emacs-devel@gnu.org; Tue, 28 Mar 2006 20:46:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FOPl4-0001Q6-VV for emacs-devel@gnu.org; Tue, 28 Mar 2006 20:46:03 -0500 Original-Received: from [70.85.162.231] (helo=tassie.newt.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FOPms-0007xn-62; Tue, 28 Mar 2006 20:47:54 -0500 Original-Received: from olgas.newt.com (m590e36d0.tmodns.net [208.54.14.89]) by tassie.newt.com (Postfix) with ESMTP id D80431D0AC4; Tue, 28 Mar 2006 17:45:54 -0800 (PST) Original-Received: by olgas.newt.com (Postfix, from userid 1000) id 7949E16FE8; Tue, 28 Mar 2006 17:45:53 -0800 (PST) Original-Received: from olgas.newt.com (localhost [127.0.0.1]) by olgas.newt.com (Postfix) with ESMTP id 76C4316FB0; Tue, 28 Mar 2006 17:45:53 -0800 (PST) Original-To: rms@gnu.org In-reply-to: Comments: In-reply-to Richard Stallman message dated "Mon, 13 Mar 2006 07:55:34 -0500." X-Mailer: MH-E 7.93+cvs; nmh 1.1; GNU Emacs 22.0.50.19 X-Image-URL: http://www.newt.com/wohler/images/bill-diving.png Mail-Followup-To: emacs-devel@gnu.org, ding@gnus.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:52176 gmane.emacs.gnus.general:62426 Archived-At: Richard Stallman wrote: > How would you like me to proceed for this release then? To just use > comments as Reiner suggested, or to use a :package-version keyword and > extend custom-handle-keyword to allow it? > > Please try implementing the extension, and see how simple and safe it is. Richard, I think it's both simple and safe to add a :package-version keyword and create a lookup table to map the package version to the Emacs version as you asked. The symbol lookup code took 62 ms before the changes, and 87 ms after the changes (28%). As I added mappings between MH-E and Emacs versions, the times slipped to 90 ms or an additional 3%. Given that the display of the customization buffer takes an additional 103 seconds, I don't think we have to worry too much here. I welcome your comments on the names and implementation, as well as a go-ahead to check in the changes. Once that is done, I'll update NEWS and the manual appropriately. Here is how MH-E would tap into the new functionality: (add-to-list 'customize-package-emacs-version-alist '(MH-E ("6.0" "22.1") ("6.1" "22.1") ("7.0" "22.1") ("7.1" "22.1") ("7.2" "22.1") ("7.3" "22.1") ("7.4" "22.1") ("8.0" "22.1"))) ... (defgroup mh-e nil "Emacs interface to the MH mail system. MH is the Rand Mail Handler. Other implementations include nmh and GNU mailutils." :link '(custom-manual "(mh-e)Top") :group 'mail :package-version '(MH-E "8.0")) ... Here's a ChangeLog entry to give you context and diffs to the implementation: * custom.el (defcustom, custom-handle-keyword): Add :package-version keyword. (custom-add-package-version): New function. Sets value of new property 'custom-package-version from :package-version keyword. * cus-edit.el (customize-package-emacs-version-alist): New variable. (customize-changed-options): Add check for custom-package-version. (customize-package-emacs-version): New function to look up Emacs version corresponding to the given package version. Index: custom.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/custom.el,v retrieving revision 1.123 diff -u -r1.123 custom.el --- custom.el 21 Mar 2006 16:44:09 -0000 1.123 +++ custom.el 29 Mar 2006 00:54:57 -0000 @@ -268,6 +268,12 @@ VALUE should be a string specifying that the variable was first introduced, or its default value was changed, in Emacs version VERSION. +:package-version + VALUE should be a list with the form (PACKAGE VERSION) + specifying that the variable was first introduced, or its + default value was changed, in PACKAGE version VERSION. This + keyword takes priority over :version. The PACKAGE and VERSION + must appear in `customize-package-emacs-version-alist'. :tag LABEL Use LABEL, a string, instead of the item's name, to label the item in customization menus and buffers. @@ -489,6 +495,8 @@ (custom-add-to-group value symbol type)) ((eq keyword :version) (custom-add-version symbol value)) + ((eq keyword :package-version) + (custom-add-package-version symbol value)) ((eq keyword :link) (custom-add-link symbol value)) ((eq keyword :load) @@ -540,6 +548,10 @@ "To the custom option SYMBOL add the version VERSION." (put symbol 'custom-version (purecopy version))) +(defun custom-add-package-version (symbol version) + "To the custom option SYMBOL add the package version VERSION." + (put symbol 'custom-package-version (purecopy version))) + (defun custom-add-load (symbol load) "To the custom option SYMBOL add the dependency LOAD. LOAD should be either a library file name, or a feature name." Index: cus-edit.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v retrieving revision 1.289 diff -u -r1.289 cus-edit.el --- cus-edit.el 21 Mar 2006 16:44:10 -0000 1.289 +++ cus-edit.el 29 Mar 2006 00:59:18 -0000 @@ -1079,6 +1079,13 @@ (defvar customize-changed-options-previous-release "21.1" "Version for `customize-changed-options' to refer back to by default.") +(defvar customize-package-emacs-version-alist nil + "Alist that maps packages to alists of package to Emacs versions. +Packages are symbols. Versions are strings. +For example: + '((MH-E (\"7.4\" \"22.1\") (\"8.0\" \"22.1\")) + (Gnus (\"5.11\" \"22.1\")))") + ;;;###autoload (defalias 'customize-changed 'customize-changed-options) @@ -1119,7 +1126,12 @@ (let (found) (mapatoms (lambda (symbol) - (let ((version (get symbol 'custom-version))) + (let* ((package-version (get symbol 'custom-package-version)) + (version + (or (and package-version + (customize-package-emacs-version symbol + package-version)) + (get symbol 'custom-version)))) (if version (when (customize-version-lessp since-version version) (if (or (get symbol 'custom-group) @@ -1135,6 +1147,31 @@ (error "No user option defaults have been changed since Emacs %s" since-version)))) +(defun customize-package-emacs-version (symbol package-version) + "Return Emacs version of SYMBOL. +PACKAGE-VERSION has the form (PACKAGE VERSION). The VERSION of +PACKAGE is looked up in the associated list +`customize-package-emacs-version-alist' to find the version of +Emacs that is associated with it." + (let (package-versions emacs-version) + ;; Use message instead of error since we want user to be able to + ;; see the rest of the symbols even if a package author has + ;; botched things up. + (cond ((not (listp package-version)) + (message "package-version value incorrect for %s" symbol)) + ((setq package-versions (assq (car package-version) + customize-package-emacs-version-alist)) + (setq emacs-version + (cadr (assoc (cadr package-version) package-versions))) + (unless emacs-version + (message "Package version of %s not found in %s" symbol + "customize-package-emacs-version-alist"))) + (t + (message "Package %s neglected to update %s" + (car package-version) + "customize-package-emacs-version-alist"))) + emacs-version)) + (defun customize-version-lessp (version1 version2) ;; Why are the versions strings, and given that they are, why aren't ;; they converted to numbers and compared as such here? -- fx -- Bill Wohler http://www.newt.com/wohler/ GnuPG ID:610BD9AD Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian! If you're passed on the right, you're in the wrong lane.