From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#66187: read-file-name unexpected behavior when MUSTMATCH is a function Date: Thu, 05 Oct 2023 15:34:32 -0400 Message-ID: References: <87r0mni6m1.fsf@breatheoutbreathe.in> <87bkdq3nw6.fsf@web.de> <875y3yx221.fsf@breatheoutbreathe.in> <87pm260wh9.fsf@web.de> <87v8bx48ww.fsf@breatheoutbreathe.in> <87msx8sbpv.fsf@web.de> <87bkdoh1gy.fsf@breatheoutbreathe.in> <87h6ngs85e.fsf@web.de> <87ttr7nzyj.fsf@breatheoutbreathe.in> <83pm1u6f8l.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24245"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: michael_heerdegen@web.de, philipk@posteo.net, 66187@debbugs.gnu.org, Joseph Turner To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 05 21:36:16 2023 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 1qoU8u-00063s-8R for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Oct 2023 21:36:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoU8X-0008VR-92; Thu, 05 Oct 2023 15:35:53 -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 1qoU8O-0008NZ-4q for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 15:35:44 -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 1qoU8N-0004Br-Qi for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 15:35:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qoU8f-0004nx-PN for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 15:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Oct 2023 19:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66187 X-GNU-PR-Package: emacs Original-Received: via spool by 66187-submit@debbugs.gnu.org id=B66187.169653450318396 (code B ref 66187); Thu, 05 Oct 2023 19:36:01 +0000 Original-Received: (at 66187) by debbugs.gnu.org; 5 Oct 2023 19:35:03 +0000 Original-Received: from localhost ([127.0.0.1]:48573 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoU7i-0004me-NH for submit@debbugs.gnu.org; Thu, 05 Oct 2023 15:35:02 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoU7f-0004m2-Bd for 66187@debbugs.gnu.org; Thu, 05 Oct 2023 15:35:01 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 40282444152; Thu, 5 Oct 2023 15:34:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1696534473; bh=guYye47qsEGSqZrJrdO5PY0/KLAAGqE92z0q32lFNX8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Q36Fmlai8kRornZpjLr8Xiph0OwF2z7RqQ2MAo+bvZ0cZOVT6CUWJqXQN9YYGK6mg 9l1uh8I6YL4NQ51f4kxP5m51TJVZ3UpVzS3IMtRku1M9Tif4oSBtgHVEW5myLPCU91 jAR0iSqwyBmuSvX9PEI1+YaWleSCvxQwxZQ5vYvVY2nH/QVD7bJld99FdgTLNByBRT VxkYsUH0ExbuBSw+ykDnZoTsbfs6fS6tCb1gBOmGgQIq6n9YmQUQecCy2TglUN7Pzr vCQAQShvkqY2SWktKj92oVCe+e5vfR2MGNS/UUIAn6onH2XUjUMGSjlDYEI+VnKqVG dQ/dy1v/EPT8A== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 8936344414F; Thu, 5 Oct 2023 15:34:33 -0400 (EDT) Original-Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 60DFB12020A; Thu, 5 Oct 2023 15:34:33 -0400 (EDT) In-Reply-To: <83pm1u6f8l.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 04 Oct 2023 10:03:54 +0300") 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:271915 Archived-At: >> For example, given: >> >> (completing-read "Prompt: " '("a" "b") nil >> (lambda (input) >> (string= "a" input))) >> >> I expected that the prompt would refuse to complete "b". I was wrong. >> >> Since completing-read is such a fundamental part of Emacs, I doubt it >> will be possible to change this behavior. What do you think about the >> attached patch to clarify the completing-read docstring? The use of a function as `require-match` is brand new in Emacs-29, so I think it's not too late to fix it. I think rather than fixing the doc we should fix the behavior, e.g. with the patch below. Stefan diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 2120e31775e..d4da2d0d19b 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1835,15 +1835,13 @@ completion--complete-and-exit (cond ;; Allow user to specify null string ((= beg end) (funcall exit-function)) - ;; The CONFIRM argument is a predicate. - ((and (functionp minibuffer-completion-confirm) - (funcall minibuffer-completion-confirm - (buffer-substring beg end))) - (funcall exit-function)) ;; See if we have a completion from the table. - ((test-completion (buffer-substring beg end) - minibuffer-completion-table - minibuffer-completion-predicate) + ((if (functionp minibuffer-completion-confirm) + (funcall minibuffer-completion-confirm + (buffer-substring beg end)) + (test-completion (buffer-substring beg end) + minibuffer-completion-table + minibuffer-completion-predicate)) ;; FIXME: completion-ignore-case has various slightly ;; incompatible meanings. E.g. it can reflect whether the user ;; wants completion to pay attention to case, or whether the