help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interactive and successive completing-reads?


From: Kevin Rodgers
Subject: Re: Interactive and successive completing-reads?
Date: Thu, 28 Oct 2004 10:46:43 -0600
User-agent: Mozilla Thunderbird 0.8 (X11/20040916)

Hattuari wrote:
> I can use this code to prompt the user for successive inputs:
>
> (defun paste-gl-array(gl-type gl-order gl-vector)
>   "Map OpenGL types to corresponding sufixes.(GL\'type\' )"
>   (interactive "sType: \nnNumber 1 to 4: \nsVector: ")
>   (message " gl-type=%s, gl-order=%d, gl-vector=%s, suffix=%s"
>            gl-type gl-order gl-vector
>            (assoc  gl-type gl-type-alist)))
>
>
> I can uses this to prompt the user for specific strings which I provide in
> gl-type-alist:
>
> (defvar gl-type nil)
>
> (defun gl-data-read ()
>   "Read a GLdata type from the minibuffer: "
>   (interactive)
>   (setq gl-type (completing-read
>                   "GL Data Type: "
>                   gl-type-alist
>                   nil t "GL"))
>   (message "gl-type=%s" gl-type)
>   )
>
> I would like to do both of the above in one invocation of an interactive
> command.  Can this be done by somehow integrating the two forms above?
> Should I, instead, simply evalueate successive `completing-read' forms from
> one enclosing form and forget about using the first form above?

It depends.  The first form allows the user to enter any string, not
just a key from gl-type-alist.  Do you want to preserve that freedom for
the user?  If so, you can't combine them.

But the conventional way to write the second function is:

(defun gl-type-message (gl-type)
  (interactive (list (completing-read "GL Data Type: " gl-type-alist
                                      nil t "GL")))
  (message "gl-type=%s" gl-type))

--
Kevin Rodgers


reply via email to

[Prev in Thread] Current Thread [Next in Thread]