emacs-devel
[Top][All Lists]
Advanced

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

Re: catching keyboard-quit from read-char


From: Eric Abrahamsen
Subject: Re: catching keyboard-quit from read-char
Date: Fri, 27 Jul 2018 10:15:31 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Noam Postavsky <address@hidden> writes:

> On 26 July 2018 at 16:03, Eric Abrahamsen <address@hidden> 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




reply via email to

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