emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom type tests


From: Lennart Borgman (gmail)
Subject: Re: custom type tests
Date: Sat, 01 Dec 2007 02:57:55 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

Lennart Borgman (gmail) wrote:
Drew Adams wrote:
Does anyone know of code that deals with custom types in such a way that you
could test whether the type of a user option is compatible with a given
type?

For instance, if a variable `foo' is of type `regexp' and `bar' is of type `color', I would want a test for compatibility with type `string' to return
non-nil for each, since a regexp and a color are strings.

As another example, if `foo' is of type `string', I would want a test for
compatibility with type (choice (const nil) string) to return non-nil, since
a string is in the union of all strings and {nil}.

Any existing code that deals with subtypes this way? Any code that deals
with custom type tests, other than just `custom-variable-type' and (get __
'custom-type)?

I'm looking for code that would allow flexible type tests - subtyping, if
possible (see above), but also not differentiating between types such as
(choice (const :tag "toto" nil) string) and (choice (const nil) string) or between (choice (choice (const nil) string) and (choice string (const nil)).

Any pointers to pertinent code or doc are appreciated. Think of it this way: Given a custom type, how can I find all user options that have that type (or
a compatible type, such as a subtype)?


I do not know exactly, but the :match property of a widget has the function you need. Look in cus-edit.el and wid-edit.el how this function is built. It does not look very easy to find out however.


Thinking about it again, the code is in set-variable. Look for :match there.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]