From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71429: Inconsistent y-or-n-p prompt behavior in Emacs Lisp Date: Sat, 08 Jun 2024 17:47:04 +0200 Message-ID: <878qzfl9mv.fsf@gmx.net> References: <0a72f9c4-3f1c-4fc8-a412-169dca892b57@medialab.sissa.it> <86bk4bet9p.fsf@gnu.org> <87cyoreqpd.fsf@gmx.net> <87h6e3lemo.fsf@gmx.net> <861q57cwhi.fsf@gnu.org> Reply-To: Stephen Berman Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17270"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: gabriele@medialab.sissa.it, 71429@debbugs.gnu.org, Stefan Monnier , stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 08 17:48:15 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 1sFyIf-0004C3-1h for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Jun 2024 17:48:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFyIH-0005Ud-EK; Sat, 08 Jun 2024 11:47:49 -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 1sFyIE-0005TY-Ka for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 11:47:46 -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 1sFyIE-00034t-BK for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 11:47:46 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sFyIU-0001Pw-6C for bug-gnu-emacs@gnu.org; Sat, 08 Jun 2024 11:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jun 2024 15:48: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.17178616575407 (code B ref 71429); Sat, 08 Jun 2024 15:48:02 +0000 Original-Received: (at 71429) by debbugs.gnu.org; 8 Jun 2024 15:47:37 +0000 Original-Received: from localhost ([127.0.0.1]:39261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFyI4-0001P9-Sv for submit@debbugs.gnu.org; Sat, 08 Jun 2024 11:47:37 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:60015) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFyI2-0001Ou-2P for 71429@debbugs.gnu.org; Sat, 08 Jun 2024 11:47:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1717861625; x=1718466425; i=stephen.berman@gmx.net; bh=bDx4+8s5HLMUiFabKFVP16Lh9hqfyNJBEzOKeeO1odc=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=JTJ5J542jiE5pqSNdZ//LRJDLBxSaVVXROKYtvb2xz9dEJEpvW0fhLhE70WICwoN 79YikXu+tchYVpMP22yNlKWyeiGeDpCQkBSZmKrIt28tbeB2rB1FyxbygIZTGE/3x xE9Vc5BCa1QXp8ol/y4h+o7R5roRDbqaz3j6zkiHadtUwATmCmNajDJUFzSyddWCA UPqsHjD2ejIM2Bpl4kfJP89N7/1U56lUEFcBz4AyUEvT6Zul208SaGoR5Rnl/JZil Y/Ep/g+UYQYT1n9Rsck+gctgq7QwOiLH28kQHtIK2TYYfHB7GP/GgP7MBNoN1Fpmb nY6+xlg65gyKtS1D2w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([94.134.94.137]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MGyxX-1sCLda0ywt-003m6N; Sat, 08 Jun 2024 17:47:05 +0200 In-Reply-To: <861q57cwhi.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 08 Jun 2024 17:58:17 +0300") X-Provags-ID: V03:K1:Rc9nIXAkFghtf6kO/j2+6hrwvQqOdX+kisDYX7BlZ4RzB2bz7el QGITcyhBdWpuSJIz0zHGR1RtXDdf3iOJMBmowwNoLGM3ocoxaJqnLMLDqxTAYkcwJVaSP31 rW3hzKUZWzyXaU9wYJpOhDaSV9jdYNzyzt7ohz76ArxgQvuTyfrD7HBRDACwOqtvTl2vEuo hrwsEYLBPVZwZ8p29rTXA== UI-OutboundReport: notjunk:1;M01:P0:YU8C7UVwW3o=;snZSNFcTzKzQ7yUnl3oJ7RmMMu9 erZGtVMaYGdDnHe7IYgEtXW/gYx6YWiYkpJJKVtKXUx6wHo5Zk/q+GfVxZRTdyLarfCsf9UCz FWqwGClqvbhLipVrASrMi7NGmsiJyXdL/xDJxody9d1LUgWV2PvEDQWtw81kfDhFfs1hB22qZ VqsVQfnLWZUxGyjXFxRRlLVDBUjF2k9n+6WMSrKzW5Oxzjla6zNCjCnCJ5D0Q/fYo799zFNAd dCAAGIfzEeYxihBYX6arANK7kYB8q0Zu+4EJfYnRfsyqF+j9UKtJFdh0rYnC/b7gnvFWOZf8v Z6zlvLuVzOKkd5id70SVPOT0GXwS6qYolqIgCTRpYTyon6PSLpwqfB2gOE185FqM2FAveHG1X 4zD74r4F0aAo3oTJwJamDx4CVebes5eZJHkkYo7+DqE652O8FbZ3S3JeejgbA17M3soqjcI8d h7Zruvr4XBXJlg9XzpLp3UH3F0azOGjhxHcy2bEUrbttwzUktchnWkN955ThrAet8vngzeM3J NoCZR/pnmK1xv3cZ/J+VNTHM2RD+Z7n3gqNZ4og4snRPInSUIdj7PMKgtGO3BcWi+aYbN5rkl wejPcPUnZFDxYjJxn1tNSAftMDMRbfnWBLGYojgLMok9rjtkwJmQEp6w+6Z9gXWFL1KhGzWeG BcYmQVTHYsBL38jKi0IwC7vVBq1OAyF43+QuyguLbMtAb9bBZnD8zKT3D16T3F265DP1WCKoT m+jx8wHEWhIQunKBlPbRkdzRLNjeFDxQKLVR9iGhCQ3Yd//Qf2pqJvSvj8sQx8dbshGwb2TK 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:286866 Archived-At: On Sat, 08 Jun 2024 17:58:17 +0300 Eli Zaretskii wrote: >> From: Stephen Berman >> Cc: Gabriele Nicolardi , Stefan Kangas >> , 71429@debbugs.gnu.org >> Date: Sat, 08 Jun 2024 15:59:11 +0200 >> >> >> 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. >> >> Without the backslashes the cond-clause in substitute-command-keys >> handling sequences starting with "\" is skipped, so "y" and "n" do not >> get the help-key-binding face property. > > This should be explained in a comment in y-or-n-p. Since this effect of using a backslash is part of what substitute-command-keys does (and it's commented there: ";; 1C. \`f' is replaced with a fontified f."), would adding a comment to y-or-n-p be an exception or would all callers of substitute-command-keys that use this handling of the backslash also need to have such a comment? >> Stepping through substitute-command-keys in Edebug, I see that when the >> regexp ends in '?' or '*' the sexp (key-valid-p k) in >> substitute-command-keys returns nil for k set to "y" and then to "n", s= o >> these strings do not get the help-key-binding face property and "(\\`y' >> or \\`n') " is returned to y-or-n-p unaltered. When the regexp does no= t >> end in '?' or '*', (key-valid-p k) returns t for "y" and "n" and these >> strings get propertized. >> >> Stepping through key-valid-p, I see that when the regexp ends in '?' or >> '*' the sexp (split-string keys " ") returns (#1=3D"" "y" #1#) for keys >> set to "y", and key-valid-p loops over this lists, and the first elemen= t >> "" is an invalid key. When the regexp does not end in '?' or '*' the >> split-string sexp in key-valid-p returns ("y"), and "y" is valid. > > Thanks. To me, this means that key-valid-p should bind > search-spaces-regexp to nil, because otherwise the value will subvert > its contract. Do you agree? The value can break key-valid-p, e.g. by only optionally matching whitespace. Maybe that's reason enough to have key-valid-p bind it to nil. The OP's use case (mentioned the the stackexchange thread Drew referred to) seems legitimate, but maybe it can be achieved without changing search-spaces-regexp. Steve Berman