aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2022-10-08 14:13:50 +0300
committerEli Zaretskii2022-10-08 14:13:50 +0300
commit32ef7550edc887f1f8e052cb57a61c4e82b6eecd (patch)
treefe0b4feaf77b1ad852ac02f9003c4ef1a175e796
parentcfb1e218447c796f7a48347f648152b30f3edf92 (diff)
downloademacs-32ef7550edc887f1f8e052cb57a61c4e82b6eecd.tar.gz
emacs-32ef7550edc887f1f8e052cb57a61c4e82b6eecd.zip
; Improve documentation of 'file-in-directory-p'
* lisp/files.el (file-in-directory-p): Clarify doc string. * doc/lispref/files.texi (Truenames): Move the documentation of 'file-in-directory-p' from here... (Contents of Directories): ...to here. Add index entries. (Bug#58364)
-rw-r--r--doc/lispref/files.texi19
-rw-r--r--lisp/files.el7
2 files changed, 15 insertions, 11 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 08677f789a5..32a862b5825 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -1250,14 +1250,6 @@ the @samp{smb} method. For all other connection methods, runtime
1250tests are performed. 1250tests are performed.
1251@end defun 1251@end defun
1252 1252
1253@defun file-in-directory-p file dir
1254This function returns @code{t} if @var{file} is a file in directory
1255@var{dir}, or in a subdirectory of @var{dir}. It also returns
1256@code{t} if @var{file} and @var{dir} are the same directory. It
1257compares the truenames of the two directories. If @var{dir} does not
1258name an existing directory, the return value is @code{nil}.
1259@end defun
1260
1261@defun vc-responsible-backend file 1253@defun vc-responsible-backend file
1262This function determines the responsible VC backend of the given 1254This function determines the responsible VC backend of the given
1263@var{file}. For example, if @file{emacs.c} is a file tracked by Git, 1255@var{file}. For example, if @file{emacs.c} is a file tracked by Git,
@@ -3052,6 +3044,17 @@ is called with one argument (the file or directory) and should return
3052non-@code{nil} if that directory is the one it is looking for. 3044non-@code{nil} if that directory is the one it is looking for.
3053@end defun 3045@end defun
3054 3046
3047@cindex parent directory of file
3048@cindex ancestor directory of file
3049@cindex file, ancestor directory of
3050@defun file-in-directory-p file dir
3051This function returns @code{t} if @var{file} is a file in directory
3052@var{dir}, or in a subdirectory of @var{dir}. It also returns
3053@code{t} if @var{file} and @var{dir} are the same directory. It
3054compares the truenames of the two directories. If @var{dir} does not
3055name an existing directory, the return value is @code{nil}.
3056@end defun
3057
3055@defun directory-files-and-attributes directory &optional full-name match-regexp nosort id-format count 3058@defun directory-files-and-attributes directory &optional full-name match-regexp nosort id-format count
3056This is similar to @code{directory-files} in deciding which files 3059This is similar to @code{directory-files} in deciding which files
3057to report on and how to report their names. However, instead 3060to report on and how to report their names. However, instead
diff --git a/lisp/files.el b/lisp/files.el
index 860b9ca7249..e07f4796258 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6166,9 +6166,10 @@ If FILE1 or FILE2 does not exist, the return value is unspecified."
6166 (equal f1-attr f2-attr)))))) 6166 (equal f1-attr f2-attr))))))
6167 6167
6168(defun file-in-directory-p (file dir) 6168(defun file-in-directory-p (file dir)
6169 "Return non-nil if FILE is in DIR or a subdirectory of DIR. 6169 "Return non-nil if DIR is a parent directory of FILE.
6170A directory is considered to be \"in\" itself. 6170Value is non-nil if FILE is inside DIR or inside a subdirectory of DIR.
6171Return nil if DIR is not an existing directory." 6171A directory is considered to be a \"parent\" of itself.
6172DIR must be an existing directory, otherwise the function returns nil."
6172 (let ((handler (or (find-file-name-handler file 'file-in-directory-p) 6173 (let ((handler (or (find-file-name-handler file 'file-in-directory-p)
6173 (find-file-name-handler dir 'file-in-directory-p)))) 6174 (find-file-name-handler dir 'file-in-directory-p))))
6174 (if handler 6175 (if handler