From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: catching keyboard-quit from read-char Date: Fri, 27 Jul 2018 10:15:31 -0700 Message-ID: <87pnz88urw.fsf@ericabrahamsen.net> References: <877eljj79j.fsf@ericabrahamsen.net> <87woth3gt0.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1532711675 10505 195.159.176.226 (27 Jul 2018 17:14:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 27 Jul 2018 17:14:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 27 19:14:31 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fj6Jy-0002eo-R8 for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2018 19:14:30 +0200 Original-Received: from localhost ([::1]:42371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj6M5-0006yv-NU for ged-emacs-devel@m.gmane.org; Fri, 27 Jul 2018 13:16:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fj6LE-0006xy-GQ for emacs-devel@gnu.org; Fri, 27 Jul 2018 13:15:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fj6LB-00089m-8i for emacs-devel@gnu.org; Fri, 27 Jul 2018 13:15:48 -0400 Original-Received: from [195.159.176.226] (port=38771 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fj6LB-00088y-06 for emacs-devel@gnu.org; Fri, 27 Jul 2018 13:15:45 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fj6J0-0001Qn-9j for emacs-devel@gnu.org; Fri, 27 Jul 2018 19:13:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 38 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:Kyv9Pv06UmD/NqCMAgigxXd2Nlc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:227862 Archived-At: Noam Postavsky writes: > On 26 July 2018 at 16:03, Eric Abrahamsen 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