unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Interactive and successive completing-reads?
@ 2004-10-28 13:13 Hattuari
  2004-10-28 16:46 ` Kevin Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Hattuari @ 2004-10-28 13:13 UTC (permalink / raw)


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?
-- 
p->m == (*p).m == p[0].m

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

* Re: Interactive and successive completing-reads?
  2004-10-28 13:13 Interactive and successive completing-reads? Hattuari
@ 2004-10-28 16:46 ` Kevin Rodgers
  2004-10-28 22:36   ` Hattuari
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2004-10-28 16:46 UTC (permalink / raw)


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

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

* Re: Interactive and successive completing-reads?
  2004-10-28 16:46 ` Kevin Rodgers
@ 2004-10-28 22:36   ` Hattuari
  0 siblings, 0 replies; 3+ messages in thread
From: Hattuari @ 2004-10-28 22:36 UTC (permalink / raw)


Kevin Rodgers wrote:


> 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.
Predetermined input.
-- 
p->m == (*p).m == p[0].m

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

end of thread, other threads:[~2004-10-28 22:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-28 13:13 Interactive and successive completing-reads? Hattuari
2004-10-28 16:46 ` Kevin Rodgers
2004-10-28 22:36   ` Hattuari

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).