From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Newsgroups: gmane.emacs.help Subject: Properly using :value-to-external and :value-to-internal? Date: Fri, 23 Aug 2013 23:20:55 -0700 Message-ID: <521850C7.3070300@thompsonclan.org> NNTP-Posting-Host: plane.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 1377340689 25605 80.91.229.3 (24 Aug 2013 10:38:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Aug 2013 10:38:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 24 12:38:11 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VDBEQ-0007KN-Or for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Aug 2013 12:38:10 +0200 Original-Received: from localhost ([::1]:41089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDBEQ-0003uZ-Bj for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Aug 2013 06:38:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD7Dg-0007BN-Ow for help-gnu-emacs@gnu.org; Sat, 24 Aug 2013 02:21:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VD7DZ-00089N-9L for help-gnu-emacs@gnu.org; Sat, 24 Aug 2013 02:21:08 -0400 Original-Received: from mail-pb0-f48.google.com ([209.85.160.48]:34317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD7DZ-00088v-3v for help-gnu-emacs@gnu.org; Sat, 24 Aug 2013 02:21:01 -0400 Original-Received: by mail-pb0-f48.google.com with SMTP id ma3so1465650pbc.7 for ; Fri, 23 Aug 2013 23:20:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=bu+2RQ1gKbilpJisAaeqnvHcAgTvZ7mArmg/4uvrNp8=; b=C44YjKKPIqW4i6IqHEaskPfLMcMlS8eCPKj401zbRQABxHOy1TUEeMKYZgyK69n2I/ Yjqi+GpAgDQiw6lZgYTa8BrDRI5bvRoqLb3myvQeYIe6cxShKZbnttC23RjjqLn2J8tz YUmDPgPI2sArTgvbkmf0/MCfLHN5WvDxWjwnwbF9ealZL6XcexzC8riD+TfPXYJWTBLf B8Fx0nWd56FyBCPnLGtNJWpEssVQboh2bDmUXgidCjvHix8i/iPLo7GsiNq6Nbt+NeNO Q0KgyCFkTrBBY5rgwcupFP7PKfpqVs3dQadIK7umT4wbsN7kGqJvZwNeUhau+CnLXgcD 7WrA== X-Gm-Message-State: ALoCoQnLd4d5VoB2+bbgVk48IkLEnvsJqIrmXYYfjACiiN1T23HlyIvW+TudFnoa3NAM1J680z5m X-Received: by 10.66.228.38 with SMTP id sf6mr3004556pac.21.1377325259464; Fri, 23 Aug 2013 23:20:59 -0700 (PDT) Original-Received: from [192.168.10.2] (user-0c9ha1q.cable.mindspring.com. [24.152.168.58]) by mx.google.com with ESMTPSA id iu7sm3991921pbc.45.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 23:20:58 -0700 (PDT) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.48 X-Mailman-Approved-At: Sat, 24 Aug 2013 06:37:57 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93076 Archived-At: Hi all, I could use some help writing a special widget for use in the "defcustom" declaration that I'm writing. I'm writing a variable that's a list of match conditions. Each match condition is a choice between a literal string that only matches exactly, a prefix string that matches anything that starts with the prefix, or a regexp. The problem is that all three of these things is internally just a string, so there's no way to tell which one the variable has been set to. Here's a minimal example demonstrating the problem: |(defcustom myvar"" "String or regexp" :type'(choice(string:tag"String") (regexp:tag"Regexp")))| Regardless of whether the user chooses the String or Regexp options, the variable gets set to a string and there's no way to tell whether or not it's supposed to be a regexp. What I'd like to do is have the variable be set to one if either "(TYPE . VALUE)", where TYPE is one of 'string or 'regexp and VALUE is whatever the user entered. I figured that I could accomplish this by creating a few custom widgets with special ":value-to-external" and ":value-to-internal" properties that handle the conversion between bare strings and the cons cells that I want. However, no matter what I try, i seem to run into errors, probably because the ":match" and ":validate" properties are looking at the cons cells instead of the bare strings and rejecting them. So can someone give me an example of a "define-widget" call that looks and works just like a "string" widget but actually gives "(string . VALUE)" as its value? Thanks, -Ryan Thompson