* defcustom - restricted list of symbols
@ 2006-10-15 18:48 Joe Casadonte
2006-10-15 23:53 ` Magnus Henoch
[not found] ` <mailman.8194.1160956463.9609.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: Joe Casadonte @ 2006-10-15 18:48 UTC (permalink / raw)
I'd like to write a defcustom variable definition that:
1. is a symbol (but could be a string, if need be)
2. is one of a list of "acceptable" symbols
3. the complete list of "acceptable" symbols is not know at the time I
write I write the defcustom itself (but is known at run-time)
4. by the nature of #3, I need to be able to add to the list of valid
symbols
5. presented to the user as a radio button or check box would be
Here's an example:
Let's say I have a generic dictionary front-end module, and I ship
with the two dictionaries: English and German. When the user goes to
customize the 'default-dictionary' for this module, I want them to be
able to choose between English, German and any other dictionary they
have installed. I don't know at the time I write the front-end which
dictionaries are available (as more could be added), and I don't know
which the user will have installed. I can, however, count on the
proper installation of a dictionary to update some other variable,
which comprises a list of installed dictionaries.
If that is somehow possible, is it then possible to make this variable
just one element in a list of values that comprise a single variable?
To continue the above (completely contrived) example, say I want to
link a given mode and a default dictionary, so that message-mode uses
German as the default, and text-mode uses English. Normally I would
create a compound defcustom definition, using the 'list type and
choice and what-not.
Now, assuming all of that *is* possible, is there a reason not to use
it? Care would have to be taken to ensure that the list of installed
dictionaries is known *before* `custom-set-variables' is called. But
I think that's possible to do given the :set-after and :require
keywords.
Thanks for the help!
--
Regards,
joe
Joe Casadonte
jcasadonte@northbound-train.com
------------------------------------------------------------------------------
Llama Fresh Farms => http://www.northbound-train.com
Gay Media Resource List => http://www.northbound-train.com/gaymedia.html
Perl for Win32 => http://www.northbound-train.com/perlwin32.html
Emacs Stuff => http://www.northbound-train.com/emacs.html
Music CD Trading => http://www.northbound-train.com/cdr.html
------------------------------------------------------------------------------
Live Free, that's the message!
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: defcustom - restricted list of symbols
2006-10-15 18:48 defcustom - restricted list of symbols Joe Casadonte
@ 2006-10-15 23:53 ` Magnus Henoch
[not found] ` <mailman.8194.1160956463.9609.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Magnus Henoch @ 2006-10-15 23:53 UTC (permalink / raw)
"Joe Casadonte" <jcasadonte@northbound-train.com> writes:
> I'd like to write a defcustom variable definition that:
>
> 1. is a symbol (but could be a string, if need be)
> 2. is one of a list of "acceptable" symbols
> 3. the complete list of "acceptable" symbols is not know at the time I
> write I write the defcustom itself (but is known at run-time)
> 4. by the nature of #3, I need to be able to add to the list of valid
> symbols
> 5. presented to the user as a radio button or check box would be
This seems to work:
(eval-when-compile (require 'cl))
(defcustom malekzista 'foo
"An option with restrictions decided at runtime."
:type '(radio (const foo)))
(defun malekzista-add-option (new-option)
"Add new option to variable `malekzista'."
(push (list 'const new-option) (cdr (get 'malekzista 'custom-type))))
Magnus
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <mailman.8194.1160956463.9609.help-gnu-emacs@gnu.org>]
* Re: defcustom - restricted list of symbols
[not found] ` <mailman.8194.1160956463.9609.help-gnu-emacs@gnu.org>
@ 2006-10-17 2:11 ` Joe Casadonte
0 siblings, 0 replies; 3+ messages in thread
From: Joe Casadonte @ 2006-10-17 2:11 UTC (permalink / raw)
On Mon, 16 Oct 2006, Magnus Henoch wrote:
> This seems to work:
Thanks, Magnus -- that's awesome! By trying to use it, though, I
found my "design" is unwieldy, as it will require me to modify many,
many variables. Your example, though, led me to this:
(defvar joe-available-dictionaries
'(choice :tag "Dictionaries"
(const :tag "English (US)" english-us)
(const :tag "German" german)))
(defcustom joe-foo nil
""
:type `(repeat
(list
(string :tag "Foo")
,joe-available-dictionaries
(string :tag "Bar")))
:group 'joe)
which is much closer to what I want (though not at all what I asked
for originally). Now, I only have one variable to manipulate.
Thanks!
--
Regards,
joe
Joe Casadonte
jcasadonte@northbound-train.com
------------------------------------------------------------------------------
Llama Fresh Farms => http://www.northbound-train.com
Gay Media Resource List => http://www.northbound-train.com/gaymedia.html
Perl for Win32 => http://www.northbound-train.com/perlwin32.html
Emacs Stuff => http://www.northbound-train.com/emacs.html
Music CD Trading => http://www.northbound-train.com/cdr.html
------------------------------------------------------------------------------
Live Free, that's the message!
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-17 2:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-15 18:48 defcustom - restricted list of symbols Joe Casadonte
2006-10-15 23:53 ` Magnus Henoch
[not found] ` <mailman.8194.1160956463.9609.help-gnu-emacs@gnu.org>
2006-10-17 2:11 ` Joe Casadonte
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.