diff options
| author | Eli Zaretskii | 2014-03-25 18:08:45 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2014-03-25 18:08:45 +0200 |
| commit | 75b7e407e8d4303930dbfad2df2f36b994f368ed (patch) | |
| tree | 33a588789d35ad27ca53dc159b406ad909f8f727 | |
| parent | 08cf935b84a0778fdf60992960f2c5a6dbad4d82 (diff) | |
| download | emacs-75b7e407e8d4303930dbfad2df2f36b994f368ed.tar.gz emacs-75b7e407e8d4303930dbfad2df2f36b994f368ed.zip | |
Improve doc of file-symlink-p per bug #17073.
doc/lispref/files.texi (Kinds of Files): Improve documentation of
file-symlink-p. Add cross-references.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 54 |
2 files changed, 51 insertions, 8 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 3dfc0dffd76..bf3c6f170ea 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-03-25 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * files.texi (Kinds of Files): Improve documentation of | ||
| 4 | file-symlink-p. (Bug#17073) Add cross-references. | ||
| 5 | |||
| 1 | 2014-03-24 Barry O'Reilly <gundaetiapo@gmail.com> | 6 | 2014-03-24 Barry O'Reilly <gundaetiapo@gmail.com> |
| 2 | 7 | ||
| 3 | * markers.texi (Moving Marker Positions): The 2014-03-02 doc | 8 | * markers.texi (Moving Marker Positions): The 2014-03-02 doc |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 3818c18f57a..278b49e51e0 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -950,22 +950,26 @@ as directories, symbolic links, and ordinary files. | |||
| 950 | @defun file-symlink-p filename | 950 | @defun file-symlink-p filename |
| 951 | @cindex file symbolic links | 951 | @cindex file symbolic links |
| 952 | If the file @var{filename} is a symbolic link, the | 952 | If the file @var{filename} is a symbolic link, the |
| 953 | @code{file-symlink-p} function returns the (non-recursive) link target | 953 | @code{file-symlink-p} function returns its (non-recursive) link target |
| 954 | as a string. (Determining the file name that the link points to from | 954 | as a string. (The link target string is not necessarily the full |
| 955 | the target is nontrivial.) First, this function recursively follows | 955 | absolute file name of the target; determining the full file name that |
| 956 | symbolic links at all levels of parent directories. | 956 | the link points to is nontrivial, see below.) If the leading |
| 957 | 957 | directories of @var{filename} include symbolic links, this function | |
| 958 | If the file @var{filename} is not a symbolic link (or there is no such file), | 958 | recursively follows them. |
| 959 | |||
| 960 | If the file @var{filename} is not a symbolic link, or does not exist, | ||
| 959 | @code{file-symlink-p} returns @code{nil}. | 961 | @code{file-symlink-p} returns @code{nil}. |
| 960 | 962 | ||
| 963 | Here are a few examples of using this function: | ||
| 964 | |||
| 961 | @example | 965 | @example |
| 962 | @group | 966 | @group |
| 963 | (file-symlink-p "foo") | 967 | (file-symlink-p "not-a-symlink") |
| 964 | @result{} nil | 968 | @result{} nil |
| 965 | @end group | 969 | @end group |
| 966 | @group | 970 | @group |
| 967 | (file-symlink-p "sym-link") | 971 | (file-symlink-p "sym-link") |
| 968 | @result{} "foo" | 972 | @result{} "not-a-symlink" |
| 969 | @end group | 973 | @end group |
| 970 | @group | 974 | @group |
| 971 | (file-symlink-p "sym-link2") | 975 | (file-symlink-p "sym-link2") |
| @@ -976,6 +980,40 @@ If the file @var{filename} is not a symbolic link (or there is no such file), | |||
| 976 | @result{} "/pub/bin" | 980 | @result{} "/pub/bin" |
| 977 | @end group | 981 | @end group |
| 978 | @end example | 982 | @end example |
| 983 | |||
| 984 | Note that in the third example, the function returned @file{sym-link}, | ||
| 985 | but did not proceed to resolve it, although that file is itself a | ||
| 986 | symbolic link. This is what we meant by ``non-recursive'' above---the | ||
| 987 | process of following the symbolic links does not recurse if the link | ||
| 988 | target is itself a link. | ||
| 989 | |||
| 990 | The string that this function returns is what is recorded in the | ||
| 991 | symbolic link; it may or may not include any leading directories. | ||
| 992 | This function does @emph{not} expand the link target to produce a | ||
| 993 | fully-qualified file name, and in particular does not use the leading | ||
| 994 | directories, if any, of the @var{filename} argument if the link target | ||
| 995 | is not an absolute file name. Here's an example: | ||
| 996 | |||
| 997 | @example | ||
| 998 | @group | ||
| 999 | (file-symlink-p "/foo/bar/baz") | ||
| 1000 | @result{} "some-file" | ||
| 1001 | @end group | ||
| 1002 | @end example | ||
| 1003 | |||
| 1004 | @noindent | ||
| 1005 | Here, although @file{/foo/bar/baz} was given as a fully-qualified file | ||
| 1006 | name, the result is not, and in fact does not have any leading | ||
| 1007 | directories at all. And since @file{some-file} might itself be a | ||
| 1008 | symbolic link, you cannot simply prepend leading directories to it, | ||
| 1009 | nor even naively use @code{expand-file-name} (@pxref{File Name | ||
| 1010 | Expansion}) to produce its absolute file name. | ||
| 1011 | |||
| 1012 | For this reason, this function is seldom useful if you need to | ||
| 1013 | determine more than just the fact that a file is or isn't a symbolic | ||
| 1014 | link. If you actually need the file name of the link target, use | ||
| 1015 | @code{file-chase-links} or @code{file-truename}, described in | ||
| 1016 | @ref{Truenames}. | ||
| 979 | @end defun | 1017 | @end defun |
| 980 | 1018 | ||
| 981 | The next two functions recursively follow symbolic links at | 1019 | The next two functions recursively follow symbolic links at |