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

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

Re: "y-or-n-p" but for other characters


From: Pascal Bourguignon
Subject: Re: "y-or-n-p" but for other characters
Date: Fri, 15 Jun 2007 19:01:53 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (gnu/linux)

Pascal Bourguignon <address@hidden> writes:

> weber <address@hidden> writes:
>
>> Hi folks!
>> I'm trying to come up with a interactive function for fixing my
>> code...
>>
>> I present three options to the user (myself), that are mapped to three
>> characters (a,b,c say)
>> Even though read-from-minibuffer solves my problem, y-or-n-p behavior
>> is more interesting because doesn't require an extra [ret].
>>
>> Is there a way to code a y-or-n for a-or-b-or-c ?
>
>   (read-char "a, b or c? ")

Well:

    (require 'cl)

    (defun a-or-b-or-c ()
       (loop for ch = (read-char "a, b or c? ")
             until (position ch "abc")
             finally (return ch)))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.


reply via email to

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