From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Re: catching keyboard-quit from read-char
Date: Fri, 27 Jul 2018 10:15:31 -0700 [thread overview]
Message-ID: <87pnz88urw.fsf@ericabrahamsen.net> (raw)
In-Reply-To: CAM-tV-_SgyXNA71HfejOkWuPQ8QmR0DBN81HuNXqyRTOLRJ1tA@mail.gmail.com
Noam Postavsky <npostavs@gmail.com> writes:
> On 26 July 2018 at 16:03, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
>> My use case above is prompting for a character to use as a register
>> name. I guess I can just use `read-char-choice', offering as choices all
>> the valid register keys from `register-alist'. The only downside is that
>> if the user enters an invalid character nothing happens: there's no
>> message indicating that they've entered an invalid character, it just
>> sits and waits for valid input.
>
> Why not use register-read-with-preview (uses read-key), which seems
> like the function specifically made for this?
Dunno what I was thinking there -- I'd even looked at the code of that
function to see how it worked, yet somehow it didn't occur to me to just
use it. Thanks for the nudge.
> Other possibilities are read-multiple-choice (currently uses
> read-char, but maybe should be changed to read-event, see Bug#32257),
> read-answer (uses read-from-minibuffer + keymap) which is new in
> master, but I plan to backport to emacs-26 soon (see Bug#31782).
Thanks for this -- I hadn't seen read-answer yet. A bit of scratch
buffer experimentation makes it look like they behave almost exactly the
same way -- why do we have two?
One other function I wish Emacs had (which I think many of us have ended
up writing ourselves) is `choose-thing-from-list'. The existing
functions return strings or characters; I'd love a function that
accepted a list of things, and a function used to derive
string/character keys for the things, and then returned the thing
itself, not the key.
But I'm off topic at this point...
Thanks again,
Eric
next prev parent reply other threads:[~2018-07-27 17:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 22:11 catching keyboard-quit from read-char Eric Abrahamsen
2018-07-26 20:03 ` Eric Abrahamsen
2018-07-27 16:00 ` Noam Postavsky
2018-07-27 17:15 ` Eric Abrahamsen [this message]
2018-07-28 1:13 ` Noam Postavsky
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pnz88urw.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-devel@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.
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.