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: Fri, 06 Oct 2023 12:43:51 -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> <83fs2o2wb0.fsf@gnu.org> <83v8bj2794.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="25067"; 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@breatheoutbreathe.in To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 06 18:45:06 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 1qonwo-0006GO-F2 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 06 Oct 2023 18:45:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qonwV-0000lI-Hm; Fri, 06 Oct 2023 12:44:47 -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 1qonwR-0000Pn-9O for bug-gnu-emacs@gnu.org; Fri, 06 Oct 2023 12:44:43 -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 1qonwR-0002Yt-0W for bug-gnu-emacs@gnu.org; Fri, 06 Oct 2023 12:44:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qonwj-0007Sa-Jw for bug-gnu-emacs@gnu.org; Fri, 06 Oct 2023 12:45: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: Fri, 06 Oct 2023 16:45: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.169661066728606 (code B ref 66187); Fri, 06 Oct 2023 16:45:01 +0000 Original-Received: (at 66187) by debbugs.gnu.org; 6 Oct 2023 16:44:27 +0000 Original-Received: from localhost ([127.0.0.1]:52530 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qonw6-0007RA-ON for submit@debbugs.gnu.org; Fri, 06 Oct 2023 12:44:27 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6351) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qonw2-0007Qo-4o for 66187@debbugs.gnu.org; Fri, 06 Oct 2023 12:44:22 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 80EED1000AD; Fri, 6 Oct 2023 12:43:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1696610632; bh=X6s5ZIPIPhxdto+GTd+1wcNiFP2yzmnKzmEkoz5+MFc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MjbqpnYNQrjgx2cbJ+T1KP35C3kK8xkntOAlTsp1pTvwfmw96M7lQoF6BUcxuvGzQ tOwrTELxap0bFfqAA4LLlVhPn7Kf8iSVFAel7cmhChHQTQ5HtUAY+FVR9JSbVNGwsN OeHUZnNb+FbEUWKELP2dkFob/J19cRhxS1NBmQhbzCXad6ebySkr+IaCdGV0Q8kfqi agF77tN/m2VTebzA3Goh/NEtY85DprAp1wvRG09KgjONiWNJdugelVQILw/jRUCOCw PpNJXIN/J88fFbxi8akbK5xWAMVmn7CLoMW5uND+ZrxaHnblXtjOal+VrDAx35MpSy eAq9sAxlMPdlQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4CA0A100033; Fri, 6 Oct 2023 12:43:52 -0400 (EDT) Original-Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 12DCB120037; Fri, 6 Oct 2023 12:43:52 -0400 (EDT) In-Reply-To: <83v8bj2794.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 06 Oct 2023 16:46:47 +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:271958 Archived-At: >> Code which wants the 29.1 behavior can easily get it by modifying their >> `require-match` function accordingly (and such code then works >> correctly both with Emacs-29.1 and with the new behavior). > Do we have any users of this feature in the tree? We do, and it turns out to be a good argument in favor of the change. The use of a function for `completing-read`s REQUIRE-MATCH and `read-file-name`s MUSTMATCH was added in commit 49e06183f5972817d93dad6acf5351c204e61cc5 Author: Lars Ingebrigtsen Date: Fri Jun 10 10:16:57 2022 +0200 Allow REQUIRE-MATCH to be a function * doc/lispref/minibuf.texi (Minibuffer Completion): Document it. * lisp/minibuffer.el (completion--complete-and-exit): Allow REQUIRE-MATCH to be a function. (read-file-name): Mention it. * src/minibuf.c (Fcompleting_read): Mention it. and the surrounding commits point to its motivation in: commit 7ee736a884766f2017a934d936bfbfa4c70b5099 Author: Lars Ingebrigtsen Date: Fri Jun 10 10:19:15 2022 +0200 Allow specifying a wildcard argument to list-directory again * lisp/files.el (list-directory): Allow specifying a wildcard argument interactively again (bug#55877). But the code in that patch uses MUSTMATCH to *restrict* the possible inputs, whereas Joseph's point is that the code currently does not allow using MUSTMATCH to restrict the possible inputs. And indeed we can currently do `M-x list-directory RET /etc/passwd RET` and Emacs happily runs `list-directory` on that non-directory, contrary to the intention of the code (IIUC): [...] (list (read-file-name (if pfx "List directory (verbose): " "List directory (brief): ") nil default-directory (lambda (file) (or (file-directory-p file) (insert-directory-wildcard-in-dir-p (file-name-as-directory (expand-file-name file)))))) [...] -- Stefan