From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#38785: 26.3; `y-or-n-p' leaves prompt and response in echo area Date: Sat, 28 Dec 2019 14:55:08 -0800 (PST) Message-ID: <787722a4-9679-4160-903d-d9de42801ddf@default> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="138302"; mail-complaints-to="usenet@blaine.gmane.org" To: 38785@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 28 23:58:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ilL2D-000ZpV-Dl for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Dec 2019 23:58:13 +0100 Original-Received: from localhost ([::1]:46932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilL2B-0002Fo-Jt for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Dec 2019 17:58:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56288) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilL23-0002FV-Sl for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:58:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ilL22-0005JV-KA for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:58:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53094) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ilL22-0005It-FO for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ilL22-00059a-EC for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Dec 2019 22:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38785 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.157757383719753 (code B ref -1); Sat, 28 Dec 2019 22:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Dec 2019 22:57:17 +0000 Original-Received: from localhost ([127.0.0.1]:59067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilL1J-00058X-7B for submit@debbugs.gnu.org; Sat, 28 Dec 2019 17:57:17 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:48393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ilL1H-00058P-Li for submit@debbugs.gnu.org; Sat, 28 Dec 2019 17:57:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilL1G-0002E4-5p for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:57:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ilL1E-0000BR-O7 for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:57:13 -0500 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:47620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ilL1E-0008Th-DM for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2019 17:57:12 -0500 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBSMtGIL040974 for ; Sat, 28 Dec 2019 22:57:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=7TV1DJ/zocFHipNLVZtZATGtcZVGrafArOc+yPcUO4I=; b=DIigXrtS8V5WkV6Dr2QNnI8OihzLDxBrrcW71UTy5GzwvoEAHITNZ+mf6w7WLBgKCm08 aXJYjYHcEjUDHXk5xkZ0uDU7QchOv2uVAvbFMAp/kiUkQAMAZ/8tWf9Ej4FlyXh8vNnT yX1bRBO4kLphdcE2sbcnC4S5Etvs9RJtsXiu6Zbox0fYbxkpURGPL8NwbraiQneSL88s r5Vsq4Ftmk8dt32cWqU6BmINXCqaaFF34aTqpeGwiJQkBCqO5lG+5U5gNM2vzDgaTUxg ZwcnmsNE7HNtA3gyZh5FLm5icVzNQrgEpajcSfA6A6UbyjIe1m/xX5NVifYVXypWAIGm gg== Original-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2x5y0p9qk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 28 Dec 2019 22:57:10 +0000 Original-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBSMrSZA082053 for ; Sat, 28 Dec 2019 22:55:09 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2x5wb8h303-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 28 Dec 2019 22:55:09 +0000 Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xBSMt8bb023036 for ; Sat, 28 Dec 2019 22:55:08 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4939.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9484 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912280215 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9484 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912280215 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173869 Archived-At: `y-or-n-p' puts its prompt in the echo area. [Aside: That is not ideal for a prompt. Some other interaction might be better, such as using a pop-up for the prompt. In any case, `y-or-n-p' and similar functions should NOT use the minibuffer. `read-key' should continue to act without any use of the minibuffer. IMHO, it would make zero sense to use the minibuffer to read a key.] At the end, `y-or-n-p' puts its prompt in the echo area again, followed by the user's response (`y' or `n'): (unless noninteractive (message "%s%c" prompt (if ret ?y ?n))) This is a bother, and it can confuse users, especially when there are additional questions that follow the `y-or-n-p' prompting. For example, consider a `y-or-n-p' followed by a `map-y-or-n-p'. When the latter is finished, the prompt from the preceding `y-or-n-p' gets restored to the echo area. That makes little sense, and it can be quite confusing. `map-y-or-n-p' does not leave any of its prompts in the echo area. This is a good thing, not a bad thing. Instead, as a good citizen, it does this at the end, to ensure that it hasn't left any of its echo-area prompts behind, as litter: ;; Clear the last prompt from the minibuffer, and restore the ;; previous echo-area message, if any. (let ((message-log-max nil)) (if msg (message "%s" msg) (message ""))) Perhaps that, or similar, is what `y-or-n-p' should do. Presumably the reason that `y-or-n-p' does what it does is to provide feedback of the char (`y' or `n') that you typed. It's true that that's helpful, but it also causes problems (see above). Perhaps `y-or-n-p' should do what it does now, but then reset the echo area after a brief delay (e.g. 1 sec), where "reset" means to do what `map-y-or-n-p' does: restore any previous echo-area content. IOW, it's not bad to echo your response to the `y-or-n-p' question. But it is bad not to clean up afterward, leaving the echo area littered with the prompt. For example, have `y-or-n-p' bind `msg' to `(current-message)' at the outset, and then do this at the end: (let ((ret (eq answer 'act))) (unless noninteractive (message "%s%c" prompt (if ret ?y ?n)) ; <=3D=3D=3D=3D (1) (run-with-timer 1 nil (lambda ()=20 (let ((message-log-max nil)) ; <=3D=3D=3D=3D (2) (if msg=20 (message "%s" msg) (message "")))))) ret) (1) is what `y-or-n-p' does now, to show you your response. (2) is what `map-y-or-n-p' does, to clean up after itself. If something similar to this 1-2 punch is not done, and if the only available choice is for `y-or-n-p' to do what it does now (#1), or to just clean up after itself (#2), then my vote is for #2. In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-08-29 Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd Windowing system distributor `Microsoft Corp.', version 10.0.17763 Configured using: `configure --without-dbus --host=3Dx86_64-w64-mingw32 --without-compress-install 'CFLAGS=3D-O2 -static -g3''