From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#66224: [PATCH] Add optional PREDICATE argument to read-directory-name Date: Tue, 26 Sep 2023 18:16:40 -0700 Message-ID: <877coch0q7.fsf@breatheoutbreathe.in> Reply-To: Joseph Turner Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18248"; mail-complaints-to="usenet@ciao.gmane.io" To: 66224@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 27 03:20:03 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 1qlJDe-0004WU-V7 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 27 Sep 2023 03:20:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlJDU-0005xV-BH; Tue, 26 Sep 2023 21:19: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 1qlJDR-0005xL-HN for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 21:19:49 -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 1qlJDR-0008B7-8v for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 21:19:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qlJDe-0004PG-Gi for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 21:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Sep 2023 01:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66224 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bugs Mailing List Original-Received: via spool by submit@debbugs.gnu.org id=B.169577758516905 (code B ref -1); Wed, 27 Sep 2023 01:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Sep 2023 01:19:45 +0000 Original-Received: from localhost ([127.0.0.1]:50132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlJDM-0004Ob-Gm for submit@debbugs.gnu.org; Tue, 26 Sep 2023 21:19:45 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:60550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlJDJ-0004OI-IQ for submit@debbugs.gnu.org; Tue, 26 Sep 2023 21:19:42 -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 1qlJD1-0005wA-03 for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 21:19:23 -0400 Original-Received: from out-201.mta1.migadu.com ([2001:41d0:203:375::c9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlJCy-00086J-5y for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 21:19:22 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1695777557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=5rCEzZ9V7sWDZ6Wkde6u4YCGWZuWPTQl9Qd9oF0OIUs=; b=dMCYpUAWai3AC/TiVUocTnO2m/Cl0VW0aI2dW5HmXnwXkIpu6YT3qcCabeOiMxzMyORR7M bWBtKIbQTvOqETTRcbE8evJ693k9hayCZ3WMB0f0l5uOfkvni0suFgm6sz91g7v6Q4vtn1 Cb4k8CKNJfcoD3+UXShwGIEl37u1jCE= X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::c9; envelope-from=joseph@breatheoutbreathe.in; helo=out-201.mta1.migadu.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:271405 Archived-At: --=-=-= Content-Type: text/plain Hello! This patch makes read-directory-name accept an optional PREDICATE arg so it can be used like read-file-name. Joseph --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-optional-PREDICATE-argument-to-read-directory-na.patch Content-Transfer-Encoding: quoted-printable >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-n= ame} ignores case when performing completion. @end defopt =20 -@defun read-directory-name prompt &optional directory default require-matc= h initial +@defun read-directory-name prompt &optional directory default require-matc= h initial predicate This function is like @code{read-file-name} but allows only directory names as completion alternatives. =20 @@ -1719,7 +1719,9 @@ combining @var{directory} (or the current buffer's de= fault 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 @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 user= has typed is a match. This is also available from functions that call 'completing-read', like 'read-file-name'. =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 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 det= ails." (dos-convert-standard-filename filename)) (t filename))) =20 -(defun read-directory-name (prompt &optional dir default-dirname mustmatch= initial) +(defun read-directory-name (prompt &optional dir default-dirname mustmatch= initial predicate) "Read directory name, prompting with PROMPT and completing in directory = 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 d= irectory'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))) =20 (defun pwd (&optional insert) --=20 2.41.0 --=-=-=--