all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* limit input allowed by read-from-minibuffer?
@ 2006-02-23 21:38 bturnip
  2006-02-24 22:28 ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: bturnip @ 2006-02-23 21:38 UTC (permalink / raw)


I want to prompt for a value in the minibuffer and only accept the
input if it matches one of the choices presented in my prompt string.
How do I do this?

(defun example()
  (interactive)
  (setq read_method(read-from-minibuffer "Read Method?
[<,>,>>,+<,+>,+>>] " nil nil nil nil "<"))
)

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

* limit input allowed by read-from-minibuffer?
@ 2006-02-23 21:39 bturnip
  2006-02-23 23:30 ` B. T. Raven
  0 siblings, 1 reply; 5+ messages in thread
From: bturnip @ 2006-02-23 21:39 UTC (permalink / raw)


I want to prompt for a value in the minibuffer and only accept the
input if it matches one of the choices presented in my prompt string.
How do I do this?

(defun example()
  (interactive)
  (setq read_method(read-from-minibuffer "Read Method?
[<,>,>>,+<,+>,+>>] " nil nil nil nil "<"))
)

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

* Re: limit input allowed by read-from-minibuffer?
  2006-02-23 21:39 bturnip
@ 2006-02-23 23:30 ` B. T. Raven
  2006-02-24 19:45   ` bturnip
  0 siblings, 1 reply; 5+ messages in thread
From: B. T. Raven @ 2006-02-23 23:30 UTC (permalink / raw)



"bturnip" <bturnip@gmail.com> wrote in message
news:1140730760.877986.48650@i39g2000cwa.googlegroups.com...
> I want to prompt for a value in the minibuffer and only accept the
> input if it matches one of the choices presented in my prompt string.
> How do I do this?
>
> (defun example()
>   (interactive)
>   (setq read_method(read-from-minibuffer "Read Method?
> [<,>,>>,+<,+>,+>>] " nil nil nil nil "<"))
> )
>

 (defun example()
   (interactive)
   (setq rm '("" "<" ">" ">>" "+<" "+>" "+>>"))
   (while (progn
       (setq read_method(read-from-minibuffer "Read Method?
[<,>,>>,+<,+>,+>>] " nil nil nil nil "<"))
    (not (member read_method rm))))

 )

I haven't tested this but something close to it should work. You have to
look for the null string because that's what will  be bound to your
'read_method variable if you just press enter. It will then be a synonym
for "<"

Ed

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

* Re: limit input allowed by read-from-minibuffer?
  2006-02-23 23:30 ` B. T. Raven
@ 2006-02-24 19:45   ` bturnip
  0 siblings, 0 replies; 5+ messages in thread
From: bturnip @ 2006-02-24 19:45 UTC (permalink / raw)


Thanks!  That did the trick.  I removed the option to just press enter-
I am going to have to do a little more work to figure out that part.

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

* RE: limit input allowed by read-from-minibuffer?
  2006-02-23 21:38 limit input allowed by read-from-minibuffer? bturnip
@ 2006-02-24 22:28 ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2006-02-24 22:28 UTC (permalink / raw)


    I want to prompt for a value in the minibuffer and only accept the
    input if it matches one of the choices presented in my prompt string.
    How do I do this?

    (defun example()
      (interactive)
      (setq read_method(read-from-minibuffer "Read Method?
    [<,>,>>,+<,+>,+>>] " nil nil nil nil "<")))

You want `completing-read', not `read-from-minibuffer'. That will: 1) let
users complete their input to any of the possible values, and 2) require
that their input be one of those values. Use non-nil for the REQUIRE-MATCH
argument.

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

end of thread, other threads:[~2006-02-24 22:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-23 21:38 limit input allowed by read-from-minibuffer? bturnip
2006-02-24 22:28 ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2006-02-23 21:39 bturnip
2006-02-23 23:30 ` B. T. Raven
2006-02-24 19:45   ` bturnip

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.