From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: custom type tests Date: Sat, 01 Dec 2007 02:38:41 +0100 Message-ID: <4750BB21.3040301@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196473178 15624 80.91.229.12 (1 Dec 2007 01:39:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Dec 2007 01:39:38 +0000 (UTC) Cc: Emacs-Devel To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 01 02:39:45 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IyHKZ-0000Aj-DS for ged-emacs-devel@m.gmane.org; Sat, 01 Dec 2007 02:39:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyHKJ-0002ul-GW for ged-emacs-devel@m.gmane.org; Fri, 30 Nov 2007 20:39:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IyHKG-0002u2-1p for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:39:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IyHKD-0002tC-L2 for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:39:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyHKD-0002t9-Ef for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:39:21 -0500 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IyHKD-0007Ne-1V for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:39:21 -0500 Original-Received: from c83-254-148-228.bredband.comhem.se ([83.254.148.228]:59759 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1IyHKB-0008CX-3i; Sat, 01 Dec 2007 02:39:19 +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 In-Reply-To: X-Antivirus: avast! (VPS 071130-0, 2007-11-30), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.148.228 X-Scan-Result: No virus found in message 1IyHKB-0008CX-3i. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1IyHKB-0008CX-3i 9f4df9d9e24793ae450fa24827a2250c X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) 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:84400 Archived-At: 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.