Add optional PREDICATE argument to read-directory-name
* lisp/files.el (read-directory-name): Add optional PREDICATE argument. * doc/lispref/minibuf.texi (Reading File Names): Document above change. (Bug#66224)
This commit is contained in:
parent
2e9413255f
commit
3f1d84d593
3 changed files with 14 additions and 4 deletions
|
|
@ -1715,7 +1715,7 @@ If this variable is non-@code{nil}, @code{read-file-name} ignores case
|
|||
when performing completion.
|
||||
@end defopt
|
||||
|
||||
@defun read-directory-name prompt &optional directory default require-match initial
|
||||
@defun read-directory-name prompt &optional directory default require-match initial predicate
|
||||
This function is like @code{read-file-name} but allows only directory
|
||||
names as completion alternatives.
|
||||
|
||||
|
|
|
|||
3
etc/NEWS
3
etc/NEWS
|
|
@ -1183,6 +1183,9 @@ runs its body, and removes the current buffer from
|
|||
** The 'rx' category name 'chinese-two-byte' must now be spelled correctly.
|
||||
An old alternative name (without the first 'e') has been removed.
|
||||
|
||||
+++
|
||||
** 'read-directory-name' now accepts an optional PREDICATE argument.
|
||||
|
||||
---
|
||||
** All the digit characters now have the 'digit' category.
|
||||
All the characters whose Unicode general-category is Nd now have the
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ See Info node `(elisp)Standard File Names' for more details."
|
|||
(dos-convert-standard-filename filename))
|
||||
(t filename)))
|
||||
|
||||
(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
|
||||
|
|
@ -889,14 +889,21 @@ 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'.
|
||||
When sixth arg PREDICATE is non-nil, the union of PREDICATE and
|
||||
`file-directory-p' is passed as the PREDICATE argument to
|
||||
`read-file-name'. Otherwise, only `file-directory-p' is passed."
|
||||
(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))
|
||||
(if predicate
|
||||
(lambda (filename)
|
||||
(and (file-directory-p filename)
|
||||
(funcall predicate filename)))
|
||||
#'file-directory-p)))
|
||||
|
||||
|
||||
(defun pwd (&optional insert)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue