* Re:Re: widget-create 'menu-choice
@ 2009-09-24 16:13 Mortimer Cladwell
2009-09-25 2:59 ` Kevin Rodgers
0 siblings, 1 reply; 2+ messages in thread
From: Mortimer Cladwell @ 2009-09-24 16:13 UTC (permalink / raw
To: kevin.d.rodgers, help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]
Your suggestion evaluates to:
((item "human") (item "rat") (item "mouse"))
which when inserted into a form results in the error:
widget-create: Invalid function: (item "human")
Evaluations that would work are:
'(item "human") '(item "rat") '(item "mouse")
OR
(quote (item "human")) (quote (item "rat")) (quote (item "mouse"))
Note that there are no enclosing parenthesis around the list.
Thanks
Mortimer-----------------------------------------------------------------
Mortimer Cladwell wrote:
Hi,
>I would like to dynamically populate a dropdown widget from a database. the 'menu-choice widget looks like
>(widget-create 'menu-choice
>:tag "Select Host Species"
>:value "unknown"
>:notify (lambda (widget &rest ignore)
>(setq host-species (widget-value widget)))
>'(item "human")
>'(item "rat")
>'(item "mouse"))
>Suppose I can generate a list '( "human "rat" "mouse") from the database. How to create
>'(item "human")
>'(item "rat")
>'(item "mouse")
>on the fly? The closest I can come is
>(progn
>(setq var '( "human" "rat" "mouse"))
>(mapcar '(lambda (a) `'(item ,a)) var)
>)
i.e.
(let ((var '("human" "rat" "mouse")))
(mapcar (lambda (label) (list 'item label))
var))
--
Kevin Rodgers
Denver, Colorado, USA
[-- Attachment #2: Type: text/html, Size: 2323 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: widget-create 'menu-choice
2009-09-24 16:13 Re:Re: widget-create 'menu-choice Mortimer Cladwell
@ 2009-09-25 2:59 ` Kevin Rodgers
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2009-09-25 2:59 UTC (permalink / raw
To: help-gnu-emacs
Mortimer Cladwell wrote:
> Your suggestion evaluates to:
>
> ((item "human") (item "rat") (item "mouse"))
>
> which when inserted into a form results in the error:
>
> widget-create: Invalid function: (item "human")
Ah, I misread the widget-create arguments. That function's doc string is
practically useless.
> Evaluations that would work are:
>
> '(item "human") '(item "rat") '(item "mouse")
> OR
>
> (quote (item "human")) (quote (item "rat")) (quote (item "mouse"))
>
> Note that there are no enclosing parenthesis around the list.
As Andreas points out, you need apply:
(defvar species '("human" "rat" "mouse"))
(apply 'widget-create
'menu-choice
:tag "Select Host Species"
:value "unknown"
:notify (lambda (widget &rest ignore)
(setq host-species (widget-value widget)))
(mapcar (lambda (label) (list 'item label))
species))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-25 2:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 16:13 Re:Re: widget-create 'menu-choice Mortimer Cladwell
2009-09-25 2:59 ` Kevin Rodgers
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.