[S] Don't bail out on :package-version in `defcustom'

Michael Sperber <[email protected]> Mon, 29 Sep 2014 10:16:40 +0200
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
"Stephen J. Turnbull" <[email protected]> writes:

> Michael Sperber writes:
>  > 
>  > "Stephen J. Turnbull" <[email protected]> writes:
>  > 
>  > > Michael Sperber writes:
>  > >
>  > >  > +: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 the alist `customize-package-emacs-version-alist'.
>  > >
>  > > Will an error be signaled if not?  Where?
>  > 
>  > No.
>
> I hate Elisp (almost as bad as X) for being so shoddy about validating
> arguments....
>
>  > > This really should document the format of VERSION.
>  > 
>  > Yes, I was wondering about that, too, but the format seems to be
>  > unspecified in GNU Emacs, as well.  Should we pick one?
>
> No, I mean whether it's a cons or a string.

Ah, sorry: string.

>
> I think that picking a format for either PACKAGE or VERSION is not
> going to work.  Just let them be strings and we'll deal with
> inconsistencies in `customize-package-emacs-version-alist' if and when
> it ever bugs somebody.

OK.  Revised patch attached.  Will commit Wednesday if there's no
objection.

-- 
Regards,
Mike

diff --git a/lisp/custom.el b/lisp/custom.el
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -274,6 +274,17 @@
         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),
+        where PACKAGE and VERSION are strings.
+
+        This specifies that the variable was first introduced, or its
+        default value was changed, in PACKAGE version VERSION.  This
+        keyword takes priority over :version.
+
+        Since PACKAGE must be unique and the user might see it in an
+        error message, a good choice is the official name of the
+        package, such as MH-E or Gnus.
 :tag LABEL
         Use LABEL, a string, instead of the item's name, to label the item
         in customization menus and buffers.
@@ -458,6 +469,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)
@@ -507,6 +520,14 @@
   "To the custom option SYMBOL add the version VERSION."
   (put symbol 'custom-version version))
 
+(defun custom-add-package-version (symbol version)
+  "To the custom option SYMBOL add the package version VERSION."
+  (unless (and (consp version)
+	       (stringp (car version))
+	       (stringp (cdr version)))
+        (error "Invalid package version `%s'" value))
+  (put symbol 'custom-package-version 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."

_______________________________________________
XEmacs-Patches mailing list
[email protected]
http://lists.xemacs.org/mailman/listinfo/xemacs-patches