From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: Re: limit input allowed by read-from-minibuffer? Date: Thu, 23 Feb 2006 23:30:31 GMT Organization: EarthLink Inc. -- http://www.EarthLink.net Message-ID: References: <1140730760.877986.48650@i39g2000cwa.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1140823081 30096 80.91.229.2 (24 Feb 2006 23:18:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 24 Feb 2006 23:18:01 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 25 00:17:55 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FCmBj-0002jb-8q for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Feb 2006 00:17:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FCmBi-0003TJ-Va for geh-help-gnu-emacs@m.gmane.org; Fri, 24 Feb 2006 18:17:26 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!0847253b!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Original-NNTP-Posting-Host: 4.158.222.65 Original-X-Complaints-To: abuse@earthlink.net Original-X-Trace: newsread2.news.atl.earthlink.net 1140737431 4.158.222.65 (Thu, 23 Feb 2006 15:30:31 PST) Original-NNTP-Posting-Date: Thu, 23 Feb 2006 15:30:31 PST Original-Xref: shelby.stanford.edu gnu.emacs.help:137765 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:33389 Archived-At: "bturnip" 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