From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#66224: [PATCH] Add optional PREDICATE argument to read-directory-name Date: Thu, 28 Sep 2023 09:05:03 +0000 Message-ID: <874jje1xds.fsf@posteo.net> References: <877coch0q7.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5772"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66224@debbugs.gnu.org To: Joseph Turner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 28 11:06:13 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 1qlmyL-0001DN-Bb for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Sep 2023 11:06:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlmy0-00058D-OE; Thu, 28 Sep 2023 05:05:52 -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 1qlmxx-000571-S4 for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2023 05:05:50 -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 1qlmxx-00082m-CZ for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2023 05:05:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qlmyA-0002le-09 for bug-gnu-emacs@gnu.org; Thu, 28 Sep 2023 05:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Sep 2023 09:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66224 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66224-submit@debbugs.gnu.org id=B66224.169589193010591 (code B ref 66224); Thu, 28 Sep 2023 09:06:01 +0000 Original-Received: (at 66224) by debbugs.gnu.org; 28 Sep 2023 09:05:30 +0000 Original-Received: from localhost ([127.0.0.1]:52968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlmxe-0002kk-DP for submit@debbugs.gnu.org; Thu, 28 Sep 2023 05:05:30 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:38805) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlmxZ-0002kQ-8e for 66224@debbugs.gnu.org; Thu, 28 Sep 2023 05:05:29 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 3FF8C240101 for <66224@debbugs.gnu.org>; Thu, 28 Sep 2023 11:05:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1695891905; bh=mIdMKR5/dCQ0gNnnEArPB32opQmUHcUnYO8tvCJdfNo=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=BKnRJONGJsjicQdvPyLPfOoX2fiYgaxFDaOl8q73LtrkpUBjoFkipFldl72mO+uQt G76CStI2+JeUO7jKACsg831c1IGlmzmUTM1cbTUSrXWuVOLENgK0YX/qeUVFDgnuX7 tp3qDgUQZ01M5VFYQPVLqHLuZ0d6v/HNNP5sdh7FG2Q3ruxqWvbgZOvNILyLT2VbPj +fnJhzcRvetNXmVooWZq7WYXroUc/pWAGqH6Qn5mWzDpumX8nNWxuWniJl54KSgi5V gaQ48h5zu0prtxT6+VhTPqXH6yADiCip6usYAFVLXBOID6owoed2oMTTw/7TWA25dY UFunZ7tREIDHw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rx6xr0xGcz6v3D; Thu, 28 Sep 2023 11:05:03 +0200 (CEST) In-Reply-To: <877coch0q7.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Tue, 26 Sep 2023 18:16:40 -0700") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM 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:271441 Archived-At: Joseph Turner writes: > Hello! > > This patch makes read-directory-name accept an optional PREDICATE arg > so it can be used like read-file-name. > > Joseph > >>>From 78ba02683bd163d8991b182ec4e8ec370e734f95 Mon Sep 17 00:00:00 2001 > From: Joseph Turner > Date: Tue, 26 Sep 2023 18:14:23 -0700 > Subject: [PATCH] Add optional PREDICATE argument to read-directory-name > > * lisp/files.el (read-directory-name): Add optional PREDICATE arg. > * doc/lispref/minibuf.texi (Reading File Names): Document change. > * etc/NEWS: Note change. > --- > doc/lispref/minibuf.texi | 6 ++++-- > etc/NEWS | 4 ++++ > lisp/files.el | 8 +++++--- > 3 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi > index 620c58ec6e9..c3528ea74d2 100644 > --- a/doc/lispref/minibuf.texi > +++ b/doc/lispref/minibuf.texi > @@ -1709,7 +1709,7 @@ If this variable is non-@code{nil}, @code{read-file= -name} ignores case > when performing completion. > @end defopt >=20=20 > -@defun read-directory-name prompt &optional directory default require-ma= tch initial > +@defun read-directory-name prompt &optional directory default require-ma= tch initial predicate > This function is like @code{read-file-name} but allows only directory > names as completion alternatives. >=20=20 > @@ -1719,7 +1719,9 @@ combining @var{directory} (or the current buffer's = default directory > if @var{directory} is @code{nil}) and @var{initial}. If both > @var{default} and @var{initial} are @code{nil}, this function uses > @var{directory} as substitute default, or the current buffer's default > -directory if @var{directory} is @code{nil}. > +directory if @var{directory} is @code{nil}. The union of sixth arg > +@code{predicate} and @code{file-directory-p} is passed as the > +@code{predicate} argument to =E2=80=98read-file-name=E2=80=99. > @end defun >=20=20 > @defopt insert-default-directory > diff --git a/etc/NEWS b/etc/NEWS > index 1b3532b5657..ee0143b1958 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -3541,6 +3541,10 @@ This function is called to see whether what the us= er has typed is a > match. This is also available from functions that call > 'completing-read', like 'read-file-name'. >=20=20 > +** 'read-directory-name' now accepts an optional PREDICATE argument. > +The union of sixth arg PREDICATE and 'file-directory-p' is passed > +as the PREDICATE argument to 'read-file-name'. > + > ** 'posn-col-row' can now give position data based on windows. > Previously, it reported data only based on the frame. >=20=20 > diff --git a/lisp/files.el b/lisp/files.el > index b72f141c0ee..e78e8ea0a36 100644 > --- a/lisp/files.el > +++ b/lisp/files.el > @@ -807,7 +807,7 @@ See Info node `(elisp)Standard File Names' for more d= etails." > (dos-convert-standard-filename filename)) > (t filename))) >=20=20 > -(defun read-directory-name (prompt &optional dir default-dirname mustmat= ch initial) > +(defun read-directory-name (prompt &optional dir default-dirname mustmat= ch initial predicate) > "Read directory name, prompting with PROMPT and completing in director= y DIR. > Value is not expanded---you must call `expand-file-name' yourself. > Default name to DEFAULT-DIRNAME if user exits with the same > @@ -821,14 +821,16 @@ Fourth arg MUSTMATCH non-nil means require existing= directory's name. > Non-nil and non-t means also require confirmation after completion. > Fifth arg INITIAL specifies text to start with. > DIR should be an absolute directory name. It defaults to > -the value of `default-directory'." > +the value of `default-directory'. > +The union of sixth arg PREDICATE and `file-directory-p' is passed > +as the PREDICATE argument to `read-file-name'." > (unless dir > (setq dir default-directory)) > (read-file-name prompt dir (or default-dirname > (if initial (expand-file-name initial dir) > dir)) > mustmatch initial > - 'file-directory-p)) > + (and #'file-directory-p predicate))) I am not sure this makes sense, #'file-directory-p is always non-nil but a PREDICATE will only be passed on to `read-file-name' is PREDICATE is also non-nil. So if no PREDICATE is passed, the expression ignored #'file-directory-p, breaking `read-directory-name', or am I mistaken (I haven't tried it out)? >=20=20 > > (defun pwd (&optional insert)