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:57:55 +0100 Message-ID: <4750BFA3.9070708@gmail.com> References: <4750BB21.3040301@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196474291 18024 80.91.229.12 (1 Dec 2007 01:58:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Dec 2007 01:58:11 +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:58:19 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 1IyHcX-00045t-23 for ged-emacs-devel@m.gmane.org; Sat, 01 Dec 2007 02:58:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyHcG-0006Nx-Ql for ged-emacs-devel@m.gmane.org; Fri, 30 Nov 2007 20:58:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IyHcD-0006Ni-Uj for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:57:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IyHcC-0006NE-Fb for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:57:56 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyHcC-0006NB-Ap for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:57:56 -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 1IyHcC-0002ZO-5u for emacs-devel@gnu.org; Fri, 30 Nov 2007 20:57:56 -0500 Original-Received: from c83-254-148-228.bredband.comhem.se ([83.254.148.228]:59867 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1IyHc9-0007Sh-6R; Sat, 01 Dec 2007 02:57:54 +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: <4750BB21.3040301@gmail.com> 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 1IyHc9-0007Sh-6R. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1IyHc9-0007Sh-6R 7f7add291c8eec26516d7a4efea15f05 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:84401 Archived-At: 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.