aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2005-05-21 13:30:24 +0000
committerEli Zaretskii2005-05-21 13:30:24 +0000
commitf42ea19f63889b59a5cb98d7f4a617eb2429251b (patch)
tree7ab911460ca6ffd6abed31e6e422e8fc27afe2fa
parenta2c9aee6a0121314f33974303de88cc26698136e (diff)
downloademacs-f42ea19f63889b59a5cb98d7f4a617eb2429251b.tar.gz
emacs-f42ea19f63889b59a5cb98d7f4a617eb2429251b.zip
(Locating Files): New subsection. Describe locate-file and executable-find.
-rw-r--r--lispref/files.texi71
1 files changed, 67 insertions, 4 deletions
diff --git a/lispref/files.texi b/lispref/files.texi
index b39a552e3af..25c4dfeb0d0 100644
--- a/lispref/files.texi
+++ b/lispref/files.texi
@@ -735,16 +735,18 @@ for its usual definition is in @file{userlock.el}.
735@section Information about Files 735@section Information about Files
736 736
737 The functions described in this section all operate on strings that 737 The functions described in this section all operate on strings that
738designate file names. All the functions have names that begin with the 738designate file names. With a few exceptions, all the functions have
739word @samp{file}. These functions all return information about actual 739names that begin with the word @samp{file}. These functions all
740files or directories, so their arguments must all exist as actual files 740return information about actual files or directories, so their
741or directories unless otherwise noted. 741arguments must all exist as actual files or directories unless
742otherwise noted.
742 743
743@menu 744@menu
744* Testing Accessibility:: Is a given file readable? Writable? 745* Testing Accessibility:: Is a given file readable? Writable?
745* Kinds of Files:: Is it a directory? A symbolic link? 746* Kinds of Files:: Is it a directory? A symbolic link?
746* Truenames:: Eliminating symbolic links from a file name. 747* Truenames:: Eliminating symbolic links from a file name.
747* File Attributes:: How large is it? Any other names? Etc. 748* File Attributes:: How large is it? Any other names? Etc.
749* Locating Files:: How to find a file in standard places.
748@end menu 750@end menu
749 751
750@node Testing Accessibility 752@node Testing Accessibility
@@ -1254,6 +1256,67 @@ is on file system number -32252.
1254@end table 1256@end table
1255@end defun 1257@end defun
1256 1258
1259@node Locating Files
1260@subsection How to Locate Files in Standard Places
1261@cindex locate files
1262@cindex find files
1263
1264 Sometimes, you need to find a file that could reside in one of the
1265standard directories. One example is when you need to look for a
1266program's executable file, e.g., to find out whether a given program
1267is installed on the user's system. Another example is the search for
1268Lisp libraries (@pxref{Library Search}). Such searches generally need
1269to try several alternative file name extensions, in addition to
1270looking in every standard directory where the file could be found.
1271Emacs provides a function for such a generalized search for a file.
1272
1273@defun locate-file filename path &optional suffixes predicate
1274This function searches for the file whose name is @var{filename} in
1275a list of directories given by @var{path}. If it finds the file, it
1276returns its full @dfn{absolute file name} (@pxref{Relative File
1277Names}); if the file is not found, the function returns @code{nil}.
1278
1279The optional argument @var{suffixes} gives the list of file-name
1280suffixes to append to @var{filename} when searching. If
1281@var{suffixes} is @code{nil}, it's equivalent to passing a list with a
1282single element that is an empty string @code{""}.
1283
1284Typical values of @var{path} are @code{exec-path} (@pxref{Subprocess
1285Creation, exec-path}) when looking for executable programs or
1286@code{load-path} (@pxref{Library Search, load-path}) when looking for
1287Lisp files. Use @code{("/")} to disable the path search (e.g., if
1288@var{filename} already includes the leading directories), but still
1289try the extensions in @var{suffixes}.
1290
1291Typical values of @var{suffixes} are @code{exec-suffixes}
1292(@pxref{Subprocess Creation, exec-suffixes}) and @code{load-suffixes}
1293(@pxref{Library Search, load-suffixes}).
1294
1295The optional argument @var{predicate}, if non-@code{nil}, specifies
1296the predicate function to use for testing whether a candidate file is
1297suitable. The predicate function is passed the candidate file name as
1298its single argument. If @var{predicate} is @code{nil} or unspecified,
1299@code{locate-file} uses @code{file-readable-p} as the default
1300predicate. Useful non-default predicates include
1301@code{file-executable-p}, @code{file-directory-p}, and other
1302predicates described in @ref{Kinds of Files}.
1303
1304For compatibility, @var{predicate} can also be one of the symbols
1305@code{executable}, @code{readable}, @code{writable}, @code{exists}, or
1306a list of one or more of these symbols.
1307@end defun
1308
1309@cindex find executable program
1310@defun executable-find program
1311This function searches for the executable file of the named
1312@var{program} and returns the full absolute name of the executable,
1313including its file-name extensions, if any. It returns @code{nil} if
1314the file is not found. The functions searches in all the directories
1315in @code{exec-path} and tries all the file-name extensions in
1316@code{exec-suffixes}.
1317@end defun
1318
1319
1257@node Changing Files 1320@node Changing Files
1258@section Changing File Names and Attributes 1321@section Changing File Names and Attributes
1259@cindex renaming files 1322@cindex renaming files