unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Properly using :value-to-external and :value-to-internal?
@ 2013-08-24  6:20 Ryan
  2013-08-24 15:20 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Ryan @ 2013-08-24  6:20 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-24 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-24  6:20 Properly using :value-to-external and :value-to-internal? Ryan
2013-08-24 15:20 ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).