From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71429: Inconsistent y-or-n-p prompt behavior in Emacs Lisp Date: Sat, 08 Jun 2024 11:24:50 +0300 Message-ID: <86bk4bet9p.fsf@gnu.org> References: <0a72f9c4-3f1c-4fc8-a412-169dca892b57@medialab.sissa.it> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18434"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71429@debbugs.gnu.org To: Gabriele Nicolardi , Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 08 10:26:04 2024 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 1sFrOl-0004aG-WF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Jun 2024 10:26:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrOW-0007W5-Fv; Sat, 08 Jun 2024 04:25:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrOV-0007Ur-0p for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 04:25:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFrOU-0006zi-P9 for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 04:25:46 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sFrOk-0005Vf-9Y for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 04:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jun 2024 08:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71429 X-GNU-PR-Package: emacs Original-Received: via spool by 71429-submit@debbugs.gnu.org id=B71429.171783511921019 (code B ref 71429); Sat, 08 Jun 2024 08:26:02 +0000 Original-Received: (at 71429) by debbugs.gnu.org; 8 Jun 2024 08:25:19 +0000 Original-Received: from localhost ([127.0.0.1]:57194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFrO3-0005Sx-Cv for submit@debbugs.gnu.org; Sat, 08 Jun 2024 04:25:19 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFrO1-0005SR-84 for 71429@debbugs.gnu.org; Sat, 08 Jun 2024 04:25:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrNe-0006ga-Ma; Sat, 08 Jun 2024 04:24:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=KxbIBZUM/6byageVCZDHcXgY2w3dDiwPUyYYO/A+OA8=; b=scFwlfXVZpb5aWps0NFL 8w+HIshfBpmIFFpxA9iSWjxjIGRVi2qHnKc2PziZjhIRbV0Cyne6uxApBZhFDh7sTWDbWtJX4J5cj Ppjbp6mbyJqoe5rupwIcPYhTdliWcbq9YJuh6olXk7ogyb2YZxFTNBmXEqG9IceP0jIc1bWbqxPgv c4GgC21krLa1v3bAdzHB4BXC+76lQCbgmJ6JG+gkYN0NHlNMjjkKZSEyOKzObixMBwRxOnuMYJUX7 MJZsOAZzisNV0IHCNlxrcXxGilLwhaVbIW9oB7kksE4fyAR/unyvXUar42IW6E/Y0HJAQLGTTQyXj 7FnNBhDjlLV6rQ==; In-Reply-To: <0a72f9c4-3f1c-4fc8-a412-169dca892b57@medialab.sissa.it> (message from Gabriele Nicolardi on Sat, 8 Jun 2024 09:03:37 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286817 Archived-At: > Date: Sat, 8 Jun 2024 09:03:37 +0200 > From: Gabriele Nicolardi > > I have the following Emacs Lisp code: > > (progn > (y-or-n-p "Test: ") > (let ((search-spaces-regexp "\\(?:\\n?[\s\t]+\\|\n\\)?")) > (y-or-n-p "Test: "))) > > The first prompt from the y-or-n-p function appears as expected: > > Test: (y or n) > > However, the second prompt appears differently: > > Test: (‘y’ or ‘n’) > > I’m trying to understand why the second prompt format changes. What causes this inconsistency in the > y-or-n-p prompt? > > I suspect it might be related to the search-spaces-regexp variable or how Emacs handles interactive > prompts, but I’m not sure. Any insights or explanations would be greatly appreciated! Stefan, can you please look into this? It sounds like some issue with substitute-command-keys: (substitute-command-keys "(\\`y' or \\`n') ") => #("(y or n) " 1 2 (font-lock-face help-key-binding face help-key-binding) 6 7 (font-lock-face help-key-binding face help-key-binding)) But (let ((search-spaces-regexp "\\(?:\\n?[\s\t]+\\|\n\\)?")) (substitute-command-keys "(\\`y' or \\`n') ")) => "(\\‘y’ or \\‘n’) " I actually don't understand why we use \\`y' and \\`n' in y-or-n-p. Why those backslashes, and not just `y' and `n'? That's your change in commit a36ecc408a. If I remove the backslashes, the results are identical whether or not search-spaces-regexp is let-bound.