From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#51101: 29.0.50; read-char-from-minibuffer accepts Enter even when not a choice. Date: Sun, 10 Oct 2021 20:31:31 +0300 Organization: LINKOV.NET Message-ID: <87h7dpc7e0.fsf@mail.linkov.net> References: <877demny4b.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6223"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: "David M. Koppelman" , 51101@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 10 19:34:57 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mZciv-0001Um-LI for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Oct 2021 19:34:57 +0200 Original-Received: from localhost ([::1]:52046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZciu-0005lV-LL for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Oct 2021 13:34:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZci3-00049q-Ve for bug-gnu-emacs@gnu.org; Sun, 10 Oct 2021 13:34:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZci3-0004mn-Ns for bug-gnu-emacs@gnu.org; Sun, 10 Oct 2021 13:34:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mZci3-0001r6-In for bug-gnu-emacs@gnu.org; Sun, 10 Oct 2021 13:34:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Oct 2021 17:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51101 X-GNU-PR-Package: emacs Original-Received: via spool by 51101-submit@debbugs.gnu.org id=B51101.16338872097060 (code B ref 51101); Sun, 10 Oct 2021 17:34:03 +0000 Original-Received: (at 51101) by debbugs.gnu.org; 10 Oct 2021 17:33:29 +0000 Original-Received: from localhost ([127.0.0.1]:55779 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZchV-0001po-FK for submit@debbugs.gnu.org; Sun, 10 Oct 2021 13:33:29 -0400 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:52615) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZchT-0001pW-RD; Sun, 10 Oct 2021 13:33:28 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id E99C7200003; Sun, 10 Oct 2021 17:33:18 +0000 (UTC) In-Reply-To: <877demny4b.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 09 Oct 2021 15:09:24 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:216819 Archived-At: close 51101 28.0.60 quit >> Execute: >> >> (read-char-from-minibuffer "Answer y or n" '(?y ?n)) >> >> and press Enter. The form returns Enter (13) rather than re-prompting >> for a y or n. > > It seems undocumented what RET is supposed to do in this function -- > I've added Juri to the CCs, perhaps he has some comments. RET is supposed to do exactly the same what it did in read-char-choice-with-read-key, or when these variables are non-nil: read-char-choice-use-read-key and y-or-n-p-use-read-key, i.e. to ignore RET and read the character again. So this is fixed accordingly now in 28.0. >> This causes a dataloss threat due to read-char-from-minibuffer being >> called through ask-user-about-supersession-threat. >> >> Even if the read-char-from-minibuffer bug is quickly fixed, I'd >> sleep better if the following patch were applied to userlock.el: >> >> @@ -194,7 +194,9 @@ ask-user-about-supersession-threat >> (list "File reverted" filename))) >> ((eq answer ?n) >> (signal 'file-supersession >> - (list "File changed on disk" filename))))) >> + (list "File changed on disk" filename))) >> + ((eq answer ?y)) >> + (t (setq answer nil)))) I installed the patch provided by David as well. > But I think ask-user-about-supersession-threat is working correctly here > already (almost by chance). RET means "yes" in functions like > `y-or-n-p', which this is basically an extended version of, so it should > work as "yes" here, too. Maybe it works here because ask-user-about-supersession-threat is called from C with some flag that disables signaling 'quit'. But when trying to type RET after (y-or-n-p "Answer y or n: ") it terminates with the 'quit' signal. And indeed in the map used by y-or-n-p, RET is bound to 'exit': (define-key query-replace-map "\r" 'exit) I noticed the recent commit ec9f25bd356c7c81d94c78f11100b97d6d52ce97 saying that RET means "yes" in y-or-n-p. But anyway since RET now does the same that read-char-choice-with-read-key does, so I removed mentions of RET from the doc string. Or should the fixed behavior be mentioned?