unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: "y-or-n-p" but for other characters
Date: Fri, 15 Jun 2007 19:01:53 +0200	[thread overview]
Message-ID: <87d4zxkv7i.fsf@thalassa.lan.informatimago.com> (raw)
In-Reply-To: 87ir9pkvmi.fsf@thalassa.lan.informatimago.com

Pascal Bourguignon <pjb@informatimago.com> writes:

> weber <hugows@gmail.com> 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	other threads:[~2007-06-15 17:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-15 14:37 "y-or-n-p" but for other characters weber
2007-06-15 16:52 ` Pascal Bourguignon
2007-06-15 17:01   ` Pascal Bourguignon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d4zxkv7i.fsf@thalassa.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).