all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mortimer Cladwell <mbcladwell@yahoo.com>
To: help-gnu-emacs@gnu.org
Subject: Re: widget-create 'menu-choice
Date: Sat, 26 Sep 2009 14:52:47 -0700 (PDT)	[thread overview]
Message-ID: <372723.63065.qm@web111602.mail.gq1.yahoo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]

(apply 'widget-create 'menu-choice....
Will create multiple dropdown lists.  I want a single dropdown that has 
multiple elements.  I am thinking a macro is the way to go.  Consider:

(defmacro item-element (var)
           (list 'quote `'(item ,var)))

Then (item-element "human") would evaluate to (quote (item "human"))

What I haven't been able to do is mapcar item-element over my list

("rat" "human" "mouse")

The desired output is:

(quote (item "rat")) (quote (item "human")) (quote (item "mouse"))

Note the absence of circumscribed parenthesis, i.e. this is not a list.
Suggestions?
Thanks

Mortimer

----------------------------------------------------------

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


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[-- Attachment #2: Type: text/html, Size: 2543 bytes --]

             reply	other threads:[~2009-09-26 21:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-26 21:52 Mortimer Cladwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-09-24 16:13 Re:Re: widget-create 'menu-choice Mortimer Cladwell
2009-09-25  2:59 ` Kevin Rodgers
2009-09-18 18:54 Mortimer Cladwell
2009-09-22  2:28 ` Kevin Rodgers
2009-09-24 17:31 ` Andreas Politz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=372723.63065.qm@web111602.mail.gq1.yahoo.com \
    --to=mbcladwell@yahoo.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.